Skip to content

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

UX: More Zoom livestream UI issues (#41824)

Martin Brennan8295113dc9f6
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/index.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/index.gjs
index 137ba0153e5..d486fecadb8 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/index.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/index.gjs
@@ -22,7 +22,7 @@ import EventStatus from "./event-status";
import Image from "./image";
import Invitees from "./invitees";
import Livestream from "./livestream";
-import Location from "./location";
+import DiscoursePostEventLocation from "./location";
import MoreMenu from "./more-menu";
import Status from "./status";
import Url from "./url";
@@ -355,7 +355,9 @@ export default class DiscoursePostEvent extends Component {
description=event.description
clamp=this.clampDescription
)
- Location=(component Location location=event.location)
+ Location=(component
+ DiscoursePostEventLocation event=event location=event.location
+ )
Dates=(component
Dates event=event expiredAndRecurring=this.expiredAndRecurring
)
@@ -385,7 +387,7 @@ export default class DiscoursePostEvent extends Component {
{{this.recurrenceLabel}}
</InfoSection>
{{/if}}
- <Location @location={{event.location}} />
+ <DiscoursePostEventLocation @event={{event}} />
<Url @url={{event.url}} />
<ChatChannel @event={{event}} />
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/location.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/location.gjs
index e92550356d2..21716b6d71e 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/location.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/location.gjs
@@ -11,32 +11,60 @@ const URL_TEST_REGEX = /^https?:\/\/\S+$/;
// separately at the bottom of the card — are rendered as plain links showing
// the raw URL instead.
export default class DiscoursePostEventLocation extends Component {
- get segments() {
- return (this.args.location || "")
+ get locationSegments() {
+ return (this.location || "")
.split(URL_SPLIT_REGEX)
.filter((part) => part.length)
.map((part) => ({ text: part, isUrl: URL_TEST_REGEX.test(part) }));
}
+ get location() {
+ return this.args.event.location;
+ }
+
+ get isSingleUrlLocation() {
+ return this.locationSegments.length === 1 && this.locationSegments[0].isUrl;
+ }
+
+ get singleUrl() {
+ return this.isSingleUrlLocation ? this.locationSegments[0].text : null;
+ }
+
<template>
- {{#if @location}}
- <section class="event__section event-location">
- {{dIcon "location-pin"}}
+ {{#if this.location}}
+ {{#if this.isSingleUrlLocation}}
+ {{#unless @event.isZoomLivestream}}
+ <section class="event__section event-location">
+ {{dIcon "location-pin"}}
- <span class="event-location__text">
- {{~#each this.segments as |segment|~}}
- {{~#if segment.isUrl~}}
+ <span class="event-location__text">
<a
- href={{segment.text}}
+ href={{this.singleUrl}}
target="_blank"
rel="noopener noreferrer"
- >{{segment.text}}</a>
- {{~else~}}
- {{segment.text}}
- {{~/if~}}
- {{~/each~}}
- </span>
- </section>
+ >{{this.singleUrl}}</a>
+ </span>
+ </section>
+ {{/unless}}
+ {{else}}
+ <section class="event__section event-location">
+ {{dIcon "location-pin"}}
+
+ <span class="event-location__text">
+ {{~#each this.locationSegments as |segment|~}}
+ {{~#if segment.isUrl~}}
+ <a
+ href={{segment.text}}
+ target="_blank"
+ rel="noopener noreferrer"
+ >{{segment.text}}</a>
+ {{~else~}}
+ {{segment.text}}
+ {{~/if~}}
+ {{~/each~}}
+ </span>
+ </section>
+ {{/if}}
{{/if}}
</template>
}
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/onebox-preview.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/onebox-preview.gjs
index 3b198e8e9e2..98367ae98e9 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/onebox-preview.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/onebox-preview.gjs
@@ -4,7 +4,7 @@ import { service } from "@ember/service";
import { trustHTML } from "@ember/template";
import dReplaceEmoji from "discourse/ui-kit/helpers/d-replace-emoji";
import Dates from "./dates";
-import Location from "./location";
+import DiscoursePostEventLocation from "./location";
export default class DiscoursePostEventOneboxPreview extends Component {
@service discoursePostEventApi;
@@ -61,7 +61,7 @@ export default class DiscoursePostEventOneboxPreview extends Component {
</div>
</header>
<Dates @event={{this.event}} />
- <Location @location={{this.event.location}} />
+ <DiscoursePostEventLocation @event={{this.event}} />
</div>
</div>
{{else}}
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/livestream/zoom-entry.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/livestream/zoom-entry.gjs
index 484b6d47303..42c32e2d699 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/livestream/zoom-entry.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/livestream/zoom-entry.gjs
@@ -36,7 +36,6 @@ export default class LivestreamZoomEntry extends Component {
get shouldRender() {
return (
this.siteSettings.livestream_zoom_enabled &&
- this.currentUser &&
this.args.event.livestreamChatChannelId &&
!this.args.event.pastEventTimeframe
);
@@ -92,6 +91,12 @@ export default class LivestreamZoomEntry extends Component {
@action
joinZoom() {
+ if (!this.currentUser) {
+ return getOwner(this)
+ .lookup("route:application")
+ .send("showCreateAccount");
+ }
+
this.session.join();
}
diff --git a/plugins/discourse-calendar/assets/stylesheets/common/livestream.scss b/plugins/discourse-calendar/assets/stylesheets/common/livestream.scss
index f4ca6960804..b8f42a08e3e 100644
--- a/plugins/discourse-calendar/assets/stylesheets/common/livestream.scss
+++ b/plugins/discourse-calendar/assets/stylesheets/common/livestream.scss
@@ -109,6 +109,7 @@ body.chat-enabled.livestream-topic.confirmed-event-assistance {
&__waiting-wrapper {
border: 1px solid var(--primary-300);
border-radius: var(--d-border-radius);
+ overflow: hidden;
}
&__waiting {
diff --git a/plugins/discourse-calendar/spec/fabricators/event_fabricator.rb b/plugins/discourse-calendar/spec/fabricators/event_fabricator.rb
index cbb7fa056fe..a6da5c5117f 100644
--- a/plugins/discourse-calendar/spec/fabricators/event_fabricator.rb
+++ b/plugins/discourse-calendar/spec/fabricators/event_fabricator.rb
@@ -45,8 +45,8 @@ Fabricator(:event_date, from: "DiscoursePostEvent::EventDate") do
ends_at { |attrs| attrs[:ends_at] }
end
-def create_post_with_event(user, extra_raw = "")
- start = (Time.now - 10.seconds).utc.iso8601(3)
+def create_post_with_event(user, extra_raw = "", start = nil)
+ start = start ? start.utc.iso8601(3) : (Time.now - 10.seconds).utc.iso8601(3)
PostCreator.create!(
user,
diff --git a/plugins/discourse-calendar/spec/system/desktop_topic_livestream_authenticated_spec.rb b/plugins/discourse-calendar/spec/system/desktop_topic_livestream_authenticated_spec.rb
index fbb8025f497..562f389c098 100644
--- a/plugins/discourse-calendar/spec/system/desktop_topic_livestream_authenticated_spec.rb
+++ b/plugins/discourse-calendar/spec/system/desktop_topic_livestream_authenticated_spec.rb
@@ -3,7 +3,6 @@
describe "Discourse Livestream - Topic Livestream - Desktop - Authenticated" do
fab!(:current_user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:category)
- fab!(:livestream_tag) { Fabricate(:tag, name: "livestream") }
let(:topic_page) { PageObjects::Pages::Topic.new }
let(:composer) { PageObjects::Components::Composer.new }
let(:topic_livestream) { PageObjects::Pages::TopicLivestream.new }
@@ -19,7 +18,7 @@ describe "Discourse Livestream - Topic Livestream - Desktop - Authenticated" do
context "when in a topic view" do
it "creates a chat channel for livestream topics" do
- topic_livestream.create_livestream_topic(composer, topic_page, livestream_tag)
+ topic_livestream.create_livestream_event_topic(composer, topic_page)
expect(topic_page).to have_css("#custom-chat-container")
expect(topic_page).to have_css("#custom-chat-container .chat-channel-preview-card")
diff --git a/plugins/discourse-calendar/spec/system/livestream_calendar_event_spec.rb b/plugins/discourse-calendar/spec/system/livestream_calendar_event_spec.rb
index 2c839201c8f..8da0e3dac85 100644
--- a/plugins/discourse-calendar/spec/system/livestream_calendar_event_spec.rb
+++ b/plugins/discourse-calendar/spec/system/livestream_calendar_event_spec.rb
@@ -4,7 +4,6 @@ describe "Discourse Livestream - Topic Livestream with events - Authenticated" d
fab!(:group)
fab!(:current_user) { Fabricate(:user, trust_level: 1, groups: [group]) }
fab!(:category)
- fab!(:livestream_tag) { Fabricate(:tag, name: "livestream") }
let(:topic_page) { PageObjects::Pages::Topic.new }
let(:composer) { PageObjects::Components::Composer.new }
let(:topic_livestream) { PageObjects::Pages::TopicLivestream.new }
@@ -20,7 +19,7 @@ describe "Discourse Livestream - Topic Livestream with events - Authenticated" d
context "when in a event topic view" do
it "clicks going to join the chat channel for livestream topics" do
- topic_livestream.create_livestream_event_topic(composer, topic_page, livestream_tag)
+ topic_livestream.create_livestream_event_topic(composer, topic_page)
find(".going-button", wait: 25).click
expect(topic_page).to have_css(".confirmed-event-assistance", wait: 25)
diff --git a/plugins/discourse-calendar/spec/system/livestream_zoom_webinar_spec.rb b/plugins/discourse-calendar/spec/system/livestream_zoom_webinar_spec.rb
new file mode 100644
index 00000000000..16fdd9e3451
--- /dev/null
+++ b/plugins/discourse-calendar/spec/system/livestream_zoom_webinar_spec.rb
@@ -0,0 +1,72 @@
+# frozen_string_literal: true
+
+describe "Discourse Livestream - Livestream with Zoom webinar" do
+ fab!(:group)
+ fab!(:current_user) { Fabricate(:user, trust_level: 1, groups: [group]) }
+ fab!(:category)
+ let(:topic_page) { PageObjects::Pages::Topic.new }
+ let(:composer) { PageObjects::Components::Composer.new }
+ let(:topic_livestream) { PageObjects::Pages::TopicLivestream.new }
+
+ before do
+ SiteSetting.calendar_enabled = true
+ SiteSetting.chat_enabled = true
+ SiteSetting.discourse_post_event_enabled = true
+ SiteSetting.discourse_post_event_allowed_on_groups = group.id.to_s
+ SiteSetting.livestream_zoom_enabled = true
+ SiteSetting.livestream_zoom_sdk_key = "blah"
+ SiteSetting.livestream_zoom_sdk_secret = "blah"
+ end
+
+ context "when user is signed in" do
+ before { sign_in(current_user) }
+ it "shows a Join Zoom button for livestream events which have a Zoom location" do
+ topic_livestream.create_livestream_event_topic(
+ composer,
+ topic_page,
+ location: "https://zoom.us/j/1234567890",
+ start: 5.minutes.from_now.strftime("%Y-%m-%d %H:%M"),
+ )
+
+ expect(page).to have_css(
+ ".discourse-calendar-livestream-zoom-entry__actions .btn",
+ text: I18n.t("js.discourse_calendar.livestream.zoom.join"),
+ )
+ end
+
+ context "when we are not close to the event start time" do
+ it "shows a disabled Join Zoom button for livestream events which have a Zoom location" do
+ topic_livestream.create_livestream_event_topic(
+ composer,
+ topic_page,
+ location: "https://zoom.us/j/1234567890",
+ start: 5.days.from_now.strftime("%Y-%m-%d %H:%M"),
+ )
+
+ expect(page).to have_css(
+ ".discourse-calendar-livestream-zoom-entry__actions .btn[disabled]",
+ text: I18n.t("js.discourse_calendar.livestream.zoom.join"),
+ )
+ expect(page).to have_content(I18n.t("js.discourse_calendar.livestream.zoom.too_early"))
+ end
+ end
+ end
+
+ context "when the user is anonymous" do
+ it "redirects to the login page when clicking the Join Zoom button" do
+ post =
+ create_post_with_event(
+ current_user,
+ 'status="public" livestream="true" location="https://zoom.us/j/1234567890"',
+ 5.minutes.from_now,
+ )
+
+ topic_page.visit_topic(post.topic)
+
+ find(".discourse-calendar-livestream-zoom-entry__actions .btn").click
+
+ expect(page).to have_css(".signup-fullpage")
+ expect(page).to have_current_path("/signup")
+ end
+ end
+end
diff --git a/plugins/discourse-calendar/spec/system/mobile_topic_livestream_authenticated_spec.rb b/plugins/discourse-calendar/spec/system/mobile_topic_livestream_authenticated_spec.rb
index b62f7bb880d..2c56d9e0044 100644
--- a/plugins/discourse-calendar/spec/system/mobile_topic_livestream_authenticated_spec.rb
+++ b/plugins/discourse-calendar/spec/system/mobile_topic_livestream_authenticated_spec.rb
@@ -3,7 +3,6 @@
describe "Discourse Livestream - Topic Livestream - Mobile - Authenticated", mobile: true do
fab!(:admin)
fab!(:current_user) { Fabricate(:user, trust_level: TrustLevel[3]) }
- fab!(:livestream_tag) { Fabricate(:tag, name: "livestream") }
fab!(:category)
let(:topic_page) { PageObjects::Pages::Topic.new }
let(:composer) { PageObjects::Components::Composer.new }
@@ -24,7 +23,7 @@ describe "Discourse Livestream - Topic Livestream - Mobile - Authenticated", mob
end
it "displays the livestream chat icon on livestream topics" do
- topic_livestream.create_livestream_topic(composer, topic_page, livestream_tag)
+ topic_livestream.create_livestream_event_topic(composer, topic_page)
expect(topic_page).to have_css(".chat-header-icon")
@@ -32,7 +31,7 @@ describe "Discourse Livestream - Topic Livestream - Mobile - Authenticated", mob
end
it "opens the chat channel and displays the preview after clicking the header icon" do
- topic_livestream.create_livestream_topic(composer, topic_page, livestream_tag)
+ topic_livestream.create_livestream_event_topic(composer, topic_page)
find(".livestream-header-icon").click
expect(topic_page).to have_css("#custom-chat-container")
@@ -41,7 +40,7 @@ describe "Discourse Livestream - Topic Livestream - Mobile - Authenticated", mob
context "when the user is going to the event" do
it "opens the chat channel and allows chatting after clicking the header icon" do
- topic_livestream.create_livestream_event_topic(composer, topic_page, livestream_tag)
+ topic_livestream.create_livestream_event_topic(composer, topic_page)
find(".going-button").click
find(".livestream-header-icon").click
diff --git a/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/livestream/topic_livestream.rb b/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/livestream/topic_livestream.rb
index f45951b4185..ef87910f7aa 100644
--- a/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/livestream/topic_livestream.rb
+++ b/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/livestream/topic_livestream.rb
@@ -12,24 +12,6 @@ module PageObjects
)
end
- def create_livestream_topic(composer, topic_page, tag)
- visit("/latest")
- topic_page.open_new_topic
-
- composer.fill_title("Creating a livestream topic")
- tag_chooser = PageObjects::Components::SelectKit.new(".composer-fields .mini-tag-chooser")
- tag_chooser.expand
- tag_chooser.select_row_by_name(tag.name)
- tag_chooser.collapse
-
- tomorrow = 1.day.from_now.strftime("%Y-%m-%d")
- composer.fill_content <<~MD
- [event start="#{tomorrow} 13:37" status="public" livestream="true" location="#{LIVESTREAM_URL}"]
- [/event]
- MD
- composer.create
- end
-
def create_regular_topic(composer, topic_page)
visit("/latest")
topic_page.open_new_topic
@@ -39,19 +21,19 @@ module PageObjects
composer.create
end
- def create_livestream_event_topic(composer, topic_page, tag)
+ def create_livestream_event_topic(composer, topic_page, opts = {})
visit("/latest")
topic_page.open_new_topic
+ opts = {
+ location: LIVESTREAM_URL,
+ start: 1.day.from_now.strftime("%Y-%m-%d") + " 13:37",
+ }.merge!(opts)
+
composer.fill_title("Creating a livestream event topic")
- tag_chooser = PageObjects::Components::SelectKit.new(".composer-fields .mini-tag-chooser")
- tag_chooser.expand
- tag_chooser.select_row_by_name(tag.name)
- tag_chooser.collapse
- tomorrow = 1.day.from_now.strftime("%Y-%m-%d")
composer.fill_content <<~MD
- [event start="#{tomorrow} 13:37" status="public" livestream="true" location="#{LIVESTREAM_URL}"]
+ [event start="#{opts[:start]}" status="public" livestream="true" location="#{opts[:location]}"]
[/event]
MD
composer.create
diff --git a/plugins/discourse-calendar/test/javascripts/integration/components/discourse-post-event-location-test.gjs b/plugins/discourse-calendar/test/javascripts/integration/components/discourse-post-event-location-test.gjs
index 1b9ce212249..a920997be83 100644
--- a/plugins/discourse-calendar/test/javascripts/integration/components/discourse-post-event-location-test.gjs
+++ b/plugins/discourse-calendar/test/javascripts/integration/components/discourse-post-event-location-test.gjs
@@ -1,7 +1,7 @@
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
-import Location from "discourse/plugins/discourse-calendar/discourse/components/discourse-post-event/location";
+import DiscoursePostEventLocation from "discourse/plugins/discourse-calendar/discourse/components/discourse-post-event/location";
module(
"Integration | Component | DiscoursePostEventLocation",
@@ -9,8 +9,12 @@ module(
setupRenderingTest(hooks);
test("renders a plain-text location", async function (assert) {
+ this.event = { location: "Conference Room A" };
+
await render(
- <template><Location @location="Conference Room A" /></template>
+ <template>
+ <DiscoursePostEventLocation @event={{this.event}} />
+ </template>
);
assert
@@ -19,9 +23,11 @@ module(
});
test("renders a URL location as a plain link, never a onebox", async function (assert) {
+ this.event = { location: "https://youtube.com/watch?v=123" };
+
await render(
<template>
- <Location @location="https://youtube.com/watch?v=123" />
+ <DiscoursePostEventLocation @event={{this.event}} />
</template>
);
@@ -37,10 +43,29 @@ module(
);
});
- test("links urls inside surrounding text", async function (assert) {
+ test("does not render the URL for Zoom-only livestreams", async function (assert) {
+ this.event = {
+ location: "https://zoom.us/j/123",
+ isZoomLivestream: true,
+ };
+
+ await render(
+ <template>
+ <DiscoursePostEventLocation @event={{this.event}} />
+ </template>
+ );
+
+ assert
+ .dom(".event-location a")
+ .doesNotExist("does not show the location URL");
+ });
+
+ test("links URLs inside surrounding text", async function (assert) {
+ this.event = { location: "Zoom: https://zoom.us/j/123 (room 2)" };
+
await render(
<template>
- <Location @location="Zoom: https://zoom.us/j/123 (room 2)" />
+ <DiscoursePostEventLocation @event={{this.event}} />
</template>
);
diff --git a/plugins/discourse-calendar/test/javascripts/integration/components/zoom-entry-test.gjs b/plugins/discourse-calendar/test/javascripts/integration/components/zoom-entry-test.gjs
index 1bf39fe93ff..e5afb7c89d7 100644
--- a/plugins/discourse-calendar/test/javascripts/integration/components/zoom-entry-test.gjs
+++ b/plugins/discourse-calendar/test/javascripts/integration/components/zoom-entry-test.gjs
@@ -214,7 +214,7 @@ module("Integration | Component | LivestreamZoomEntry", function (hooks) {
assert.dom(".discourse-calendar-livestream-zoom-entry").doesNotExist();
});
- test("renders nothing for anonymous users", async function (assert) {
+ test("renders button for anonymous users", async function (assert) {
stubCapabilities(getOwner(this), { lg: true });
getOwner(this).unregister("service:current-user");
@@ -222,7 +222,7 @@ module("Integration | Component | LivestreamZoomEntry", function (hooks) {
<template><LivestreamZoomEntry @event={{this.event}} /></template>
);
- assert.dom(".discourse-calendar-livestream-zoom-entry").doesNotExist();
+ assert.dom(".discourse-calendar-livestream-zoom-entry").exists();
});
module("when marking attendance", function (innerHooks) {
diff --git a/spec/fabricators/topic_fabricator.rb b/spec/fabricators/topic_fabricator.rb
index 0f601840109..b4145af304e 100644
--- a/spec/fabricators/topic_fabricator.rb
+++ b/spec/fabricators/topic_fabricator.rb
@@ -8,7 +8,16 @@ Fabricator(:topic) do
end
end
-Fabricator(:topic_with_op, from: :topic) { after_create { |topic| Fabricate(:post, topic: topic) } }
+Fabricator(:topic_with_op, from: :topic) do
+ transient :raw
+ after_create do |topic, transient|
+ if transient[:raw].present?
+ Fabricate(:post, topic: topic, raw: transient[:raw])
+ else
+ Fabricate(:post, topic: topic)
+ end
+ end
+end
Fabricator(:deleted_topic, from: :topic) { deleted_at { 1.minute.ago } }