DEV: Removed all Ember.computed. in select-kit (#8322)

This commit is contained in:
Mark VanLandingham 2019-11-08 10:32:20 -06:00 committed by GitHub
parent 03bba8c7e0
commit 7f3812b90a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 75 additions and 54 deletions

View File

@ -1,3 +1,4 @@
import { alias, not } from "@ember/object/computed";
import ComboBoxComponent from "select-kit/components/combo-box";
import DiscourseURL from "discourse/lib/url";
import { default as discourseComputed } from "discourse-common/utils/decorators";
@ -10,18 +11,18 @@ export default ComboBoxComponent.extend({
classNameBindings: ["categoryStyle"],
classNames: "category-drop",
verticalOffset: 3,
content: Ember.computed.alias("categoriesWithShortcuts"),
content: alias("categoriesWithShortcuts"),
rowComponent: "category-row",
headerComponent: "category-drop/category-drop-header",
allowAutoSelectFirst: false,
tagName: "li",
categoryStyle: Ember.computed.alias("siteSettings.category_style"),
categoryStyle: alias("siteSettings.category_style"),
noCategoriesLabel: I18n.t("categories.no_subcategory"),
fullWidthOnMobile: true,
caretDownIcon: "caret-right",
caretUpIcon: "caret-down",
subCategory: false,
isAsync: Ember.computed.not("subCategory"),
isAsync: not("subCategory"),
@discourseComputed(
"categories",

View File

@ -1,3 +1,4 @@
import { alias } from "@ember/object/computed";
import { isEmpty } from "@ember/utils";
import ComboBoxSelectBoxHeaderComponent from "select-kit/components/combo-box/combo-box-header";
import discourseComputed from "discourse-common/utils/decorators";
@ -9,7 +10,7 @@ export default ComboBoxSelectBoxHeaderComponent.extend({
classNames: "category-drop-header",
classNameBindings: ["categoryStyleClass"],
categoryStyleClass: Ember.computed.alias("site.category_style"),
categoryStyleClass: alias("site.category_style"),
@discourseComputed("computedContent.value", "computedContent.name")
category(value, name) {

View File

@ -1,10 +1,11 @@
import { or, alias } from "@ember/object/computed";
import NotificationOptionsComponent from "select-kit/components/notifications-button";
export default NotificationOptionsComponent.extend({
pluginApiIdentifiers: ["category-notifications-button"],
classNames: "category-notifications-button",
isHidden: Ember.computed.or("category.deleted"),
headerIcon: Ember.computed.alias("iconForSelectedDetails"),
isHidden: or("category.deleted"),
headerIcon: alias("iconForSelectedDetails"),
i18nPrefix: "category.notifications",
showFullTitle: false,
allowInitialValueMutation: false,

View File

@ -1,3 +1,4 @@
import { bool } from "@ember/object/computed";
import { isEmpty } from "@ember/utils";
import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-row";
import discourseComputed from "discourse-common/utils/decorators";
@ -8,9 +9,9 @@ export default SelectKitRowComponent.extend({
layoutName: "select-kit/templates/components/category-row",
classNames: "category-row",
hideParentCategory: Ember.computed.bool("options.hideParentCategory"),
allowUncategorized: Ember.computed.bool("options.allowUncategorized"),
categoryLink: Ember.computed.bool("options.categoryLink"),
hideParentCategory: bool("options.hideParentCategory"),
allowUncategorized: bool("options.allowUncategorized"),
categoryLink: bool("options.categoryLink"),
@discourseComputed("options.displayCategoryDescription")
displayCategoryDescription(displayCategoryDescription) {

View File

@ -1,13 +1,14 @@
import { alias, and } from "@ember/object/computed";
import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";
export default SelectKitHeaderComponent.extend({
layoutName: "select-kit/templates/components/combo-box/combo-box-header",
classNames: "combo-box-header",
clearable: Ember.computed.alias("options.clearable"),
caretUpIcon: Ember.computed.alias("options.caretUpIcon"),
caretDownIcon: Ember.computed.alias("options.caretDownIcon"),
shouldDisplayClearableButton: Ember.computed.and(
clearable: alias("options.clearable"),
caretUpIcon: alias("options.caretUpIcon"),
caretDownIcon: alias("options.caretDownIcon"),
shouldDisplayClearableButton: and(
"clearable",
"computedContent.hasSelection"
)

View File

@ -1,3 +1,4 @@
import { alias } from "@ember/object/computed";
import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-row";
export default SelectKitRowComponent.extend({
@ -5,7 +6,7 @@ export default SelectKitRowComponent.extend({
"select-kit/templates/components/dropdown-select-box/dropdown-select-box-row",
classNames: "dropdown-select-box-row",
description: Ember.computed.alias(
description: alias(
"computedContent.originalContent.description"
)
});

View File

@ -1,3 +1,4 @@
import { equal } from "@ember/object/computed";
import { isEmpty } from "@ember/utils";
import ComboBoxComponent from "select-kit/components/combo-box";
import { CLOSE_STATUS_TYPE } from "discourse/controllers/edit-topic-timer";
@ -188,8 +189,8 @@ export const FORMAT = "YYYY-MM-DD HH:mmZ";
export default ComboBoxComponent.extend(DatetimeMixin, {
pluginApiIdentifiers: ["future-date-input-selector"],
classNames: ["future-date-input-selector"],
isCustom: Ember.computed.equal("value", "pick_date_and_time"),
isBasedOnLastPost: Ember.computed.equal("value", "set_based_on_last_post"),
isCustom: equal("value", "pick_date_and_time"),
isBasedOnLastPost: equal("value", "set_based_on_last_post"),
rowComponent: "future-date-input-selector/future-date-input-selector-row",
headerComponent:
"future-date-input-selector/future-date-input-selector-header",

View File

@ -1,3 +1,4 @@
import { alias } from "@ember/object/computed";
import ComboBoxComponent from "select-kit/components/combo-box";
import DiscourseURL from "discourse/lib/url";
import { default as discourseComputed } from "discourse-common/utils/decorators";
@ -5,7 +6,7 @@ import { default as discourseComputed } from "discourse-common/utils/decorators"
export default ComboBoxComponent.extend({
pluginApiIdentifiers: ["group-dropdown"],
classNames: "group-dropdown",
content: Ember.computed.alias("groups"),
content: alias("groups"),
tagName: "li",
caretDownIcon: "caret-right",
caretUpIcon: "caret-down",

View File

@ -1,3 +1,4 @@
import { empty, alias } from "@ember/object/computed";
import Category from "discourse/models/category";
import ComboBox from "select-kit/components/combo-box";
import TagsMixin from "select-kit/mixins/tags";
@ -19,11 +20,11 @@ export default ComboBox.extend(TagsMixin, {
classNameBindings: ["noTags"],
verticalOffset: 3,
filterable: true,
noTags: Ember.computed.empty("selection"),
noTags: empty("selection"),
allowCreate: null,
allowAny: Ember.computed.alias("allowCreate"),
caretUpIcon: Ember.computed.alias("caretIcon"),
caretDownIcon: Ember.computed.alias("caretIcon"),
allowAny: alias("allowCreate"),
caretUpIcon: alias("caretIcon"),
caretDownIcon: alias("caretIcon"),
isAsync: true,
fullWidthOnMobile: true,

View File

@ -1,3 +1,4 @@
import { alias, or } from "@ember/object/computed";
import { makeArray } from "discourse-common/lib/helpers";
import { on } from "discourse-common/utils/decorators";
import discourseComputed from "discourse-common/utils/decorators";
@ -13,13 +14,13 @@ export default SelectKitHeaderComponent.extend({
classNames: "multi-select-header",
layoutName:
"select-kit/templates/components/multi-select/multi-select-header",
selectedNameComponent: Ember.computed.alias("options.selectedNameComponent"),
selectedNameComponent: alias("options.selectedNameComponent"),
forceEscape: Ember.computed.alias("options.forceEscape"),
forceEscape: alias("options.forceEscape"),
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "title", "names"),
ariaLabel: or("computedContent.ariaLabel", "title", "names"),
title: Ember.computed.or("computedContent.title", "names"),
title: or("computedContent.title", "names"),
@on("didRender")
_positionFilter() {

View File

@ -1,3 +1,4 @@
import { or, alias } from "@ember/object/computed";
import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators";
@ -21,7 +22,7 @@ export default Component.extend({
return Ember.guidFor(computedContent);
},
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "title"),
ariaLabel: or("computedContent.ariaLabel", "title"),
@discourseComputed("computedContent.title", "name")
title(computedContentTitle, name) {
@ -31,11 +32,11 @@ export default Component.extend({
return null;
},
label: Ember.computed.or("computedContent.label", "title", "name"),
label: or("computedContent.label", "title", "name"),
name: Ember.computed.alias("computedContent.name"),
name: alias("computedContent.name"),
value: Ember.computed.alias("computedContent.value"),
value: alias("computedContent.value"),
isLocked: Ember.computed("computedContent.locked", function() {
return this.getWithDefault("computedContent.locked", false);

View File

@ -1,3 +1,4 @@
import { alias } from "@ember/object/computed";
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import {
default as discourseComputed,
@ -34,7 +35,7 @@ export default DropdownSelectBoxComponent.extend({
});
},
iconForSelectedDetails: Ember.computed.alias("selectedDetails.icon"),
iconForSelectedDetails: alias("selectedDetails.icon"),
computeHeaderContent() {
let content = this._super(...arguments);

View File

@ -1,3 +1,4 @@
import { alias } from "@ember/object/computed";
import DropdownSelectBoxRoxComponent from "select-kit/components/dropdown-select-box/dropdown-select-box-row";
import { buttonDetails } from "discourse/lib/notification-levels";
import discourseComputed from "discourse-common/utils/decorators";
@ -6,8 +7,8 @@ import { iconHTML } from "discourse-common/lib/icon-library";
export default DropdownSelectBoxRoxComponent.extend({
classNames: "notifications-button-row",
i18nPrefix: Ember.computed.alias("options.i18nPrefix"),
i18nPostfix: Ember.computed.alias("options.i18nPostfix"),
i18nPrefix: alias("options.i18nPrefix"),
i18nPostfix: alias("options.i18nPostfix"),
@discourseComputed("computedContent.value", "i18nPrefix", "i18nPostfix")
title(value, prefix, postfix) {

View File

@ -1,3 +1,4 @@
import { oneWay, alias } from "@ember/object/computed";
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import discourseComputed, { on } from "discourse-common/utils/decorators";
@ -5,9 +6,9 @@ export default DropdownSelectBoxComponent.extend({
classNames: ["period-chooser"],
rowComponent: "period-chooser/period-chooser-row",
headerComponent: "period-chooser/period-chooser-header",
content: Ember.computed.oneWay("site.periods"),
value: Ember.computed.alias("period"),
isHidden: Ember.computed.alias("showPeriods"),
content: oneWay("site.periods"),
value: alias("period"),
isHidden: alias("showPeriods"),
@discourseComputed("isExpanded")
caretIcon(isExpanded) {

View File

@ -1,3 +1,4 @@
import { not } from "@ember/object/computed";
import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators";
@ -7,7 +8,7 @@ export default Component.extend({
layoutName: "select-kit/templates/components/select-kit/select-kit-filter",
classNames: ["select-kit-filter"],
classNameBindings: ["isFocused", "isHidden"],
isHidden: Ember.computed.not("shouldDisplayFilter"),
isHidden: not("shouldDisplayFilter"),
@discourseComputed("placeholder")
discourseComputedPlaceholder(placeholder) {

View File

@ -1,3 +1,4 @@
import { alias, none, or } from "@ember/object/computed";
import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators";
@ -16,13 +17,13 @@ export default Component.extend({
"name:data-name"
],
forceEscape: Ember.computed.alias("options.forceEscape"),
forceEscape: alias("options.forceEscape"),
isNone: Ember.computed.none("computedContent.value"),
isNone: none("computedContent.value"),
ariaHasPopup: "true",
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "sanitizedTitle"),
ariaLabel: or("computedContent.ariaLabel", "sanitizedTitle"),
@discourseComputed("computedContent.title", "name")
title(computedContentTitle, name) {
@ -39,11 +40,11 @@ export default Component.extend({
return String(title).replace("…", "");
},
label: Ember.computed.or("computedContent.label", "title", "name"),
label: or("computedContent.label", "title", "name"),
name: Ember.computed.alias("computedContent.name"),
name: alias("computedContent.name"),
value: Ember.computed.alias("computedContent.value"),
value: alias("computedContent.value"),
@discourseComputed("computedContent.icon", "computedContent.icons")
icons(icon, icons) {

View File

@ -1,3 +1,4 @@
import { alias, or } from "@ember/object/computed";
import Component from "@ember/component";
import {
default as discourseComputed,
@ -26,9 +27,9 @@ export default Component.extend(UtilsMixin, {
"computedContent.originalContent.classNames"
],
forceEscape: Ember.computed.alias("options.forceEscape"),
forceEscape: alias("options.forceEscape"),
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "title"),
ariaLabel: or("computedContent.ariaLabel", "title"),
@discourseComputed("computedContent.title", "name")
title(computedContentTitle, name) {
@ -43,11 +44,11 @@ export default Component.extend(UtilsMixin, {
return Ember.guidFor(computedContent);
},
label: Ember.computed.or("computedContent.label", "title", "name"),
label: or("computedContent.label", "title", "name"),
name: Ember.computed.alias("computedContent.name"),
name: alias("computedContent.name"),
value: Ember.computed.alias("computedContent.value"),
value: alias("computedContent.value"),
@discourseComputed("templateForRow")
template(templateForRow) {

View File

@ -1,3 +1,4 @@
import { alias } from "@ember/object/computed";
import MultiSelectComponent from "select-kit/components/multi-select";
import TagsMixin from "select-kit/mixins/tags";
import renderTag from "discourse/lib/render-tag";
@ -15,7 +16,7 @@ export default MultiSelectComponent.extend(TagsMixin, {
blacklist: null,
attributeBindings: ["categoryId"],
allowCreate: null,
allowAny: Ember.computed.alias("allowCreate"),
allowAny: alias("allowCreate"),
init() {
this._super(...arguments);

View File

@ -1,3 +1,4 @@
import { alias, or } from "@ember/object/computed";
import { makeArray } from "discourse-common/lib/helpers";
import ComboBoxComponent from "select-kit/components/combo-box";
import DiscourseURL from "discourse/lib/url";
@ -10,14 +11,14 @@ export default ComboBoxComponent.extend(TagsMixin, {
classNameBindings: ["categoryStyle", "tagClass"],
classNames: "tag-drop",
verticalOffset: 3,
value: Ember.computed.alias("tagId"),
value: alias("tagId"),
headerComponent: "tag-drop/tag-drop-header",
allowAutoSelectFirst: false,
tagName: "li",
showFilterByTag: Ember.computed.alias("siteSettings.show_filter_by_tag"),
currentCategory: Ember.computed.or("secondCategory", "firstCategory"),
showFilterByTag: alias("siteSettings.show_filter_by_tag"),
currentCategory: or("secondCategory", "firstCategory"),
tagId: null,
categoryStyle: Ember.computed.alias("siteSettings.category_style"),
categoryStyle: alias("siteSettings.category_style"),
mutateAttributes() {},
fullWidthOnMobile: true,
caretDownIcon: "caret-right",

View File

@ -1,10 +1,11 @@
import { empty } from "@ember/object/computed";
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import discourseComputed from "discourse-common/utils/decorators";
export default DropdownSelectBoxComponent.extend({
pluginApiIdentifiers: ["toolbar-popup-menu-options"],
classNames: ["toolbar-popup-menu-options"],
isHidden: Ember.computed.empty("computedContent"),
isHidden: empty("computedContent"),
showFullTitle: false,
@discourseComputed("title")

View File

@ -1,3 +1,4 @@
import { empty } from "@ember/object/computed";
import ComboBoxComponent from "select-kit/components/combo-box";
export default ComboBoxComponent.extend({
@ -8,7 +9,7 @@ export default ComboBoxComponent.extend({
allowInitialValueMutation: false,
allowAutoSelectFirst: false,
nameProperty: "label",
isHidden: Ember.computed.empty("content"),
isHidden: empty("content"),
computeHeaderContent() {
const content = this._super(...arguments);