Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 bucket types icon in target association #2503

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/core/translations/resources/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ storage-bucket:
plugin-types:
aws: Amazon S3
minio: MinIO
unknown: Unknown
form:
scope:
label: Scope
Expand Down
16 changes: 14 additions & 2 deletions ui/admin/app/routes/scopes/scope/targets/target/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ export default class ScopesScopeTargetsTargetIndexRoute extends Route {
'storage-bucket',
storage_bucket_id,
);
const storage_bucket_name = storageBucket.displayName;
controller.set('storage_bucket_name', storage_bucket_name);
const {
displayName: name,
plugin: { name: pluginName },
isAWS,
isMinIO,
isUnknown,
} = storageBucket;
let icon;
if (isAWS) {
icon = 'aws';
} else if (isMinIO) {
icon = 'cloud-upload';
}
controller.set('storageBucket', { name, pluginName, icon, isUnknown });
}
}
}
66 changes: 42 additions & 24 deletions ui/admin/app/templates/scopes/scope/targets/target/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
}}

<Rose::Layout::Page as |page|>

<page.breadcrumbs>
<Breadcrumbs::Container />
</page.breadcrumbs>
Expand Down Expand Up @@ -36,7 +35,9 @@
<bc.Sidebar>
{{#if @model.aliases}}
<div class='target-sidebar-aliases'>
<h3>{{t 'resources.alias.title_plural'}}</h3>
<h3>
{{t 'resources.alias.title_plural'}}
</h3>
<p class='description'>
{{t 'resources.alias.form.sidebar.help'}}
</p>
Expand Down Expand Up @@ -92,7 +93,9 @@
{{else}}
{{#if (can 'create model' this.globalScope collection='aliases')}}
<div class='target-sidebar-aliases'>
<h3>{{t 'resources.alias.title_plural'}}</h3>
<h3>
{{t 'resources.alias.title_plural'}}
</h3>
<p class='description'>
{{t 'resources.alias.form.sidebar.help'}}
</p>
Expand All @@ -108,31 +111,46 @@
{{/if}}
<div class='target-sidebar'>
{{#if (and @model.isSSH (feature-flag 'ssh-session-recording'))}}
<h3>{{t 'resources.target.form.sidebar.label'}}</h3>
<h3>
{{t 'resources.target.form.sidebar.label'}}
</h3>
<p class='description'>
{{t 'resources.target.form.sidebar.help'}}
</p>
{{#if @model.enable_session_recording}}
<LinkListPanel as |P|>
<P.Item
@icon='cloud-upload'
@color='boundary'
@text={{this.storage_bucket_name}}
@route='scopes.scope.storage-buckets.storage-bucket'
@model={{@model.storage_bucket_id}}
>
<Hds::Badge
@text={{t 'resources.storage-bucket.types.aws_s3'}}
@icon='aws'
/>
</P.Item>
</LinkListPanel>
<Hds::Link::Standalone
@icon='arrow-right'
@iconPosition='trailing'
@text={{t 'resources.target.form.sidebar.link'}}
@route='scopes.scope.targets.target.enable-session-recording'
/>
{{#if this.storageBucket.isUnknown}}
<LinkListPanel as |P|>
<P.Item @color='boundary' @text={{this.storageBucket.name}}>
{{t 'resources.storage-bucket.plugin-types.unknown'}}
</P.Item>
</LinkListPanel>
{{else}}
<LinkListPanel as |P|>
<P.Item
@icon='cloud-upload'
@color='boundary'
@text={{this.storageBucket.name}}
@route='scopes.scope.storage-buckets.storage-bucket'
@model={{@model.storage_bucket_id}}
>
<Hds::Badge
@text={{t
(concat
'resources.storage-bucket.plugin-types.'
this.storageBucket.pluginName
)
}}
@icon={{this.storageBucket.icon}}
/>
</P.Item>
</LinkListPanel>
<Hds::Link::Standalone
@icon='arrow-right'
@iconPosition='trailing'
@text={{t 'resources.target.form.sidebar.link'}}
@route='scopes.scope.targets.target.enable-session-recording'
/>
{{/if}}
{{else}}
<Hds::Button
@text={{t 'resources.target.actions.enable-recording'}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module(
function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);

let intl;
let featuresService;
let storageBucketOne;
let storageBucketTwo;
Expand All @@ -27,6 +27,7 @@ module(
const DROPDOWN_SELECTOR = '[name=storage_bucket_id]';
const LINK_LIST_SELECTOR = '.link-list-item > a';
const LINK_LIST_SELECTOR_ITEM_TEXT = '.link-list-item__text';
const BADGE_TEXT_SELECTOR = '.target-sidebar .hds-badge__text';
const TOGGLE_SELECTOR = '[name=target-enable-session-recording]';
const LINK_TO_NEW_STORAGE_BUCKET =
'.enable-session-recording-toggle .hds-link-standalone';
Expand Down Expand Up @@ -91,6 +92,8 @@ module(
urls.newStorageBucket = `${urls.enableSessionRecording}/create-storage-bucket`;
urls.storageBucket = `${urls.storageBuckets}/${storageBucketOne.id}`;

intl = this.owner.lookup('service:intl');

authenticateSession({ username: 'admin' });
});

Expand Down Expand Up @@ -196,6 +199,12 @@ module(
await click(SAVE_BTN_SELECTOR);

assert.strictEqual(currentURL(), urls.target);
assert.strictEqual(
find(BADGE_TEXT_SELECTOR).textContent.trim(),
intl.t(
`resources.storage-bucket.plugin-types.${storageBucketTwo.plugin.name}`,
),
);

assert.strictEqual(
find(LINK_LIST_SELECTOR_ITEM_TEXT).textContent.trim(),
Expand All @@ -219,6 +228,12 @@ module(

await click(CANCEL_BTN_SELECTOR);
assert.strictEqual(currentURL(), urls.target);
assert.strictEqual(
find(BADGE_TEXT_SELECTOR).textContent.trim(),
intl.t(
`resources.storage-bucket.plugin-types.${storageBucketOne.plugin.name}`,
),
);

assert.strictEqual(
find(LINK_LIST_SELECTOR_ITEM_TEXT).textContent.trim(),
Expand Down