Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UX: "view all" link on upcoming events list #518

Merged
merged 4 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions assets/javascripts/discourse/components/upcoming-events-list.gjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { LinkTo } from "@ember/routing";
import { inject as service } from "@ember/service";
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
import DButton from "discourse/components/d-button";
Expand Down Expand Up @@ -40,6 +41,9 @@ export default class UpcomingEventsList extends Component {
errorMessage = I18n.t(
"discourse_calendar.discourse_post_event.upcoming_events_list.error"
);
viewAllLabel = I18n.t(
"discourse_calendar.discourse_post_event.upcoming_events_list.view_all"
);

constructor() {
super(...arguments);
Expand Down Expand Up @@ -182,6 +186,15 @@ export default class UpcomingEventsList extends Component {
{{/each-in}}
{{/unless}}
</div>

<div class="upcoming-events-list__footer">
<LinkTo
@route="discourse-post-event-upcoming-events"
class="upcoming-events-list__view-all"
>
{{this.viewAllLabel}}
</LinkTo>
</div>
</div>
{{/if}}
</template>
Expand Down
7 changes: 7 additions & 0 deletions assets/stylesheets/common/upcoming-events-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@
width: 30%;
text-align: center;
}

&__footer {
border-top: 1px solid var(--primary-low);
padding-top: 0.5em;
font-size: var(--font-down-1);
line-height: var(--line-height-medium);
}
}
1 change: 1 addition & 0 deletions config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ en:
all_day: "All-day"
error: "Failed to retrieve events"
try_again: "Try again"
view_all: "View all"
group_timezones:
search: "Search..."
group_availability: "%{group} availability"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { hash } from "@ember/helper";
import Service from "@ember/service";
import { render, waitFor } from "@ember/test-helpers";
import { click, currentURL, render, waitFor } from "@ember/test-helpers";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
Expand All @@ -19,6 +19,9 @@ import UpcomingEventsList, {

class RouterStub extends Service {
currentRoute = { attributes: { category: { id: 1 } } };
currentRouteName = "discovery.latest";
on() {}
off() {}
}

const today = "2100-02-01T08:00:00";
Expand Down Expand Up @@ -132,6 +135,37 @@ module("Integration | Component | upcoming-events-list", function (hooks) {
["Awesome Event", "Another Awesome Event"],
"it displays the event name"
);

assert.ok(
exists(".upcoming-events-list__view-all"),
"it displays the view-all link"
);
});

test("with events, view-all navigation", async function (assert) {
pretender.get("/discourse-post-event/events", twoEventsResponseHandler);

await render(<template><UpcomingEventsList /></template>);

this.appEvents.trigger("page:changed", { url: "/" });

await waitFor(".loading-container .spinner", { count: 0 });

assert.strictEqual(
query(".upcoming-events-list__view-all").innerText,
I18n.t(
"discourse_calendar.discourse_post_event.upcoming_events_list.view_all"
),
"it displays the view-all link"
);

await click(".upcoming-events-list__view-all");

assert.strictEqual(
currentURL(),
"/upcoming-events",
"view-all link navigates to the upcoming-events page"
);
});

test("with events, overridden formats", async function (assert) {
Expand Down