Skip to content

Commit

Permalink
Merge pull request #297 from paviliondev/fix_tests_and_deprecations
Browse files Browse the repository at this point in the history
FIX: tests and deprecations
  • Loading branch information
angusmcleod authored Nov 22, 2024
2 parents 577501e + 777b17f commit 86bd86b
Show file tree
Hide file tree
Showing 229 changed files with 5,059 additions and 9,496 deletions.
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

1 change: 1 addition & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/prettier");
1 change: 1 addition & 0 deletions .template-lintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/template-lint");
4 changes: 0 additions & 4 deletions .template-lintrc.js

This file was deleted.

10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{{#if showInputs}}
{{#if this.showInputs}}
<td>
{{wizard-subscription-selector
value=field.klass
value=this.field.klass
feature="custom_field"
attribute="klass"
onChange=(action (mut field.klass))
onChange=(action (mut this.field.klass))
options=(hash none="admin.wizard.custom_field.klass.select")
}}
</td>
<td>
{{wizard-subscription-selector
value=field.type
value=this.field.type
feature="custom_field"
attribute="type"
onChange=(action (mut field.type))
onChange=(action (mut this.field.type))
options=(hash none="admin.wizard.custom_field.type.select")
}}
</td>
Expand All @@ -25,48 +25,52 @@
</td>
<td class="multi-select">
{{multi-select
value=field.serializers
content=serializerContent
onChange=(action (mut field.serializers))
value=this.field.serializers
content=this.serializerContent
onChange=(action (mut this.field.serializers))
options=(hash none="admin.wizard.custom_field.serializers.select")
}}
</td>
<td class="actions">
{{#if loading}}
{{#if this.loading}}
{{loading-spinner size="small"}}
{{else}}
{{#if saveIcon}}
{{d-icon saveIcon}}
{{#if this.saveIcon}}
{{d-icon this.saveIcon}}
{{/if}}
{{/if}}
{{d-button
action=(action "destroy")
icon="trash-alt"
class="destroy"
disabled=destroyDisabled
disabled=this.destroyDisabled
}}
{{d-button
icon="save"
action=(action "save")
disabled=saveDisabled
disabled=this.saveDisabled
class="save"
}}
{{d-button action=(action "close") icon="times" disabled=closeDisabled}}
{{d-button
action=(action "close")
icon="times"
disabled=this.closeDisabled
}}
</td>
{{else}}
<td><label>{{field.klass}}</label></td>
<td><label>{{field.type}}</label></td>
<td class="input"><label>{{field.name}}</label></td>
<td><label>{{this.field.klass}}</label></td>
<td><label>{{this.field.type}}</label></td>
<td class="input"><label>{{this.field.name}}</label></td>
<td class="multi-select">
{{#if isExternal}}
{{#if this.isExternal}}
&mdash;
{{else}}
{{#each field.serializers as |serializer|}}
{{#each this.field.serializers as |serializer|}}
<label>{{serializer}}</label>
{{/each}}
{{/if}}
</td>
{{#if isExternal}}
{{#if this.isExternal}}
<td class="external">
<label title={{i18n "admin.wizard.custom_field.external.title"}}>
{{i18n "admin.wizard.custom_field.external.label"}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Component from "@ember/component";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { alias, equal, or } from "@ember/object/computed";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import I18n from "I18n";

export default Component.extend({
Expand All @@ -17,6 +17,7 @@ export default Component.extend({
isExternal: equal("field.id", "external"),

didInsertElement() {
this._super(...arguments);
this.set("originalField", JSON.parse(JSON.stringify(this.field)));
},

Expand Down Expand Up @@ -119,7 +120,12 @@ export default Component.extend({
} else {
this.set("saveIcon", "times");
}
setTimeout(() => this.set("saveIcon", null), 10000);
setTimeout(() => {
if (this.isDestroyed) {
return;
}
this.set("saveIcon", null);
}, 10000);
});
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { isEmpty } from "@ember/utils";
import Handlebars from "handlebars";
import $ from "jquery";
import TextField from "discourse/components/text-field";
import { renderAvatar } from "discourse/helpers/user-avatar";
import userSearch from "discourse/lib/user-search";
import {
default as computed,
observes,
} from "discourse-common/utils/decorators";
import { renderAvatar } from "discourse/helpers/user-avatar";
import userSearch from "discourse/lib/user-search";
import I18n from "I18n";
import Handlebars from "handlebars";
import { isEmpty } from "@ember/utils";
import TextField from "discourse/components/text-field";

const template = function (params) {
const options = params.options;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import CategorySelector from "select-kit/components/category-selector";
import { computed } from "@ember/object";
import { makeArray } from "discourse-common/lib/helpers";
import CategorySelector from "select-kit/components/category-selector";

export default CategorySelector.extend({
classNames: ["category-selector", "wizard-category-selector"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<div class={{this.fieldClass}}>
<DEditor
@tabindex={{field.tabindex}}
@value={{composer.reply}}
@placeholderOverride={{replyPlaceholder}}
@tabindex={{this.field.tabindex}}
@value={{this.composer.reply}}
@placeholderOverride={{this.replyPlaceholder}}
@previewUpdated={{this.previewUpdated}}
@markdownOptions={{markdownOptions}}
@markdownOptions={{this.markdownOptions}}
@extraButtons={{this.extraButtons}}
@importQuote={{this.importQuote}}
@showUploadModal={{this.showUploadModal}}
@togglePreview={{this.togglePreview}}
@validation={{validation}}
@loading={{composer.loading}}
@showLink={{showLink}}
@validation={{this.validation}}
@loading={{this.composer.loading}}
@showLink={{this.showLink}}
@wizardComposer={{true}}
@fieldId={{field.id}}
@disabled={{disableTextarea}}
@outletArgs={{hash composer=composer editorType="composer"}}
@fieldId={{this.field.id}}
@disabled={{this.disableTextarea}}
@outletArgs={{hash composer=this.composer editorType="composer"}}
/>

<input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import ComposerEditor from "discourse/components/composer-editor";
import discourseComputed, { bind } from "discourse-common/utils/decorators";
import { action } from "@ember/object";
import { alias } from "@ember/object/computed";
import { uploadIcon } from "discourse/lib/uploads";
import { service } from "@ember/service";
import { dasherize } from "@ember/string";
import ComposerEditor from "discourse/components/composer-editor";
import InsertHyperlink from "discourse/components/modal/insert-hyperlink";
import { inject as service } from "@ember/service";
import { action } from "@ember/object";
import { uploadIcon } from "discourse/lib/uploads";
import discourseComputed, { bind } from "discourse-common/utils/decorators";

export const wizardComposerEdtiorEventPrefix = "wizard-editor";

Expand Down Expand Up @@ -33,6 +33,9 @@ export default class CustomWizardComposerEditor extends ComposerEditor {
this.field.type
)}-${dasherize(this.field.id)} .d-editor-input`;
this.uppyComposerUpload.composerModel = this.composer;
if (!this.currentUser) {
this.currentUser = {};
}
}

@discourseComputed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{#unless this.timeFirst}}
{{custom-wizard-date-input
date=this.date
relativeDate=this.relativeDate
onChange=(action "onChangeDate")
tabindex=this.dateTabindex
}}
{{/unless}}

{{#if this.showTime}}
{{custom-wizard-time-input
date=this.date
relativeDate=this.relativeDate
onChange=(action "onChangeTime")
tabindex=this.timeTabindex
}}
{{/if}}

{{#if this.timeFirst}}
{{custom-wizard-date-input
date=this.date
relativeDate=this.relativeDate
onChange=(action "onChangeDate")
tabindex=this.dateTabindex
}}
{{/if}}

{{#if this.clearable}}
{{d-button class="clear-date-time" icon="times" action=(action "onClear")}}
{{/if}}
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
<div class="d-editor-overlay hidden"></div>

<div class="d-editor-container">
{{#if showPreview}}
<div class="d-editor-preview-wrapper {{if forcePreview 'force-preview'}}">
{{#if this.showPreview}}
<div
class="d-editor-preview-wrapper {{if this.forcePreview 'force-preview'}}"
>
<div class="d-editor-preview">
{{html-safe preview}}
{{html-safe this.preview}}
</div>
</div>
{{else}}
<div class="d-editor-textarea-wrapper">
<div class="d-editor-button-bar">
{{#each toolbar.groups as |group|}}
{{#each this.toolbar.groups as |group|}}
{{#each group.buttons as |b|}}
{{#if b.popupMenu}}
{{toolbar-popup-menu-options
onPopupMenuAction=onPopupMenuAction
onPopupMenuAction=this.onPopupMenuAction
onExpand=(action b.action b)
class=b.className
content=popupMenuOptions
content=this.popupMenuOptions
options=(hash popupTitle=b.title icon=b.icon)
}}
{{else}}
<div>{{d.icon}}</div>
<div>{{b.icon}}</div>
<button
class="wizard-btn {{b.className}}"
{{action b.action b}}
Expand All @@ -42,7 +44,7 @@
{{/each}}
</div>

{{conditional-loading-spinner condition=loading}}
{{conditional-loading-spinner condition=this.loading}}
<Textarea
tabindex={{this.tabindex}}
@value={{this.value}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{custom-wizard-category-selector
categories=this.categories
class=this.fieldClass
whitelist=this.field.content
onChange=(action (mut this.categories))
tabindex=this.field.tabindex
options=(hash maximum=this.field.limit)
}}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { observes } from "discourse-common/utils/decorators";
import Category from "discourse/models/category";
import Component from "@ember/component";
import Category from "discourse/models/category";
import { observes } from "discourse-common/utils/decorators";

export default Component.extend({
categories: [],

didInsertElement() {
this._super(...arguments);
const property = this.field.property || "id";
const value = this.field.value;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="wizard-composer-preview d-editor-preview-wrapper">
<div class="d-editor-preview">
{{html-safe field.preview_template}}
{{html-safe this.field.preview_template}}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Component from "@ember/component";
import { loadOneboxes } from "discourse/lib/load-oneboxes";
import { schedule } from "@ember/runloop";
import discourseDebounce from "discourse-common/lib/debounce";
import $ from "jquery";
import { resolveAllShortUrls } from "pretty-text/upload-short-url";
import { ajax } from "discourse/lib/ajax";
import { loadOneboxes } from "discourse/lib/load-oneboxes";
import discourseDebounce from "discourse-common/lib/debounce";
import { on } from "discourse-common/utils/decorators";

export default Component.extend({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<DButton
@action={{this.togglePreview}}
class="wizard-btn toggle-preview"
@label={{togglePreviewLabel}}
@label={{this.togglePreviewLabel}}
/>

{{#if this.field.char_counter}}
{{wizard-char-counter this.field.value field.max_length}}
{{wizard-char-counter this.field.value this.field.max_length}}
{{/if}}
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Component from "@ember/component";
import EmberObject, { action } from "@ember/object";
import {
default as computed,
observes,
} from "discourse-common/utils/decorators";
import Component from "@ember/component";
import EmberObject, { action } from "@ember/object";

export default Component.extend({
showPreview: false,
Expand All @@ -19,6 +19,7 @@ export default Component.extend({
EmberObject.create({
loading: false,
reply: this.get("field.value") || "",
afterRefresh: () => {},
})
);
},
Expand Down
Loading

0 comments on commit 86bd86b

Please sign in to comment.