feat: Show message when no cred-libs are available in target

This commit is contained in:
Susmitha Girumala committed 2021-07-25 10:25:09 -04:00
1 parent 8f2deadc49
commit 0fbcf8e16e
4 files changed
+67 -64

No files matched your search

@@ -273,6 +273,9 @@ target:
welcome:
title: Welcome to Credential Libraries
description: No credential libraries in this target.
none:
title: No Credential Libraries Available
description: No credential libraries available to add to this target.
add:
title: Add Credential Libraries
description: Select credential libraries to assign to this target.
@@ -1,36 +1,55 @@
<Rose::Form
class='full-width'
@onSubmit={{fn this.submit @submit}}
@cancel={{@cancel}}
@disabled={{@model.isSaving}}
@error={{@model.errors.base}}
as |form|
>
<form.actions
@submitText={{t 'resources.target.actions.add-credential-libraries'}}
@cancelText={{t 'actions.cancel'}}
/>
{{#if this.hasAvailableCredentialLibraries}}
<Rose::Form
class='full-width'
@onSubmit={{fn this.submit @submit}}
@cancel={{@cancel}}
@disabled={{@model.isSaving}}
@error={{@model.errors.base}}
as |form|
>
<form.actions
@submitText={{t 'resources.target.actions.add-credential-libraries'}}
@cancelText={{t 'actions.cancel'}}
/>
<Rose::Table as |table|>
<table.header as |header|>
<header.row as |row|>
<row.headerCell>{{t 'form.id.label'}}</row.headerCell>
<row.headerCell>{{t 'form.name.label'}}</row.headerCell>
</header.row>
</table.header>
<table.body as |body|>
{{#each this.filteredCredentialLibraries as |credentialLibrary|}}
<body.row as |row|>
<row.headerCell>
<form.checkbox
@label={{credentialLibrary.id}}
@description={{credentialLibrary.description}}
onChange={{fn this.toggleCredentialLibrary credentialLibrary}}
/>
</row.headerCell>
<row.cell>{{credentialLibrary.name}}</row.cell>
</body.row>
{{/each}}
</table.body>
</Rose::Table>
</Rose::Form>
<Rose::Table as |table|>
<table.header as |header|>
<header.row as |row|>
<row.headerCell>{{t 'form.id.label'}}</row.headerCell>
<row.headerCell>{{t 'form.name.label'}}</row.headerCell>
</header.row>
</table.header>
<table.body as |body|>
{{#each this.filteredCredentialLibraries as |credentialLibrary|}}
<body.row as |row|>
<row.headerCell>
<form.checkbox
@label={{credentialLibrary.id}}
@description={{credentialLibrary.description}}
onChange={{fn this.toggleCredentialLibrary credentialLibrary}}
/>
</row.headerCell>
<row.cell>{{credentialLibrary.name}}</row.cell>
</body.row>
{{/each}}
</table.body>
</Rose::Table>
</Rose::Form>
{{/if}}
{{#unless this.hasAvailableCredentialLibraries}}
<Rose::Layout::Centered>
<Rose::Message
@title={{t 'resources.target.credential-library.messages.none.title'}}
as |message|
>
<message.description>
{{t 'resources.target.credential-library.messages.none.description'}}
</message.description>
<message.link @route='scopes.scope.targets.target.credential-libraries'>
<Rose::Icon @name='chevron-left' />
{{t 'actions.back'}}
</message.link>
</Rose::Message>
</Rose::Layout::Centered>
{{/unless}}
@@ -11,6 +11,16 @@ export default class FormTargetAddCredentialLibrariesIndexComponent extends Comp
*/
selectedCredentialLibraryIDs = A();
/**
* Checks for unassigned credential libraries.
* @param {[CredentialLibraryModel]} filteredCredentialLibraries
* @type {boolean}
*/
@computed('filteredCredentialLibraries.length')
get hasAvailableCredentialLibraries() {
return this.filteredCredentialLibraries.length > 0;
}
/**
* Filter out credential libraries not already added to the target.
* @type {[CredentialLibraryModel]}
@@ -1,29 +0,0 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module(
'Integration | Component | form/target/add-credential-libraries/index',
function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Form::Target::AddCredentialLibraries::Index />`);
assert.equal(this.element.textContent.trim(), '');
// Template block usage:
await render(hbs`
<Form::Target::AddCredentialLibraries::Index>
template block text
</Form::Target::AddCredentialLibraries::Index>
`);
assert.equal(this.element.textContent.trim(), 'template block text');
});
}
);