-
Notifications
You must be signed in to change notification settings - Fork 7
feat: resource conflict #976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e50452b
feat: add ResourceConflictDeployDialog for handling resource ownershi…
AbhishekA1509 c9f566f
feat: implement ResourceConflictDetailsModal and ConflictedResourcesT…
AbhishekA1509 7f658c5
feat: enhance resource conflict handling with redeploy functionality …
AbhishekA1509 60936ef
feat: add resource conflict management components and enhance related…
AbhishekA1509 2236a28
feat: enhance ConflictedResourcesTable styling and improve resource c…
AbhishekA1509 13407fd
fix: update alignment of content in ResourceConflictDetailsModal
AbhishekA1509 ddf9e21
fix: disable deploy button when no resource conflict details are avai…
AbhishekA1509 b907e3f
fix: rename wfrId to wfrIdForDeploymentWithSpecificTrigger in redeplo…
AbhishekA1509 2bb1aed
fix: remove toast notifications from redeploy functions and update ar…
AbhishekA1509 d8f7911
fix: update resource conflict routes and payload structure for redepl…
AbhishekA1509 c4c7515
fix: update version to 1.21.0-beta-4 in package.json and package-lock…
AbhishekA1509 a45a097
fix: integrate useMainContext to conditionally display resource confl…
AbhishekA1509 87b59cc
fix: update version to 1.21.1 in package.json and package-lock.json
AbhishekA1509 4c73a76
fix: streamline loading state handling in ResourceConflictDeployDialo…
AbhishekA1509 0f1d57f
fix: update button styles to warning in TriggerDetails component
AbhishekA1509 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
src/Shared/Components/CICDHistory/ConflictedResourcesTable.scss
This file contains hidden or 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,9 @@ | ||
| [id*="table__resource-conflict-details"] { | ||
| .generic-table__row { | ||
| .generic-table__cell { | ||
| display: flex; | ||
| align-items: center; | ||
| padding: 10px 0; | ||
| } | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
src/Shared/Components/CICDHistory/ConflictedResourcesTable.tsx
This file contains hidden or 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,50 @@ | ||
| import { useMemo } from 'react' | ||
|
|
||
| import { FiltersTypeEnum, PaginationEnum, Table, TableViewWrapperProps } from '../Table' | ||
| import { RowsType } from '../Table/types' | ||
| import { CONFLICTED_RESOURCES_COLUMNS } from './constants' | ||
| import { ConflictedResourcesTableProps, ResourceConflictItemType } from './types' | ||
|
|
||
| import './ConflictedResourcesTable.scss' | ||
|
|
||
| const Wrapper = ({ children }: TableViewWrapperProps<unknown, FiltersTypeEnum.STATE>) => ( | ||
| <div className="dc__overflow-hidden flexbox-col flex-grow-1">{children}</div> | ||
| ) | ||
| const filter = () => true | ||
|
|
||
| const ConflictedResourcesTable = ({ resourceConflictDetails }: ConflictedResourcesTableProps) => { | ||
| const rows: RowsType<ResourceConflictItemType> = useMemo( | ||
| () => | ||
| (resourceConflictDetails || []).map<RowsType<ResourceConflictItemType>[number]>((resource) => ({ | ||
| data: resource, | ||
| id: resource.id, | ||
| })), | ||
| [resourceConflictDetails], | ||
| ) | ||
|
|
||
| return ( | ||
| <Table<ResourceConflictItemType, FiltersTypeEnum.STATE> | ||
| id="table__resource-conflict-details" | ||
| columns={CONFLICTED_RESOURCES_COLUMNS} | ||
| rows={rows} | ||
| emptyStateConfig={{ | ||
| noRowsConfig: { | ||
| title: 'No resource found', | ||
| }, | ||
| noRowsForFilterConfig: { | ||
| title: 'No results', | ||
| subTitle: "We couldn't find any matching results", | ||
| }, | ||
| }} | ||
| paginationVariant={PaginationEnum.NOT_PAGINATED} | ||
| additionalFilterProps={{ | ||
| initialSortKey: 'name' satisfies keyof ResourceConflictItemType, | ||
| }} | ||
| filtersVariant={FiltersTypeEnum.STATE} | ||
| ViewWrapper={Wrapper} | ||
| filter={filter} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| export default ConflictedResourcesTable | ||
64 changes: 64 additions & 0 deletions
64
src/Shared/Components/CICDHistory/ResourceConflictDeployDialog.tsx
This file contains hidden or 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,64 @@ | ||
| import { useState } from 'react' | ||
| import { useHistory, useParams } from 'react-router-dom' | ||
|
|
||
| import { URLS } from '@Common/Constants' | ||
| import { showError } from '@Common/Helper' | ||
| import { ToastManager, ToastVariantType } from '@Shared/Services' | ||
|
|
||
| import { ButtonStyleType } from '../Button' | ||
| import { ConfirmationModal, ConfirmationModalVariantType } from '../ConfirmationModal' | ||
| import { Icon } from '../Icon' | ||
| import { resourceConflictRedeploy } from './service' | ||
| import { ResourceConflictDeployDialogProps, ResourceConflictDeployDialogURLParamsType } from './types' | ||
|
|
||
| const ResourceConflictDeployDialog = ({ appName, environmentName, handleClose }: ResourceConflictDeployDialogProps) => { | ||
| const history = useHistory() | ||
| const { appId, envId, pipelineId, triggerId } = useParams<ResourceConflictDeployDialogURLParamsType>() | ||
| const [isLoading, setIsLoading] = useState(false) | ||
|
|
||
| const handleDeploy = async () => { | ||
| setIsLoading(true) | ||
| try { | ||
| await resourceConflictRedeploy({ | ||
| pipelineId, | ||
| triggerId, | ||
| appId, | ||
| }) | ||
| ToastManager.showToast({ | ||
| variant: ToastVariantType.success, | ||
| title: 'Redeploy initiated', | ||
| description: `Redeployment for application '${appName}' in environment '${environmentName}' has been initiated successfully.`, | ||
| }) | ||
| handleClose() | ||
| history.push(`${URLS.APP}/${appId}/details/${envId}`) | ||
| } catch (error) { | ||
| showError(error) | ||
| } finally { | ||
| setIsLoading(false) | ||
| } | ||
| } | ||
|
AbhishekA1509 marked this conversation as resolved.
|
||
|
|
||
| return ( | ||
| <ConfirmationModal | ||
| variant={ConfirmationModalVariantType.custom} | ||
| Icon={<Icon name="ic-warning" color={null} size={48} />} | ||
|
AbhishekA1509 marked this conversation as resolved.
|
||
| title="Take resource ownership and redeploy" | ||
| subtitle={`Ensure the resources belong to the '${appName}' application and the '${environmentName}' environment to avoid destructive changes.`} | ||
| handleClose={handleClose} | ||
| buttonConfig={{ | ||
| secondaryButtonConfig: { | ||
| text: 'Cancel', | ||
| onClick: handleClose, | ||
| }, | ||
| primaryButtonConfig: { | ||
| isLoading, | ||
| text: 'Re-deploy', | ||
| onClick: handleDeploy, | ||
| style: ButtonStyleType.warning, | ||
| }, | ||
| }} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| export default ResourceConflictDeployDialog | ||
136 changes: 136 additions & 0 deletions
136
src/Shared/Components/CICDHistory/ResourceConflictDetailsModal.tsx
This file contains hidden or 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,136 @@ | ||
| import { useState } from 'react' | ||
| import { useHistory, useParams } from 'react-router-dom' | ||
|
|
||
| import { useQuery } from '@Common/API' | ||
| import { URLS } from '@Common/Constants' | ||
| import { Drawer } from '@Common/Drawer' | ||
| import { showError, stopPropagation } from '@Common/Helper' | ||
| import { ComponentSizeType } from '@Shared/constants' | ||
| import { ToastManager, ToastVariantType } from '@Shared/Services' | ||
|
|
||
| import { APIResponseHandler } from '../APIResponseHandler' | ||
| import { Button, ButtonStyleType, ButtonVariantType } from '../Button' | ||
| import { Icon } from '../Icon' | ||
| import ConflictedResourcesTable from './ConflictedResourcesTable' | ||
| import { getResourceConflictDetails, resourceConflictRedeploy } from './service' | ||
| import { | ||
| ResourceConflictDeployDialogURLParamsType, | ||
| ResourceConflictDetailsModalProps, | ||
| ResourceConflictItemType, | ||
| } from './types' | ||
|
|
||
| const ResourceConflictDetailsModal = ({ appName, environmentName, handleClose }: ResourceConflictDetailsModalProps) => { | ||
| const { appId, envId, pipelineId, triggerId } = useParams<ResourceConflictDeployDialogURLParamsType>() | ||
| const history = useHistory() | ||
|
|
||
| const { | ||
| isFetching: isLoadingResourceData, | ||
| data: resourceConflictDetails, | ||
| refetch: refetchResourceConflictDetails, | ||
| error: resourceConflictDetailsError, | ||
| } = useQuery<ResourceConflictItemType[], ResourceConflictItemType[], [string, string, string, string], false>({ | ||
| queryKey: ['getResourceConflictDetails', pipelineId, triggerId, appId], | ||
| queryFn: ({ signal }) => getResourceConflictDetails({ pipelineId, triggerId, appId, signal }), | ||
| }) | ||
|
|
||
| const [isDeploying, setIsDeploying] = useState(false) | ||
|
|
||
| const handleDeploy = async () => { | ||
| setIsDeploying(true) | ||
| try { | ||
| await resourceConflictRedeploy({ | ||
| pipelineId, | ||
| triggerId, | ||
| appId, | ||
| }) | ||
| ToastManager.showToast({ | ||
| variant: ToastVariantType.success, | ||
| title: 'Redeploy initiated', | ||
| description: `Redeployment for application '${appName}' in environment '${environmentName}' has been initiated successfully.`, | ||
| }) | ||
| handleClose() | ||
| history.push(`${URLS.APP}/${appId}/details/${envId}`) | ||
| } catch (error) { | ||
| showError(error) | ||
| } finally { | ||
| setIsDeploying(false) | ||
| } | ||
| } | ||
|
AbhishekA1509 marked this conversation as resolved.
|
||
|
|
||
| return ( | ||
| <Drawer width="800px" onClose={handleClose} onEscape={handleClose} position="right"> | ||
| <div | ||
| className="flexbox-col dc__content-space h-100 bg__modal--primary shadow__modal dc__overflow-auto" | ||
| onClick={stopPropagation} | ||
| > | ||
| <div className="flexbox-col dc__overflow-auto flex-grow-1"> | ||
| <div className="px-20 py-12 flexbox dc__content-space dc__align-items-center border__primary--bottom"> | ||
| <h2 className="m-0 fs-16 fw-6 lh-24 cn-9">Resources with conflict</h2> | ||
|
|
||
| <Button | ||
| dataTestId="header-close-button" | ||
| ariaLabel="Close" | ||
| showAriaLabelInTippy={false} | ||
| onClick={handleClose} | ||
| variant={ButtonVariantType.borderLess} | ||
| style={ButtonStyleType.negativeGrey} | ||
| icon={<Icon name="ic-close-large" color={null} />} | ||
| size={ComponentSizeType.xs} | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="flexbox-col flex-grow-1 dc__overflow-auto w-100"> | ||
| <APIResponseHandler | ||
| isLoading={isLoadingResourceData} | ||
| progressingProps={{ | ||
| pageLoader: true, | ||
| }} | ||
| error={resourceConflictDetailsError} | ||
| errorScreenManagerProps={{ | ||
| code: resourceConflictDetailsError?.code, | ||
| reload: refetchResourceConflictDetails, | ||
| on404Redirect: handleClose, | ||
| }} | ||
| > | ||
| <ConflictedResourcesTable resourceConflictDetails={resourceConflictDetails} /> | ||
| </APIResponseHandler> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="flexbox dc__align-items-center dc__content-space dc__gap-20 py-16 px-20 border__primary--top dc__no-shrink"> | ||
| <div className="flexbox dc__gap-8"> | ||
| <Icon name="ic-warning" size={20} color={null} /> | ||
|
AbhishekA1509 marked this conversation as resolved.
|
||
| <div className="flexbox-col"> | ||
| <span className="cn-9 fs-13 fw-6 lh-1-5">Take resource ownership and redeploy</span> | ||
| <span> | ||
| Ensure all resources strictly belong to the {appName} application and the | ||
| {environmentName} | ||
| environment. Any resource outside this Helm release may cause incorrect associations and | ||
| potentially destructive changes. | ||
| </span> | ||
| </div> | ||
| </div> | ||
| <div className="dc__no-shrink"> | ||
| <Button | ||
| dataTestId="footer-redeploy-button" | ||
| variant={ButtonVariantType.primary} | ||
| style={ButtonStyleType.warning} | ||
| size={ComponentSizeType.large} | ||
| text="Re-deploy" | ||
| startIcon={<Icon name="ic-rocket-launch" color={null} />} | ||
| isLoading={isDeploying} | ||
| disabled={ | ||
| !!resourceConflictDetailsError || | ||
| isLoadingResourceData || | ||
| resourceConflictDetails?.length === 0 | ||
| } | ||
| onClick={handleDeploy} | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </Drawer> | ||
| ) | ||
| } | ||
|
|
||
| export default ResourceConflictDetailsModal | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.