Icu 5476 refactor target model serializer and mirage (#1235)

chore: 🤖 refactor target model to support credentials
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2022-08-08 09:21:07 -07:00
1 parent 2cda4f639e
commit 1f0baceb5e
12 files changed
+210 -66

No files matched your search

@@ -10,15 +10,19 @@ export default class ScopesScopeTargetsTargetCredentialSourcesRoute extends Rout
/**
* Loads all credential libraries under the current target.
* @return {Promise{[CredentialLibraryModel]}}
* @return {Promise{[CredentialLibraryModel, CredentialModel]}}
*/
beforeModel() {
const { application_credential_source_ids: sourceIDFragments } =
this.modelFor('scopes.scope.targets.target');
return all(
sourceIDFragments.map(({ value }) => {
const isStoreOrLibrary = !value.includes('cred');
if (isStoreOrLibrary) {
const isStatic = value.includes('cred');
if (isStatic) {
return this.store.findRecord('credential', value, {
reload: true,
});
} else {
return this.store.findRecord('credential-library', value, {
reload: true,
});
@@ -19,7 +19,7 @@
</page.actions>
<page.body>
{{#if @model.credentialLibraries}}
{{#if @model.credentialSources}}
<Rose::Table as |table|>
<table.header as |header|>
@@ -31,35 +31,48 @@
</header.row>
</table.header>
<table.body as |body|>
{{#each @model.credentialLibraries as |credentialLibrary|}}
{{#each @model.credentialSources as |credentialSource|}}
<body.row as |row|>
<row.headerCell>
<LinkTo
@route='scopes.scope.credential-stores.credential-store.credential-libraries.credential-library'
@models={{array
credentialLibrary.credential_store_id
credentialLibrary.id
}}
>
{{credentialLibrary.displayName}}
</LinkTo>
<p>{{credentialLibrary.description}}</p>
{{#if (eq credentialSource.type 'username_password')}}
<LinkTo
@route='scopes.scope.credential-stores.credential-store.credentials.credential'
@models={{array
credentialSource.credential_store_id
credentialSource.id
}}
>
{{credentialSource.displayName}}
</LinkTo>
{{else}}
<LinkTo
@route='scopes.scope.credential-stores.credential-store.credential-libraries.credential-library'
@models={{array
credentialSource.credential_store_id
credentialSource.id
}}
>
{{credentialSource.displayName}}
</LinkTo>
{{/if}}
<p>{{credentialSource.description}}</p>
</row.headerCell>
<row.cell>
<Rose::Badge>{{t
(concat
'resources.credential-library.types.'
credentialLibrary.type
'resources.target.credential-source.types.'
credentialSource.type
)
}}</Rose::Badge>
</row.cell>
<row.cell>
<Copyable
@text={{credentialLibrary.id}}
@text={{credentialSource.id}}
@buttonText={{t 'actions.copy-to-clipboard'}}
@acknowledgeText={{t 'states.copied'}}
>
<code>{{credentialLibrary.id}}</code>
<code>{{credentialSource.id}}</code>
</Copyable>
</row.cell>
<row.cell>
@@ -77,7 +90,7 @@
{{on
'click'
(route-action
'removeCredentialSource' @model credentialLibrary
'removeCredentialSource' @model credentialSource
)
}}
>