Files
vault/ui/lib/core/addon/components/confirm-action.js
Chelsea Shaw 84dc7969bd UI: keymgmt secret engine (#15523)
* No default provider on create, add subText to service_account_file field

* Show empty state if no provider selected -- sorry for all the conditionals

* Button and distribution title styling on key edit

* Fix key distribute empty state permissions

* Don't try to fetch distribution if provider is permissionError

* Use search-select component for provider on distribute component

* Show distribution form errors on page rather than popup

* Add id, label, subtext to input-search for search-select fallback

* Remove created field from provider, default to querying for keys unless capabilities is false

* Fix link to provider from key-edit

* Search select label styling and add subText to fallback

* Refetch model after key rotate

* Create distribution method is task so we can load and disable button

* Move keymgmt to cloud group on mount options

* Key actions are tasks, fix tab active class

* Add isRunning attr to confirm-action which disables confirm button and replaces text with loader

* Fix provider active tab class

* Handle control groups on distribution

* Correctly handle error message on key-edit

* Show loading state on distribute, reload key after distribute

* Clear old validation errors if valid

* Fix tests

* Fix delete url

* Add changelog

* Address PR comments

* kick circle-ci

* Format go file breaking fmt

* Rename old changelog

* Remove resolved TODO
2022-05-20 10:41:24 -05:00

58 lines
1.8 KiB
JavaScript

import Component from '@ember/component';
import layout from '../templates/components/confirm-action';
/**
* @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>
* ```
*
* @property {Func} [onConfirmAction=null] - The action to take upon confirming.
* @property {String} [confirmTitle=Delete this?] - The title to display when confirming.
* @property {String} [confirmMessage=You will not be able to recover it later.] - The message to display when confirming.
* @property {String} [confirmButtonText=Delete] - The confirm button text.
* @property {String} [cancelButtonText=Cancel] - The cancel button text.
*
*/
export default Component.extend({
layout,
tagName: '',
supportsDataTestProperties: true,
buttonText: 'Delete',
confirmTitle: 'Delete this?',
confirmMessage: 'You will not be able to recover it later.',
confirmButtonText: 'Delete',
cancelButtonText: 'Cancel',
horizontalPosition: 'auto-right',
verticalPosition: 'below',
isRunning: false,
disabled: false,
showConfirm: false,
onConfirmAction: null,
actions: {
toggleConfirm() {
this.toggleProperty('showConfirm');
},
onConfirm() {
const confirmAction = this.onConfirmAction;
if (typeof confirmAction !== 'function') {
throw new Error('confirm-action components expects `onConfirmAction` attr to be a function');
} else {
confirmAction();
this.toggleProperty('showConfirm');
}
},
},
});