-
Notifications
You must be signed in to change notification settings - Fork 32
Icu 18007 read details #3104
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
Open
sohail-hashicorp
wants to merge
10
commits into
llb/app-tokens
Choose a base branch
from
ICU-18007-read-details
base: llb/app-tokens
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,025
−13
Open
Icu 18007 read details #3104
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ecdf75d
feat: Add app token details page
sohail-hashicorp a095489
Fixed few UI alighnment issue and added tooltip
sohail-hashicorp 6895234
test: 💍 Added tests for app-token details page
sohail-hashicorp ba23582
Clean up
sohail-hashicorp 7aa42f1
Add missing copyright headers
sohail-hashicorp 013c810
fix the linting issue is scss
sohail-hashicorp 05cf8af
fixed the linting again
sohail-hashicorp 4a37232
Fixed PR comments
sohail-hashicorp 5426abc
fixed PR comments
sohail-hashicorp 3153e35
Add read-only form component for app token details
sohail-hashicorp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| {{! | ||
| Copyright (c) HashiCorp, Inc. | ||
| SPDX-License-Identifier: BUSL-1.1 | ||
|
|
||
| A reusable component for displaying a bordered container with a title | ||
| and a list of label-value pairs. | ||
|
|
||
| Usage example in templates: | ||
| <DescriptionList @title="Section Title" as |DL|> | ||
| <DL.Item @label="Label 1">Value 1</DL.Item> | ||
| <DL.Item @label="Label 2">Value 2</DL.Item> | ||
| </DescriptionList> | ||
|
|
||
| Arguments: | ||
| @title (string, optional) - Section title displayed at the top | ||
| }} | ||
|
|
||
| <dl class='description-list'> | ||
| {{! Optional title spanning full width }} | ||
| {{#if @title}} | ||
| <div class='description-list-title'> | ||
| <Hds::Text::Display @tag='h3' @size='300' @weight='semibold'> | ||
| {{@title}} | ||
| </Hds::Text::Display> | ||
| </div> | ||
| {{/if}} | ||
| {{! Yield DL.Item component for each label-value pair }} | ||
| {{yield (hash Item=(component 'description-list/item'))}} | ||
| </dl> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| {{! | ||
| Copyright (c) HashiCorp, Inc. | ||
| SPDX-License-Identifier: BUSL-1.1 | ||
|
|
||
| Individual item within a DescriptionList. | ||
| Displays a label (dt) above a value (dd) with 8px vertical spacing. | ||
|
|
||
| Arguments: | ||
| @label (string, required) - The label text for this item | ||
| Block content - The value to display (can be text, components, etc.) | ||
| }} | ||
|
|
||
| <div class='description-list-item'> | ||
| <dt> | ||
| <Hds::Text::Body @tag='span' @weight='semibold'> | ||
| {{@label}} | ||
| </Hds::Text::Body> | ||
| </dt> | ||
| <dd> | ||
| {{yield}} | ||
| </dd> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| {{! | ||
| Copyright (c) HashiCorp, Inc. | ||
| SPDX-License-Identifier: BUSL-1.1 | ||
| }} | ||
|
|
||
| <Rose::Form> | ||
| <Hds::Form::TextInput::Field | ||
| @value={{@model.name}} | ||
| @type='text' | ||
| readOnly={{true}} | ||
| as |F| | ||
| > | ||
| <F.Label>{{t 'form.name.label'}}</F.Label> | ||
| <F.HelperText>{{t 'resources.app-token.form.name.help'}}</F.HelperText> | ||
| </Hds::Form::TextInput::Field> | ||
|
|
||
| <Hds::Form::Textarea::Field | ||
| @value={{@model.description}} | ||
| readOnly={{true}} | ||
| as |F| | ||
| > | ||
| <F.Label>{{t 'form.description.label'}}</F.Label> | ||
| <F.HelperText>{{t | ||
| 'resources.app-token.form.description.help' | ||
| }}</F.HelperText> | ||
| </Hds::Form::Textarea::Field> | ||
|
|
||
| <DescriptionList @title={{t 'resources.app-token.about.title'}} as |DL|> | ||
| <DL.Item @label={{t 'resources.app-token.form.status.label'}}> | ||
| <Hds::Badge | ||
| @text={{this.statusBadge.text}} | ||
| @color={{this.statusBadge.color}} | ||
| /> | ||
| </DL.Item> | ||
| {{! TODO: Check where to navigate the user for global/org/proj levels }} | ||
| <DL.Item @label={{t 'resources.app-token.form.created_by.label'}}> | ||
| <Hds::Link::Inline | ||
| @route='scopes.scope.users.user' | ||
| @models={{array @model.scope.id @model.created_by_user_id}} | ||
| @icon='user' | ||
| @iconPosition='leading' | ||
| > | ||
| {{@model.created_by_user_id}} | ||
| </Hds::Link::Inline> | ||
| </DL.Item> | ||
| <DL.Item @label={{t 'resources.app-token.form.scope.label'}}> | ||
| <Hds::Link::Inline | ||
| @route='scopes.scope' | ||
| @model={{@model.scope.id}} | ||
| @icon={{this.scopeInfo.icon}} | ||
| @iconPosition='leading' | ||
| > | ||
| {{this.scopeInfo.text}} | ||
| </Hds::Link::Inline> | ||
| </DL.Item> | ||
| </DescriptionList> | ||
|
|
||
| <DescriptionList @title={{t 'resources.app-token.form.ttl.label.0'}} as |DL|> | ||
| <DL.Item @label={{t 'resources.app-token.form.ttl.label.1'}}> | ||
| {{#if this.ttlFormatted}} | ||
| {{format-day-year this.ttlFormatted}} | ||
| {{else}} | ||
| {{t 'labels.none'}} | ||
| {{/if}} | ||
| </DL.Item> | ||
| <DL.Item @label={{t 'resources.app-token.form.expiration_date.label'}}> | ||
| {{#if @model.expire_time}} | ||
| <Hds::Time @date={{@model.expire_time}} /> | ||
| {{else}} | ||
| {{t 'labels.none'}} | ||
| {{/if}} | ||
| </DL.Item> | ||
| <DL.Item @label={{t 'resources.app-token.form.created_time.label'}}> | ||
| {{#if @model.created_time}} | ||
| <Hds::Time @date={{@model.created_time}} /> | ||
| {{else}} | ||
| {{t 'labels.none'}} | ||
| {{/if}} | ||
| </DL.Item> | ||
| </DescriptionList> | ||
|
|
||
| <DescriptionList @title={{t 'resources.app-token.form.tts.label.0'}} as |DL|> | ||
| <DL.Item @label={{t 'resources.app-token.form.tts.label.1'}}> | ||
| {{#if this.ttsFormatted}} | ||
| {{format-day-year this.ttsFormatted}} | ||
| {{else}} | ||
| {{t 'labels.none'}} | ||
| {{/if}} | ||
| </DL.Item> | ||
| <div class='description-list-item'> | ||
| <dt class='label-with-tooltip'> | ||
| {{t 'resources.app-token.form.last_used.label'}} | ||
| <Hds::Icon | ||
| @name='info' | ||
| @isInline={{true}} | ||
| {{hds-tooltip (t 'resources.app-token.form.last_used.tooltip')}} | ||
| /> | ||
| </dt> | ||
| <dd> | ||
| {{#if @model.approximate_last_access_time}} | ||
| <Hds::Time | ||
| @date={{@model.approximate_last_access_time}} | ||
| @format='relative' | ||
| /> | ||
| {{else}} | ||
| {{t 'labels.none'}} | ||
| {{/if}} | ||
| </dd> | ||
| </div> | ||
| </DescriptionList> | ||
| </Rose::Form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /** | ||
| * Copyright (c) HashiCorp, Inc. | ||
| * SPDX-License-Identifier: BUSL-1.1 | ||
| */ | ||
|
|
||
| import Component from '@glimmer/component'; | ||
| import { service } from '@ember/service'; | ||
|
|
||
| export default class FormAppTokenReadComponent extends Component { | ||
| @service intl; | ||
|
|
||
| statusConfig = { | ||
| active: { color: 'success' }, | ||
| expired: { color: 'critical' }, | ||
| revoked: { color: 'critical' }, | ||
| stale: { color: 'critical' }, | ||
| unknown: { color: 'neutral' }, | ||
| }; | ||
|
|
||
| /** | ||
| * Returns status badge configuration for app tokens | ||
| * @returns {object} | ||
| */ | ||
| get statusBadge() { | ||
| const status = this.args.model?.status; | ||
| if (!status) return { text: '', color: 'neutral' }; | ||
|
|
||
| const config = this.statusConfig[status] || { color: 'neutral' }; | ||
| return { | ||
| text: this.intl.t(`resources.app-token.status.${status}`), | ||
| color: config.color, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Returns scope information (icon, text) based on scope type | ||
| * @returns {object} | ||
| */ | ||
| get scopeInfo() { | ||
| const scope = this.args.model.scope; | ||
|
|
||
| if (scope.isGlobal) { | ||
| return { | ||
| icon: 'globe', | ||
| text: this.intl.t('resources.scope.types.global'), | ||
| }; | ||
| } | ||
|
|
||
| if (scope.isOrg) { | ||
| return { | ||
| icon: 'org', | ||
| text: this.intl.t('resources.scope.types.org'), | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| icon: 'grid', | ||
| text: this.intl.t('resources.scope.types.project'), | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Returns formatted TTL using format-time-duration helper | ||
| * @returns {number|null} TTL in days for format-day-year helper, or null | ||
| */ | ||
| get ttlFormatted() { | ||
| const ttl = this.args.model?.TTL; | ||
| if (!ttl) return null; | ||
|
|
||
| // Convert milliseconds to days for format-day-year helper | ||
| return Math.floor(ttl / (1000 * 60 * 60 * 24)); | ||
| } | ||
|
|
||
| /** | ||
| * Returns formatted TTS in days for format-day-year helper | ||
| * @returns {number|null} | ||
| */ | ||
| get ttsFormatted() { | ||
| const tts = this.args.model?.TTS; | ||
| if (!tts) return null; | ||
|
|
||
| // Convert milliseconds to days for format-day-year helper | ||
| return Math.floor(tts / (1000 * 60 * 60 * 24)); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /** | ||
| * Copyright (c) HashiCorp, Inc. | ||
| * SPDX-License-Identifier: BUSL-1.1 | ||
| */ | ||
|
|
||
| import Route from '@ember/routing/route'; | ||
| import { service } from '@ember/service'; | ||
|
|
||
| export default class ScopesScopeAppTokensAppTokenRoute extends Route { | ||
| @service store; | ||
|
|
||
| async model(params) { | ||
| // Fetch the app-token details using the token id and scope id | ||
| return this.store.findRecord('app-token', params.token_id, { | ||
sohail-hashicorp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| reload: true, | ||
| adapterOptions: { scope_id: params.scope_id }, | ||
| }); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see we are using
textfor the display. This is showing up asGlobal,Org, orProjectdepending on the scope level. We should be using thescope.displayNamehere to show the scope name or id if it has no name.