From 6459ab9320b73e3735b75b0c184be2d921fae13c Mon Sep 17 00:00:00 2001 From: Renato Atilio Date: Mon, 4 Nov 2024 12:35:45 -0300 Subject: [PATCH] UX: allow anon users to download calendar (#29551) Allows anonymous users to download the calendar file. Before, they were given the option, but it would fail silently with a `TypeError: Cannot read properties of null (reading 'user_option')`. --- .../components/modal/download-calendar.hbs | 16 +++++---- .../discourse/app/lib/download-calendar.js | 8 ++--- .../acceptance/download-calendar-test.js | 34 +++++++++++++++++++ 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/modal/download-calendar.hbs b/app/assets/javascripts/discourse/app/components/modal/download-calendar.hbs index 1777700cafd..2ec84769b81 100644 --- a/app/assets/javascripts/discourse/app/components/modal/download-calendar.hbs +++ b/app/assets/javascripts/discourse/app/components/modal/download-calendar.hbs @@ -31,13 +31,15 @@ -
- - {{i18n "download_calendar.remember_explanation"}} -
+ {{#if this.currentUser}} +
+ + {{i18n "download_calendar.remember_explanation"}} +
+ {{/if}} <:footer> { + const response = cloneJSON(fixturesByUrl["/t/281.json"]); + const startDate = moment + .tz("America/Lima") + .add(1, "days") + .format("YYYY-MM-DD"); + response.post_stream.posts[0].cooked = `

${startDate}T18:00:00Z

`; + + server.get("/t/281.json", () => helper.response(response)); + }); + + test("Display pick calendar modal", async function (assert) { + await visit("/t/local-dates/281"); + await click(".discourse-local-date"); + await click(".download-calendar"); + + assert + .dom("#discourse-modal-title") + .hasText( + I18n.t("download_calendar.title"), + "it should display modal to select calendar" + ); + + assert.dom(".control-group.remember").doesNotExist(); }); } );