|
1 | 1 | /* eslint-disable no-undef */ |
2 | 2 | import * as React from 'react'; |
3 | 3 | import * as _ from 'lodash-es'; |
4 | | -import { Checkbox, Icon, MessageDialog } from 'patternfly-react'; |
| 4 | +import { Checkbox, Icon } from 'patternfly-react'; |
5 | 5 |
|
6 | 6 | import { RH_OPERATOR_SUPPORT_POLICY_LINK } from '../../const'; |
| 7 | +import { createModalLauncher, ModalTitle, ModalBody, ModalSubmitFooter } from '../factory/modal'; |
7 | 8 | import { ExternalLink } from '../utils'; |
8 | 9 |
|
9 | | -export class OperatorHubCommunityProviderModal extends React.Component<MarketplaceCommunityProviderModalProps, MarketplaceCommunityProviderModalState> { |
| 10 | +export class OperatorHubCommunityProviderModal extends React.Component<OperatorHubCommunityProviderModalProps, OperatorHubCommunityProviderModalState> { |
10 | 11 | constructor(props) { |
11 | 12 | super(props); |
12 | 13 | this.state = { |
13 | 14 | ignoreWarnings: false, |
14 | 15 | }; |
15 | 16 | } |
16 | 17 |
|
17 | | - componentDidUpdate(prevProps) { |
18 | | - const { show } = this.props; |
19 | | - const { ignoreWarnings } = this.state; |
20 | | - if (show && !prevProps.show && ignoreWarnings) { |
21 | | - this.setState({ignoreWarnings: false }); |
22 | | - } |
23 | | - } |
24 | | - |
25 | 18 | onIgnoreChange = (event) => { |
26 | 19 | this.setState({ ignoreWarnings: _.get(event, 'target.checked', false) }); |
27 | 20 | }; |
28 | 21 |
|
| 22 | + submit = (event) => { |
| 23 | + event.preventDefault(); |
| 24 | + this.props.showCommunityOperators(this.state.ignoreWarnings); |
| 25 | + this.props.close(); |
| 26 | + }; |
| 27 | + |
29 | 28 | render() { |
30 | | - const {show, close} = this.props; |
31 | 29 | const { ignoreWarnings } = this.state; |
32 | | - |
33 | | - const messageText = ( |
34 | | - <p> |
35 | | - These are operators which have not been vetted or verified by Red Hat. Community Operators should be used with |
36 | | - caution because their stability is unknown. Red Hat provides no support for Community Operators. |
37 | | - {RH_OPERATOR_SUPPORT_POLICY_LINK && ( |
38 | | - <span className="co-modal-ignore-warning__link"> |
39 | | - <ExternalLink href={RH_OPERATOR_SUPPORT_POLICY_LINK} text="Learn more about Red Hat’s third party software support policy" /> |
40 | | - </span> |
41 | | - )} |
42 | | - Do you want to show Community Operators in the Operator Hub? |
43 | | - </p> |
44 | | - ); |
45 | | - |
46 | | - const ignoreWarningsContent = ( |
47 | | - <Checkbox className="co-modal-ignore-warning__checkbox" onChange={this.onIgnoreChange} checked={ignoreWarnings}> |
48 | | - Do not show this warning again |
49 | | - </Checkbox> |
50 | | - ); |
51 | | - |
52 | | - return <MessageDialog |
53 | | - className="co-modal-ignore-warning" |
54 | | - show={show === true} |
55 | | - onHide={() => close(false, false)} |
56 | | - primaryAction={() => close(true, ignoreWarnings)} |
57 | | - secondaryAction={() => close(false, false)} |
58 | | - primaryActionButtonContent="Show Community Operators" |
59 | | - secondaryActionButtonContent="Cancel" |
60 | | - title="Show Community Operators" |
61 | | - icon={<Icon type="pf" name="info" />} |
62 | | - primaryContent={messageText} |
63 | | - secondaryContent={ignoreWarningsContent} |
64 | | - accessibleName="communityProviderWarningDialog" |
65 | | - accessibleDescription="communityProviderWarningContent" |
66 | | - />; |
| 30 | + const submitButtonContent = <React.Fragment>Show<span className="hidden-xs"> Community Operators</span></React.Fragment>; |
| 31 | + return <form onSubmit={this.submit} className="modal-content co-modal-ignore-warning"> |
| 32 | + <ModalTitle>Show Community Operators</ModalTitle> |
| 33 | + <ModalBody className="modal-body"> |
| 34 | + <div className="co-modal-ignore-warning__content"> |
| 35 | + <div className="co-modal-ignore-warning__icon"> |
| 36 | + <Icon type="pf" name="info" /> |
| 37 | + </div> |
| 38 | + <div> |
| 39 | + <p> |
| 40 | + These are operators which have not been vetted or verified by Red Hat. Community Operators should be used with |
| 41 | + caution because their stability is unknown. Red Hat provides no support for Community Operators. |
| 42 | + {RH_OPERATOR_SUPPORT_POLICY_LINK && ( |
| 43 | + <span className="co-modal-ignore-warning__link"> |
| 44 | + <ExternalLink href={RH_OPERATOR_SUPPORT_POLICY_LINK} text="Learn more about Red Hat’s third party software support policy" /> |
| 45 | + </span> |
| 46 | + )} |
| 47 | + Do you want to show Community Operators in the Operator Hub? |
| 48 | + </p> |
| 49 | + <Checkbox className="co-modal-ignore-warning__checkbox" onChange={this.onIgnoreChange} checked={ignoreWarnings}> |
| 50 | + Do not show this warning again |
| 51 | + </Checkbox> |
| 52 | + </div> |
| 53 | + </div> |
| 54 | + </ModalBody> |
| 55 | + <ModalSubmitFooter submitText={submitButtonContent} inProgress={false} errorMessage="" cancel={this.props.close} /> |
| 56 | + </form>; |
67 | 57 | } |
68 | 58 | } |
69 | 59 |
|
70 | | -export type MarketplaceCommunityProviderModalProps = { |
71 | | - show: boolean; |
72 | | - close: (show: boolean, ignoreWarnings: boolean) => void; |
| 60 | +export type OperatorHubCommunityProviderModalProps = { |
| 61 | + showCommunityOperators: (ignoreWarnings: boolean) => void; |
| 62 | + close: () => void; |
73 | 63 | }; |
74 | 64 |
|
75 | | -export type MarketplaceCommunityProviderModalState = { |
| 65 | +export type OperatorHubCommunityProviderModalState = { |
76 | 66 | ignoreWarnings: boolean; |
77 | 67 | }; |
| 68 | + |
| 69 | +export const communityOperatorWarningModal = createModalLauncher(OperatorHubCommunityProviderModal); |
0 commit comments