mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 18:01:25 +08:00
DEV: Clean up mobileView/desktopView uses (#26229)
Inspired by a piece of "do not do x if it's not a mobile view" code 🙃
This commit is contained in:
@ -81,7 +81,7 @@ export default Component.extend({
|
|||||||
click(e) {
|
click(e) {
|
||||||
// Mobile basic-topic-list doesn't use the `topic-list-item` view so
|
// Mobile basic-topic-list doesn't use the `topic-list-item` view so
|
||||||
// the event for the topic entrance is never wired up.
|
// the event for the topic entrance is never wired up.
|
||||||
if (!this.site.mobileView) {
|
if (this.site.desktopView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
>
|
>
|
||||||
<table class="topic-list bookmark-list">
|
<table class="topic-list bookmark-list">
|
||||||
<thead class="topic-list-header">
|
<thead class="topic-list-header">
|
||||||
{{#unless this.site.mobileView}}
|
{{#if this.site.desktopView}}
|
||||||
<PluginOutlet @name="bookmark-list-table-header">
|
<PluginOutlet @name="bookmark-list-table-header">
|
||||||
<th class="topic-list-data">{{i18n "topic.title"}}</th>
|
<th class="topic-list-data">{{i18n "topic.title"}}</th>
|
||||||
<th class="topic-list-data"> </th>
|
<th class="topic-list-data"> </th>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<th class="post-metadata topic-list-data">{{i18n "activity"}}</th>
|
<th class="post-metadata topic-list-data">{{i18n "activity"}}</th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
</PluginOutlet>
|
</PluginOutlet>
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="topic-list-body">
|
<tbody class="topic-list-body">
|
||||||
{{#each this.content as |bookmark|}}
|
{{#each this.content as |bookmark|}}
|
||||||
@ -98,7 +98,7 @@
|
|||||||
{{on "click" this.screenExcerptForExternalLink}}
|
{{on "click" this.screenExcerptForExternalLink}}
|
||||||
>{{html-safe bookmark.excerpt}}</p>
|
>{{html-safe bookmark.excerpt}}</p>
|
||||||
</th>
|
</th>
|
||||||
{{#unless this.site.mobileView}}
|
{{#if this.site.desktopView}}
|
||||||
<td class="author-avatar topic-list-data">
|
<td class="author-avatar topic-list-data">
|
||||||
{{#if bookmark.user.avatar_template}}
|
{{#if bookmark.user.avatar_template}}
|
||||||
<a
|
<a
|
||||||
@ -126,7 +126,7 @@
|
|||||||
class="num post-metadata"
|
class="num post-metadata"
|
||||||
tagName="td"
|
tagName="td"
|
||||||
}}
|
}}
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
<td class="topic-list-data">
|
<td class="topic-list-data">
|
||||||
<BookmarkActionsDropdown
|
<BookmarkActionsDropdown
|
||||||
@bookmark={{bookmark}}
|
@bookmark={{bookmark}}
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
@outletArgs={{hash model=this.composer.model}}
|
@outletArgs={{hash model=this.composer.model}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{{#unless this.composer.site.mobileView}}
|
{{#if this.site.desktopView}}
|
||||||
{{#if this.composer.model.unlistTopic}}
|
{{#if this.composer.model.unlistTopic}}
|
||||||
<span class="unlist">({{i18n "composer.unlist"}})</span>
|
<span class="unlist">({{i18n "composer.unlist"}})</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@ -67,7 +67,7 @@
|
|||||||
<span class="no-bump">{{d-icon "anchor"}}</span>
|
<span class="no-bump">{{d-icon "anchor"}}</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if this.composer.canEdit}}
|
{{#if this.composer.canEdit}}
|
||||||
<LinkToInput
|
<LinkToInput
|
||||||
@ -264,7 +264,7 @@
|
|||||||
@disableSubmit={{this.composer.disableSubmit}}
|
@disableSubmit={{this.composer.disableSubmit}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{{#if this.composer.site.mobileView}}
|
{{#if this.site.mobileView}}
|
||||||
<a
|
<a
|
||||||
href
|
href
|
||||||
{{on "click" this.composer.cancel}}
|
{{on "click" this.composer.cancel}}
|
||||||
@ -286,7 +286,7 @@
|
|||||||
>{{i18n "close"}}</a>
|
>{{i18n "close"}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if this.composer.site.mobileView}}
|
{{#if this.site.mobileView}}
|
||||||
{{#if this.composer.whisperOrUnlistTopic}}
|
{{#if this.composer.whisperOrUnlistTopic}}
|
||||||
<span class="whisper">
|
<span class="whisper">
|
||||||
{{d-icon "far-eye-slash"}}
|
{{d-icon "far-eye-slash"}}
|
||||||
@ -306,7 +306,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if this.composer.site.mobileView}}
|
{{#if this.site.mobileView}}
|
||||||
<span>
|
<span>
|
||||||
<PluginOutlet
|
<PluginOutlet
|
||||||
@name="composer-mobile-buttons-bottom"
|
@name="composer-mobile-buttons-bottom"
|
||||||
@ -388,14 +388,14 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
{{d-icon "exclamation-triangle"}}
|
{{d-icon "exclamation-triangle"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#unless this.composer.site.mobileView}}
|
{{#if this.site.desktopView}}
|
||||||
{{this.composer.model.draftStatus}}
|
{{this.composer.model.draftStatus}}
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
</span>
|
</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#unless this.site.mobileView}}
|
{{#if this.site.desktopView}}
|
||||||
<DButton
|
<DButton
|
||||||
@action={{this.composer.togglePreview}}
|
@action={{this.composer.togglePreview}}
|
||||||
@translatedTitle={{this.composer.toggleText}}
|
@translatedTitle={{this.composer.toggleText}}
|
||||||
@ -405,7 +405,7 @@
|
|||||||
(unless this.composer.showPreview "active")
|
(unless this.composer.showPreview "active")
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
@ -899,7 +899,7 @@ export default Component.extend(ComposerUploadUppy, {
|
|||||||
unshift: true,
|
unshift: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.allowUpload && this.uploadIcon && !this.site.mobileView) {
|
if (this.allowUpload && this.uploadIcon && this.site.desktopView) {
|
||||||
toolbar.addButton({
|
toolbar.addButton({
|
||||||
id: "upload",
|
id: "upload",
|
||||||
group: "insertions",
|
group: "insertions",
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
{{#if this.currentUser.staff}}
|
{{#if this.currentUser.staff}}
|
||||||
<a href={{this.banner.url}} class="btn btn-transparent edit-banner">
|
<a href={{this.banner.url}} class="btn btn-transparent edit-banner">
|
||||||
{{d-icon "pencil-alt"}}
|
{{d-icon "pencil-alt"}}
|
||||||
{{#unless this.site.mobileView}}
|
{{#if this.site.desktopView}}
|
||||||
{{html-safe (i18n "banner.edit")}}
|
{{html-safe (i18n "banner.edit")}}
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
</a>
|
</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ export default Component.extend(Scrolling, MobileScrollDirection, {
|
|||||||
// On desktop the user only needs to scroll past the topic title.
|
// On desktop the user only needs to scroll past the topic title.
|
||||||
return (
|
return (
|
||||||
offset > this.dockAt &&
|
offset > this.dockAt &&
|
||||||
(!this.site.mobileView || this.mobileScrollDirection === "down")
|
(this.site.desktopView || this.mobileScrollDirection === "down")
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -161,10 +161,9 @@ export default class GlimmerHeader extends Component {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
toggleBodyScrolling(bool) {
|
toggleBodyScrolling(bool) {
|
||||||
if (!this.site.mobileView) {
|
if (this.site.mobileView) {
|
||||||
return;
|
scrollLock(bool);
|
||||||
}
|
}
|
||||||
scrollLock(bool);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
@ -180,7 +179,6 @@ export default class GlimmerHeader extends Component {
|
|||||||
@toggleHamburger={{this.toggleHamburger}}
|
@toggleHamburger={{this.toggleHamburger}}
|
||||||
@showSidebar={{@showSidebar}}
|
@showSidebar={{@showSidebar}}
|
||||||
>
|
>
|
||||||
|
|
||||||
<span class="header-buttons">
|
<span class="header-buttons">
|
||||||
{{#each (headerButtons.resolve) as |entry|}}
|
{{#each (headerButtons.resolve) as |entry|}}
|
||||||
{{#if (and (eq entry.key "auth") (not this.currentUser))}}
|
{{#if (and (eq entry.key "auth") (not this.currentUser))}}
|
||||||
|
@ -129,7 +129,7 @@ export default class Info extends Component {
|
|||||||
{{#if
|
{{#if
|
||||||
(and
|
(and
|
||||||
@topic.category.parentCategory.parentCategory
|
@topic.category.parentCategory.parentCategory
|
||||||
(not this.site.mobileView)
|
this.site.desktopView
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
{{categoryLink
|
{{categoryLink
|
||||||
|
@ -432,7 +432,7 @@ export default class GlimmerSiteHeader extends Component {
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class={{concatClass
|
class={{concatClass
|
||||||
(unless this.site.mobileView "drop-down-mode")
|
(if this.site.desktopView "drop-down-mode")
|
||||||
"d-header-wrap"
|
"d-header-wrap"
|
||||||
}}
|
}}
|
||||||
{{didInsert this.setupHeader}}
|
{{didInsert this.setupHeader}}
|
||||||
|
@ -8,7 +8,7 @@ import { on } from "discourse-common/utils/decorators";
|
|||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
@on("init")
|
@on("init")
|
||||||
_init() {
|
_init() {
|
||||||
if (!this.get("site.mobileView")) {
|
if (this.site.desktopView) {
|
||||||
let classes = this.desktopClass;
|
let classes = this.desktopClass;
|
||||||
if (classes) {
|
if (classes) {
|
||||||
classes = classes.split(" ");
|
classes = classes.split(" ");
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
<ConditionalLoadingSpinner @condition={{this.initialLoad}}>
|
<ConditionalLoadingSpinner @condition={{this.initialLoad}}>
|
||||||
<Modal::History::Revision
|
<Modal::History::Revision
|
||||||
@model={{this.postRevision}}
|
@model={{this.postRevision}}
|
||||||
@mobileView={{this.site.mobileView}}
|
|
||||||
@wikiDisabled={{this.wikiDisabled}}
|
@wikiDisabled={{this.wikiDisabled}}
|
||||||
@previousCategory={{this.previousCategory}}
|
@previousCategory={{this.previousCategory}}
|
||||||
@currentCategory={{this.currentCategory}}
|
@currentCategory={{this.currentCategory}}
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
{{#if @model.edit_reason}}
|
{{#if @model.edit_reason}}
|
||||||
<span class="edit-reason">{{@model.edit_reason}}</span>
|
<span class="edit-reason">{{@model.edit_reason}}</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#unless @mobileView}}
|
|
||||||
|
{{#if this.site.desktopView}}
|
||||||
<span>
|
<span>
|
||||||
{{#if @model.user_changes}}
|
{{#if @model.user_changes}}
|
||||||
|
|
||||||
{{bound-avatar-template
|
{{bound-avatar-template
|
||||||
@model.user_changes.previous.avatar_template
|
@model.user_changes.previous.avatar_template
|
||||||
"small"
|
"small"
|
||||||
@ -33,24 +33,25 @@
|
|||||||
}}
|
}}
|
||||||
{{@model.user_changes.current.username}}
|
{{@model.user_changes.current.username}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if @model.wiki_changes}}
|
|
||||||
|
|
||||||
|
{{#if @model.wiki_changes}}
|
||||||
<DisabledIcon @icon="far-edit" @disabled={{@wikiDisabled}} />
|
<DisabledIcon @icon="far-edit" @disabled={{@wikiDisabled}} />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if @model.post_type_changes}}
|
|
||||||
|
|
||||||
|
{{#if @model.post_type_changes}}
|
||||||
<DisabledIcon @icon="shield-alt" @disabled={{@postTypeDisabled}} />
|
<DisabledIcon @icon="shield-alt" @disabled={{@postTypeDisabled}} />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if @model.category_id_changes}}
|
|
||||||
|
|
||||||
|
{{#if @model.category_id_changes}}
|
||||||
{{html-safe @previousCategory}}
|
{{html-safe @previousCategory}}
|
||||||
→
|
→
|
||||||
{{html-safe @currentCategory}}
|
{{html-safe @currentCategory}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</span>
|
</span>
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{#unless @mobileView}}
|
|
||||||
|
{{#if this.site.desktopView}}
|
||||||
<div id="display-modes">
|
<div id="display-modes">
|
||||||
<ul class="nav nav-pills">
|
<ul class="nav nav-pills">
|
||||||
<li>
|
<li>
|
||||||
@ -102,5 +103,5 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
@ -0,0 +1,6 @@
|
|||||||
|
import Component from "@glimmer/component";
|
||||||
|
import { service } from "@ember/service";
|
||||||
|
|
||||||
|
export default class Revision extends Component {
|
||||||
|
@service site;
|
||||||
|
}
|
@ -49,7 +49,7 @@ const ShareTopicModal = Component.extend(bufferedProperty("invite"), {
|
|||||||
@afterRender
|
@afterRender
|
||||||
_selectUrl() {
|
_selectUrl() {
|
||||||
const input = document.querySelector("input.invite-link");
|
const input = document.querySelector("input.invite-link");
|
||||||
if (input && !this.site.mobileView) {
|
if (input && this.site.desktopView) {
|
||||||
// if the input is auto-focused on mobile, iOS requires two taps of the copy button
|
// if the input is auto-focused on mobile, iOS requires two taps of the copy button
|
||||||
input.setSelectionRange(0, this.url.length);
|
input.setSelectionRange(0, this.url.length);
|
||||||
input.focus();
|
input.focus();
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
role="row"
|
role="row"
|
||||||
data-row-id={{@link.objectId}}
|
data-row-id={{@link.objectId}}
|
||||||
>
|
>
|
||||||
{{#unless this.site.mobileView}}
|
{{#if this.site.desktopView}}
|
||||||
<div class="draggable" data-link-name={{@link.name}}>
|
<div class="draggable" data-link-name={{@link.name}}>
|
||||||
{{d-icon "grip-lines"}}
|
{{d-icon "grip-lines"}}
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
<div class="input-group" role="cell">
|
<div class="input-group" role="cell">
|
||||||
<IconPicker
|
<IconPicker
|
||||||
@name="icon"
|
@name="icon"
|
||||||
|
@ -379,7 +379,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_shouldFocusLastVisited() {
|
_shouldFocusLastVisited() {
|
||||||
return !this.site.mobileView && this.focusLastVisitedTopic;
|
return this.site.desktopView && this.focusLastVisitedTopic;
|
||||||
},
|
},
|
||||||
|
|
||||||
_mainLinkElement() {
|
_mainLinkElement() {
|
||||||
|
@ -23,7 +23,7 @@ export default Component.extend({
|
|||||||
"postStream.filteredPostsCount"
|
"postStream.filteredPostsCount"
|
||||||
)
|
)
|
||||||
hideProgress(loaded, currentPost, filteredPostsCount) {
|
hideProgress(loaded, currentPost, filteredPostsCount) {
|
||||||
const hideOnShortStream = !this.site.mobileView && filteredPostsCount < 2;
|
const hideOnShortStream = this.site.desktopView && filteredPostsCount < 2;
|
||||||
return !loaded || !currentPost || hideOnShortStream;
|
return !loaded || !currentPost || hideOnShortStream;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ export default Component.extend({
|
|||||||
// on desktop, pin this element to the composer
|
// on desktop, pin this element to the composer
|
||||||
// otherwise the grid layout will change too much when toggling the composer
|
// otherwise the grid layout will change too much when toggling the composer
|
||||||
// and jitter when the viewport is near the topic bottom
|
// and jitter when the viewport is near the topic bottom
|
||||||
if (!this.site.mobileView && composerH) {
|
if (this.site.desktopView && composerH) {
|
||||||
this.set("docked", false);
|
this.set("docked", false);
|
||||||
this.element.style.setProperty("bottom", `${composerH}px`);
|
this.element.style.setProperty("bottom", `${composerH}px`);
|
||||||
return;
|
return;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import { and, readOnly } from "@ember/object/computed";
|
import { and } from "@ember/object/computed";
|
||||||
import { service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import { underscore } from "@ember/string";
|
import { underscore } from "@ember/string";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
@ -22,7 +22,6 @@ export default Controller.extend({
|
|||||||
showTooltip: false,
|
showTooltip: false,
|
||||||
createdCategory: false,
|
createdCategory: false,
|
||||||
expandedMenu: false,
|
expandedMenu: false,
|
||||||
mobileView: readOnly("site.mobileView"),
|
|
||||||
parentParams: null,
|
parentParams: null,
|
||||||
showDeleteReason: and("showTooltip", "model.cannot_delete_reason"),
|
showDeleteReason: and("showTooltip", "model.cannot_delete_reason"),
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ export default Controller.extend({
|
|||||||
init(...args) {
|
init(...args) {
|
||||||
this._super(...args);
|
this._super(...args);
|
||||||
this.set("priority", this.siteSettings.reviewable_default_visibility);
|
this.set("priority", this.siteSettings.reviewable_default_visibility);
|
||||||
this.set("filtersExpanded", !this.site.mobileView);
|
this.set("filtersExpanded", this.site.desktopView);
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("reviewableTypes")
|
@discourseComputed("reviewableTypes")
|
||||||
|
@ -7,7 +7,7 @@ export default {
|
|||||||
const site = owner.lookup("service:site");
|
const site = owner.lookup("service:site");
|
||||||
this.capabilities = owner.lookup("service:capabilities");
|
this.capabilities = owner.lookup("service:capabilities");
|
||||||
|
|
||||||
if (!this.capabilities.isIpadOS && !site.mobileView) {
|
if (!this.capabilities.isIpadOS && site.desktopView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ export default class Composer extends RestModel {
|
|||||||
options.label = I18n.t(`post.${action}`);
|
options.label = I18n.t(`post.${action}`);
|
||||||
options.userAvatar = tinyAvatar(post.avatar_template);
|
options.userAvatar = tinyAvatar(post.avatar_template);
|
||||||
|
|
||||||
if (!this.site.mobileView) {
|
if (this.site.desktopView) {
|
||||||
const originalUserName = post.get("reply_to_user.username");
|
const originalUserName = post.get("reply_to_user.username");
|
||||||
const originalUserAvatar = post.get("reply_to_user.avatar_template");
|
const originalUserAvatar = post.get("reply_to_user.avatar_template");
|
||||||
if (originalUserName && originalUserAvatar && isEdit(action)) {
|
if (originalUserName && originalUserAvatar && isEdit(action)) {
|
||||||
|
@ -250,7 +250,7 @@ export default class NavItem extends EmberObject {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
this.name === "latest" &&
|
this.name === "latest" &&
|
||||||
(!Site.currentProp("mobileView") || this.tagId !== undefined)
|
(Site.currentProp("desktopView") || this.tagId !== undefined)
|
||||||
) {
|
) {
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ export default class TopicTrackingState extends EmberObject {
|
|||||||
if (
|
if (
|
||||||
filter === "categories" &&
|
filter === "categories" &&
|
||||||
data.message_type === "latest" &&
|
data.message_type === "latest" &&
|
||||||
!Site.current().mobileView &&
|
Site.current().desktopView &&
|
||||||
(this.siteSettings.desktop_category_page_style ===
|
(this.siteSettings.desktop_category_page_style ===
|
||||||
"categories_and_latest_topics" ||
|
"categories_and_latest_topics" ||
|
||||||
this.siteSettings.desktop_category_page_style ===
|
this.siteSettings.desktop_category_page_style ===
|
||||||
|
@ -19,7 +19,7 @@ export default class DiscoveryCategoriesRoute extends DiscourseRoute {
|
|||||||
|
|
||||||
findCategories() {
|
findCategories() {
|
||||||
let style =
|
let style =
|
||||||
!this.site.mobileView && this.siteSettings.desktop_category_page_style;
|
this.site.desktopView && this.siteSettings.desktop_category_page_style;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
style === "categories_and_latest_topics" ||
|
style === "categories_and_latest_topics" ||
|
||||||
|
@ -206,7 +206,7 @@ export default class ComposerService extends Service {
|
|||||||
|
|
||||||
@observes("showPreview")
|
@observes("showPreview")
|
||||||
showPreviewChanged() {
|
showPreviewChanged() {
|
||||||
if (!this.site.mobileView) {
|
if (this.site.desktopView) {
|
||||||
this.keyValueStore.set({
|
this.keyValueStore.set({
|
||||||
key: "composer.showPreview",
|
key: "composer.showPreview",
|
||||||
value: this.showPreview,
|
value: this.showPreview,
|
||||||
|
@ -10,6 +10,6 @@ export default class NavigationMenu extends Service {
|
|||||||
const headerDropdownMode =
|
const headerDropdownMode =
|
||||||
this.siteSettings.navigation_menu === "header dropdown";
|
this.siteSettings.navigation_menu === "header dropdown";
|
||||||
|
|
||||||
return !this.site.mobileView && headerDropdownMode;
|
return this.site.desktopView && headerDropdownMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,14 @@
|
|||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{#unless this.mobileView}}
|
{{#if (and this.site.desktopView this.model.id)}}
|
||||||
{{#if this.model.id}}
|
<DButton
|
||||||
<DButton
|
@action={{action "goBack"}}
|
||||||
@action={{action "goBack"}}
|
@label="category.back"
|
||||||
@label="category.back"
|
@icon="caret-left"
|
||||||
@icon="caret-left"
|
class="category-back"
|
||||||
class="category-back"
|
/>
|
||||||
/>
|
{{/if}}
|
||||||
{{/if}}
|
|
||||||
{{/unless}}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="edit-category-nav">
|
<div class="edit-category-nav">
|
||||||
|
@ -25,14 +25,14 @@
|
|||||||
/>
|
/>
|
||||||
{{#if this.canBulkInvite}}
|
{{#if this.canBulkInvite}}
|
||||||
{{#if this.siteSettings.allow_bulk_invite}}
|
{{#if this.siteSettings.allow_bulk_invite}}
|
||||||
{{#unless this.site.mobileView}}
|
{{#if this.site.desktopView}}
|
||||||
<DButton
|
<DButton
|
||||||
@icon="upload"
|
@icon="upload"
|
||||||
@action={{this.createInviteCsv}}
|
@action={{this.createInviteCsv}}
|
||||||
@label="user.invited.bulk_invite.text"
|
@label="user.invited.bulk_invite.text"
|
||||||
class="btn-default"
|
class="btn-default"
|
||||||
/>
|
/>
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if this.showBulkActionButtons}}
|
{{#if this.showBulkActionButtons}}
|
||||||
|
@ -142,7 +142,7 @@ export default createWidget("header-topic-info", {
|
|||||||
if (parentCategory) {
|
if (parentCategory) {
|
||||||
if (
|
if (
|
||||||
this.siteSettings.max_category_nesting > 2 &&
|
this.siteSettings.max_category_nesting > 2 &&
|
||||||
!this.site.mobileView
|
this.site.desktopView
|
||||||
) {
|
) {
|
||||||
const grandParentCategory = parentCategory.get("parentCategory");
|
const grandParentCategory = parentCategory.get("parentCategory");
|
||||||
if (grandParentCategory) {
|
if (grandParentCategory) {
|
||||||
|
@ -674,10 +674,9 @@ export default createWidget("header", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleBodyScrolling(bool) {
|
toggleBodyScrolling(bool) {
|
||||||
if (!this.site.mobileView) {
|
if (this.site.mobileView) {
|
||||||
return;
|
scrollLock(bool);
|
||||||
}
|
}
|
||||||
scrollLock(bool);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
togglePageSearch() {
|
togglePageSearch() {
|
||||||
|
@ -42,7 +42,7 @@ createWidget("topic-admin-menu-button", {
|
|||||||
position: state.position,
|
position: state.position,
|
||||||
topic: attrs.topic,
|
topic: attrs.topic,
|
||||||
openUpwards: attrs.openUpwards,
|
openUpwards: attrs.openUpwards,
|
||||||
rightSide: !this.site.mobileView && attrs.rightSide,
|
rightSide: this.site.desktopView && attrs.rightSide,
|
||||||
actionButtons: [],
|
actionButtons: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -905,8 +905,8 @@ export default Component.extend(
|
|||||||
{
|
{
|
||||||
name: "eventListeners",
|
name: "eventListeners",
|
||||||
options: {
|
options: {
|
||||||
resize: !this.site.mobileView,
|
resize: this.site.desktopView,
|
||||||
scroll: !this.site.mobileView,
|
scroll: this.site.desktopView,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ export default Component.extend(UtilsMixin, {
|
|||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
if (!this.site.mobileView) {
|
if (this.site.desktopView) {
|
||||||
this.element.addEventListener("mouseenter", this.handleMouseEnter);
|
this.element.addEventListener("mouseenter", this.handleMouseEnter);
|
||||||
this.element.addEventListener("focus", this.handleMouseEnter);
|
this.element.addEventListener("focus", this.handleMouseEnter);
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ export default Component.extend(UtilsMixin, {
|
|||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
if (!this.site.mobileView) {
|
if (this.site.desktopView) {
|
||||||
this.element.removeEventListener("mouseenter", this.handleMouseEnter);
|
this.element.removeEventListener("mouseenter", this.handleMouseEnter);
|
||||||
this.element.removeEventListener("focus", this.handleMouseEnter);
|
this.element.removeEventListener("focus", this.handleMouseEnter);
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,13 @@ import Component from "@glimmer/component";
|
|||||||
import { service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import { isPresent } from "@ember/utils";
|
import { isPresent } from "@ember/utils";
|
||||||
import DButton from "discourse/components/d-button";
|
import DButton from "discourse/components/d-button";
|
||||||
|
|
||||||
export default class ChatChannelLeaveBtn extends Component {
|
export default class ChatChannelLeaveBtn extends Component {
|
||||||
@service chat;
|
@service chat;
|
||||||
@service site;
|
@service site;
|
||||||
|
|
||||||
get shouldRender() {
|
get shouldRender() {
|
||||||
return !this.site.mobileView && isPresent(this.args.channel);
|
return this.site.desktopView && isPresent(this.args.channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
get leaveChatTitleKey() {
|
get leaveChatTitleKey() {
|
||||||
|
@ -40,7 +40,7 @@ export default class ChatHeaderIcon extends Component {
|
|||||||
if (
|
if (
|
||||||
this.chatStateManager.isFullPageActive &&
|
this.chatStateManager.isFullPageActive &&
|
||||||
!this.chatSeparateSidebarMode.never &&
|
!this.chatSeparateSidebarMode.never &&
|
||||||
!this.site.mobileView
|
this.site.desktopView
|
||||||
) {
|
) {
|
||||||
return I18n.t("sidebar.panels.forum.label");
|
return I18n.t("sidebar.panels.forum.label");
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ export default class ChatHeaderIcon extends Component {
|
|||||||
if (
|
if (
|
||||||
this.chatStateManager.isFullPageActive &&
|
this.chatStateManager.isFullPageActive &&
|
||||||
!this.chatSeparateSidebarMode.never &&
|
!this.chatSeparateSidebarMode.never &&
|
||||||
!this.site.mobileView
|
this.site.desktopView
|
||||||
) {
|
) {
|
||||||
return "random";
|
return "random";
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ export default class ChatThreadHeader extends Component {
|
|||||||
route = "chat.channel.threads";
|
route = "chat.channel.threads";
|
||||||
title = I18n.t("chat.return_to_threads_list");
|
title = I18n.t("chat.return_to_threads_list");
|
||||||
models = this.channel?.routeModels;
|
models = this.channel?.routeModels;
|
||||||
} else if (prevPage === "chat.channel.index" && !this.site.mobileView) {
|
} else if (prevPage === "chat.channel.index" && this.site.desktopView) {
|
||||||
route = "chat.channel.threads";
|
route = "chat.channel.threads";
|
||||||
title = I18n.t("chat.return_to_threads_list");
|
title = I18n.t("chat.return_to_threads_list");
|
||||||
models = this.channel?.routeModels;
|
models = this.channel?.routeModels;
|
||||||
|
@ -4,7 +4,6 @@ import KeyValueStore from "discourse/lib/key-value-store";
|
|||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import { MAIN_PANEL } from "discourse/lib/sidebar/panels";
|
import { MAIN_PANEL } from "discourse/lib/sidebar/panels";
|
||||||
import { defaultHomepage } from "discourse/lib/utilities";
|
import { defaultHomepage } from "discourse/lib/utilities";
|
||||||
import Site from "discourse/models/site";
|
|
||||||
import getURL from "discourse-common/lib/get-url";
|
import getURL from "discourse-common/lib/get-url";
|
||||||
import { getUserChatSeparateSidebarMode } from "discourse/plugins/chat/discourse/lib/get-user-chat-separate-sidebar-mode";
|
import { getUserChatSeparateSidebarMode } from "discourse/plugins/chat/discourse/lib/get-user-chat-separate-sidebar-mode";
|
||||||
|
|
||||||
@ -22,10 +21,12 @@ export function addChatDrawerStateCallback(callback) {
|
|||||||
export function resetChatDrawerStateCallbacks() {
|
export function resetChatDrawerStateCallbacks() {
|
||||||
chatDrawerStateCallbacks = [];
|
chatDrawerStateCallbacks = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ChatStateManager extends Service {
|
export default class ChatStateManager extends Service {
|
||||||
@service chat;
|
@service chat;
|
||||||
@service chatHistory;
|
@service chatHistory;
|
||||||
@service router;
|
@service router;
|
||||||
|
@service site;
|
||||||
|
|
||||||
@tracked isSidePanelExpanded = false;
|
@tracked isSidePanelExpanded = false;
|
||||||
@tracked isDrawerExpanded = false;
|
@tracked isDrawerExpanded = false;
|
||||||
@ -126,7 +127,7 @@ export default class ChatStateManager extends Service {
|
|||||||
|
|
||||||
get isFullPagePreferred() {
|
get isFullPagePreferred() {
|
||||||
return !!(
|
return !!(
|
||||||
Site.currentProp("mobileView") ||
|
this.site.mobileView ||
|
||||||
this._store.getObject(PREFERRED_MODE_KEY) === FULL_PAGE_CHAT
|
this._store.getObject(PREFERRED_MODE_KEY) === FULL_PAGE_CHAT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -134,7 +135,7 @@ export default class ChatStateManager extends Service {
|
|||||||
get isDrawerPreferred() {
|
get isDrawerPreferred() {
|
||||||
return !!(
|
return !!(
|
||||||
!this.isFullPagePreferred ||
|
!this.isFullPagePreferred ||
|
||||||
(!Site.currentProp("mobileView") &&
|
(this.site.desktopView &&
|
||||||
(!this._store.getObject(PREFERRED_MODE_KEY) ||
|
(!this._store.getObject(PREFERRED_MODE_KEY) ||
|
||||||
this._store.getObject(PREFERRED_MODE_KEY) === DRAWER_CHAT))
|
this._store.getObject(PREFERRED_MODE_KEY) === DRAWER_CHAT))
|
||||||
);
|
);
|
||||||
|
@ -3,7 +3,7 @@ import hbs from "htmlbars-inline-precompile";
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender from "discourse/tests/helpers/create-pretender";
|
||||||
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
|
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import I18n from "discourse-i18n";
|
import I18n from "discourse-i18n";
|
||||||
import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||||||
|
|
||||||
@ -47,11 +47,11 @@ module("Discourse Chat | Component | chat-channel-leave-btn", function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("is not visible on mobile", async function (assert) {
|
test("is not visible on mobile", async function (assert) {
|
||||||
this.site.mobileView = true;
|
this.site.desktopView = false;
|
||||||
this.channel = fabricators.channel();
|
this.channel = fabricators.channel();
|
||||||
|
|
||||||
await render(hbs`<ChatChannelLeaveBtn @channel={{this.channel}} />`);
|
await render(hbs`<ChatChannelLeaveBtn @channel={{this.channel}} />`);
|
||||||
|
|
||||||
assert.false(exists(".chat-channel-leave-btn"));
|
assert.dom(".chat-channel-leave-btn").doesNotExist();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -57,13 +57,13 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#unless this.site.mobileView}}
|
{{#if this.site.desktopView}}
|
||||||
<TimezoneInput
|
<TimezoneInput
|
||||||
@options={{hash icon="globe"}}
|
@options={{hash icon="globe"}}
|
||||||
@value={{this.timezone}}
|
@value={{this.timezone}}
|
||||||
@onChange={{fn (mut this.timezone)}}
|
@onChange={{fn (mut this.timezone)}}
|
||||||
/>
|
/>
|
||||||
{{/unless}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="picker-panel">
|
<div class="picker-panel">
|
||||||
|
Reference in New Issue
Block a user