Refactor edition enablement (#1657)

* refactor: 💡 consolidate ssh features into ssh-target flag

✅ Closes: ICU-8383

* refactor: 💡 factor out base edition

* feat: 🎸 dynamic feature edition enablement and toggling
This commit is contained in:
Randall Morey authored and GitHub committed 2023-03-17 14:34:37 -07:00
1 parent bd6eee8eb3
commit acd719140d
24 files changed
+303 -91

No files matched your search

+3 -4
View File
@@ -12,13 +12,12 @@ export default class OverrideCredentialLibraryAbility extends CredentialLibraryA
/**
* This override ensures that vault ssh cert may be read only if the
* credential-library-vault-ssh-certificate feature flag is enabled.
* ssh-target feature flag is enabled.
* All other types are subject to the standard logic found in the api addon.
*/
get canRead() {
return this.features.isEnabled(
'credential-library-vault-ssh-certificate'
) || !this.model.isVaultSSHCertificate
return this.features.isEnabled('ssh-target') ||
!this.model.isVaultSSHCertificate
? super.canRead
: false;
}
@@ -50,9 +50,7 @@
{{/if}}
</Hds::Form::Textarea::Field>
{{#if
(and @model.isNew (feature-flag 'credential-library-vault-ssh-certificate'))
}}
{{#if (and @model.isNew (feature-flag 'ssh-target'))}}
<Hds::Form::RadioCard::Group @name='type' @alignment='center' as |G|>
<G.Legend>{{t 'form.type.label'}}</G.Legend>
{{#each this.types as |type|}}
@@ -6,7 +6,7 @@
<div class='target-worker-filter' data-test-filter={{@name}}>
<Hds::Form::Toggle::Field
name='target-worker-filter-toggle'
name={{concat 'target-worker-filter-toggle-' @name}}
checked={{@toggleEnabled}}
disabled={{@disabled}}
@isOptional={{true}}
+1
View File
@@ -11,4 +11,5 @@ export default class ApplicationController extends Controller {
@service session;
@service flashMessages;
@service featureEdition;
}
@@ -0,0 +1,8 @@
export function initialize(owner) {
const service = owner.lookup('service:feature-edition');
service.initialize();
}
export default {
initialize,
};
+6
View File
@@ -20,6 +20,7 @@ export default class ApplicationRoute extends Route {
@service confirm;
@service router;
@service intl;
@service featureEdition;
// =attributes
@@ -126,4 +127,9 @@ export default class ApplicationRoute extends Route {
rootEl.classList.remove('rose-theme-light');
}
}
@action
toggleEdition(edition) {
this.featureEdition.setEdition(edition);
}
}
@@ -36,7 +36,7 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari
// Set the type to generic vault if feature flag isn't enabled in cases where
// user sets the query parameter manually
if (!this.features.isEnabled('credential-library-vault-ssh-certificate')) {
if (!this.features.isEnabled('ssh-target')) {
type = TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC;
}
+42
View File
@@ -0,0 +1,42 @@
import Service from '@ember/service';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import config from 'admin/config/environment';
const { selectedEdition, featureEditions } = config;
export default class FeatureEditionService extends Service {
// =services
@service features;
// =attributes
@tracked edition;
// array of edition strings
get editions() {
return Object.keys(featureEditions);
}
// =methods
/**
* Initializes the selected edition from the config.
*/
initialize() {
this.setEdition(selectedEdition);
}
setEdition(edition) {
const editionFlags = featureEditions[edition];
Object.keys(editionFlags).forEach((flag) => {
if (editionFlags[flag]) {
this.features.enable(flag);
} else {
this.features.disable(flag);
}
});
this.edition = edition;
}
}
+34 -1
View File
@@ -33,7 +33,7 @@
<dropdown.separator />
<dropdown.section @title={{t 'titles.toggle-color-theme'}}>
<dropdown.section @title={{t 'actions.toggle-color-theme'}}>
<Rose::Form as |form|>
<form.radioGroup
@name='theme'
@@ -67,6 +67,39 @@
</dropdown.section>
</utilities.dropdown>
{{#if (feature-flag 'dev-edition-toggle')}}
<utilities.dropdown
data-test-dev-edition-toggle
@text={{t
'titles.feature-edition'
edition=(t (concat 'editions.' this.featureEdition.edition))
}}
@icon='flight-icons/svg/layers-16'
as |dropdown|
>
<dropdown.section @title={{t 'actions.toggle-feature-edition'}}>
<Rose::Form as |form|>
<form.radioGroup
@name='edition'
@selectedValue={{this.featureEdition.edition}}
@changed={{route-action 'toggleEdition'}}
as |radioGroup|
>
{{#each this.featureEdition.editions as |edition|}}
<dropdown.item>
<radioGroup.radio
@label={{t (concat 'editions.' edition)}}
@value={{edition}}
/>
</dropdown.item>
{{/each}}
</form.radioGroup>
</Rose::Form>
</dropdown.section>
</utilities.dropdown>
{{/if}}
</header.utilities>
{{/if}}