mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Fix ember/no-arrow-function-computed-properties
lint (#29110)
This commit is contained in:
parent
1ba8b6b22a
commit
48c908c04d
@ -22,16 +22,18 @@ export default class PluginConnector extends Component {
|
|||||||
init() {
|
init() {
|
||||||
super.init(...arguments);
|
super.init(...arguments);
|
||||||
|
|
||||||
const args = this.args || {};
|
if (this.args) {
|
||||||
Object.keys(args).forEach((key) => {
|
Object.keys(this.args).forEach((key) => {
|
||||||
defineProperty(
|
defineProperty(
|
||||||
this,
|
this,
|
||||||
key,
|
key,
|
||||||
computed("args", () => (this.args || {})[key])
|
computed("args", function () {
|
||||||
);
|
return this.args[key];
|
||||||
});
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const deprecatedArgs = this.deprecatedArgs || {};
|
|
||||||
const connectorInfo = {
|
const connectorInfo = {
|
||||||
outletName: this.connector?.outletName,
|
outletName: this.connector?.outletName,
|
||||||
connectorName: this.connector?.connectorName,
|
connectorName: this.connector?.connectorName,
|
||||||
@ -40,18 +42,20 @@ export default class PluginConnector extends Component {
|
|||||||
layoutName: this.layoutName,
|
layoutName: this.layoutName,
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.keys(deprecatedArgs).forEach((key) => {
|
if (this.deprecatedArgs) {
|
||||||
defineProperty(
|
Object.keys(this.deprecatedArgs).forEach((key) => {
|
||||||
this,
|
defineProperty(
|
||||||
key,
|
this,
|
||||||
computed("deprecatedArgs", () => {
|
key,
|
||||||
return deprecatedArgumentValue(deprecatedArgs[key], {
|
computed("deprecatedArgs", function () {
|
||||||
...connectorInfo,
|
return deprecatedArgumentValue(this.deprecatedArgs[key], {
|
||||||
argumentName: key,
|
...connectorInfo,
|
||||||
});
|
argumentName: key,
|
||||||
})
|
});
|
||||||
);
|
})
|
||||||
});
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const connectorClass = this.connector.connectorClass;
|
const connectorClass = this.connector.connectorClass;
|
||||||
this.set("actions", connectorClass?.actions);
|
this.set("actions", connectorClass?.actions);
|
||||||
@ -63,8 +67,8 @@ export default class PluginConnector extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const merged = buildArgsWithDeprecations(
|
const merged = buildArgsWithDeprecations(
|
||||||
args,
|
this.args,
|
||||||
deprecatedArgs,
|
this.deprecatedArgs,
|
||||||
connectorInfo
|
connectorInfo
|
||||||
);
|
);
|
||||||
connectorClass?.setupComponent?.call(this, merged, this);
|
connectorClass?.setupComponent?.call(this, merged, this);
|
||||||
|
@ -241,22 +241,26 @@ export function rawConnectorsFor(outletName) {
|
|||||||
export function buildArgsWithDeprecations(args, deprecatedArgs, opts = {}) {
|
export function buildArgsWithDeprecations(args, deprecatedArgs, opts = {}) {
|
||||||
const output = {};
|
const output = {};
|
||||||
|
|
||||||
Object.keys(args).forEach((key) => {
|
if (args) {
|
||||||
Object.defineProperty(output, key, { value: args[key] });
|
Object.keys(args).forEach((key) => {
|
||||||
});
|
Object.defineProperty(output, key, { value: args[key] });
|
||||||
|
|
||||||
Object.keys(deprecatedArgs).forEach((argumentName) => {
|
|
||||||
Object.defineProperty(output, argumentName, {
|
|
||||||
get() {
|
|
||||||
const deprecatedArg = deprecatedArgs[argumentName];
|
|
||||||
|
|
||||||
return deprecatedArgumentValue(deprecatedArg, {
|
|
||||||
...opts,
|
|
||||||
argumentName,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (deprecatedArgs) {
|
||||||
|
Object.keys(deprecatedArgs).forEach((argumentName) => {
|
||||||
|
Object.defineProperty(output, argumentName, {
|
||||||
|
get() {
|
||||||
|
const deprecatedArg = deprecatedArgs[argumentName];
|
||||||
|
|
||||||
|
return deprecatedArgumentValue(deprecatedArg, {
|
||||||
|
...opts,
|
||||||
|
argumentName,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user