migrate credential store radio card component (#1492)
chore: 🤖 cred store radio card migration
This commit is contained in:
1 parent
5474465463
commit
28a43251ac
6 files changed
+94
-98
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import GeneratedCredentialStoreModel from '../generated/models/credential-store';
|
||||
import { equal } from '@ember/object/computed';
|
||||
|
||||
export const types = ['static', 'vault'];
|
||||
|
||||
export default class CredentialStoreModel extends GeneratedCredentialStoreModel {
|
||||
// =attributes
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// field bottom margin (HDS leaves this to implementers)
|
||||
[class^='hds-form-field'] {
|
||||
[class^='hds-form-field'],
|
||||
[class^='hds-form-group'] {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
@@ -46,46 +46,42 @@
|
||||
|
||||
{{#if (feature-flag 'static-credentials')}}
|
||||
{{#if @model.isNew}}
|
||||
<form.fieldset>
|
||||
<:title>{{t 'form.type.label'}}</:title>
|
||||
<:body>
|
||||
<form.radioGroup
|
||||
@name='types'
|
||||
@selectedValue={{@model.type}}
|
||||
@changed={{@changeType}}
|
||||
as |radioGroup|
|
||||
|
||||
<Hds::Form::RadioCard::Group @alignment='center' as |G|>
|
||||
<G.Legend>{{t 'form.type.label'}}</G.Legend>
|
||||
{{#each-in this.mapResourceTypewithIcon as |credentialStoreType icon|}}
|
||||
<G.RadioCard
|
||||
@name={{credentialStoreType}}
|
||||
@value={{credentialStoreType}}
|
||||
@checked={{eq credentialStoreType @model.type}}
|
||||
@maxWidth='20rem'
|
||||
{{on 'input' (fn @changeType credentialStoreType)}}
|
||||
as |R|
|
||||
>
|
||||
<radioGroup.card
|
||||
@label={{t 'resources.credential-store.types.static'}}
|
||||
@helperText={{t 'resources.credential-store.help.static'}}
|
||||
@value='static'
|
||||
@layout='wide'
|
||||
/>
|
||||
<radioGroup.card
|
||||
@label={{t 'resources.credential-store.types.vault'}}
|
||||
@helperText={{t 'resources.credential-store.help.vault'}}
|
||||
@value='vault'
|
||||
@layout='wide'
|
||||
/>
|
||||
</form.radioGroup>
|
||||
</:body>
|
||||
</form.fieldset>
|
||||
<R.Label>{{t
|
||||
(concat 'resources.credential-store.types.' credentialStoreType)
|
||||
}}</R.Label>
|
||||
<R.Description>{{t
|
||||
(concat 'resources.credential-store.help.' credentialStoreType)
|
||||
}}</R.Description>
|
||||
<R.Icon @name={{icon}} />
|
||||
</G.RadioCard>
|
||||
{{/each-in}}
|
||||
</Hds::Form::RadioCard::Group>
|
||||
{{else}}
|
||||
<InfoField
|
||||
@value={{t (concat 'resources.credential-store.types.' @model.type)}}
|
||||
disabled={{form.disabled}}
|
||||
@value={{t (concat 'resources.credential-store.help.' @model.type)}}
|
||||
@icon='keychain'
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t 'form.type.label'}}</F.Label>
|
||||
<F.HelperText>{{t
|
||||
(concat 'resources.credential-store.help.' @model.type)
|
||||
(concat 'resources.credential-store.types.' @model.type)
|
||||
}}
|
||||
</F.HelperText>
|
||||
</InfoField>
|
||||
{{/if}}
|
||||
|
||||
{{/if}}
|
||||
|
||||
{{#if (can 'save model' @model)}}
|
||||
<form.actions
|
||||
@enableEditText={{t 'actions.edit-form'}}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { types } from 'api/models/credential-store';
|
||||
|
||||
//Note: this is a temporary solution till we have resource type helper in place
|
||||
const icons = ['keychain', 'vault'];
|
||||
|
||||
export default class FormStaticCredentialStoreIndexComponent extends Component {
|
||||
// =properties
|
||||
/**
|
||||
* maps resource type with icon
|
||||
* @type {object}
|
||||
*/
|
||||
get mapResourceTypewithIcon() {
|
||||
return types.reduce((obj, type, i) => ({ ...obj, [type]: icons[i] }), {});
|
||||
}
|
||||
}
|
||||
@@ -46,77 +46,42 @@
|
||||
</form.textarea>
|
||||
|
||||
{{#if (feature-flag 'static-credentials')}}
|
||||
<form.fieldset>
|
||||
<:title>{{t 'form.type.label'}}</:title>
|
||||
<:body>
|
||||
{{#if @model.isNew}}
|
||||
<form.radioGroup
|
||||
@name='types'
|
||||
@selectedValue={{@model.type}}
|
||||
@changed={{@changeType}}
|
||||
as |radioGroup|
|
||||
{{#if @model.isNew}}
|
||||
<Hds::Form::RadioCard::Group @alignment='center' as |G|>
|
||||
<G.Legend>{{t 'form.type.label'}}</G.Legend>
|
||||
{{#each-in this.mapResourceTypewithIcon as |credentialStoreType icon|}}
|
||||
<G.RadioCard
|
||||
@name={{credentialStoreType}}
|
||||
@value={{credentialStoreType}}
|
||||
@checked={{eq credentialStoreType @model.type}}
|
||||
@maxWidth='20rem'
|
||||
{{on 'input' (fn @changeType credentialStoreType)}}
|
||||
as |R|
|
||||
>
|
||||
<radioGroup.card
|
||||
@label={{t 'resources.credential-store.types.static'}}
|
||||
@helperText={{t 'resources.credential-store.help.static'}}
|
||||
@value='static'
|
||||
@layout='wide'
|
||||
/>
|
||||
<radioGroup.card
|
||||
@label={{t 'resources.credential-store.types.vault'}}
|
||||
@helperText={{t 'resources.credential-store.help.vault'}}
|
||||
@value='vault'
|
||||
@layout='wide'
|
||||
/>
|
||||
</form.radioGroup>
|
||||
{{else}}
|
||||
<form.radioGroup
|
||||
@name='types'
|
||||
@selectedValue={{@model.type}}
|
||||
as |radioGroup|
|
||||
>
|
||||
<radioGroup.card
|
||||
@label={{t
|
||||
(concat 'resources.credential-store.types.' @model.type)
|
||||
}}
|
||||
@helperText={{t
|
||||
(concat 'resources.credential-store.help.' @model.type)
|
||||
}}
|
||||
@value={{@model.type}}
|
||||
@layout='wide'
|
||||
readonly={{true}}
|
||||
@disabled={{true}}
|
||||
/>
|
||||
</form.radioGroup>
|
||||
{{/if}}
|
||||
</:body>
|
||||
</form.fieldset>
|
||||
{{else}}
|
||||
<form.fieldset>
|
||||
<:title>{{t 'form.type.label'}}</:title>
|
||||
<:body>
|
||||
<form.radioGroup
|
||||
@name='types'
|
||||
@selectedValue={{@model.type}}
|
||||
as |radioGroup|
|
||||
>
|
||||
<radioGroup.card
|
||||
@label={{t
|
||||
(concat 'resources.credential-store.types.' @model.type)
|
||||
}}
|
||||
@helperText={{t
|
||||
(concat 'resources.credential-store.help.' @model.type)
|
||||
}}
|
||||
@value={{@model.type}}
|
||||
@layout='wide'
|
||||
readonly={{true}}
|
||||
@disabled={{true}}
|
||||
/>
|
||||
</form.radioGroup>
|
||||
</:body>
|
||||
</form.fieldset>
|
||||
<R.Label>{{t
|
||||
(concat 'resources.credential-store.types.' credentialStoreType)
|
||||
}}</R.Label>
|
||||
<R.Description>{{t
|
||||
(concat 'resources.credential-store.help.' credentialStoreType)
|
||||
}}</R.Description>
|
||||
<R.Icon @name={{icon}} />
|
||||
</G.RadioCard>
|
||||
{{/each-in}}
|
||||
</Hds::Form::RadioCard::Group>
|
||||
{{else}}
|
||||
<InfoField
|
||||
@value={{t (concat 'resources.credential-store.help.' @model.type)}}
|
||||
@icon='vault'
|
||||
as |F|
|
||||
>
|
||||
<F.Label>{{t 'form.type.label'}}</F.Label>
|
||||
<F.HelperText>{{t
|
||||
(concat 'resources.credential-store.types.' @model.type)
|
||||
}}
|
||||
</F.HelperText>
|
||||
</InfoField>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
<form.input
|
||||
@name='address'
|
||||
@type='text'
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { types } from 'api/models/credential-store';
|
||||
|
||||
//Note: this is a temporary solution till we have resource type helper in place
|
||||
const icons = ['keychain', 'vault'];
|
||||
|
||||
export default class FormVaultCredentialStoreIndexComponent extends Component {
|
||||
// =properties
|
||||
/**
|
||||
* maps resource type with icon
|
||||
* @type {object}
|
||||
*/
|
||||
get mapResourceTypewithIcon() {
|
||||
return types.reduce((obj, type, i) => ({ ...obj, [type]: icons[i] }), {});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user