Skip to content

A platform for community discussion. Free, open, simple.

UX: Place the admin onboarding banner inside the chat homepage channel (#45167)

Jordan Vidrineec963d7d56c8
diff --git a/frontend/discourse/app/components/admin-onboarding/banner.gjs b/frontend/discourse/app/components/admin-onboarding/banner.gjs
index 48ad4ce0aa7..6da3337727d 100644
--- a/frontend/discourse/app/components/admin-onboarding/banner.gjs
+++ b/frontend/discourse/app/components/admin-onboarding/banner.gjs
@@ -1,5 +1,5 @@
import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
+import { cached, tracked } from "@glimmer/tracking";
import { hash } from "@ember/helper";
import { action } from "@ember/object";
import { trackedArray, trackedSet } from "@ember/reactive/collections";
@@ -20,6 +20,8 @@ import dIcon from "discourse/ui-kit/helpers/d-icon";
import dOnResize from "discourse/ui-kit/modifiers/d-on-resize";
import { i18n } from "discourse-i18n";
+const DEFAULT_LOCATION = "above_main_container";
+
const STEPS = [
class SelectTheme extends OnboardingStep {
static name = "select_theme";
@@ -150,9 +152,11 @@ export default class AdminOnboardingBanner extends Component {
@tracked minimized = false;
// the key value store isn't reactive, but the progress count must be
completedStepNames = trackedSet(
- STEPS.filter(
- (Step) => !!this.keyValueStore.get(`onboarding_step_${Step.name}`)
- ).map((Step) => Step.name)
+ this.steps
+ .filter(
+ (Step) => !!this.keyValueStore.get(`onboarding_step_${Step.name}`)
+ )
+ .map((Step) => Step.name)
);
#heightContainer;
@@ -175,6 +179,23 @@ export default class AdminOnboardingBanner extends Component {
);
}
+ // Where the banner renders. A customization can return a location of its
+ // own and render the banner there, as long as it passes a matching @location
+ get location() {
+ return applyValueTransformer(
+ "admin-onboarding-banner-location",
+ DEFAULT_LOCATION,
+ { homepage: defaultHomepage() }
+ );
+ }
+
+ // A bare <AdminOnboardingBanner> without @location renders regardless of the chosen location
+ get matchesLocation() {
+ return (
+ this.args.location === undefined || this.args.location === this.location
+ );
+ }
+
get shouldDisplay() {
if (this.dismissed) {
return false;
@@ -184,6 +205,10 @@ export default class AdminOnboardingBanner extends Component {
return false;
}
+ if (!this.matchesLocation) {
+ return false;
+ }
+
const { currentRouteName, currentURL } = this.router;
const path = currentURL?.split(/[?#]/)[0];
return (
@@ -193,6 +218,16 @@ export default class AdminOnboardingBanner extends Component {
);
}
+ /**
+ * @returns {(typeof OnboardingStep)[]}
+ */
+ @cached
+ get steps() {
+ return applyValueTransformer("admin-onboarding-steps", [...STEPS], {
+ homepage: defaultHomepage(),
+ });
+ }
+
get completedSteps() {
return this.completedStepNames.size;
}
@@ -204,7 +239,7 @@ export default class AdminOnboardingBanner extends Component {
@action
async checkIfOnboardingIsComplete() {
- const allStepsAreDone = STEPS.every(
+ const allStepsAreDone = this.steps.every(
(Step) => !!this.keyValueStore.get(`onboarding_step_${Step.name}`)
);
@@ -241,7 +276,7 @@ export default class AdminOnboardingBanner extends Component {
await SiteSetting.update("enable_site_owner_onboarding", false);
await logOnboardingEvent(skipped ? "dismissed" : "completed");
this.dismissed = true;
- STEPS.forEach((Step) => {
+ this.steps.forEach((Step) => {
this.keyValueStore.remove(`onboarding_step_${Step.name}`);
});
this.completedStepNames.clear();
@@ -275,7 +310,7 @@ export default class AdminOnboardingBanner extends Component {
"admin_onboarding_banner.launch_in_easy_steps_subtitle"
(hash
completed_steps=this.completedSteps
- step_count=STEPS.length
+ step_count=this.steps.length
)
}}
</span>
@@ -303,7 +338,7 @@ export default class AdminOnboardingBanner extends Component {
{{#unless this.minimized}}
<div class="admin-onboarding-banner__content">
<div class="admin-onboarding-banner__steps">
- {{#each STEPS as |Step|}}
+ {{#each this.steps as |Step|}}
<Step @onCompleted={{this.checkIfOnboardingIsComplete}} />
{{/each}}
</div>
diff --git a/frontend/discourse/app/components/admin-onboarding/step.gjs b/frontend/discourse/app/components/admin-onboarding/step.gjs
index a52650165b2..0ae446ac5aa 100644
--- a/frontend/discourse/app/components/admin-onboarding/step.gjs
+++ b/frontend/discourse/app/components/admin-onboarding/step.gjs
@@ -1,6 +1,5 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
-import { concat } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { service } from "@ember/service";
@@ -31,10 +30,16 @@ export default class OnboardingStep extends Component {
return this.completed ? "circle-check" : "far-circle";
}
+ get title() {
+ return i18n(`${this.i18nKey}${this.name}.title`);
+ }
+
+ get description() {
+ return i18n(`${this.i18nKey}${this.name}.description`);
+ }
+
get buttonLabel() {
- return this.completed
- ? `admin_onboarding_banner.${this.name}.completed`
- : `admin_onboarding_banner.${this.name}.action`;
+ return `${this.i18nKey}${this.name}.${this.completed ? "completed" : "action"}`;
}
@action
@@ -81,14 +86,12 @@ export default class OnboardingStep extends Component {
"onboarding-step__checkbox-icon" (if this.completed "--completed")
)
}}
- <span class="onboarding-step__title">{{i18n
- (concat this.i18nKey this.name ".title")
- }}</span>
+ <span class="onboarding-step__title">{{this.title}}</span>
</div>
<div class="onboarding-step__description">
- {{i18n (concat this.i18nKey this.name ".description")}}
+ {{this.description}}
</div>
<div class="onboarding-step__action">
<DButton
diff --git a/frontend/discourse/app/lib/registry/transformers.ts b/frontend/discourse/app/lib/registry/transformers.ts
index c6ca07a6f0b..76c9324aeb5 100644
--- a/frontend/discourse/app/lib/registry/transformers.ts
+++ b/frontend/discourse/app/lib/registry/transformers.ts
@@ -42,7 +42,9 @@ export const BEHAVIOR_TRANSFORMERS = Object.freeze([
// eslint-discourse keep-array-sorted
export const VALUE_TRANSFORMERS = Object.freeze([
"admin-dashboard-report-renderer",
+ "admin-onboarding-banner-location",
"admin-onboarding-start-posting-options",
+ "admin-onboarding-steps",
"admin-plugin-icon",
"admin-reports-show-query-params",
"admin-theme-card-show-full-controls",
diff --git a/frontend/discourse/app/templates/application.gjs b/frontend/discourse/app/templates/application.gjs
index ae0d8686de7..efc1b619de0 100644
--- a/frontend/discourse/app/templates/application.gjs
+++ b/frontend/discourse/app/templates/application.gjs
@@ -104,7 +104,7 @@ export default <template>
{{/unless}}
{{#if @controller.siteSettings.enable_site_owner_onboarding}}
- <AdminOnboardingBanner />
+ <AdminOnboardingBanner @location="above_main_container" />
{{/if}}
<WelcomeBanner @location="above_topic_content" />
diff --git a/frontend/discourse/tests/acceptance/admin-onboarding-banner-test.gjs b/frontend/discourse/tests/acceptance/admin-onboarding-banner-test.gjs
index 4903ee68d8c..64ceb996cb1 100644
--- a/frontend/discourse/tests/acceptance/admin-onboarding-banner-test.gjs
+++ b/frontend/discourse/tests/acceptance/admin-onboarding-banner-test.gjs
@@ -2,7 +2,9 @@ import { action } from "@ember/object";
import { service } from "@ember/service";
import { click, fillIn, settled, visit } from "@ember/test-helpers";
import { test } from "qunit";
+import AdminOnboardingBanner from "discourse/components/admin-onboarding/banner";
import StartPostingOption from "discourse/components/admin-onboarding/start-posting-option";
+import OnboardingStep from "discourse/components/admin-onboarding/step";
import { AUTO_GROUPS } from "discourse/lib/constants";
import { withPluginApi } from "discourse/lib/plugin-api";
import { setDefaultHomepage } from "discourse/lib/utilities";
@@ -484,6 +486,65 @@ acceptance("Admin - Onboarding Banner", function (needs) {
.isDisabled("card is disabled after step completion");
});
+ test("a registered step can stand in for `start_posting`", async function (assert) {
+ withPluginApi((api) => {
+ api.registerValueTransformer("admin-onboarding-steps", ({ value }) =>
+ value.map((Step) =>
+ Step.name === "start_posting"
+ ? class StartChatting extends OnboardingStep {
+ static name = "start_posting";
+
+ i18nKey = "admin_onboarding_banner.custom.";
+
+ get description() {
+ return "Say hello in #general.";
+ }
+
+ @action
+ performAction() {
+ this.markAsCompleted();
+ }
+ }
+ : Step
+ )
+ );
+ });
+
+ const step = withStep("start_posting", assert);
+ await visit("/");
+
+ assert.deepEqual(
+ [...document.querySelectorAll(".onboarding-step")].map((el) => el.id),
+ ["select_theme", "start_posting", "invite_collaborators"],
+ "keeps the stand-in step in the posting step's place"
+ );
+ assert
+ .dom("#start_posting .onboarding-step__title")
+ .includesText(
+ "custom.start_posting.title",
+ "reads the title from the step's own locale keys"
+ );
+ assert
+ .dom("#start_posting .onboarding-step__description")
+ .hasText("Say hello in #general.", "renders the step's own description");
+ assert
+ .dom("#start_posting .onboarding-step__action .btn")
+ .includesText(
+ "custom.start_posting.action",
+ "reads the action label from the step's own locale keys"
+ );
+ step.isNotChecked();
+
+ await step.clickAction();
+
+ step.isChecked();
+ assert.deepEqual(
+ loggedEvents,
+ [{ event: "step_completed", step: "start_posting" }],
+ "logs the completion under the posting step"
+ );
+ });
+
test("it can complete `invite_collaborators` step", async function (assert) {
const step = withStep("invite_collaborators", assert);
await visit("/");
@@ -796,6 +857,40 @@ acceptance("Admin - Onboarding Banner - setting disabled", function (needs) {
});
});
+acceptance("Admin - Onboarding Banner - relocated banner", function (needs) {
+ needs.user({ admin: true, show_site_owner_onboarding: true });
+ needs.settings({ enable_site_owner_onboarding: true });
+
+ test("renders only at the render point matching the transformed location", async function (assert) {
+ withPluginApi((api) => {
+ api.registerValueTransformer(
+ "admin-onboarding-banner-location",
+ () => "custom_spot"
+ );
+ api.renderInOutlet(
+ "below-site-header",
+ <template>
+ <div class="custom-spot">
+ <AdminOnboardingBanner @location="custom_spot" />
+ </div>
+ </template>
+ );
+ });
+
+ await visit("/");
+
+ assert
+ .dom(".admin-onboarding-banner")
+ .exists({ count: 1 }, "renders the banner once");
+ assert
+ .dom(".custom-spot .admin-onboarding-banner")
+ .exists("renders at the render point that claimed the location");
+ assert
+ .dom("#main-outlet .admin-onboarding-banner")
+ .doesNotExist("leaves the default render point empty");
+ });
+});
+
acceptance("Admin - Onboarding Banner - registered homepage", function (needs) {
needs.user({ admin: true, show_site_owner_onboarding: true });
needs.settings({ enable_site_owner_onboarding: true });
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
index f86e68d14ed..cdf56e49d24 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
@@ -7,6 +7,7 @@ import didUpdate from "@ember/render-modifiers/modifiers/did-update";
import willDestroy from "@ember/render-modifiers/modifiers/will-destroy";
import { cancel, next, schedule } from "@ember/runloop";
import { service } from "@ember/service";
+import { modifier } from "ember-modifier";
import { popupAjaxError } from "discourse/lib/ajax-error";
import discourseDebounce from "discourse/lib/debounce";
import { bind } from "discourse/lib/decorators";
@@ -76,6 +77,48 @@ export default class ChatChannel extends Component {
jumpToPinnedMessage = (messageId) => {
this.highlightOrFetchMessage(messageId, { position: "center" });
};
+ // the overlays only read as raised while list content runs beneath them
+ elevateOverlays = modifier((element) => {
+ const scroller = element.parentElement.querySelector(
+ ".chat-messages-scroller"
+ );
+ const content = scroller?.querySelector(".chat-messages-container");
+ if (!scroller || !content) {
+ return;
+ }
+
+ // the topmost message, so the loading skeleton and the empty state don't count
+ const update = () => {
+ const card = element.querySelector(".admin-onboarding-banner__wrap");
+ const firstMessage = content.querySelector(".chat-message-container");
+ const covered =
+ !!card &&
+ !!firstMessage &&
+ firstMessage.getBoundingClientRect().top <
+ card.getBoundingClientRect().bottom;
+ element.classList.toggle("--over-content", covered);
+ };
+
+ const resizeObserver = new ResizeObserver(update);
+ resizeObserver.observe(scroller);
+ resizeObserver.observe(content);
+ const observeChildren = () => {
+ for (const child of element.children) {
+ resizeObserver.observe(child);
+ }
+ update();
+ };
+ const mutationObserver = new MutationObserver(observeChildren);
+ mutationObserver.observe(element, { childList: true });
+ observeChildren();
+ scroller.addEventListener("scroll", update, { passive: true });
+
+ return () => {
+ resizeObserver.disconnect();
+ mutationObserver.disconnect();
+ scroller.removeEventListener("scroll", update);
+ };
+ });
// real user input flips this, so onScroll drops the pinned-bar tap override
// only on a scroll the user drove — not the programmatic jump that set it
#userScrolled = false;
@@ -808,7 +851,6 @@ export default class ChatChannel extends Component {
{{didUpdate this.loadMessages @targetMessageId}}
>
<ChatChannelStatus @channel={{@channel}} />
- <ChatNotices @channel={{@channel}} />
<ChatMentionWarnings />
<ChatChannelFilter
@channel={{@channel}}
@@ -824,6 +866,11 @@ export default class ChatChannel extends Component {
@viewportBottomMessageId={{this.lastVisibleMessageId}}
/>
+ <div class="chat-channel__overlays" {{this.elevateOverlays}}>
+ {{yield to="aboveMessages"}}
+ <ChatNotices @channel={{@channel}} />
+ </div>
+
<ChatMessagesScroller
@onRegisterScroller={{this.registerScroller}}
@onScroll={{this.onScroll}}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/onboarding/start-chatting-step.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/onboarding/start-chatting-step.gjs
new file mode 100644
index 00000000000..688df1cd88c
--- /dev/null
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/onboarding/start-chatting-step.gjs
@@ -0,0 +1,36 @@
+import { action } from "@ember/object";
+import { service } from "@ember/service";
+import OnboardingStep from "discourse/components/admin-onboarding/step";
+import { i18n } from "discourse-i18n";
+
+// Stands in for the posting step when a chat channel is the homepage, so the
+// checklist is ticked by the first message rather than the first topic
+export default class StartChattingStep extends OnboardingStep {
+ static name = "start_posting";
+
+ @service chat;
+ @service("chat-channel-composer") composer;
+
+ i18nKey = "chat.admin_onboarding.";
+
+ constructor() {
+ super(...arguments);
+ this.appEvents.on("chat:message-sent", this, this.markAsCompleted);
+ }
+
+ willDestroy() {
+ super.willDestroy(...arguments);
+ this.appEvents.off("chat:message-sent", this, this.markAsCompleted);
+ }
+
+ get description() {
+ return i18n(`${this.i18nKey}${this.name}.description`, {
+ channel: this.chat.activeChannel?.title,
+ });
+ }
+
+ @action
+ performAction() {
+ this.composer.focus({ ensureAtEnd: true, refreshHeight: true });
+ }
+}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/routes/channel.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/routes/channel.gjs
index 25a131db51a..4f079f3380f 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/routes/channel.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/routes/channel.gjs
@@ -2,6 +2,7 @@ import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { service } from "@ember/service";
+import AdminOnboardingBanner from "discourse/components/admin-onboarding/banner";
import PluginOutlet from "discourse/components/plugin-outlet";
import lazyHash from "discourse/helpers/lazy-hash";
import Navbar from "discourse/plugins/chat/discourse/components/chat/navbar";
@@ -103,7 +104,13 @@ export default class ChatRoutesChannel extends Component {
@isFiltering={{this.isFiltering}}
@onToggleFilter={{this.toggleIsFiltering}}
@targetMessageId={{@targetMessageId}}
- />
+ >
+ <:aboveMessages>
+ {{#if this.siteSettings.enable_site_owner_onboarding}}
+ <AdminOnboardingBanner @location="chat_channel" />
+ {{/if}}
+ </:aboveMessages>
+ </FullPageChat>
</div>
<ChatSidePanel>
diff --git a/plugins/chat/assets/javascripts/discourse/components/full-page-chat.gjs b/plugins/chat/assets/javascripts/discourse/components/full-page-chat.gjs
index 84ae9078f70..1a33401ddba 100644
--- a/plugins/chat/assets/javascripts/discourse/components/full-page-chat.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/full-page-chat.gjs
@@ -8,7 +8,9 @@ const FullPageChat = <template>
@isFiltering={{@isFiltering}}
@onToggleFilter={{@onToggleFilter}}
@targetMessageId={{@targetMessageId}}
- />
+ >
+ <:aboveMessages>{{yield to="aboveMessages"}}</:aboveMessages>
+ </ChatChannel>
{{/each}}
</template>;
diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-setup.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-setup.js
index 5cb727a733f..d4388884ade 100644
--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-setup.js
+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-setup.js
@@ -14,6 +14,7 @@ import groupChatTranscripts from "discourse/plugins/chat/discourse/lib/group-cha
import ChannelHashtagType from "discourse/plugins/chat/discourse/lib/hashtag-types/channel";
import richEditorExtension from "../../lib/rich-editor-extension.js";
import ChatHeaderIcon from "../components/chat/header/icon.gjs";
+import StartChattingStep from "../components/chat/onboarding/start-chatting-step.gjs";
import chatStyleguide from "../components/styleguide/organisms/chat.gjs";
let _lastForcedRefreshAt;
@@ -48,6 +49,22 @@ class ChatSetupInit {
(await import("../components/reviewable/chat-message.gjs")).default
);
+ api.registerValueTransformer(
+ "admin-onboarding-banner-location",
+ ({ value, context }) =>
+ context.homepage === "chat" ? "chat_channel" : value
+ );
+
+ api.registerValueTransformer(
+ "admin-onboarding-steps",
+ ({ value, context }) =>
+ context.homepage === "chat"
+ ? value.map((Step) =>
+ Step.name === "start_posting" ? StartChattingStep : Step
+ )
+ : value
+ );
+
api.addAboutPageActivity("chat_messages", (periods) => {
const count = periods["7_days"];
if (count) {
diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-api.js b/plugins/chat/assets/javascripts/discourse/services/chat-api.js
index c1b93d30a01..3b773d8840b 100644
--- a/plugins/chat/assets/javascripts/discourse/services/chat-api.js
+++ b/plugins/chat/assets/javascripts/discourse/services/chat-api.js
@@ -11,6 +11,7 @@ import Collection from "../lib/collection.js";
* @implements {@ember/service}
*/
export default class ChatApi extends Service {
+ @service appEvents;
@service chatChannelsManager;
get #basePath() {
@@ -189,12 +190,22 @@ export default class ChatApi extends Service {
* @param {Array.<number>} [data.upload_ids] - Array of upload ids linked to the message.
* @returns {Promise}
*/
- sendMessage(channelId, data = {}) {
- return ajax(`/chat/${channelId}`, {
+ async sendMessage(channelId, data = {}) {
+ const response = await ajax(`/chat/${channelId}`, {
ignoreUnsent: false,
type: "POST",
data,
});
+
+ // a caller that does not await the send can outlive the app in tests
+ if (!this.isDestroying) {
+ this.appEvents.trigger("chat:message-sent", {
+ channelId,
+ messageId: response.message_id,
+ });
+ }
+
+ return response;
}
/**
diff --git a/plugins/chat/assets/stylesheets/common/base-common.scss b/plugins/chat/assets/stylesheets/common/base-common.scss
index 4bb4f52777f..0a71a88be67 100644
--- a/plugins/chat/assets/stylesheets/common/base-common.scss
+++ b/plugins/chat/assets/stylesheets/common/base-common.scss
@@ -1,3 +1,5 @@
+@use "lib/viewport";
+
:root {
--message-left-width: 42px;
--full-page-border-radius: 12px;
@@ -226,6 +228,39 @@ body.has-full-page-chat {
}
}
+// a zero-height region right above the message list: whatever it holds flows
+// in normal order below the status, filter and pinned bars, and overflows
+// downward over the list, which keeps its full height underneath
+.chat-channel__overlays {
+ position: relative;
+
+ // what the notices stacked at before they moved in here
+ z-index: 10;
+ display: flex;
+ flex-direction: column;
+ flex: 0 0 0px;
+ min-height: 0;
+
+ .admin-onboarding-banner {
+ padding: var(--space-4) var(--space-6);
+ pointer-events: none;
+
+ @include viewport.until(sm) {
+ padding: var(--space-2);
+ }
+ }
+
+ .admin-onboarding-banner__wrap {
+ pointer-events: auto;
+ background: var(--secondary);
+ transition: box-shadow 150ms ease;
+ }
+
+ &.--over-content .admin-onboarding-banner__wrap {
+ box-shadow: var(--shadow-card);
+ }
+}
+
.user-preferences .chat-setting .controls {
margin-bottom: 0;
}
diff --git a/plugins/chat/assets/stylesheets/common/chat-notices.scss b/plugins/chat/assets/stylesheets/common/chat-notices.scss
index fb88839297a..f584ab39480 100644
--- a/plugins/chat/assets/stylesheets/common/chat-notices.scss
+++ b/plugins/chat/assets/stylesheets/common/chat-notices.scss
@@ -2,20 +2,12 @@
display: flex;
flex-direction: column;
gap: 0.5em;
- position: absolute;
- top: 0;
- z-index: 10;
width: 100%;
.full-page-chat & {
padding-inline: 1rem;
box-sizing: border-box;
- top: 2rem;
- }
-
- // float notices below the pinned bar only while it's actually visible
- .chat-channel:has(.chat-pinned-bar:not(.--dismissed, .--loading)) & {
- top: var(--chat-pinned-bar-height);
+ margin-top: 2rem;
}
&__notice,
diff --git a/plugins/chat/assets/stylesheets/common/chat-pinned-bar.scss b/plugins/chat/assets/stylesheets/common/chat-pinned-bar.scss
index 76f53362d93..e66d9140aaa 100644
--- a/plugins/chat/assets/stylesheets/common/chat-pinned-bar.scss
+++ b/plugins/chat/assets/stylesheets/common/chat-pinned-bar.scss
@@ -1,5 +1,4 @@
.chat-channel {
- // shared by the bar (its height) and the floating notices (their top offset)
--chat-pinned-bar-height: 2.75rem;
}
diff --git a/plugins/chat/config/locales/client.en.yml b/plugins/chat/config/locales/client.en.yml
index b9d2610b0b3..eb7188d90eb 100644
--- a/plugins/chat/config/locales/client.en.yml
+++ b/plugins/chat/config/locales/client.en.yml
@@ -40,6 +40,12 @@ en:
chat:
homepage_option: "Chat channel"
+ admin_onboarding:
+ start_posting:
+ title: "Start chatting"
+ description: "Send your first message in #%{channel}."
+ action: "Write a message"
+ completed: "Keep chatting"
edit_category:
tab_title: "Chat"
channel: "Channel"
diff --git a/plugins/chat/spec/system/homepage_channel_spec.rb b/plugins/chat/spec/system/homepage_channel_spec.rb
index a75173cb11a..ab378d55d75 100644
--- a/plugins/chat/spec/system/homepage_channel_spec.rb
+++ b/plugins/chat/spec/system/homepage_channel_spec.rb
@@ -83,11 +83,11 @@ RSpec.describe "Chat channel as the homepage" do
other_channel.add(current_user)
end
- it "lets the owner see the checklist on the Chat homepage but not another channel" do
+ it "lets the owner see the checklist under the channel header on the Chat homepage but not another channel" do
visit("/")
expect(channel_page.messages).to have_message(id: message_1.id)
- expect(banner).to be_visible
+ expect(channel_page).to have_onboarding_banner_below_header
expect_composer_in_viewport
click_button(I18n.t("js.admin_onboarding_banner.collapse"), enable_aria_label: true)
@@ -96,7 +96,7 @@ RSpec.describe "Chat channel as the homepage" do
visit(channel_1.relative_url)
expect(channel_page.messages).to have_message(id: message_1.id)
- expect(banner).to be_visible
+ expect(channel_page).to have_onboarding_banner_below_header
expect_composer_in_viewport
sidebar.open_channel(other_channel)
@@ -106,6 +106,53 @@ RSpec.describe "Chat channel as the homepage" do
expect_composer_in_viewport
end
+ it "lets the owner tick off chatting by sending a first message in the homepage channel" do
+ visit("/")
+
+ expect(banner).to have_step(
+ "start_posting",
+ title: I18n.t("js.chat.admin_onboarding.start_posting.title"),
+ description:
+ I18n.t("js.chat.admin_onboarding.start_posting.description", channel: channel_1.title),
+ )
+ expect(banner.step_not_completed?("start_posting")).to eq(true)
+
+ banner.click_step_action("start_posting")
+ expect(channel_page.composer).to be_focused
+
+ channel_page.send_message("Hello everyone")
+
+ expect(banner.step_completed?("start_posting")).to eq(true)
+ end
+
+ it "raises the checklist only once messages run beneath it" do
+ visit("/")
+
+ expect(channel_page).to have_onboarding_banner_below_header
+ expect(channel_page).to have_no_elevated_overlays
+
+ Fabricate.times(40, :chat_message, chat_channel: channel_1)
+ page.refresh
+
+ expect(channel_page).to have_onboarding_banner_below_header
+ expect(channel_page).to have_elevated_overlays
+ end
+
+ it "keeps the pinned message bar and channel notices clear of the checklist" do
+ SiteSetting.chat_pinned_messages = true
+ Fabricate(
+ :chat_pinned_message,
+ chat_message: message_1,
+ chat_channel: channel_1,
+ user: current_user,
+ )
+
+ visit("/")
+
+ expect(channel_page).to have_onboarding_banner_below_pinned_bar
+ try_until_success { expect(channel_page).to have_notices_below_onboarding_banner }
+ end
+
def expect_composer_in_viewport
try_until_success do
bottom =
diff --git a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb b/plugins/chat/spec/system/page_objects/chat/chat_channel.rb
index 65de54af478..21816a08f1c 100644
--- a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb
+++ b/plugins/chat/spec/system/page_objects/chat/chat_channel.rb
@@ -262,6 +262,35 @@ module PageObjects
has_no_css?(".c-navbar__star-channel-button")
end
+ def has_onboarding_banner_below_header?
+ has_css?(".c-routes.--channel .chat-channel__overlays .admin-onboarding-banner") &&
+ has_css?(".admin-onboarding-banner", count: 1)
+ end
+
+ def has_onboarding_banner_below_pinned_bar?
+ has_css?(".chat-pinned-bar") &&
+ has_css?(".chat-channel__overlays .admin-onboarding-banner") &&
+ page.evaluate_script(<<~JS)
+ document.querySelector(".chat-channel__overlays .admin-onboarding-banner").getBoundingClientRect().top >=
+ document.querySelector(".chat-pinned-bar").getBoundingClientRect().bottom
+ JS
+ end
+
+ def has_elevated_overlays?
+ has_css?(".chat-channel__overlays.--over-content")
+ end
+
+ def has_no_elevated_overlays?
+ has_no_css?(".chat-channel__overlays.--over-content")
+ end
+
+ def has_notices_below_onboarding_banner?
+ has_css?(".chat-notices .chat-retention-reminder") && page.evaluate_script(<<~JS)
+ document.querySelector(".chat-notices").getBoundingClientRect().top >=
+ document.querySelector(".chat-channel__overlays .admin-onboarding-banner").getBoundingClientRect().bottom
+ JS
+ end
+
def thread_list_button_selector
".c-navbar__threads-list-button"
end
diff --git a/spec/system/page_objects/components/admin_onboarding_banner.rb b/spec/system/page_objects/components/admin_onboarding_banner.rb
index 9ebcfcaf5c1..846f7ffea2a 100644
--- a/spec/system/page_objects/components/admin_onboarding_banner.rb
+++ b/spec/system/page_objects/components/admin_onboarding_banner.rb
@@ -23,6 +23,11 @@ module PageObjects
find("div##{step_id}")
end
+ def has_step?(step_id, title:, description:)
+ has_css?("div##{step_id} .onboarding-step__title", text: title) &&
+ has_css?("div##{step_id} .onboarding-step__description", text: description)
+ end
+
def step_completed?(step_id)
has_css?("div##{step_id} .onboarding-step__checkbox > svg.--completed")
end