-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #36576 - Add Activation Key details top bar
- Loading branch information
Trevor Allison
committed
Jul 7, 2023
1 parent
2fdde82
commit 2f723ae
Showing
7 changed files
with
494 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
webpack/scenes/ActivationKeys/Details/ActivationKeyActions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { translate as __ } from 'foremanReact/common/I18n'; | ||
import { APIActions, API_OPERATIONS, put, get } from 'foremanReact/redux/API'; | ||
import { errorToast } from '../../Tasks/helpers'; | ||
import api from '../../../services/api'; | ||
import { ACTIVATION_KEY } from './ActivationKeyConstants'; | ||
|
||
export const getActivationKey = akId => get({ | ||
type: API_OPERATIONS.GET, | ||
key: `${ACTIVATION_KEY}_${akId}`, | ||
url: api.getApiUrl(`/activation_keys/${akId}`), | ||
}); | ||
|
||
export const putActivationKey = (akId, params) => put({ | ||
type: API_OPERATIONS.PUT, | ||
key: `${ACTIVATION_KEY}_${akId}`, | ||
url: api.getApiUrl(`/activation_keys/${akId}`), | ||
successToast: () => __('Activation key details updated'), | ||
errorToast, | ||
params, | ||
}); | ||
|
||
export const deleteActivationKey = akId => APIActions.delete({ | ||
type: API_OPERATIONS.DELETE, | ||
key: `${ACTIVATION_KEY}_${akId}`, | ||
url: api.getApiUrl(`/activation_keys/${akId}`), | ||
successToast: () => __('Activation key deleted'), | ||
errorToast, | ||
}); | ||
|
||
export default getActivationKey; |
3 changes: 3 additions & 0 deletions
3
webpack/scenes/ActivationKeys/Details/ActivationKeyConstants.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const ACTIVATION_KEY = 'ACTIVATION_KEY'; | ||
|
||
export default ACTIVATION_KEY; |
106 changes: 104 additions & 2 deletions
106
webpack/scenes/ActivationKeys/Details/ActivationKeyDetails.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
webpack/scenes/ActivationKeys/Details/ActivationKeyDetails.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.ak-details-header { | ||
margin: 0 24px 16px; | ||
padding-top: 16px; | ||
} | ||
|
||
.ak-details-description { | ||
padding-top: 16px; | ||
} | ||
|
||
.breadcrumb-bar-pf4 { | ||
margin: 0 0 16px; | ||
} | ||
|
||
.breadcrumb-display { | ||
display: block; | ||
} | ||
|
||
.breadcrumb-list { | ||
display: flex; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
} | ||
|
||
.ak-name-truncate { | ||
text-overflow: ellipsis; | ||
max-width: 100%; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
display: inline-block; | ||
margin-right: 16px | ||
} | ||
|
||
.ak-name-wrapper { | ||
display: inline-flex; | ||
max-width: 60%; | ||
margin-right: 8px; | ||
} |
61 changes: 61 additions & 0 deletions
61
webpack/scenes/ActivationKeys/Details/components/DeleteMenu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Dropdown, DropdownItem, KebabToggle, DropdownPosition } from '@patternfly/react-core'; | ||
import { noop } from 'foremanReact/common/helpers'; | ||
|
||
const DeleteMenu = ({ handleModalToggle, akId }) => { | ||
const [isOpen, setIsOpen] = React.useState(false); | ||
const onToggle = (isOpenValue) => { | ||
setIsOpen(isOpenValue); | ||
}; | ||
const onFocus = () => { | ||
const element = document.getElementById('toggle-kebab'); | ||
element.focus(); | ||
}; | ||
const onSelect = () => { | ||
setIsOpen(false); | ||
onFocus(); | ||
}; | ||
const dropdownItems = [ | ||
<DropdownItem | ||
ouiaId="delete-menu-option" | ||
key="delete" | ||
component="button" | ||
onClick={handleModalToggle} | ||
> | ||
Delete | ||
</DropdownItem>, | ||
<DropdownItem | ||
ouiaId="linkbacktooldpage" | ||
key="link" | ||
href={`../../../activation_keys/${akId}`} | ||
> | ||
Old Activation key Details Page | ||
</DropdownItem>]; | ||
return ( | ||
<React.Fragment> | ||
<Dropdown | ||
ouiaId="dekete-action" | ||
onSelect={onSelect} | ||
position={DropdownPosition.right} | ||
toggle={<KebabToggle id="toggle-kebab" onToggle={onToggle} />} | ||
isOpen={isOpen} | ||
isPlain | ||
dropdownItems={dropdownItems} | ||
/> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
DeleteMenu.propTypes = { | ||
handleModalToggle: PropTypes.func, | ||
akId: PropTypes.string, | ||
}; | ||
|
||
DeleteMenu.defaultProps = { | ||
handleModalToggle: noop, | ||
akId: '', | ||
}; | ||
|
||
export default DeleteMenu; | ||
|
65 changes: 65 additions & 0 deletions
65
webpack/scenes/ActivationKeys/Details/components/DeleteModal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React from 'react'; | ||
import { | ||
useDispatch, | ||
} from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import { noop } from 'foremanReact/common/helpers'; | ||
import { Modal, ModalVariant, Button, Icon, Title, Flex } from '@patternfly/react-core'; | ||
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon'; | ||
import { deleteActivationKey } from '../ActivationKeyActions'; | ||
|
||
const DeleteModal = ({ isModalOpen, handleModalToggle, akId }) => { | ||
const dispatch = useDispatch(); | ||
|
||
const handleDelete = () => { | ||
dispatch(deleteActivationKey(akId)); | ||
handleModalToggle(); | ||
window.location.replace('/activation_keys'); | ||
}; | ||
|
||
return ( | ||
<React.Fragment> | ||
<Modal | ||
ouiaId="ak-delete-modal" | ||
variant={ModalVariant.small} | ||
title={[ | ||
<Flex> | ||
<Icon status="warning"> | ||
<ExclamationTriangleIcon /> | ||
</Icon> | ||
<Title ouiaId="ak-delete-header" headingLevel="h5" size="2xl"> | ||
Delete activation key? | ||
</Title> | ||
</Flex>, | ||
]} | ||
isOpen={isModalOpen} | ||
onClose={handleModalToggle} | ||
actions={[ | ||
<Button ouiaId="delete-button" key="delete" variant="danger" onClick={handleDelete}> | ||
Delete | ||
</Button>, | ||
<Button ouiaId="cancel-button" key="cancel" variant="link" onClick={handleModalToggle}> | ||
Cancel | ||
</Button>, | ||
]} | ||
> | ||
Activation Key will no longer be available for use. This operation cannot be undone. | ||
</Modal> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
|
||
DeleteModal.propTypes = { | ||
isModalOpen: PropTypes.bool, | ||
handleModalToggle: PropTypes.func, | ||
akId: PropTypes.string, | ||
}; | ||
|
||
DeleteModal.defaultProps = { | ||
isModalOpen: false, | ||
handleModalToggle: noop, | ||
akId: '', | ||
}; | ||
|
||
export default DeleteModal; |
Oops, something went wrong.