DEV: Move computed to discourseComputed (#8312)

This commit is contained in:
Mark VanLandingham
2019-11-07 15:38:28 -06:00
committed by GitHub
parent d74546f50e
commit 6275c05c0d
395 changed files with 1770 additions and 1649 deletions

View File

@@ -1,5 +1,6 @@
import MultiSelectComponent from "select-kit/components/multi-select";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
const { makeArray } = Ember;
export default MultiSelectComponent.extend({
@@ -10,7 +11,7 @@ export default MultiSelectComponent.extend({
allowAny: false,
buffer: null,
@computed("buffer")
@discourseComputed("buffer")
values(buffer) {
return buffer === null
? makeArray(this.selected).map(s => this.valueForContentItem(s))

View File

@@ -1,5 +1,5 @@
import ComboBoxComponent from "select-kit/components/combo-box";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
import PermissionType from "discourse/models/permission-type";
import Category from "discourse/models/category";
import { categoryBadgeHTML } from "discourse/helpers/category-link";
@@ -53,7 +53,7 @@ export default ComboBoxComponent.extend({
});
},
@computed("rootNone", "rootNoneLabel")
@discourseComputed("rootNone", "rootNoneLabel")
none(rootNone, rootNoneLabel) {
if (
this.siteSettings.allow_uncategorized_topics ||

View File

@@ -1,6 +1,6 @@
import ComboBoxComponent from "select-kit/components/combo-box";
import DiscourseURL from "discourse/lib/url";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { default as discourseComputed } from "discourse-common/utils/decorators";
import Category from "discourse/models/category";
import { categoryBadgeHTML } from "discourse/helpers/category-link";
const { isEmpty } = Ember;
@@ -23,7 +23,12 @@ export default ComboBoxComponent.extend({
subCategory: false,
isAsync: Ember.computed.not("subCategory"),
@computed("categories", "hasSelection", "subCategory", "noSubcategories")
@discourseComputed(
"categories",
"hasSelection",
"subCategory",
"noSubcategories"
)
categoriesWithShortcuts(
categories,
hasSelection,
@@ -70,7 +75,7 @@ export default ComboBoxComponent.extend({
this.forceValue(this.get("category.id"));
},
@computed("content")
@discourseComputed("content")
filterable(content) {
const contentLength = (content && content.length) || 0;
return (
@@ -107,7 +112,7 @@ export default ComboBoxComponent.extend({
return content;
},
@computed("parentCategory.name", "subCategory")
@discourseComputed("parentCategory.name", "subCategory")
allCategoriesLabel(categoryName, subCategory) {
if (subCategory) {
return I18n.t("categories.all_subcategories", { categoryName });
@@ -115,12 +120,12 @@ export default ComboBoxComponent.extend({
return I18n.t("categories.all");
},
@computed("parentCategory.url", "subCategory")
@discourseComputed("parentCategory.url", "subCategory")
allCategoriesUrl(parentCategoryUrl, subCategory) {
return Discourse.getURL(subCategory ? parentCategoryUrl || "/" : "/");
},
@computed("parentCategory.url")
@discourseComputed("parentCategory.url")
noCategoriesUrl(parentCategoryUrl) {
return Discourse.getURL(`${parentCategoryUrl}/none`);
},

View File

@@ -1,6 +1,6 @@
import { isEmpty } from "@ember/utils";
import ComboBoxSelectBoxHeaderComponent from "select-kit/components/combo-box/combo-box-header";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
import Category from "discourse/models/category";
export default ComboBoxSelectBoxHeaderComponent.extend({
@@ -11,7 +11,7 @@ export default ComboBoxSelectBoxHeaderComponent.extend({
classNameBindings: ["categoryStyleClass"],
categoryStyleClass: Ember.computed.alias("site.category_style"),
@computed("computedContent.value", "computedContent.name")
@discourseComputed("computedContent.value", "computedContent.name")
category(value, name) {
if (isEmpty(value)) {
const uncat = Category.findUncategorized();
@@ -23,17 +23,17 @@ export default ComboBoxSelectBoxHeaderComponent.extend({
}
},
@computed("category.color")
@discourseComputed("category.color")
categoryBackgroundColor(categoryColor) {
return categoryColor || "#e9e9e9";
},
@computed("category.text_color")
@discourseComputed("category.text_color")
categoryTextColor(categoryTextColor) {
return categoryTextColor || "#333";
},
@computed("category", "categoryBackgroundColor", "categoryTextColor")
@discourseComputed("category", "categoryBackgroundColor", "categoryTextColor")
categoryStyle(category, categoryBackgroundColor, categoryTextColor) {
const categoryStyle = this.siteSettings.category_style;

View File

@@ -1,6 +1,6 @@
import { isEmpty } from "@ember/utils";
import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-row";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
import Category from "discourse/models/category";
import { categoryBadgeHTML } from "discourse/helpers/category-link";
@@ -12,7 +12,7 @@ export default SelectKitRowComponent.extend({
allowUncategorized: Ember.computed.bool("options.allowUncategorized"),
categoryLink: Ember.computed.bool("options.categoryLink"),
@computed("options.displayCategoryDescription")
@discourseComputed("options.displayCategoryDescription")
displayCategoryDescription(displayCategoryDescription) {
if (Ember.isNone(displayCategoryDescription)) {
return true;
@@ -21,12 +21,12 @@ export default SelectKitRowComponent.extend({
return displayCategoryDescription;
},
@computed("descriptionText", "description", "category.name")
@discourseComputed("descriptionText", "description", "category.name")
title(descriptionText, description, name) {
return descriptionText || description || name;
},
@computed("computedContent.value", "computedContent.name")
@discourseComputed("computedContent.value", "computedContent.name")
category(value, name) {
if (isEmpty(value)) {
const uncat = Category.findUncategorized();
@@ -38,7 +38,7 @@ export default SelectKitRowComponent.extend({
}
},
@computed("category", "parentCategory")
@discourseComputed("category", "parentCategory")
badgeForCategory(category, parentCategory) {
return categoryBadgeHTML(category, {
link: this.categoryLink,
@@ -47,7 +47,7 @@ export default SelectKitRowComponent.extend({
}).htmlSafe();
},
@computed("parentCategory")
@discourseComputed("parentCategory")
badgeForParentCategory(parentCategory) {
return categoryBadgeHTML(parentCategory, {
link: this.categoryLink,
@@ -55,22 +55,22 @@ export default SelectKitRowComponent.extend({
}).htmlSafe();
},
@computed("parentCategoryid")
@discourseComputed("parentCategoryid")
parentCategory(parentCategoryId) {
return Category.findById(parentCategoryId);
},
@computed("parentCategoryid")
@discourseComputed("parentCategoryid")
hasParentCategory(parentCategoryid) {
return !Ember.isNone(parentCategoryid);
},
@computed("category")
@discourseComputed("category")
parentCategoryid(category) {
return category.get("parent_category_id");
},
@computed(
@discourseComputed(
"category.totalTopicCount",
"category.topic_count",
"options.countSubcategories"
@@ -79,19 +79,19 @@ export default SelectKitRowComponent.extend({
return countSubcats ? totalCount : topicCount;
},
@computed("displayCategoryDescription", "category.description")
@discourseComputed("displayCategoryDescription", "category.description")
shouldDisplayDescription(displayCategoryDescription, description) {
return displayCategoryDescription && description && description !== "null";
},
@computed("category.description_text")
@discourseComputed("category.description_text")
descriptionText(descriptionText) {
if (descriptionText) {
return this._formatCategoryDescription(descriptionText);
}
},
@computed("category.description")
@discourseComputed("category.description")
description(description) {
if (description) {
return this._formatCategoryDescription(description);

View File

@@ -1,13 +1,13 @@
import { escapeExpression } from "discourse/lib/utilities";
import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-row";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { default as discourseComputed } from "discourse-common/utils/decorators";
export default SelectKitRowComponent.extend({
layoutName:
"select-kit/templates/components/color-palettes/color-palettes-row",
classNames: "color-palettes-row",
@computed("computedContent.originalContent.colors")
@discourseComputed("computedContent.originalContent.colors")
colors(colors) {
return (colors || []).map(color => `#${escapeExpression(color.hex)}`);
}

View File

@@ -1,8 +1,8 @@
import SingleSelectComponent from "select-kit/components/single-select";
import {
on,
default as computed
} from "ember-addons/ember-computed-decorators";
default as discourseComputed
} from "discourse-common/utils/decorators";
export default SingleSelectComponent.extend({
pluginApiIdentifiers: ["combo-box"],
@@ -20,7 +20,7 @@ export default SingleSelectComponent.extend({
return content;
},
@computed("isExpanded", "caretUpIcon", "caretDownIcon")
@discourseComputed("isExpanded", "caretUpIcon", "caretDownIcon")
caretIcon(isExpanded, caretUpIcon, caretDownIcon) {
return isExpanded ? caretUpIcon : caretDownIcon;
},

View File

@@ -1,5 +1,5 @@
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
import {
PRIVATE_MESSAGE,
CREATE_TOPIC,
@@ -76,7 +76,7 @@ export default DropdownSelectBoxComponent.extend({
return content;
},
@computed("options", "canWhisper", "action")
@discourseComputed("options", "canWhisper", "action")
content(options, canWhisper, action) {
let items = [];

View File

@@ -1,5 +1,5 @@
import SingleSelectComponent from "select-kit/components/single-select";
import { on } from "ember-addons/ember-computed-decorators";
import { on } from "discourse-common/utils/decorators";
export default SingleSelectComponent.extend({
pluginApiIdentifiers: ["dropdown-select-box"],

View File

@@ -1,5 +1,5 @@
import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default SelectKitHeaderComponent.extend({
layoutName:
@@ -9,7 +9,7 @@ export default SelectKitHeaderComponent.extend({
classNameBindings: ["btnClassName"],
@computed("options.showFullTitle")
@discourseComputed("options.showFullTitle")
btnClassName(showFullTitle) {
return `btn ${showFullTitle ? "btn-icon-text" : "no-text btn-icon"}`;
}

View File

@@ -1,6 +1,6 @@
import ComboBoxComponent from "select-kit/components/combo-box";
import DiscourseURL from "discourse/lib/url";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { default as discourseComputed } from "discourse-common/utils/decorators";
export default ComboBoxComponent.extend({
pluginApiIdentifiers: ["group-dropdown"],
@@ -12,7 +12,7 @@ export default ComboBoxComponent.extend({
allowAutoSelectFirst: false,
valueAttribute: "name",
@computed("content")
@discourseComputed("content")
filterable(content) {
return content && content.length >= 10;
},
@@ -27,7 +27,7 @@ export default ComboBoxComponent.extend({
return content;
},
@computed
@discourseComputed
collectionHeader() {
if (
this.siteSettings.enable_group_directory ||

View File

@@ -1,7 +1,7 @@
import Category from "discourse/models/category";
import ComboBox from "select-kit/components/combo-box";
import TagsMixin from "select-kit/mixins/tags";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { default as discourseComputed } from "discourse-common/utils/decorators";
import renderTag from "discourse/lib/render-tag";
import { escapeExpression } from "discourse/lib/utilities";
import { makeArray } from "discourse-common/lib/helpers";
@@ -55,7 +55,7 @@ export default ComboBox.extend(TagsMixin, {
);
},
@computed(
@discourseComputed(
"computedValue",
"filter",
"collectionComputedContent.[]",
@@ -98,12 +98,12 @@ export default ComboBox.extend(TagsMixin, {
);
},
@computed("hasReachedMaximum")
@discourseComputed("hasReachedMaximum")
caretIcon(hasReachedMaximum) {
return hasReachedMaximum ? null : "plus";
},
@computed("tags")
@discourseComputed("tags")
selection(tags) {
return makeArray(tags).map(c => this.computeContentItem(c));
},
@@ -139,7 +139,7 @@ export default ComboBox.extend(TagsMixin, {
return true;
},
@computed("tags.[]", "filter", "highlightedSelection.[]")
@discourseComputed("tags.[]", "filter", "highlightedSelection.[]")
collectionHeader(tags, filter, highlightedSelection) {
if (!isEmpty(tags)) {
let output = "";

View File

@@ -1,6 +1,8 @@
import SelectKitComponent from "select-kit/components/select-kit";
import computed from "ember-addons/ember-computed-decorators";
import { on } from "ember-addons/ember-computed-decorators";
import {
default as discourseComputed,
on
} from "discourse-common/utils/decorators";
const { get, isNone, isEmpty, makeArray, run } = Ember;
import {
applyOnSelectPluginApiCallbacks,
@@ -67,7 +69,7 @@ export default SelectKitComponent.extend({
});
},
@computed("filter", "shouldDisplayCreateRow")
@discourseComputed("filter", "shouldDisplayCreateRow")
createRowComputedContent(filter, shouldDisplayCreateRow) {
if (shouldDisplayCreateRow) {
let content = this.createContentFromInput(filter);
@@ -75,12 +77,12 @@ export default SelectKitComponent.extend({
}
},
@computed("filter", "computedValues")
@discourseComputed("filter", "computedValues")
shouldDisplayCreateRow(filter, computedValues) {
return this._super() && !computedValues.includes(filter);
},
@computed
@discourseComputed
shouldDisplayFilter() {
return true;
},
@@ -126,7 +128,7 @@ export default SelectKitComponent.extend({
});
},
@computed("computedAsyncContent.[]", "computedValues.[]")
@discourseComputed("computedAsyncContent.[]", "computedValues.[]")
filteredAsyncComputedContent(computedAsyncContent, computedValues) {
computedAsyncContent = computedAsyncContent.filter(c => {
return !computedValues.includes(get(c, "value"));
@@ -139,7 +141,7 @@ export default SelectKitComponent.extend({
return computedAsyncContent;
},
@computed("computedContent.[]", "computedValues.[]", "filter")
@discourseComputed("computedContent.[]", "computedValues.[]", "filter")
filteredComputedContent(computedContent, computedValues, filter) {
computedContent = computedContent.filter(c => {
return !computedValues.includes(get(c, "value"));
@@ -182,7 +184,7 @@ export default SelectKitComponent.extend({
return content;
},
@computed("filter")
@discourseComputed("filter")
templateForCreateRow() {
return rowComponent => {
return I18n.t("select_kit.create", {
@@ -195,7 +197,7 @@ export default SelectKitComponent.extend({
return this._super() && !this.hasReachedMaximum;
},
@computed("computedValues.[]", "computedContent.[]")
@discourseComputed("computedValues.[]", "computedContent.[]")
selection(computedValues, computedContent) {
const selected = [];
@@ -207,7 +209,7 @@ export default SelectKitComponent.extend({
return selected;
},
@computed("selection.[]")
@discourseComputed("selection.[]")
hasSelection(selection) {
return !isEmpty(selection);
},

View File

@@ -1,4 +1,4 @@
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
const { isEmpty } = Ember;
import SelectKitFilterComponent from "select-kit/components/select-kit/select-kit-filter";
@@ -6,8 +6,8 @@ export default SelectKitFilterComponent.extend({
layoutName: "select-kit/templates/components/select-kit/select-kit-filter",
classNames: ["multi-select-filter"],
@computed("placeholder", "hasSelection")
computedPlaceholder(placeholder, hasSelection) {
@discourseComputed("placeholder", "hasSelection")
discourseComputedPlaceholder(placeholder, hasSelection) {
if (hasSelection) return "";
return isEmpty(placeholder) ? "" : I18n.t(placeholder);
}

View File

@@ -1,6 +1,6 @@
import { makeArray } from "discourse-common/lib/helpers";
import { on } from "ember-addons/ember-computed-decorators";
import computed from "ember-addons/ember-computed-decorators";
import { on } from "discourse-common/utils/decorators";
import discourseComputed from "discourse-common/utils/decorators";
import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";
export default SelectKitHeaderComponent.extend({
@@ -38,14 +38,14 @@ export default SelectKitHeaderComponent.extend({
$filter.width(availableSpace - parentRightPadding * 4);
},
@computed("computedContent.selection.[]")
@discourseComputed("computedContent.selection.[]")
names(selection) {
return makeArray(selection)
.map(s => s.name)
.join(",");
},
@computed("computedContent.selection.[]")
@discourseComputed("computedContent.selection.[]")
values(selection) {
return makeArray(selection)
.map(s => s.value)

View File

@@ -1,12 +1,12 @@
import SelectedNameComponent from "select-kit/components/multi-select/selected-name";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
import { categoryBadgeHTML } from "discourse/helpers/category-link";
export default SelectedNameComponent.extend({
classNames: "selected-category",
layoutName: "select-kit/templates/components/multi-select/selected-category",
@computed("computedContent.originalContent")
@discourseComputed("computedContent.originalContent")
badge(category) {
return categoryBadgeHTML(category, {
allowUncategorized: true,

View File

@@ -1,10 +1,10 @@
import SelectedNameComponent from "select-kit/components/multi-select/selected-name";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default SelectedNameComponent.extend({
classNames: "selected-color",
@computed("name")
@discourseComputed("name")
footerContent(name) {
return `<span class="color-preview" style="background:#${name}"></span>`.htmlSafe();
}

View File

@@ -1,5 +1,5 @@
import Component from "@ember/component";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default Component.extend({
attributeBindings: [
@@ -16,14 +16,14 @@ export default Component.extend({
tagName: "span",
tabindex: -1,
@computed("computedContent")
@discourseComputed("computedContent")
guid(computedContent) {
return Ember.guidFor(computedContent);
},
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "title"),
@computed("computedContent.title", "name")
@discourseComputed("computedContent.title", "name")
title(computedContentTitle, name) {
if (computedContentTitle) return computedContentTitle;
if (name) return name;
@@ -41,7 +41,7 @@ export default Component.extend({
return this.getWithDefault("computedContent.locked", false);
}),
@computed("computedContent", "highlightedSelection.[]")
@discourseComputed("computedContent", "highlightedSelection.[]")
isHighlighted(computedContent, highlightedSelection) {
return highlightedSelection.includes(this.computedContent);
},

View File

@@ -1,12 +1,12 @@
import CategoryRowComponent from "select-kit/components/category-row";
import { categoryBadgeHTML } from "discourse/helpers/category-link";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default CategoryRowComponent.extend({
layoutName: "select-kit/templates/components/category-row",
classNames: "none category-row",
@computed("category")
@discourseComputed("category")
badgeForCategory(category) {
return categoryBadgeHTML(category, {
link: this.categoryLink,

View File

@@ -1,9 +1,9 @@
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import {
default as computed,
default as discourseComputed,
observes,
on
} from "ember-addons/ember-computed-decorators";
} from "discourse-common/utils/decorators";
import { buttonDetails } from "discourse/lib/notification-levels";
import { allLevels } from "discourse/lib/notification-levels";
@@ -20,7 +20,7 @@ export default DropdownSelectBoxComponent.extend({
i18nPrefix: "",
i18nPostfix: "",
@computed("iconForSelectedDetails")
@discourseComputed("iconForSelectedDetails")
headerIcon(iconForSelectedDetails) {
return iconForSelectedDetails;
},
@@ -47,7 +47,7 @@ export default DropdownSelectBoxComponent.extend({
return content;
},
@computed("computedValue")
@discourseComputed("computedValue")
selectedDetails(computedValue) {
return buttonDetails(computedValue);
}

View File

@@ -1,6 +1,6 @@
import DropdownSelectBoxRoxComponent from "select-kit/components/dropdown-select-box/dropdown-select-box-row";
import { buttonDetails } from "discourse/lib/notification-levels";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
import { iconHTML } from "discourse-common/lib/icon-library";
export default DropdownSelectBoxRoxComponent.extend({
@@ -9,18 +9,21 @@ export default DropdownSelectBoxRoxComponent.extend({
i18nPrefix: Ember.computed.alias("options.i18nPrefix"),
i18nPostfix: Ember.computed.alias("options.i18nPostfix"),
@computed("computedContent.value", "i18nPrefix", "i18nPostfix")
@discourseComputed("computedContent.value", "i18nPrefix", "i18nPostfix")
title(value, prefix, postfix) {
const key = buttonDetails(value).key;
return I18n.t(`${prefix}.${key}${postfix}.title`);
},
@computed("computedContent.name", "computedContent.originalContent.icon")
@discourseComputed(
"computedContent.name",
"computedContent.originalContent.icon"
)
icon(contentName, icon) {
return iconHTML(icon, { class: contentName.dasherize() });
},
@computed("_start")
@discourseComputed("_start")
description(_start) {
if (this.site && this.site.mobileView) {
return null;
@@ -29,12 +32,12 @@ export default DropdownSelectBoxRoxComponent.extend({
return Handlebars.escapeExpression(I18n.t(`${_start}.description`));
},
@computed("_start")
@discourseComputed("_start")
name(_start) {
return Handlebars.escapeExpression(I18n.t(`${_start}.title`));
},
@computed("i18nPrefix", "i18nPostfix", "computedContent.name")
@discourseComputed("i18nPrefix", "i18nPostfix", "computedContent.name")
_start(prefix, postfix, contentName) {
return `${prefix}.${contentName}${postfix}`;
}

View File

@@ -1,5 +1,5 @@
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import computed, { on } from "ember-addons/ember-computed-decorators";
import discourseComputed, { on } from "discourse-common/utils/decorators";
export default DropdownSelectBoxComponent.extend({
classNames: ["period-chooser"],
@@ -9,7 +9,7 @@ export default DropdownSelectBoxComponent.extend({
value: Ember.computed.alias("period"),
isHidden: Ember.computed.alias("showPeriods"),
@computed("isExpanded")
@discourseComputed("isExpanded")
caretIcon(isExpanded) {
return isExpanded ? "caret-up" : "caret-down";
},

View File

@@ -1,12 +1,12 @@
import DropdownSelectBoxRowComponent from "select-kit/components/dropdown-select-box/dropdown-select-box-row";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default DropdownSelectBoxRowComponent.extend({
layoutName:
"select-kit/templates/components/period-chooser/period-chooser-row",
classNames: "period-chooser-row",
@computed("computedContent")
@discourseComputed("computedContent")
title(computedContent) {
return I18n.t(`filters.top.${computedContent.name || "this_week"}`).title;
}

View File

@@ -1,5 +1,5 @@
import Component from "@ember/component";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default Component.extend({
pluginApiIdentifiers: ["pinned-button"],
@@ -8,7 +8,7 @@ export default Component.extend({
classNameBindings: ["isHidden"],
layoutName: "select-kit/templates/components/pinned-button",
@computed("topic.pinned_globally", "pinned")
@discourseComputed("topic.pinned_globally", "pinned")
reasonText(pinnedGlobally, pinned) {
const globally = pinnedGlobally ? "_globally" : "";
const pinnedKey = pinned ? `pinned${globally}` : "unpinned";
@@ -16,7 +16,7 @@ export default Component.extend({
return I18n.t(key);
},
@computed("pinned", "topic.deleted", "topic.unpinned")
@discourseComputed("pinned", "topic.deleted", "topic.unpinned")
isHidden(pinned, deleted, unpinned) {
return deleted || (!pinned && !unpinned);
}

View File

@@ -1,5 +1,5 @@
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import { on } from "ember-addons/ember-computed-decorators";
import { on } from "discourse-common/utils/decorators";
import { iconHTML } from "discourse-common/lib/icon-library";
export default DropdownSelectBoxComponent.extend({

View File

@@ -1,7 +1,8 @@
import discourseComputed from "discourse-common/utils/decorators";
import EmberObject from "@ember/object";
import Component from "@ember/component";
const { get, isNone, run, isEmpty, makeArray } = Ember;
import computed from "ember-addons/ember-computed-decorators";
import UtilsMixin from "select-kit/mixins/utils";
import DomHelpersMixin from "select-kit/mixins/dom-helpers";
import EventsMixin from "select-kit/mixins/events";
@@ -223,7 +224,7 @@ export default Component.extend(
return this.computeContentItem(contentItem, options);
},
@computed(
@discourseComputed(
"isAsync",
"isLoading",
"filteredAsyncComputedContent.[]",
@@ -250,28 +251,28 @@ export default Component.extend(
return !this.hasReachedMaximum;
},
@computed("maximum", "selection.[]")
@discourseComputed("maximum", "selection.[]")
hasReachedMaximum(maximum, selection) {
if (!maximum) return false;
selection = makeArray(selection);
return selection.length >= maximum;
},
@computed("minimum", "selection.[]")
@discourseComputed("minimum", "selection.[]")
hasReachedMinimum(minimum, selection) {
if (!minimum) return true;
selection = makeArray(selection);
return selection.length >= minimum;
},
@computed("shouldFilter", "allowAny")
@discourseComputed("shouldFilter", "allowAny")
shouldDisplayFilter(shouldFilter, allowAny) {
if (shouldFilter) return true;
if (allowAny) return true;
return false;
},
@computed("filter", "collectionComputedContent.[]", "isLoading")
@discourseComputed("filter", "collectionComputedContent.[]", "isLoading")
noContentRow(filter, collectionComputedContent, isLoading) {
if (
filter.length > 0 &&
@@ -282,7 +283,7 @@ export default Component.extend(
}
},
@computed("hasReachedMaximum", "hasReachedMinimum", "isExpanded")
@discourseComputed("hasReachedMaximum", "hasReachedMinimum", "isExpanded")
validationMessage(hasReachedMaximum, hasReachedMinimum) {
if (hasReachedMaximum && this.maximum) {
const key = this.maximumLabel || "select_kit.max_content_reached";
@@ -295,14 +296,19 @@ export default Component.extend(
}
},
@computed("allowAny")
@discourseComputed("allowAny")
filterPlaceholder(allowAny) {
return allowAny
? "select_kit.filter_placeholder_with_any"
: "select_kit.filter_placeholder";
},
@computed("filter", "filterable", "autoFilterable", "renderedFilterOnce")
@discourseComputed(
"filter",
"filterable",
"autoFilterable",
"renderedFilterOnce"
)
shouldFilter(filter, filterable, autoFilterable, renderedFilterOnce) {
if (renderedFilterOnce && filterable) return true;
if (filterable) return true;
@@ -310,7 +316,7 @@ export default Component.extend(
return false;
},
@computed(
@discourseComputed(
"computedValue",
"filter",
"collectionComputedContent.[]",
@@ -331,7 +337,7 @@ export default Component.extend(
return false;
},
@computed("filter", "shouldDisplayCreateRow")
@discourseComputed("filter", "shouldDisplayCreateRow")
createRowComputedContent(filter, shouldDisplayCreateRow) {
if (shouldDisplayCreateRow) {
let content = this.createContentFromInput(filter);
@@ -343,17 +349,17 @@ export default Component.extend(
}
},
@computed
@discourseComputed
templateForRow() {
return () => null;
},
@computed
@discourseComputed
templateForNoneRow() {
return () => null;
},
@computed("filter")
@discourseComputed("filter")
templateForCreateRow() {
return rowComponent => {
return I18n.t("select_kit.create", {
@@ -362,7 +368,7 @@ export default Component.extend(
};
},
@computed("none")
@discourseComputed("none")
noneRowComputedContent(none) {
if (isNone(none)) return null;
@@ -427,7 +433,12 @@ export default Component.extend(
this._boundaryActionHandler("onStopLoading");
},
@computed("selection.[]", "isExpanded", "filter", "highlightedSelection.[]")
@discourseComputed(
"selection.[]",
"isExpanded",
"filter",
"highlightedSelection.[]"
)
collectionHeaderComputedContent() {
return applyCollectionHeaderCallbacks(
this.pluginApiIdentifiers,
@@ -436,7 +447,7 @@ export default Component.extend(
);
},
@computed("selection.[]", "isExpanded", "headerIcon")
@discourseComputed("selection.[]", "isExpanded", "headerIcon")
headerComputedContent() {
return applyHeaderContentPluginApiCallbacks(
this.pluginApiIdentifiers,

View File

@@ -1,5 +1,6 @@
import Component from "@ember/component";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
const { isEmpty } = Ember;
export default Component.extend({
@@ -8,8 +9,8 @@ export default Component.extend({
classNameBindings: ["isFocused", "isHidden"],
isHidden: Ember.computed.not("shouldDisplayFilter"),
@computed("placeholder")
computedPlaceholder(placeholder) {
@discourseComputed("placeholder")
discourseComputedPlaceholder(placeholder) {
return isEmpty(placeholder) ? "" : I18n.t(placeholder);
}
});

View File

@@ -1,5 +1,6 @@
import Component from "@ember/component";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
const { isEmpty, makeArray } = Ember;
export default Component.extend({
@@ -23,7 +24,7 @@ export default Component.extend({
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "sanitizedTitle"),
@computed("computedContent.title", "name")
@discourseComputed("computedContent.title", "name")
title(computedContentTitle, name) {
if (computedContentTitle) return computedContentTitle;
if (name) return name;
@@ -33,7 +34,7 @@ export default Component.extend({
// this might need a more advanced solution
// but atm it's the only case we have to handle
@computed("title")
@discourseComputed("title")
sanitizedTitle(title) {
return String(title).replace("&hellip;", "");
},
@@ -44,7 +45,7 @@ export default Component.extend({
value: Ember.computed.alias("computedContent.value"),
@computed("computedContent.icon", "computedContent.icons")
@discourseComputed("computedContent.icon", "computedContent.icons")
icons(icon, icons) {
return makeArray(icon)
.concat(icons)

View File

@@ -1,6 +1,9 @@
import Component from "@ember/component";
import { on } from "ember-addons/ember-computed-decorators";
import computed from "ember-addons/ember-computed-decorators";
import {
default as discourseComputed,
on
} from "discourse-common/utils/decorators";
const { run, isPresent, makeArray, isEmpty } = Ember;
import UtilsMixin from "select-kit/mixins/utils";
@@ -27,7 +30,7 @@ export default Component.extend(UtilsMixin, {
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "title"),
@computed("computedContent.title", "name")
@discourseComputed("computedContent.title", "name")
title(computedContentTitle, name) {
if (computedContentTitle) return computedContentTitle;
if (name) return name;
@@ -35,7 +38,7 @@ export default Component.extend(UtilsMixin, {
return null;
},
@computed("computedContent")
@discourseComputed("computedContent")
guid(computedContent) {
return Ember.guidFor(computedContent);
},
@@ -46,7 +49,7 @@ export default Component.extend(UtilsMixin, {
value: Ember.computed.alias("computedContent.value"),
@computed("templateForRow")
@discourseComputed("templateForRow")
template(templateForRow) {
return templateForRow(this);
},
@@ -67,7 +70,7 @@ export default Component.extend(UtilsMixin, {
}
},
@computed(
@discourseComputed(
"computedContent.icon",
"computedContent.icons",
"computedContent.originalContent.icon"

View File

@@ -1,8 +1,8 @@
import SelectKitComponent from "select-kit/components/select-kit";
import {
default as computed,
default as discourseComputed,
on
} from "ember-addons/ember-computed-decorators";
} from "discourse-common/utils/decorators";
const { get, isNone, isEmpty, isPresent, run, makeArray } = Ember;
import {
@@ -115,7 +115,7 @@ export default SelectKitComponent.extend({
return content;
},
@computed("computedAsyncContent.[]", "computedValue")
@discourseComputed("computedAsyncContent.[]", "computedValue")
filteredAsyncComputedContent(computedAsyncContent, computedValue) {
computedAsyncContent = (computedAsyncContent || []).filter(c => {
return computedValue !== get(c, "value");
@@ -128,7 +128,12 @@ export default SelectKitComponent.extend({
return computedAsyncContent;
},
@computed("computedContent.[]", "computedValue", "filter", "shouldFilter")
@discourseComputed(
"computedContent.[]",
"computedValue",
"filter",
"shouldFilter"
)
filteredComputedContent(
computedContent,
computedValue,
@@ -150,17 +155,17 @@ export default SelectKitComponent.extend({
return computedContent;
},
@computed("computedValue", "computedContent.[]")
@discourseComputed("computedValue", "computedContent.[]")
selection(computedValue, computedContent) {
return computedContent.findBy("value", computedValue);
},
@computed("selection")
@discourseComputed("selection")
hasSelection(selection) {
return selection !== this.noneRowComputedContent && !isNone(selection);
},
@computed(
@discourseComputed(
"computedValue",
"filter",
"collectionComputedContent.[]",

View File

@@ -1,7 +1,7 @@
import MultiSelectComponent from "select-kit/components/multi-select";
import TagsMixin from "select-kit/mixins/tags";
import renderTag from "discourse/lib/render-tag";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
import { makeArray } from "discourse-common/lib/helpers";
const { get, run } = Ember;
@@ -55,12 +55,12 @@ export default MultiSelectComponent.extend(TagsMixin, {
this.set("tags", values.filter(v => v));
},
@computed("tags")
@discourseComputed("tags")
values(tags) {
return makeArray(tags);
},
@computed("tags")
@discourseComputed("tags")
content(tags) {
return makeArray(tags);
},

View File

@@ -2,7 +2,7 @@ import { makeArray } from "discourse-common/lib/helpers";
import ComboBoxComponent from "select-kit/components/combo-box";
import DiscourseURL from "discourse/lib/url";
import TagsMixin from "select-kit/mixins/tags";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { default as discourseComputed } from "discourse-common/utils/decorators";
const { isEmpty, run } = Ember;
export default ComboBoxComponent.extend(TagsMixin, {
@@ -25,18 +25,18 @@ export default ComboBoxComponent.extend(TagsMixin, {
allowContentReplacement: true,
isAsync: true,
@computed("tagId")
@discourseComputed("tagId")
noTagsSelected() {
return this.tagId === "none";
},
@computed("showFilterByTag", "content")
@discourseComputed("showFilterByTag", "content")
isHidden(showFilterByTag, content) {
if (showFilterByTag && !isEmpty(content)) return false;
return true;
},
@computed("content")
@discourseComputed("content")
filterable(content) {
return content && content.length >= 15;
},
@@ -63,12 +63,12 @@ export default ComboBoxComponent.extend(TagsMixin, {
return content;
},
@computed("tagId")
@discourseComputed("tagId")
tagClass(tagId) {
return tagId ? `tag-${tagId}` : "tag_all";
},
@computed("firstCategory", "secondCategory")
@discourseComputed("firstCategory", "secondCategory")
allTagsUrl() {
if (this.currentCategory) {
return Discourse.getURL(this.get("currentCategory.url") + "?allTags=1");
@@ -77,7 +77,7 @@ export default ComboBoxComponent.extend(TagsMixin, {
}
},
@computed("firstCategory", "secondCategory")
@discourseComputed("firstCategory", "secondCategory")
noTagsUrl() {
var url = "/tags";
if (this.currentCategory) {
@@ -86,17 +86,17 @@ export default ComboBoxComponent.extend(TagsMixin, {
return Discourse.getURL(`${url}/none`);
},
@computed("tag")
@discourseComputed("tag")
allTagsLabel() {
return I18n.t("tagging.selector_all_tags");
},
@computed("tag")
@discourseComputed("tag")
noTagsLabel() {
return I18n.t("tagging.selector_no_tags");
},
@computed("tagId", "allTagsLabel", "noTagsLabel")
@discourseComputed("tagId", "allTagsLabel", "noTagsLabel")
shortcuts(tagId, allTagsLabel, noTagsLabel) {
const shortcuts = [];
@@ -119,7 +119,7 @@ export default ComboBoxComponent.extend(TagsMixin, {
return shortcuts;
},
@computed("site.top_tags", "shortcuts")
@discourseComputed("site.top_tags", "shortcuts")
content(topTags, shortcuts) {
if (this.siteSettings.tags_sort_alphabetically && topTags) {
return shortcuts.concat(topTags.sort());

View File

@@ -1,7 +1,8 @@
import MultiSelectComponent from "select-kit/components/multi-select";
import TagsMixin from "select-kit/mixins/tags";
import renderTag from "discourse/lib/render-tag";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
const { get, isEmpty, run, makeArray } = Ember;
export default MultiSelectComponent.extend(TagsMixin, {
@@ -29,12 +30,12 @@ export default MultiSelectComponent.extend(TagsMixin, {
this.set("tagGroups", values.filter(v => v));
},
@computed("tagGroups")
@discourseComputed("tagGroups")
values(tagGroups) {
return makeArray(tagGroups);
},
@computed("tagGroups")
@discourseComputed("tagGroups")
content(tagGroups) {
return makeArray(tagGroups);
},

View File

@@ -1,5 +1,5 @@
import NotificationOptionsComponent from "select-kit/components/notifications-button";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default NotificationOptionsComponent.extend({
pluginApiIdentifiers: ["tag-notifications-button"],
@@ -16,7 +16,7 @@ export default NotificationOptionsComponent.extend({
return this.notificationLevel;
},
@computed("iconForSelectedDetails")
@discourseComputed("iconForSelectedDetails")
headerIcon(iconForSelectedDetails) {
return iconForSelectedDetails;
}

View File

@@ -1,5 +1,5 @@
import ComboBoxComponent from "select-kit/components/combo-box";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { default as discourseComputed } from "discourse-common/utils/decorators";
export default ComboBoxComponent.extend({
pluginApiIdentifiers: ["timezone-input"],
@@ -9,7 +9,7 @@ export default ComboBoxComponent.extend({
filterable: true,
allowAny: false,
@computed
@discourseComputed
content() {
let timezones;

View File

@@ -1,5 +1,5 @@
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default DropdownSelectBoxComponent.extend({
pluginApiIdentifiers: ["toolbar-popup-menu-options"],
@@ -7,7 +7,7 @@ export default DropdownSelectBoxComponent.extend({
isHidden: Ember.computed.empty("computedContent"),
showFullTitle: false,
@computed("title")
@discourseComputed("title")
collectionHeader(title) {
return `<h3>${title}</h3>`;
},

View File

@@ -1,8 +1,8 @@
import NotificationOptionsComponent from "select-kit/components/notifications-button";
import {
default as computed,
default as discourseComputed,
on
} from "ember-addons/ember-computed-decorators";
} from "discourse-common/utils/decorators";
import { topicLevels } from "discourse/lib/notification-levels";
export default NotificationOptionsComponent.extend({
@@ -12,7 +12,7 @@ export default NotificationOptionsComponent.extend({
i18nPrefix: "topic.notifications",
allowInitialValueMutation: false,
@computed("topic.archetype")
@discourseComputed("topic.archetype")
i18nPostfix(archetype) {
return archetype === "private_message" ? "_pm" : "";
},

View File

@@ -1,7 +1,7 @@
import DropdownSelectBox from "select-kit/components/dropdown-select-box";
import { popupAjaxError } from "discourse/lib/ajax-error";
import showModal from "discourse/lib/show-modal";
import computed from "ember-addons/ember-computed-decorators";
import discourseComputed from "discourse-common/utils/decorators";
export default DropdownSelectBox.extend({
classNames: ["user-notifications", "user-notifications-dropdown"],
@@ -36,7 +36,7 @@ export default DropdownSelectBox.extend({
return content;
},
@computed("value")
@discourseComputed("value")
headerIcon(value) {
return this.computeContent().find(row => row.id === value).icon;
},
@@ -53,7 +53,7 @@ export default DropdownSelectBox.extend({
});
},
@computed("user.ignored", "user.muted")
@discourseComputed("user.ignored", "user.muted")
value() {
if (this.get("user.ignored")) {
return "changeToIgnored";

View File

@@ -1,6 +1,6 @@
import { next } from "@ember/runloop";
import { schedule } from "@ember/runloop";
import { on } from "ember-addons/ember-computed-decorators";
import { on } from "discourse-common/utils/decorators";
import Mixin from "@ember/object/mixin";
export default Mixin.create({

View File

@@ -3,7 +3,7 @@ import { makeArray } from "discourse-common/lib/helpers";
import { isEmpty } from "@ember/utils";
import { throttle } from "@ember/runloop";
import { schedule } from "@ember/runloop";
import { on } from "ember-addons/ember-computed-decorators";
import { on } from "discourse-common/utils/decorators";
import Mixin from "@ember/object/mixin";
const { bind } = Ember.run;