check capabilities for version actions
This commit is contained in:
parent
08ef32d332
commit
ba33c04cc9
|
@ -93,7 +93,7 @@ export default Component.extend(FocusOnInsertMixin, {
|
|||
if (context.mode === 'create') {
|
||||
return;
|
||||
}
|
||||
let backend = context.isV2 ? context.model.belongsTo('engine').id : context.model.backend;
|
||||
let backend = context.isV2 ? context.get('model.engine.id') : context.model.backend;
|
||||
let id = context.model.id;
|
||||
let path = context.isV2 ? `${backend}/data/${id}` : `${backend}/${id}`;
|
||||
return {
|
||||
|
@ -114,7 +114,7 @@ export default Component.extend(FocusOnInsertMixin, {
|
|||
if (context.mode === 'create' || context.isV2 === false) {
|
||||
return;
|
||||
}
|
||||
let backend = context.model.belongsTo('engine').id;
|
||||
let backend = context.get('model.engine.id');
|
||||
let id = context.model.id;
|
||||
return {
|
||||
id: `${backend}/metadata/${id}`,
|
||||
|
@ -127,6 +127,49 @@ export default Component.extend(FocusOnInsertMixin, {
|
|||
),
|
||||
canEditV2Secret: alias('v2UpdatePath.canUpdate'),
|
||||
|
||||
deleteVersionPath: maybeQueryRecord(
|
||||
'capabilities',
|
||||
context => {
|
||||
let backend = context.get('model.engine.id');
|
||||
let id = context.model.id;
|
||||
return {
|
||||
id: `${backend}/delete/${id}`,
|
||||
};
|
||||
},
|
||||
'model.id'
|
||||
),
|
||||
canDeleteVersion: alias('deleteVersionPath.canUpdate'),
|
||||
destroyVersionPath: maybeQueryRecord(
|
||||
'capabilities',
|
||||
context => {
|
||||
let backend = context.get('model.engine.id');
|
||||
let id = context.model.id;
|
||||
return {
|
||||
id: `${backend}/destroy/${id}`,
|
||||
};
|
||||
},
|
||||
'model.id'
|
||||
),
|
||||
canDestroyVersion: alias('destroyVersionPath.canUpdate'),
|
||||
undeleteVersionPath: maybeQueryRecord(
|
||||
'capabilities',
|
||||
context => {
|
||||
let backend = context.get('model.engine.id');
|
||||
let id = context.model.id;
|
||||
return {
|
||||
id: `${backend}/undelete/${id}`,
|
||||
};
|
||||
},
|
||||
'model.id'
|
||||
),
|
||||
canUndeleteVersion: alias('undeleteVersionPath.canUpdate'),
|
||||
|
||||
isFetchingVersionCapabilities: or(
|
||||
'deleteVersionPath.isLoading',
|
||||
'destroyVersionPath.isLoading',
|
||||
'undeleteVersionPath.isLoading'
|
||||
),
|
||||
|
||||
requestInFlight: or('model.isLoading', 'model.isReloading', 'model.isSaving'),
|
||||
|
||||
buttonDisabled: or(
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
@buttonClasses="button is-compact is-ghost has-icon-right"
|
||||
@onConfirmAction={{action "deleteKey"}}
|
||||
@confirmMessage={{if isV2
|
||||
(concat "Are you sure you want to delete " model.id " AND ALL ITS VERSIONS?")
|
||||
(concat "This will permanently delete " model.id " and all its versions. Are you sure you want to do this?")
|
||||
(concat "Are you sure you want to delete " model.id "?")
|
||||
}}
|
||||
@cancelButtonText="Cancel"
|
||||
|
@ -52,7 +52,7 @@
|
|||
/>
|
||||
<label for="json" class="has-text-grey">JSON</label>
|
||||
</div>
|
||||
{{#if (and (eq mode 'show') canEdit)}}
|
||||
{{#if (and (eq mode 'show') (or canEditV2Secret canEdit))}}
|
||||
<div class="control">
|
||||
{{#let (concat 'vault.cluster.secrets.backend.' (if (eq mode 'show') 'edit' 'show')) as |targetRoute|}}
|
||||
{{#if isV2}}
|
||||
|
@ -101,44 +101,57 @@
|
|||
</button>
|
||||
</li>
|
||||
{{else}}
|
||||
<li class="action">
|
||||
{{#if this.modelForData.deleted}}
|
||||
<button type="button" class="link" {{action "deleteVersion" "undelete"}}>
|
||||
Undelete version
|
||||
</button>
|
||||
{{else}}
|
||||
<ConfirmAction
|
||||
@buttonClasses="link has-text-danger"
|
||||
@containerClasses="message-body is-block"
|
||||
@messageClasses="is-block"
|
||||
@onConfirmAction={{action "deleteVersion" "delete"}}
|
||||
@confirmMessage={{
|
||||
concat "Are you sure you want to delete " model.id " version " this.modelForData.version "?"
|
||||
}}
|
||||
@cancelButtonText="Cancel"
|
||||
data-test-secret-v2-delete="true"
|
||||
>
|
||||
Delete version
|
||||
</ConfirmAction>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{!-- TODO - check if canDestroy --}}
|
||||
{{#if true}}
|
||||
{{#if isFetchingVersionCapabilities}}
|
||||
<li class="action">
|
||||
<ConfirmAction
|
||||
@buttonClasses="link has-text-danger"
|
||||
@containerClasses="message-body is-block"
|
||||
@messageClasses="is-block"
|
||||
@onConfirmAction={{action "deleteVersion" "destroy"}}
|
||||
@confirmMessage={{
|
||||
concat "This will permanently destroy " model.id " version " this.modelForData.version ". Are you sure you want to do this?"
|
||||
}}
|
||||
@cancelButtonText="Cancel"
|
||||
data-test-secret-v2-destroy="true"
|
||||
>
|
||||
Permanently destroy version
|
||||
</ConfirmAction>
|
||||
<button disabled=true type="button" class="link button is-loading is-transparent">
|
||||
loading
|
||||
</button>
|
||||
</li>
|
||||
{{else}}
|
||||
<li class="action">
|
||||
{{#if this.modelForData.deleted}}
|
||||
{{#if canUndeleteVersion}}
|
||||
<button type="button" class="link" {{action "deleteVersion" "undelete"}}>
|
||||
Undelete version
|
||||
</button>
|
||||
{{else}}
|
||||
<button type="button" class="link" disabled >
|
||||
The data for {{this.model.id}} version {{this.modelForData.version}} has been deleted. You do not have the capabilities to undelete it.
|
||||
</button>
|
||||
{{/if}}
|
||||
{{else if canDeleteVersion}}
|
||||
<ConfirmAction
|
||||
@buttonClasses="link has-text-danger"
|
||||
@containerClasses="message-body is-block"
|
||||
@messageClasses="is-block"
|
||||
@onConfirmAction={{action "deleteVersion" "delete"}}
|
||||
@confirmMessage={{
|
||||
concat "Are you sure you want to delete " model.id " version " this.modelForData.version "?"
|
||||
}}
|
||||
@cancelButtonText="Cancel"
|
||||
data-test-secret-v2-delete="true"
|
||||
>
|
||||
Delete version
|
||||
</ConfirmAction>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{#if canDestroyVersion}}
|
||||
<li class="action">
|
||||
<ConfirmAction
|
||||
@buttonClasses="link has-text-danger"
|
||||
@containerClasses="message-body is-block"
|
||||
@messageClasses="is-block"
|
||||
@onConfirmAction={{action "deleteVersion" "destroy"}}
|
||||
@confirmMessage={{
|
||||
concat "This will permanently destroy " model.id " version " this.modelForData.version ". Are you sure you want to do this?"
|
||||
}}
|
||||
@cancelButtonText="Cancel"
|
||||
data-test-secret-v2-destroy="true"
|
||||
>
|
||||
Permanently destroy version
|
||||
</ConfirmAction>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue