mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 23:21:08 +02:00
* build out snapshots index route * add card for loaded snapshot * add tests * lint fix and remove logs * use api enum * lint fix * remove extra imports * tidy * routing updates * update tests * update styling * improve types * lint * add copyright header * update capability check * pull out header * add copyright headers * update url * Update ui/app/routes/vault/cluster/recovery/snapshots/snapshot.ts Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com> * test + error handling updates * update details route and add integration tests * tidy tests and pull out header title * lint * test updates --------- Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
90 lines
3.0 KiB
TypeScript
90 lines
3.0 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
import { service } from '@ember/service';
|
|
|
|
import type NamespaceService from 'vault/services/namespace';
|
|
import type VersionService from 'vault/services/version';
|
|
|
|
enum State {
|
|
COMMUNITY_VERSION = 'community',
|
|
NON_ROOT_NAMESPACE = 'non-root-namespace',
|
|
ALLOW_UPLOAD = 'default',
|
|
CANNOT_UPLOAD = 'cannot-upload',
|
|
}
|
|
|
|
interface Args {
|
|
model: { canLoadSnapshot: boolean; snapshots: Record<string, unknown>[] };
|
|
}
|
|
|
|
export default class Index extends Component<Args> {
|
|
@service declare readonly version: VersionService;
|
|
@service declare readonly namespace: NamespaceService;
|
|
|
|
viewState = State;
|
|
|
|
emptyStateDetails = {
|
|
[this.viewState.COMMUNITY_VERSION]: {
|
|
title: 'Secrets Recovery is an enterprise feature',
|
|
icon: 'sync-reverse',
|
|
message:
|
|
'Secrets Recovery allows you to restore accidentally deleted or lost secrets from a snapshot. The snapshots can be provided via upload or loaded from external storage.',
|
|
buttonText: 'Learn more about upgrading',
|
|
buttonHref: '/vault/docs/enterprise',
|
|
buttonIcon: 'docs-link',
|
|
buttonColor: 'tertiary',
|
|
},
|
|
[this.viewState.NON_ROOT_NAMESPACE]: {
|
|
title: 'Snapshot upload is restricted',
|
|
icon: 'sync-reverse',
|
|
message:
|
|
'Snapshot uploading is only available in root namespace. Please navigate to root and upload your snapshot.',
|
|
buttonText: 'Take me to root namespace',
|
|
buttonRoute: 'vault.cluster.dashboard',
|
|
buttonIcon: 'arrow-right',
|
|
buttonColor: 'tertiary',
|
|
},
|
|
[this.viewState.CANNOT_UPLOAD]: {
|
|
title: 'No snapshot available',
|
|
icon: 'skip',
|
|
message:
|
|
'Ready to restore secrets? Please contact your admin to either upload a snapshot or grant you uploading permissions to get started.',
|
|
buttonText: 'Learn more about Secrets Recovery',
|
|
buttonHref: '/vault/docs/sysadmin/snapshots/restore',
|
|
buttonIcon: 'docs-link',
|
|
buttonColor: 'tertiary',
|
|
},
|
|
[this.viewState.ALLOW_UPLOAD]: {
|
|
title: 'Upload a snapshot to get started',
|
|
icon: 'sync-reverse',
|
|
message:
|
|
'Secrets Recovery allows you to restore accidentally deleted or lost secrets from a snapshot. The snapshots can be provided via upload or loaded from external storage.',
|
|
buttonText: 'Upload snapshot',
|
|
buttonColor: 'primary',
|
|
},
|
|
};
|
|
|
|
get state() {
|
|
const { canLoadSnapshot } = this.args.model;
|
|
|
|
if (this.version.isCommunity) {
|
|
return this.viewState.COMMUNITY_VERSION;
|
|
} else if (!this.namespace.inRootNamespace) {
|
|
return this.viewState.NON_ROOT_NAMESPACE;
|
|
} else if (!canLoadSnapshot) {
|
|
return this.viewState.CANNOT_UPLOAD;
|
|
} else {
|
|
return this.viewState.ALLOW_UPLOAD;
|
|
}
|
|
}
|
|
|
|
@action
|
|
uploadSnapshot() {
|
|
// TODO this will be completed in further feature work for single item recovery in the 1.21 release
|
|
}
|
|
}
|