1 parent
bd394d9517
commit
bedcdee048
7 files changed
+54
-84
No files matched your search
@@ -152,8 +152,8 @@ export default class ScopesScopeTargetsRoute extends Route {
|
||||
@notifySuccess('notifications.delete-success')
|
||||
async deleteAlias(alias) {
|
||||
await alias.destroyRecord();
|
||||
await this.router.replaceWith('scopes.scope.targets.target');
|
||||
this.router.refresh();
|
||||
this.router.refresh('scopes.scope.targets.target');
|
||||
await this.router.transitionTo('scopes.scope.targets.target');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,12 +14,15 @@ export default class ScopesScopeTargetsTargetIndexRoute extends Route {
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Adds storage bucket name to the context.
|
||||
* Adds storage bucket name, globalScope and aliases model to the context.
|
||||
* @param {Controller} controller
|
||||
* @param {TargetModel} target
|
||||
*/
|
||||
async setupController(controller, target) {
|
||||
super.setupController(...arguments);
|
||||
const globalScope = await this.store.peekRecord('scope', 'global');
|
||||
controller.set('globalScope', globalScope);
|
||||
|
||||
if (target?.storage_bucket_id) {
|
||||
const { storage_bucket_id } = target;
|
||||
const storageBucket = await this.store.findRecord(
|
||||
|
||||
@@ -625,7 +625,6 @@
|
||||
|
||||
.target-sidebar-aliases {
|
||||
margin-bottom: 3rem;
|
||||
width: 300px;
|
||||
|
||||
.description {
|
||||
color: var(--token-form-helper-text-color);
|
||||
|
||||
@@ -30,36 +30,22 @@
|
||||
@cancel={{route-action 'cancel' @model}}
|
||||
/>
|
||||
</bc.Body>
|
||||
|
||||
<bc.Sidebar>
|
||||
<div class='target-sidebar-aliases'>
|
||||
<h3>{{t 'resources.alias.title_plural'}}</h3>
|
||||
<p class='description'>
|
||||
{{t 'resources.alias.form.sidebar.help'}}
|
||||
</p>
|
||||
{{#if @model.aliases}}
|
||||
{{#if @model.aliases}}
|
||||
<div class='target-sidebar-aliases'>
|
||||
<h3>{{t 'resources.alias.title_plural'}}</h3>
|
||||
<p class='description'>
|
||||
{{t 'resources.alias.form.sidebar.help'}}
|
||||
</p>
|
||||
{{#each this.aliases as |alias|}}
|
||||
<LinkListPanel as |P|>
|
||||
<P.Item
|
||||
@icon='at-sign'
|
||||
@color='boundary'
|
||||
@text={{alias.value}}
|
||||
@route={{'scopes.scope.targets.target.manage-alias'}}
|
||||
@model={{alias.id}}
|
||||
/>
|
||||
<P.Item>
|
||||
<Hds::Dropdown as |dd|>
|
||||
<dd.ToggleIcon
|
||||
@icon='more-horizontal'
|
||||
@text={{t 'actions.manage'}}
|
||||
@hasChevron={{false}}
|
||||
@size='small'
|
||||
/>
|
||||
<dd.Interactive
|
||||
@route='scopes.scope.targets.target.manage-alias'
|
||||
@model={{alias.id}}
|
||||
@text={{t 'actions.manage'}}
|
||||
/>
|
||||
</Hds::Dropdown>
|
||||
</P.Item>
|
||||
</LinkListPanel>
|
||||
{{/each}}
|
||||
|
||||
@@ -91,36 +77,32 @@
|
||||
@icon='at-sign'
|
||||
@color='boundary'
|
||||
@text={{alias.value}}
|
||||
@route='scopes.scope.targets.target.manage-alias'
|
||||
@model={{alias.id}}
|
||||
/>
|
||||
<P.Item>
|
||||
<Hds::Dropdown as |dd|>
|
||||
<dd.ToggleIcon
|
||||
@icon='more-horizontal'
|
||||
@text={{t 'actions.manage'}}
|
||||
@hasChevron={{false}}
|
||||
@size='small'
|
||||
/>
|
||||
<dd.Interactive
|
||||
@route='scopes.scope.targets.target.manage-alias'
|
||||
@model={{alias.id}}
|
||||
@text={{t 'actions.manage'}}
|
||||
/>
|
||||
</Hds::Dropdown>
|
||||
</P.Item>
|
||||
</LinkListPanel>
|
||||
{{/each}}
|
||||
</M.Body>
|
||||
</Hds::Flyout>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<Hds::Button
|
||||
@icon='plus'
|
||||
@text={{t 'resources.target.actions.add-an-alias'}}
|
||||
@color='secondary'
|
||||
@route='scopes.scope.targets.target.create-alias'
|
||||
/>
|
||||
</div>
|
||||
{{else}}
|
||||
{{#if (can 'create model' this.globalScope collection='aliases')}}
|
||||
<div class='target-sidebar-aliases'>
|
||||
<h3>{{t 'resources.alias.title_plural'}}</h3>
|
||||
<p class='description'>
|
||||
{{t 'resources.alias.form.sidebar.help'}}
|
||||
</p>
|
||||
|
||||
<Hds::Button
|
||||
@icon='plus'
|
||||
@text={{t 'resources.target.actions.add-an-alias'}}
|
||||
@color='secondary'
|
||||
@route='scopes.scope.targets.target.create-alias'
|
||||
/>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
<div class='target-sidebar'>
|
||||
{{#if (and @model.isSSH (feature-flag 'ssh-session-recording'))}}
|
||||
<h3>{{t 'resources.target.form.sidebar.label'}}</h3>
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
/>
|
||||
{{/if}}
|
||||
{{#if perms.canDelete}}
|
||||
<dd.Separator />
|
||||
<dd.Interactive
|
||||
@color='critical'
|
||||
@text={{t 'actions.delete'}}
|
||||
|
||||
@@ -17,13 +17,12 @@ module('Acceptance | targets | manage-alias', function (hooks) {
|
||||
let aliasResourceTwo, aliasResourceOne, getAliasCount;
|
||||
const ALIASES_SIDEBAR = '.target-sidebar-aliases';
|
||||
const ALIASES_SIDEBAR_LIST = '.link-list-item';
|
||||
const DROPDOWN_BUTTON_SELECTOR = '.hds-dropdown-toggle-icon';
|
||||
const DROPDOWN_ITEM_SELECTOR = '.hds-dropdown-list-item a';
|
||||
const DROPDOWN_ACTION = '.hds-dropdown-toggle-button__text';
|
||||
const CLEAR_BTN_SELECTOR = '.hds-dropdown-list-item--color-action button';
|
||||
const DELETE_BTN_SELECTOR = '.hds-dropdown-list-item--color-critical button';
|
||||
const LINK_TO_NEW_ALIAS = '.target-sidebar-aliases .hds-button';
|
||||
const DEST_FIELD_SELECTOR = '[name="destination_id"]';
|
||||
const ITEM_SELECTOR = '.link-list-item a';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -33,6 +32,7 @@ module('Acceptance | targets | manage-alias', function (hooks) {
|
||||
},
|
||||
sshTarget: null,
|
||||
tcpTarget: null,
|
||||
alias: null,
|
||||
};
|
||||
const urls = {
|
||||
globalScope: null,
|
||||
@@ -97,13 +97,8 @@ module('Acceptance | targets | manage-alias', function (hooks) {
|
||||
await visit(urls.tcpTarget);
|
||||
assert.dom(ALIASES_SIDEBAR).exists();
|
||||
assert.dom(ALIASES_SIDEBAR_LIST).exists();
|
||||
await click(ITEM_SELECTOR);
|
||||
|
||||
await click(DROPDOWN_BUTTON_SELECTOR);
|
||||
|
||||
assert.dom(DROPDOWN_ITEM_SELECTOR).exists();
|
||||
assert.dom(DROPDOWN_ITEM_SELECTOR).hasText('Manage');
|
||||
|
||||
await click(DROPDOWN_ITEM_SELECTOR);
|
||||
assert.strictEqual(currentURL(), urls.tcpAlias);
|
||||
await a11yAudit();
|
||||
});
|
||||
@@ -115,12 +110,9 @@ module('Acceptance | targets | manage-alias', function (hooks) {
|
||||
await visit(urls.tcpTarget);
|
||||
assert.dom(ALIASES_SIDEBAR).exists();
|
||||
assert.dom(ALIASES_SIDEBAR_LIST).exists();
|
||||
await click(DROPDOWN_BUTTON_SELECTOR);
|
||||
|
||||
assert.dom(DROPDOWN_ITEM_SELECTOR).exists();
|
||||
assert.dom(DROPDOWN_ITEM_SELECTOR).hasText('Manage');
|
||||
await click(ITEM_SELECTOR);
|
||||
|
||||
await click(DROPDOWN_ITEM_SELECTOR);
|
||||
assert.strictEqual(currentURL(), urls.tcpAlias);
|
||||
await click(DROPDOWN_ACTION);
|
||||
|
||||
@@ -144,12 +136,9 @@ module('Acceptance | targets | manage-alias', function (hooks) {
|
||||
await visit(urls.tcpTarget);
|
||||
assert.dom(ALIASES_SIDEBAR).exists();
|
||||
assert.dom(ALIASES_SIDEBAR_LIST).exists();
|
||||
await click(DROPDOWN_BUTTON_SELECTOR);
|
||||
|
||||
assert.dom(DROPDOWN_ITEM_SELECTOR).exists();
|
||||
assert.dom(DROPDOWN_ITEM_SELECTOR).hasText('Manage');
|
||||
await click(ITEM_SELECTOR);
|
||||
|
||||
await click(DROPDOWN_ITEM_SELECTOR);
|
||||
assert.dom(DEST_FIELD_SELECTOR).doesNotHaveAttribute('readOnly');
|
||||
|
||||
assert.strictEqual(currentURL(), urls.tcpAlias);
|
||||
|
||||
@@ -29,8 +29,6 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
const LINK_TO_NEW_ALIAS = '.target-sidebar-aliases .hds-button';
|
||||
const VIEW_MORE_BTN = '[data-test-view-more]';
|
||||
const FLYOUT_COMPONENT = '[data-test-flyout]';
|
||||
const DROPDOWN_BUTTON_SELECTOR = '.hds-dropdown-toggle-icon';
|
||||
const DROPDOWN_ITEM_SELECTOR = '.hds-dropdown-list-item a';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -40,6 +38,7 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
},
|
||||
sshTarget: null,
|
||||
tcpTarget: null,
|
||||
alias: null,
|
||||
};
|
||||
const urls = {
|
||||
globalScope: null,
|
||||
@@ -75,6 +74,7 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
|
||||
instances.alias = this.server.createList('alias', 1, {
|
||||
scope: instances.scopes.global,
|
||||
value: 'alias 1',
|
||||
});
|
||||
|
||||
aliasResource = instances.alias[0];
|
||||
@@ -213,7 +213,7 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
|
||||
test('can view aliases on the right sidebar', async function (assert) {
|
||||
instances.tcpTarget.update({
|
||||
aliases: [{ id: aliasResource.id, value: 'alias 1' }],
|
||||
aliases: [{ id: aliasResource.id, value: aliasResource.value }],
|
||||
});
|
||||
await visit(urls.tcpTarget);
|
||||
assert.dom(ALIASES_SIDEBAR).exists();
|
||||
@@ -225,12 +225,25 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
});
|
||||
|
||||
test('cannot view aliases list on the right sidebar if there is no alias associated with the target', async function (assert) {
|
||||
aliasResource.authorized_collection_actions = ['create'];
|
||||
await visit(urls.tcpTarget);
|
||||
assert.dom(ALIASES_SIDEBAR).exists();
|
||||
assert.dom(LINK_TO_NEW_ALIAS).hasText('Add an alias');
|
||||
assert.dom(ALIASES_SIDEBAR_LIST).doesNotExist();
|
||||
});
|
||||
|
||||
test('user should not see add a new alias button without proper auth ', async function (assert) {
|
||||
instances.scopes.global.authorized_collection_actions['aliases'] =
|
||||
instances.scopes.global.authorized_collection_actions['aliases'].filter(
|
||||
(item) => item !== 'create',
|
||||
);
|
||||
await visit(urls.tcpTarget);
|
||||
|
||||
assert.dom(ALIASES_SIDEBAR).doesNotExist();
|
||||
assert.dom(LINK_TO_NEW_ALIAS).doesNotExist();
|
||||
assert.dom(ALIASES_SIDEBAR_LIST).doesNotExist();
|
||||
});
|
||||
|
||||
test('can click `view more aliases` to see the remaining associated aliases if there are more than 3', async function (assert) {
|
||||
instances.tcpTarget.update({
|
||||
aliases: [
|
||||
@@ -247,19 +260,4 @@ module('Acceptance | targets | read', function (hooks) {
|
||||
await click(VIEW_MORE_BTN);
|
||||
assert.dom(FLYOUT_COMPONENT).exists();
|
||||
});
|
||||
|
||||
test('users can click on associated alias card on the right sidebar', async function (assert) {
|
||||
instances.tcpTarget.update({
|
||||
aliases: [{ id: aliasResource.id, value: aliasResource.value }],
|
||||
});
|
||||
await visit(urls.tcpTarget);
|
||||
|
||||
assert.dom(ALIASES_SIDEBAR_LIST).exists();
|
||||
await click(DROPDOWN_BUTTON_SELECTOR);
|
||||
|
||||
assert.dom(DROPDOWN_ITEM_SELECTOR).exists();
|
||||
assert.dom(DROPDOWN_ITEM_SELECTOR).hasText('Manage');
|
||||
await click(DROPDOWN_ITEM_SELECTOR);
|
||||
assert.strictEqual(currentURL(), urls.alias);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user