Skip to content

Commit 1489612

Browse files
justinorringerflorkbr
authored andcommitted
fix: using new modal component
1 parent 8298393 commit 1489612

File tree

1 file changed

+57
-53
lines changed

1 file changed

+57
-53
lines changed

packages/components/src/TagModal/TagModal.tsx

+57-53
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component } from 'react';
22
import './tagModal.scss';
33
import { Button } from '@patternfly/react-core/dist/dynamic/components/Button';
4-
import { Modal } from '@patternfly/react-core/dist/dynamic/components/Modal';
4+
import { Modal, ModalBody, ModalFooter, ModalHeader } from '@patternfly/react-core/dist/dynamic/components/Modal';
55
import { Tab } from '@patternfly/react-core/dist/dynamic/components/Tabs';
66
import { TabTitleText } from '@patternfly/react-core/dist/dynamic/components/Tabs';
77
import { Tabs } from '@patternfly/react-core/dist/dynamic/components/Tabs';
@@ -117,61 +117,65 @@ class TagModal extends Component<
117117
{...props}
118118
className={classNames('ins-c-tag-modal', className)}
119119
isOpen={isOpen}
120-
title={title || `Tags for ${systemName}`}
121120
onClose={() => toggleModal(undefined, false)}
122121
variant="medium"
123-
{...(onApply && {
124-
actions: [
125-
<Button
126-
key="confirm"
127-
variant="primary"
128-
isDisabled={
129-
isTabbed ? Object.values(selected || {}).every((values) => !values || values?.length === 0) : !selected || selected?.length === 0
130-
}
131-
onClick={(e) => {
132-
onApply();
133-
toggleModal(e, true);
134-
}}
135-
>
136-
Apply {isTabbed ? 'selected' : 'tags'}
137-
</Button>,
138-
<Button key="cancel" variant="link" onClick={(e) => toggleModal(e, false)}>
139-
Cancel
140-
</Button>,
141-
],
142-
})}
143122
>
144-
{isTabbed ? (
145-
<Tabs activeKey={this.state.activeTabKey} onSelect={this.handleTabClick}>
146-
{tabNames.map((item, key) => (
147-
<Tab key={key} eventKey={key} title={<TabTitleText>All {item}</TabTitleText>}>
148-
{this.renderTable(
149-
rows?.[key] as IRow[],
150-
columns?.[key] as ICell[],
151-
(pagination as TableWithFilterPagination[])?.[key],
152-
(loaded as boolean[])?.[key],
153-
(filters as ConditionalFilterItem[][])?.[key],
154-
(selected as IRow[][])?.[key],
155-
(onSelect as unknown as ((selected?: IRow[]) => void)[])?.[key],
156-
(onUpdateData as unknown as ((pagination: TableWithFilterPagination) => number)[])?.[key],
157-
(bulkSelect as BulkSelectProps[])?.[key]
158-
)}
159-
</Tab>
160-
))}
161-
</Tabs>
162-
) : (
163-
this.renderTable(
164-
rows,
165-
columns as ICell[],
166-
pagination as TableWithFilterPagination,
167-
loaded as boolean,
168-
filters as ConditionalFilterItem[],
169-
selected as IRow[],
170-
onSelect as TableWithFilterProps['onSelect'],
171-
onUpdateData as TableWithFilterProps['onUpdateData'],
172-
bulkSelect as BulkSelectProps
173-
)
174-
)}
123+
<ModalHeader title={title || `Tags for ${systemName}`} />
124+
<ModalBody>
125+
{isTabbed ? (
126+
<Tabs activeKey={this.state.activeTabKey} onSelect={this.handleTabClick}>
127+
{tabNames.map((item, key) => (
128+
<Tab key={key} eventKey={key} title={<TabTitleText>All {item}</TabTitleText>}>
129+
{this.renderTable(
130+
rows?.[key] as IRow[],
131+
columns?.[key] as ICell[],
132+
(pagination as TableWithFilterPagination[])?.[key],
133+
(loaded as boolean[])?.[key],
134+
(filters as ConditionalFilterItem[][])?.[key],
135+
(selected as IRow[][])?.[key],
136+
(onSelect as unknown as ((selected?: IRow[]) => void)[])?.[key],
137+
(onUpdateData as unknown as ((pagination: TableWithFilterPagination) => number)[])?.[key],
138+
(bulkSelect as BulkSelectProps[])?.[key]
139+
)}
140+
</Tab>
141+
))}
142+
</Tabs>
143+
) : (
144+
this.renderTable(
145+
rows,
146+
columns as ICell[],
147+
pagination as TableWithFilterPagination,
148+
loaded as boolean,
149+
filters as ConditionalFilterItem[],
150+
selected as IRow[],
151+
onSelect as TableWithFilterProps['onSelect'],
152+
onUpdateData as TableWithFilterProps['onUpdateData'],
153+
bulkSelect as BulkSelectProps
154+
)
155+
)}
156+
</ModalBody>
157+
<ModalFooter>
158+
{onApply && (
159+
<>
160+
<Button
161+
key="confirm"
162+
variant="primary"
163+
isDisabled={
164+
isTabbed ? Object.values(selected || {}).every((values) => !values || values?.length === 0) : !selected || selected?.length === 0
165+
}
166+
onClick={(e) => {
167+
onApply();
168+
toggleModal(e, true);
169+
}}
170+
>
171+
Apply {isTabbed ? 'selected' : 'tags'}
172+
</Button>
173+
<Button key="cancel" variant="link" onClick={(e) => toggleModal(e, false)}>
174+
Cancel
175+
</Button>
176+
</>
177+
)}
178+
</ModalFooter>
175179
</Modal>
176180
);
177181
}

0 commit comments

Comments
 (0)