mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
91 lines
2.6 KiB
JavaScript
91 lines
2.6 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
import { assert } from '@ember/debug';
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
/**
|
|
* @module ConfirmAction
|
|
* `ConfirmAction` is a button followed by a pop up confirmation message and button used to prevent users from performing actions they do not intend to.
|
|
*
|
|
* @example
|
|
* ```js
|
|
* <ConfirmAction
|
|
* @onConfirmAction={{ () => { console.log('Action!') } }}
|
|
* @confirmMessage="Are you sure you want to delete this config?">
|
|
* Delete
|
|
* </ConfirmAction>
|
|
* ```
|
|
*
|
|
* @param {Func} [onConfirmAction=null] - The action to take upon confirming.
|
|
* @param {String} [confirmTitle=Delete this?] - The title to display when confirming.
|
|
* @param {String} [confirmMessage=You will not be able to recover it later.] - The message to display when confirming.
|
|
* @param {String} [confirmButtonText=Delete] - The confirm button text.
|
|
* @param {String} [cancelButtonText=Cancel] - The cancel button text.
|
|
* @param {String} [buttonClasses] - A string to indicate the button class.
|
|
* @param {String} [horizontalPosition=auto-right] - For the position of the dropdown.
|
|
* @param {String} [verticalPosition=below] - For the position of the dropdown.
|
|
* @param {Boolean} [isRunning=false] - If action is still running disable the confirm.
|
|
* @param {Boolean} [disable=false] - To disable the confirm action.
|
|
*
|
|
*/
|
|
|
|
export default class ConfirmActionComponent extends Component {
|
|
@tracked showConfirm = false;
|
|
|
|
get horizontalPosition() {
|
|
return this.args.horizontalPosition || 'auto-right';
|
|
}
|
|
|
|
get verticalPosition() {
|
|
return this.args.verticalPosition || 'below';
|
|
}
|
|
|
|
get isRunning() {
|
|
return this.args.isRunning || false;
|
|
}
|
|
|
|
get disabled() {
|
|
return this.args.disabled || false;
|
|
}
|
|
|
|
get confirmTitle() {
|
|
return this.args.confirmTitle || 'Delete this?';
|
|
}
|
|
|
|
get confirmMessage() {
|
|
return this.args.confirmMessage || 'You will not be able to recover it later.';
|
|
}
|
|
|
|
get confirmButtonText() {
|
|
return this.args.confirmButtonText || 'Delete';
|
|
}
|
|
|
|
get cancelButtonText() {
|
|
return this.args.cancelButtonText || 'Cancel';
|
|
}
|
|
|
|
@action
|
|
toggleConfirm() {
|
|
// toggle
|
|
this.showConfirm = !this.showConfirm;
|
|
}
|
|
|
|
@action
|
|
onConfirm(actions) {
|
|
const confirmAction = this.args.onConfirmAction;
|
|
|
|
if (typeof confirmAction !== 'function') {
|
|
assert('confirm-action components expects `onConfirmAction` attr to be a function');
|
|
} else {
|
|
confirmAction();
|
|
// close the dropdown content
|
|
actions.close();
|
|
}
|
|
}
|
|
}
|