Skip to content

Commit

Permalink
Revert "Changed type prop to buttonColor on EuiConfirmModal"
Browse files Browse the repository at this point in the history
This reverts commit b27fe390272c84eda0af20434b83d588017b1b72.
  • Loading branch information
cchaos committed Mar 22, 2018
1 parent 2cf7fc3 commit e52977b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src-docs/src/views/modal/confirm_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class ConfirmModal extends Component {
onConfirm={this.closeDestroyModal}
cancelButtonText="No, don't do it"
confirmButtonText="Yes, do it"
buttonColor="danger"
type="destroy"
defaultFocusedButton={EUI_MODAL_CONFIRM_BUTTON}
>
<p>You&rsquo;re about to destroy something.</p>
Expand All @@ -92,7 +92,7 @@ export class ConfirmModal extends Component {
&nbsp;

<EuiButton onClick={this.showDestroyModal}>
Show dangerous ConfirmModal
Show destroy type of ConfirmModal
</EuiButton>

{modal}
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/modal/modal_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export const ModalExample = {
text: (
<p>
Use the <EuiCode>EuiConfirmModal</EuiCode> to ask the user to confirm a decision.
The default type is a positive or neutral confirmation. To change the main button color
change the the <EuiCode>buttonColor</EuiCode> property to any of the button color options.
The default type is a positive or neutral confirmation. Change the <EuiCode>type</EuiCode>
property to <EuiCode>&quot;destroy&quot;</EuiCode> for those that are destructive and potentially regrettable.
</p>
),
props: { EuiConfirmModal },
Expand Down
15 changes: 11 additions & 4 deletions src/components/modal/confirm_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ const CONFIRM_MODAL_BUTTONS = [
CANCEL_BUTTON,
];

const typeToButtonColorMap = {
'confirm': 'primary',
'destroy': 'danger',
};

export const MODAL_TYPES = Object.keys(typeToButtonColorMap);

export class EuiConfirmModal extends Component {
componentDidMount() {
// We have to do this instead of using `autoFocus` because React's polyfill for auto-focusing
Expand Down Expand Up @@ -54,7 +61,7 @@ export class EuiConfirmModal extends Component {
cancelButtonText,
confirmButtonText,
className,
buttonColor,
type,
defaultFocusedButton, // eslint-disable-line no-unused-vars
...rest
} = this.props;
Expand Down Expand Up @@ -109,7 +116,7 @@ export class EuiConfirmModal extends Component {
onClick={onConfirm}
fill
buttonRef={this.confirmRef}
color={buttonColor}
color={typeToButtonColorMap[type]}
>
{confirmButtonText}
</EuiButton>
Expand All @@ -128,9 +135,9 @@ EuiConfirmModal.propTypes = {
onConfirm: PropTypes.func,
className: PropTypes.string,
defaultFocusedButton: PropTypes.oneOf(CONFIRM_MODAL_BUTTONS),
buttonColor: PropTypes.string,
type: PropTypes.oneOf(MODAL_TYPES),
};

EuiConfirmModal.defaultProps = {
buttonColor: 'primary',
type: 'confirm',
};

0 comments on commit e52977b

Please sign in to comment.