1 |
- {"version":3,"sources":["../../src/app/widgets/ContinueCancelModal.tsx"],"names":["React","Modal","Button","Msg","ContinueCancelModal","Component","constructor","props","setState","isModalOpen","onClose","handleModalToggle","onContinue","state","render","buttonId","buttonVariant","isDisabled","buttonTitle","localize","modalTitle","modalCancelButtonLabel","handleContinue","modalContinueButtonLabel","modalMessage","children","isSmall"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,KAAKA,KAAZ;AACA,SAASC,KAAT,EAAgBC,MAAhB;AACA,SAAQC,GAAR;AAEA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAN,SAAkCJ,KAAK,CAACK,SAAxC,CAAsG;AASlGC,EAAAA,WAAW,CAACC,KAAD,EAAkC;AAChD,UAAMA,KAAN;;AADgD,+CAOxB,MAAM;AAC9B,WAAKC,QAAL,CAAc,CAAC;AAAEC,QAAAA;AAAF,OAAD,MAAsB;AAChCA,QAAAA,WAAW,EAAE,CAACA;AADkB,OAAtB,CAAd;AAGA,UAAI,KAAKF,KAAL,CAAWG,OAAf,EAAwB,KAAKH,KAAL,CAAWG,OAAX;AAC3B,KAZmD;;AAAA,4CAc3B,MAAM;AAC3B,WAAKC,iBAAL;AACA,WAAKJ,KAAL,CAAWK,UAAX;AACH,KAjBmD;;AAEhD,SAAKC,KAAL,GAAa;AACTJ,MAAAA,WAAW,EAAE;AADJ,KAAb;AAGH;;AAcMK,EAAAA,MAAM,GAAoB;AAC7B,UAAM;AAAEL,MAAAA;AAAF,QAAkB,KAAKI,KAA7B;AAEA,WACI,oBAAC,KAAD,CAAO,QAAP,QACK,CAAC,KAAKN,KAAL,CAAWO,MAAZ,IACD,oBAAC,MAAD;AAAQ,MAAA,EAAE,EAAE,KAAKP,KAAL,CAAWQ,QAAvB;AAAiC,MAAA,OAAO,EAAE,KAAKR,KAAL,CAAWS,aAArD;AAA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A,aAAa,EAAE,SADa;AAE5BO,EAAAA,wBAAwB,EAAE,UAFE;AAG5BF,EAAAA,sBAAsB,EAAE,UAHI;AAI5BJ,EAAAA,UAAU,EAAE,KAJgB;AAK5BS,EAAAA,OAAO,EAAE;AALmB,C;;AAyDnC","sourcesContent":["/*\n * Copyright 2019 Red Hat, Inc. and/or its affiliates.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from 'react';\nimport { Modal, Button, ButtonProps } from '@patternfly/react-core';\nimport {Msg} from './Msg';\n\n/**\n * For any of these properties that are strings, you can\n * pass in a localization key instead of a static string.\n */\ninterface ContinueCancelModalProps {\n buttonTitle?: string;\n buttonVariant?: ButtonProps['variant'];\n buttonId?: string;\n render?(toggle: () => void): React.ReactNode;\n modalTitle: string;\n modalMessage?: string;\n modalContinueButtonLabel?: string;\n modalCancelButtonLabel?: string;\n onContinue: () => void;\n onClose?: () => void;\n isDisabled?: boolean;\n isLarge?: boolean;\n}\n\ninterface ContinueCancelModalState {\n isModalOpen: boolean;\n}\n\n/**\n * This class renders a button that provides a continue/cancel modal dialog when clicked. If the user selects 'Continue'\n * then the onContinue function is executed.\n *\n * @author Stan Silvert ssilvert@redhat.com (C) 2019 Red Hat Inc.\n */\nexport class ContinueCancelModal extends React.Component<ContinueCancelModalProps, ContinueCancelModalState> {\n protected static defaultProps = {\n buttonVariant: 'primary',\n modalContinueButtonLabel: 'continue',\n modalCancelButtonLabel: 'doCancel',\n isDisabled: false,\n isSmall: true\n };\n\n public constructor(props: ContinueCancelModalProps) {\n super(props);\n this.state = {\n isModalOpen: false\n };\n }\n\n private handleModalToggle = () => {\n this.setState(({ isModalOpen }) => ({\n isModalOpen: !isModalOpen\n }));\n if (this.props.onClose) this.props.onClose();\n };\n\n private handleContinue = () => {\n this.handleModalToggle();\n this.props.onContinue();\n }\n\n public render(): React.ReactNode {\n const { isModalOpen } = this.state;\n\n return (\n <React.Fragment>\n {!this.props.render &&\n <Button id={this.props.buttonId} variant={this.props.buttonVariant} onClick={this.handleModalToggle} isDisabled={this.props.isDisabled}>\n <Msg msgKey={this.props.buttonTitle!}/>\n </Button>}\n {this.props.render && this.props.render(this.handleModalToggle)}\n <Modal\n {...this.props}\n title={Msg.localize(this.props.modalTitle)}\n isOpen={isModalOpen}\n onClose={this.handleModalToggle}\n actions={[\n <Button id='modal-cancel' key=\"cancel\" variant=\"secondary\" onClick={this.handleModalToggle}>\n <Msg msgKey={this.props.modalCancelButtonLabel!}/>\n </Button>,\n <Button id='modal-confirm' key=\"confirm\" variant=\"primary\" onClick={this.handleContinue}>\n <Msg msgKey={this.props.modalContinueButtonLabel!}/>\n </Button>\n ]}\n >\n { !this.props.modalMessage && this.props.children}\n { this.props.modalMessage && <Msg msgKey={this.props.modalMessage}/>}\n </Modal>\n </React.Fragment>\n );\n }\n};"],"file":"ContinueCancelModal.js"}
|