Linting
Dieser Commit ist enthalten in:
Ursprung
853634be27
Commit
49538d554d
16 geänderte Dateien mit 135 neuen und 112 gelöschten Zeilen
|
@ -4,11 +4,16 @@ import NoticeMessage from "../mixins/notice-message";
|
|||
export default Component.extend(NoticeMessage, {
|
||||
tagName: "tr",
|
||||
attributeBindings: ["notice.id:data-notice-id"],
|
||||
classNameBindings: [":wizard-notice-row", "notice.typeClass", "notice.expired:expired", "notice.dismissed:dismissed"],
|
||||
classNameBindings: [
|
||||
":wizard-notice-row",
|
||||
"notice.typeClass",
|
||||
"notice.expired:expired",
|
||||
"notice.dismissed:dismissed",
|
||||
],
|
||||
|
||||
actions: {
|
||||
dismiss() {
|
||||
this.notice.dismiss();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
|
@ -3,7 +3,13 @@ import NoticeMessage from "../mixins/notice-message";
|
|||
|
||||
export default Component.extend(NoticeMessage, {
|
||||
attributeBindings: ["notice.id:data-notice-id"],
|
||||
classNameBindings: [':wizard-notice', 'notice.typeClass', 'notice.dismissed:dismissed', 'notice.expired:expired', 'notice.hidden:hidden'],
|
||||
classNameBindings: [
|
||||
":wizard-notice",
|
||||
"notice.typeClass",
|
||||
"notice.dismissed:dismissed",
|
||||
"notice.expired:expired",
|
||||
"notice.hidden:hidden",
|
||||
],
|
||||
|
||||
actions: {
|
||||
dismiss() {
|
||||
|
@ -14,10 +20,10 @@ export default Component.extend(NoticeMessage, {
|
|||
},
|
||||
|
||||
hide() {
|
||||
this.set('hiding', true);
|
||||
this.set("hiding", true);
|
||||
this.notice.hide().then(() => {
|
||||
this.set('hiding', false);
|
||||
this.set("hiding", false);
|
||||
});
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,14 +6,14 @@ export default {
|
|||
},
|
||||
|
||||
setupComponent(attrs, component) {
|
||||
const controller = getOwner(this).lookup('controller:admin-dashboard');
|
||||
const controller = getOwner(this).lookup("controller:admin-dashboard");
|
||||
|
||||
component.set('notices', controller.get('customWizardCriticalNotices'));
|
||||
controller.addObserver('customWizardCriticalNotices.[]', () => {
|
||||
component.set("notices", controller.get("customWizardCriticalNotices"));
|
||||
controller.addObserver("customWizardCriticalNotices.[]", () => {
|
||||
if (this._state === "destroying") {
|
||||
return;
|
||||
}
|
||||
component.set('notices', controller.get('customWizardCriticalNotices'));
|
||||
component.set("notices", controller.get("customWizardCriticalNotices"));
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
|
@ -15,9 +15,9 @@ export default Controller.extend({
|
|||
loadingMore: false,
|
||||
canLoadMore: true,
|
||||
|
||||
@discourseComputed('notices.[]', 'notices.@each.dismissed')
|
||||
@discourseComputed("notices.[]", "notices.@each.dismissed")
|
||||
allDismisssed(notices) {
|
||||
return notices.every(n => !n.canDismiss || n.dismissed);
|
||||
return notices.every((n) => !n.canDismiss || n.dismissed);
|
||||
},
|
||||
|
||||
loadMoreNotices() {
|
||||
|
@ -35,7 +35,7 @@ export default Controller.extend({
|
|||
}
|
||||
|
||||
this.get("notices").pushObjects(
|
||||
A(result.notices.map(notice => CustomWizardNotice.create(notice)))
|
||||
A(result.notices.map((notice) => CustomWizardNotice.create(notice)))
|
||||
);
|
||||
})
|
||||
.finally(() => this.set("loadingMore", false));
|
||||
|
@ -56,12 +56,13 @@ export default Controller.extend({
|
|||
I18n.t("yes_value"),
|
||||
(result) => {
|
||||
if (result) {
|
||||
this.set('loadingMore', true);
|
||||
CustomWizardNotice.dismissAll()
|
||||
.finally(() => this.set("loadingMore", false));
|
||||
}
|
||||
}
|
||||
this.set("loadingMore", true);
|
||||
CustomWizardNotice.dismissAll().finally(() =>
|
||||
this.set("loadingMore", false)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -17,10 +17,10 @@ export default Controller.extend({
|
|||
this.adminWizardsNotices.setProperties({
|
||||
notices: A(),
|
||||
page: 0,
|
||||
canLoadMore: true
|
||||
canLoadMore: true,
|
||||
});
|
||||
this.adminWizardsNotices.loadMoreNotices();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,34 +4,36 @@ import I18n from "I18n";
|
|||
import { registerUnbound } from "discourse-common/lib/helpers";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
registerUnbound("notice-badge", function(attrs) {
|
||||
let tag = attrs.url ? 'a' : 'div';
|
||||
let attrStr = '';
|
||||
registerUnbound("notice-badge", function (attrs) {
|
||||
let tag = attrs.url ? "a" : "div";
|
||||
let attrStr = "";
|
||||
if (attrs.title) {
|
||||
attrStr += `title='${I18n.t(attrs.title)}'`;
|
||||
}
|
||||
if (attrs.url) {
|
||||
attrStr += `href='${attrs.url}'`;
|
||||
}
|
||||
let html = `<${tag} class="${attrs.class ? `${attrs.class} ` : ''}notice-badge" ${attrStr}>`;
|
||||
let html = `<${tag} class="${
|
||||
attrs.class ? `${attrs.class} ` : ""
|
||||
}notice-badge" ${attrStr}>`;
|
||||
if (attrs.icon) {
|
||||
html += iconHTML(attrs.icon);
|
||||
}
|
||||
if (attrs.label) {
|
||||
if (attrs.icon) {
|
||||
html += ' ';
|
||||
html += " ";
|
||||
}
|
||||
html += `<span>${I18n.t(attrs.label)}</span>`;
|
||||
}
|
||||
if (attrs.date) {
|
||||
if (attrs.icon || attrs.label) {
|
||||
html += ' ';
|
||||
html += " ";
|
||||
}
|
||||
let dateAttrs = {};
|
||||
if (attrs.leaveAgo) {
|
||||
dateAttrs = {
|
||||
format: "medium",
|
||||
leaveAgo: true
|
||||
leaveAgo: true,
|
||||
};
|
||||
}
|
||||
html += autoUpdatingRelativeAge(new Date(attrs.date), dateAttrs);
|
||||
|
|
|
@ -22,16 +22,16 @@ export default {
|
|||
};
|
||||
|
||||
withPluginApi("0.8.36", (api) => {
|
||||
api.modifyClass('route:admin-dashboard', {
|
||||
api.modifyClass("route:admin-dashboard", {
|
||||
setupController(controller) {
|
||||
this._super(...arguments);
|
||||
|
||||
controller.loadCriticalNotices();
|
||||
controller.subscribe();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
api.modifyClass('controller:admin-dashboard', {
|
||||
api.modifyClass("controller:admin-dashboard", {
|
||||
criticalNotices: A(),
|
||||
|
||||
unsubscribe() {
|
||||
|
@ -41,7 +41,6 @@ export default {
|
|||
subscribe() {
|
||||
this.unsubscribe();
|
||||
this.messageBus.subscribe("/custom-wizard/notices", (data) => {
|
||||
|
||||
if (isPresent(data.active_notice_count)) {
|
||||
this.loadCriticalNotices();
|
||||
}
|
||||
|
@ -50,19 +49,18 @@ export default {
|
|||
|
||||
loadCriticalNotices() {
|
||||
CustomWizardNotice.list({
|
||||
type: [
|
||||
'connection_error',
|
||||
'warning'
|
||||
],
|
||||
archetype: 'plugin_status',
|
||||
visible: true
|
||||
}).then(result => {
|
||||
type: ["connection_error", "warning"],
|
||||
archetype: "plugin_status",
|
||||
visible: true,
|
||||
}).then((result) => {
|
||||
if (result.notices && result.notices.length) {
|
||||
const criticalNotices = A(result.notices.map(n => CustomWizardNotice.create(n)));
|
||||
this.set('customWizardCriticalNotices', criticalNotices);
|
||||
const criticalNotices = A(
|
||||
result.notices.map((n) => CustomWizardNotice.create(n))
|
||||
);
|
||||
this.set("customWizardCriticalNotices", criticalNotices);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -6,7 +6,7 @@ import { createPopper } from "@popperjs/core";
|
|||
export default Mixin.create({
|
||||
showCookedMessage: false,
|
||||
|
||||
didReceiveAttrs(){
|
||||
didReceiveAttrs() {
|
||||
const message = this.notice.message;
|
||||
cookAsync(message).then((cooked) => {
|
||||
this.set("cookedMessage", cooked);
|
||||
|
@ -14,12 +14,10 @@ export default Mixin.create({
|
|||
},
|
||||
|
||||
createMessageModal() {
|
||||
let container = this.element.querySelector('.notice-message');
|
||||
let modal = this.element.querySelector('.cooked-notice-message');
|
||||
let container = this.element.querySelector(".notice-message");
|
||||
let modal = this.element.querySelector(".cooked-notice-message");
|
||||
|
||||
this._popper = createPopper(
|
||||
container,
|
||||
modal, {
|
||||
this._popper = createPopper(container, modal, {
|
||||
strategy: "absolute",
|
||||
placement: "bottom-start",
|
||||
modifiers: [
|
||||
|
@ -33,8 +31,7 @@ export default Mixin.create({
|
|||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
|
@ -46,10 +43,16 @@ export default Mixin.create({
|
|||
},
|
||||
|
||||
documentClick(event) {
|
||||
if (this._state === "destroying") { return; }
|
||||
if (this._state === "destroying") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.target.closest(`[data-notice-id="${this.notice.id}"] .notice-message`)) {
|
||||
this.set('showCookedMessage', false);
|
||||
if (
|
||||
!event.target.closest(
|
||||
`[data-notice-id="${this.notice.id}"] .notice-message`
|
||||
)
|
||||
) {
|
||||
this.set("showCookedMessage", false);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -60,6 +63,6 @@ export default Mixin.create({
|
|||
if (this.showCookedMessage) {
|
||||
scheduleOnce("afterRender", this, this.createMessageModal);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
|
@ -7,62 +7,68 @@ import { dasherize } from "@ember/string";
|
|||
import I18n from "I18n";
|
||||
|
||||
const CustomWizardNotice = EmberObject.extend({
|
||||
expired: notEmpty('expired_at'),
|
||||
dismissed: notEmpty('dismissed_at'),
|
||||
hidden: notEmpty('hidden_at'),
|
||||
notHidden: not('hidden'),
|
||||
notDismissed: not('dismissed'),
|
||||
canDismiss: and('dismissable', 'notDismissed'),
|
||||
canHide: and('can_hide', 'notHidden'),
|
||||
expired: notEmpty("expired_at"),
|
||||
dismissed: notEmpty("dismissed_at"),
|
||||
hidden: notEmpty("hidden_at"),
|
||||
notHidden: not("hidden"),
|
||||
notDismissed: not("dismissed"),
|
||||
canDismiss: and("dismissable", "notDismissed"),
|
||||
canHide: and("can_hide", "notHidden"),
|
||||
|
||||
@discourseComputed('type')
|
||||
@discourseComputed("type")
|
||||
typeClass(type) {
|
||||
return dasherize(type);
|
||||
},
|
||||
|
||||
@discourseComputed('type')
|
||||
@discourseComputed("type")
|
||||
typeLabel(type) {
|
||||
return I18n.t(`admin.wizard.notice.type.${type}`);
|
||||
},
|
||||
|
||||
dismiss() {
|
||||
if (!this.get('canDismiss')) {
|
||||
if (!this.get("canDismiss")) {
|
||||
return;
|
||||
}
|
||||
|
||||
return ajax(`/admin/wizards/notice/${this.get('id')}/dismiss`, { type: 'PUT' }).then(result => {
|
||||
return ajax(`/admin/wizards/notice/${this.get("id")}/dismiss`, {
|
||||
type: "PUT",
|
||||
})
|
||||
.then((result) => {
|
||||
if (result.success) {
|
||||
this.set('dismissed_at', result.dismissed_at);
|
||||
this.set("dismissed_at", result.dismissed_at);
|
||||
}
|
||||
}).catch(popupAjaxError);
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
|
||||
hide() {
|
||||
if (!this.get('canHide')) {
|
||||
if (!this.get("canHide")) {
|
||||
return;
|
||||
}
|
||||
|
||||
return ajax(`/admin/wizards/notice/${this.get('id')}/hide`, { type: 'PUT' }).then(result => {
|
||||
return ajax(`/admin/wizards/notice/${this.get("id")}/hide`, { type: "PUT" })
|
||||
.then((result) => {
|
||||
if (result.success) {
|
||||
this.set('hidden_at', result.hidden_at);
|
||||
}
|
||||
}).catch(popupAjaxError);
|
||||
this.set("hidden_at", result.hidden_at);
|
||||
}
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
});
|
||||
|
||||
CustomWizardNotice.reopenClass({
|
||||
list(data = {}) {
|
||||
return ajax('/admin/wizards/notice', {
|
||||
return ajax("/admin/wizards/notice", {
|
||||
type: "GET",
|
||||
data
|
||||
data,
|
||||
}).catch(popupAjaxError);
|
||||
},
|
||||
|
||||
dismissAll() {
|
||||
return ajax('/admin/wizards/notice/dismiss', {
|
||||
type: "PUT"
|
||||
return ajax("/admin/wizards/notice/dismiss", {
|
||||
type: "PUT",
|
||||
}).catch(popupAjaxError);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default CustomWizardNotice;
|
||||
|
|
|
@ -9,7 +9,9 @@ export default DiscourseRoute.extend({
|
|||
|
||||
setupController(controller, model) {
|
||||
controller.setProperties({
|
||||
notices: A(model.notices.map(notice => CustomWizardNotice.create(notice))),
|
||||
notices: A(
|
||||
model.notices.map((notice) => CustomWizardNotice.create(notice))
|
||||
),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -23,5 +23,5 @@ export default DiscourseRoute.extend({
|
|||
if (transition.targetName === "adminWizards.index") {
|
||||
this.transitionTo("adminWizardsWizard");
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -926,7 +926,7 @@ $error: #ef1700;
|
|||
}
|
||||
|
||||
.wizard-notice {
|
||||
padding: .75em;
|
||||
padding: 0.75em;
|
||||
margin-bottom: 1em;
|
||||
border: 1px solid var(--primary-low);
|
||||
|
||||
|
@ -941,7 +941,7 @@ $error: #ef1700;
|
|||
}
|
||||
|
||||
.notice-badge {
|
||||
padding: 0 .5em;
|
||||
padding: 0 0.5em;
|
||||
}
|
||||
|
||||
.notice-header {
|
||||
|
@ -957,7 +957,7 @@ $error: #ef1700;
|
|||
align-items: center;
|
||||
|
||||
.notice-badge {
|
||||
margin-left: .5em;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1022,11 +1022,11 @@ $error: #ef1700;
|
|||
position: absolute;
|
||||
top: -8px;
|
||||
right: -8px;
|
||||
font-size: .7em;
|
||||
font-size: 0.7em;
|
||||
}
|
||||
|
||||
a.show-notice-message {
|
||||
padding: .25em .5em;
|
||||
padding: 0.25em 0.5em;
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class CustomWizard::AdminNoticeController < CustomWizard::AdminController
|
|||
|
||||
if type
|
||||
if type.is_a?(Array)
|
||||
type = type.map { |type| CustomWizard::Notice.types[type.to_sym] }
|
||||
type = type.map { |t| CustomWizard::Notice.types[t.to_sym] }
|
||||
else
|
||||
type = CustomWizard::Notice.types[type.to_sym]
|
||||
end
|
||||
|
@ -20,7 +20,7 @@ class CustomWizard::AdminNoticeController < CustomWizard::AdminController
|
|||
|
||||
if archetype
|
||||
if archetype.is_a?(Array)
|
||||
archetype = archetype.map { |type| CustomWizard::Notice.archetypes[archetype.to_sym] }
|
||||
archetype = archetype.map { |t| CustomWizard::Notice.archetypes[archetype.to_sym] }
|
||||
else
|
||||
archetype = CustomWizard::Notice.archetypes[archetype.to_sym]
|
||||
end
|
||||
|
|
Laden …
In neuem Issue referenzieren