-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2188 from devtron-labs/fix/kubecon-ephemeral-fix
fix: Ephemeral delete icon missing in the dropdown
- Loading branch information
Showing
9 changed files
with
176 additions
and
245 deletions.
There are no files selected for viewing
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
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
75 changes: 75 additions & 0 deletions
75
src/components/v2/appDetails/k8Resource/nodeDetail/DeleteEphemeralButton.tsx
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,75 @@ | ||
import { ToastManager, ToastVariantType, showError, IndexStore } from '@devtron-labs/devtron-fe-common-lib' | ||
import { ReactComponent as Close } from '@Icons/ic-cross.svg' | ||
import { useParams } from 'react-router-dom' | ||
import { deleteEphemeralUrl } from './nodeDetail.api' | ||
import { DeleteEphemeralButtonType, ParamsType, ResponsePayload } from './nodeDetail.type' | ||
import '../k8resources.scss' | ||
|
||
export const DeleteEphemeralButton = ({ | ||
containerName, | ||
isResourceBrowserView, | ||
selectedNamespace, | ||
selectedClusterId, | ||
selectedPodName, | ||
switchSelectedContainer, | ||
setContainers, | ||
containers, | ||
isExternal, | ||
}: DeleteEphemeralButtonType) => { | ||
const params = useParams<ParamsType>() | ||
const { clusterId, environmentId, namespace, appName, appId, appType, fluxTemplateType } = | ||
IndexStore.getAppDetails() | ||
|
||
const getPayload = () => { | ||
const payload: ResponsePayload = { | ||
namespace: selectedNamespace, | ||
clusterId: selectedClusterId, | ||
podName: selectedPodName, | ||
basicData: { | ||
containerName, | ||
}, | ||
} | ||
return payload | ||
} | ||
|
||
const deleteEphemeralContainer = async () => { | ||
try { | ||
const { result } = await deleteEphemeralUrl({ | ||
requestData: getPayload(), | ||
clusterId, | ||
environmentId, | ||
namespace, | ||
appName, | ||
appId, | ||
appType, | ||
fluxTemplateType, | ||
isResourceBrowserView, | ||
params, | ||
}) | ||
|
||
const updatedContainers = containers.filter((con) => con.name !== result) || [] | ||
switchSelectedContainer(updatedContainers[0].name || '') | ||
setContainers(updatedContainers) | ||
ToastManager.showToast({ | ||
variant: ToastVariantType.success, | ||
description: 'Deleted successfully', | ||
}) | ||
} catch (error) { | ||
showError(error) | ||
} | ||
} | ||
|
||
return ( | ||
// Not using button component from devtron-fe-common-lib due to icon size visibility issue | ||
<button | ||
onClick={deleteEphemeralContainer} | ||
type="button" | ||
aria-label="delete-button" | ||
className="ephemeral-delete-button dc__unset-button-styles" | ||
disabled={!!isExternal} | ||
data-testid="ephemeral-delete-button" | ||
> | ||
<Close className="icon-dim-16 dc__hover-color-r500--fill" /> | ||
</button> | ||
) | ||
} |
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
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
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
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
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
Oops, something went wrong.