-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
UI: Pki key read view #18087
UI: Pki key read view #18087
Changes from 5 commits
49a3c9f
889ba39
62e1041
71b87b6
5a22ef6
1cab111
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,10 +1,21 @@ | ||||||||||||||||||||||||
import Model, { attr } from '@ember-data/model'; | ||||||||||||||||||||||||
import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
export default class PkiKeyModel extends Model { | ||||||||||||||||||||||||
@attr('string', { readOnly: true }) backend; | ||||||||||||||||||||||||
@attr('boolean') isDefault; | ||||||||||||||||||||||||
@attr('string') keyRef; // reference to an existing key: either, vault generate identifier, literal string 'default', or the name assigned to the key. Part of the request URL. | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the docs refer to |
||||||||||||||||||||||||
@attr('string') keyId; | ||||||||||||||||||||||||
@attr('string', { possibleValues: ['internal', 'external'] }) type; | ||||||||||||||||||||||||
@attr('string', { detailsLabel: 'Key ID' }) keyId; | ||||||||||||||||||||||||
@attr('string') keyName; | ||||||||||||||||||||||||
@attr('string') keyType; | ||||||||||||||||||||||||
@attr('string', { detailsLabel: 'Key bit length' }) keyBits; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
// TODO refactor when field-to-attrs util is refactored as decorator | ||||||||||||||||||||||||
_attributeMeta = null; // cache initial result of expandAttributeMeta in getter and return | ||||||||||||||||||||||||
get formFields() { | ||||||||||||||||||||||||
if (!this._attributeMeta) { | ||||||||||||||||||||||||
this._attributeMeta = expandAttributeMeta(this, ['keyId', 'keyName', 'keyType', 'keyBits']); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
return this._attributeMeta; | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the mean time you could move this to the constructor instead which is how
Suggested change
|
||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<PageHeader as |p|> | ||
<p.top> | ||
{{! TODO: This should be replaced with HDS::Breadcrumbs }} | ||
<nav class="breadcrumb" aria-label="breadcrumbs" data-test-breadcrumbs="key-details"> | ||
<ul> | ||
<li> | ||
<span class="sep">/</span> | ||
<LinkToExternal @route="secrets">secrets</LinkToExternal> | ||
</li> | ||
{{#each this.breadcrumbs as |breadcrumb|}} | ||
<li> | ||
<span class="sep">/</span> | ||
{{#if breadcrumb.path}} | ||
<LinkTo @route={{breadcrumb.path}}> | ||
{{breadcrumb.label}} | ||
</LinkTo> | ||
{{else}} | ||
{{breadcrumb.label}} | ||
{{/if}} | ||
</li> | ||
{{/each}} | ||
</ul> | ||
</nav> | ||
Comment on lines
+4
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might not be worth it if this exists in HDS but if not could we turn this into a component? This pattern appears to be copied in a lot of places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied this from Chelsea's PR along with her "TODO" - I can ask what her thoughts are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reminds me that I also wanted to consult @hashishaw about which also includes breadcrumbs and is used elsewhere in the PKI engine. I think some general cleanup could happen with all of these headers and would be a good follow-on ticket to tackle all of the views in one PR |
||
</p.top> | ||
<p.levelLeft> | ||
<h1 class="title is-3" data-test-key-details-title> | ||
<Icon @name="certificate" @size="24" class="has-text-grey-light" /> | ||
View key | ||
</h1> | ||
</p.levelLeft> | ||
</PageHeader> | ||
<Toolbar> | ||
<ToolbarActions> | ||
<ConfirmAction | ||
@buttonClasses="toolbar-link" | ||
@onConfirmAction={{this.deleteKey}} | ||
@confirmTitle="Delete key?" | ||
@confirmButtonText="Delete" | ||
data-test-pki-key-delete | ||
> | ||
Delete | ||
</ConfirmAction> | ||
<ToolbarLink @route="keys.key.edit" @model={{@key.model.name}}> | ||
Edit key | ||
</ToolbarLink> | ||
</ToolbarActions> | ||
</Toolbar> | ||
|
||
<div class="box is-fullwidth is-sideless is-paddingless is-marginless"> | ||
{{#each @key.formFields as |attr|}} | ||
{{#let (get @key attr.name) as |value|}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you - good catch! I forgot to fix this when I added |
||
<InfoTableRow | ||
@label={{capitalize (or attr.options.detailsLabel attr.options.label (humanize (dasherize attr.name)))}} | ||
@value={{value}} | ||
@alwaysRender={{true}} | ||
/> | ||
{{/let}} | ||
{{/each}} | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { action } from '@ember/object'; | ||
import Component from '@glimmer/component'; | ||
|
||
interface Args { | ||
key: { | ||
backend: string; | ||
keyName: string; | ||
keyId: string; | ||
}; | ||
} | ||
Comment on lines
+4
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
|
||
export default class PkiKeyDetails extends Component<Args> { | ||
get breadcrumbs() { | ||
return [ | ||
{ label: this.args.key.backend || 'pki', path: 'overview' }, | ||
{ label: 'keys', path: 'keys.index' }, | ||
{ label: this.args.key.keyId }, | ||
]; | ||
} | ||
|
||
@action deleteKey() { | ||
// TODO handle delete | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import PkiKeysIndexRoute from './index'; | ||
|
||
export default class PkiKeyRoute extends PkiKeysIndexRoute { | ||
model() { | ||
const { key_id } = this.paramsFor('keys/key'); | ||
return this.store.queryRecord('pki/key', { | ||
backend: this.secretMountPath.currentPath, | ||
id: key_id, | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
keys.key.:id.details | ||
<PkiKeyDetails @key={{this.model}} /> |
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 wonder if changing the name to something like
getURL
would be more succinct since you are bypassing theurlForQuery
andurlForQueryRecord
hooks? It seems like this method could handle constructing the url for other methods likecreateRecord
as well if need be.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.
Yeah! I can do that. I struggled with method naming in this adapter, and wasn't sure if combining the methods into one was okay in the first place
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 think it is. I might have done it slightly different. All you are doing in the
queryRecord
override is calling that custom url method. You could instead overrideurlForQueryRecord
and return the url you need and then not have to overridequeryRecord
.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.
So the adapter instead would just be these three methods?
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.
Yep that looks good! The way you approached it works too but I personally like to work with the provided hooks when possible.
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.
Yeah, I haven't worked much with adapters and couldn't discern a clear pattern that we use. I also didn't realize
urlForQueryRecord
was a built in hook!