* chore: 🤖 Upgrade eslint config for admin ui * chore: 🤖 Fix eslint issues for admin * chore: 🤖 Upgrade eslint config for desktop * chore: 🤖 Fix linting errors in desktop * chore: 🤖 Upgrade eslint for api addon * chore: 🤖 Fix eslint issues in api addon * chore: 🤖 Upgrade eslint for auth addon * chore: 🤖 Fix eslint issues in auth addon * chore: 🤖 Upgrade core eslint config * chore: 🤖 Fix eslint issue for core addon * chore: 🤖 Upgrade eslint config for rose addon * chore: 🤖 Fix eslint issue for rose addon * chore: 🤖 Upgrade e2e eslint config * chore: 🤖 Fix eslint issues in e2e * chore: 🤖 Fix CI linting issues * chore: 🤖 Add back linting server files for the future * chore: 🤖 Update qunit rules to use extends
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright IBM Corp. 2021, 2026
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import CanHelper from 'ember-can/helpers/can';
|
|
import { service } from '@ember/service';
|
|
import config from 'admin/config/environment';
|
|
|
|
const isDevelopment = config.environment === 'development';
|
|
|
|
/**
|
|
* Normally, abilities that access tracked values are not recomputed on change.
|
|
* This helper overrides the Ember Can helper to trigger recompute whenever
|
|
* a feature flag changes. This functionality is available only in the
|
|
* development environment, since feature flags may be toggled in the UI, and
|
|
* also for performance reasons as this effectively recomputes _all_ `can`
|
|
* helpers on any feature flag change.
|
|
*/
|
|
class DevelopmentCanHelper extends CanHelper {
|
|
// =services
|
|
|
|
@service features;
|
|
|
|
// =methods
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
this.observeAllFlags();
|
|
}
|
|
|
|
willDestroy() {
|
|
this.removeAllFlags();
|
|
super.willDestroy();
|
|
}
|
|
|
|
observeAllFlags() {
|
|
this.features.flags.forEach((flag) =>
|
|
/* eslint-disable-next-line ember/no-observers */
|
|
this.features.addObserver(flag, this, 'recompute'),
|
|
);
|
|
}
|
|
|
|
removeAllFlags() {
|
|
this.features.flags.forEach((flag) =>
|
|
this.features.removeObserver(flag, this, 'recompute'),
|
|
);
|
|
}
|
|
}
|
|
|
|
// In development, export the development helper, otherwise the original.
|
|
export default isDevelopment ? DevelopmentCanHelper : CanHelper;
|