open-vault/ui/lib/core/addon/components/shamir-modal-flow.js
Hamid Ghaf 27bb03bbc0
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

45 lines
1.3 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
/**
* @module ShamirModalFlow
* ShamirModalFlow is an extension of the ShamirFlow component that does the Generate Action Token workflow inside of a Modal.
* Please note, this is not an extensive list of the required parameters -- please see ShamirFlow for others
*
* @example
* ```js
* <ShamirModalFlow @onClose={action 'onClose'}>This copy is the main paragraph when the token flow has not started</ShamirModalFlow>
* ```
* @param {function} onClose - This function will be triggered when the modal intends to be closed
*/
import { inject as service } from '@ember/service';
import ShamirFlow from './shamir-flow';
import layout from '../templates/components/shamir-modal-flow';
export default ShamirFlow.extend({
layout,
store: service(),
onClose: () => {},
actions: {
onCancelClose() {
if (this.encoded_token) {
this.send('reset');
} else if (this.generateAction && !this.started) {
if (this.generateStep !== 'chooseMethod') {
this.send('reset');
}
} else {
const adapter = this.store.adapterFor('cluster');
adapter.generateDrOperationToken(this.model, { cancel: true });
this.send('reset');
}
this.onClose();
},
onClose() {
this.onClose();
},
},
});