diff --git a/src/components/LogViewer/index.tsx b/src/components/LogViewer/index.tsx index 8d507b4cd..e22715c38 100644 --- a/src/components/LogViewer/index.tsx +++ b/src/components/LogViewer/index.tsx @@ -351,7 +351,7 @@ export function SearchPopover(props: SearchPopoverProps) { }); } catch (e) { // Catch invalid regular expression error - console.log('Error searching logs: ', e); + // console.log('Error searching logs: ', e); searchAddonRef.current?.findNext(''); } diff --git a/src/k8s/groups/EDP/Codemie/index.ts b/src/k8s/groups/EDP/Codemie/index.ts index 793241e9b..ec3588be4 100644 --- a/src/k8s/groups/EDP/Codemie/index.ts +++ b/src/k8s/groups/EDP/Codemie/index.ts @@ -8,7 +8,9 @@ const { version, } = CodemieKubeObjectConfig; -export class CodemieKubeObject extends K8s.cluster.makeKubeObject(singularForm) { +export class CodemieKubeObject extends K8s.cluster.makeKubeObject( + singularForm +) { static apiEndpoint = ApiProxy.apiFactoryWithNamespace(group, version, pluralForm); static get className(): string { diff --git a/src/k8s/groups/EDP/CodemieProject/index.ts b/src/k8s/groups/EDP/CodemieProject/index.ts index 0342efa3d..63b9201c7 100644 --- a/src/k8s/groups/EDP/CodemieProject/index.ts +++ b/src/k8s/groups/EDP/CodemieProject/index.ts @@ -8,7 +8,9 @@ const { version, } = CodemieProjectKubeObjectConfig; -export class CodemieProjectKubeObject extends K8s.cluster.makeKubeObject(singularForm) { +export class CodemieProjectKubeObject extends K8s.cluster.makeKubeObject( + singularForm +) { static apiEndpoint = ApiProxy.apiFactoryWithNamespace(group, version, pluralForm); static get className(): string { diff --git a/src/pages/stage-details/components/Applications/hooks/useConfigurationHandlers.ts b/src/pages/stage-details/components/Applications/hooks/useConfigurationHandlers.ts index 683c1c778..2892c86fa 100644 --- a/src/pages/stage-details/components/Applications/hooks/useConfigurationHandlers.ts +++ b/src/pages/stage-details/components/Applications/hooks/useConfigurationHandlers.ts @@ -1,7 +1,6 @@ import React from 'react'; import { FieldValues, useFormContext } from 'react-hook-form'; import { editResource } from '../../../../../k8s/common/editResource'; -import { ApplicationKubeObjectInterface } from '../../../../../k8s/groups/ArgoCD/Application/types'; import { useCreateCleanPipelineRun } from '../../../../../k8s/groups/Tekton/PipelineRun/hooks/useCreateCleanPipelineRun'; import { useCreateDeployPipelineRun } from '../../../../../k8s/groups/Tekton/PipelineRun/hooks/useCreateDeployPipelineRun'; import { @@ -98,18 +97,14 @@ export const useConfigurationHandlers = ({ setSelected, enrichedApplicationsByApplicationName, enrichedApplicationsWithArgoApplications, - deleteArgoApplication, + setDeleteDialogOpen, }: { values: FieldValues; selected: string[]; setSelected: React.Dispatch>; enrichedApplicationsByApplicationName: Map; enrichedApplicationsWithArgoApplications: EnrichedApplicationWithArgoApplication[]; - deleteArgoApplication: ({ - argoApplication, - }: { - argoApplication: ApplicationKubeObjectInterface; - }) => Promise; + setDeleteDialogOpen?: React.Dispatch>; }) => { const { CDPipeline } = useDataContext(); const { @@ -348,27 +343,8 @@ export const useConfigurationHandlers = ({ }, [handleClean, setDialog]); const handleClickUninstall = React.useCallback(async () => { - for (const enrichedApplication of enrichedApplicationsWithArgoApplications) { - const appName = enrichedApplication.application.metadata.name; - - if (!selected.includes(appName)) { - continue; - } - - const argoApplication = enrichedApplicationsByApplicationName.get(appName)?.argoApplication; - - await deleteArgoApplication({ - argoApplication, - }); - } - setSelected([]); - }, [ - deleteArgoApplication, - enrichedApplicationsByApplicationName, - enrichedApplicationsWithArgoApplications, - selected, - setSelected, - ]); + setDeleteDialogOpen(true); + }, [setDeleteDialogOpen]); return { handleClickDeploy, diff --git a/src/pages/stage-details/components/Applications/index.tsx b/src/pages/stage-details/components/Applications/index.tsx index d12ca8c2c..9bf6361b8 100644 --- a/src/pages/stage-details/components/Applications/index.tsx +++ b/src/pages/stage-details/components/Applications/index.tsx @@ -12,6 +12,7 @@ import { useCreateArgoApplication } from '../../../../k8s/groups/ArgoCD/Applicat import { APPLICATIONS_TABLE_MODE } from '../../constants'; import { usePermissionsContext } from '../../providers/Permissions/hooks'; import { EnrichedApplicationWithArgoApplication } from '../../types'; +import { ApplicationsMultiDeletion } from '../ApplicationsMultiDeletion'; import { useButtonsEnabledMap } from './hooks/useButtonsEnabled'; import { useColumns } from './hooks/useColumns'; import { useConfigurationHandlers } from './hooks/useConfigurationHandlers'; @@ -25,6 +26,10 @@ export const Applications = ({ }: ApplicationsProps) => { const permissions = usePermissionsContext(); + const allArgoApplications = enrichedApplicationsWithArgoApplications?.map( + ({ argoApplication }) => argoApplication + ); + const enrichedApplicationsByApplicationName = React.useMemo(() => { return ( enrichedApplicationsWithArgoApplications && @@ -46,7 +51,9 @@ export const Applications = ({ ); const [selected, setSelected] = React.useState([]); + const [mode, setMode] = React.useState(APPLICATIONS_TABLE_MODE.PREVIEW); + const [deleteDialogOpen, setDeleteDialogOpen] = React.useState(false); const toggleMode = () => mode === APPLICATIONS_TABLE_MODE.PREVIEW @@ -74,8 +81,8 @@ export const Applications = ({ setSelected, enrichedApplicationsByApplicationName, enrichedApplicationsWithArgoApplications, - deleteArgoApplication, values, + setDeleteDialogOpen, }); const buttonsEnabledMap = useButtonsEnabledMap({ @@ -239,6 +246,17 @@ export const Applications = ({ } > {..._TableProps} /> + setDeleteDialogOpen(false)} + onDelete={() => { + setSelected([]); + setDeleteDialogOpen(false); + }} + deleteArgoApplication={deleteArgoApplication} + /> ); }; diff --git a/src/pages/stage-details/components/ApplicationsMultiDeletion/index.tsx b/src/pages/stage-details/components/ApplicationsMultiDeletion/index.tsx new file mode 100644 index 000000000..5b8bdc448 --- /dev/null +++ b/src/pages/stage-details/components/ApplicationsMultiDeletion/index.tsx @@ -0,0 +1,95 @@ +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + Table, + TableBody, + TableCell, + TableHead, + TableRow, + TextField, +} from '@mui/material'; +import React from 'react'; +import { APPLICATION_LABEL_SELECTOR_APP_NAME } from '../../../../k8s/groups/ArgoCD/Application/labels'; +import { ApplicationMultiDeletionProps } from './types'; + +const CONFIRM_TEXT_VALUE = 'confirm'; + +export const ApplicationsMultiDeletion = ({ + applications, + open, + handleClose, + selected, + onDelete, + deleteArgoApplication, +}: ApplicationMultiDeletionProps) => { + const [value, setValue] = React.useState(''); + + const deletionDisabled = value !== CONFIRM_TEXT_VALUE; + + const selectedApplications = React.useMemo( + () => + applications?.filter((application) => + selected.includes(application?.metadata?.labels?.[APPLICATION_LABEL_SELECTOR_APP_NAME]) + ), + [applications, selected] + ); + + const handleDelete = React.useCallback(() => { + if (deletionDisabled || !selectedApplications || !selectedApplications.length) { + return; + } + + selectedApplications.forEach((application) => { + deleteArgoApplication({ argoApplication: application }); + }); + + setValue(''); + + if (onDelete) { + onDelete(); + } + }, [deleteArgoApplication, deletionDisabled, onDelete, selectedApplications]); + + return ( + + Are you sure you want to delete the selected applications? + + t.typography.pxToRem(20) }}> + + + Application name + ArgoCD Application name + + + + {selectedApplications && + selectedApplications?.map((application, index) => ( + + + {application?.metadata?.labels?.[APPLICATION_LABEL_SELECTOR_APP_NAME]} + + {application?.metadata.name} + + ))} + +
+ setValue(e.target.value)} + variant="outlined" + fullWidth + /> +
+ + + + +
+ ); +}; diff --git a/src/pages/stage-details/components/ApplicationsMultiDeletion/types.ts b/src/pages/stage-details/components/ApplicationsMultiDeletion/types.ts new file mode 100644 index 000000000..4961cbd38 --- /dev/null +++ b/src/pages/stage-details/components/ApplicationsMultiDeletion/types.ts @@ -0,0 +1,10 @@ +import { ApplicationKubeObjectInterface } from '../../../../k8s/groups/ArgoCD/Application/types'; + +export interface ApplicationMultiDeletionProps { + applications: ApplicationKubeObjectInterface[]; + selected: string[]; + open: boolean; + handleClose: () => void; + onDelete: () => void; + deleteArgoApplication: ({ argoApplication }) => Promise; +} diff --git a/src/widgets/AIChat/components/Chat/index.tsx b/src/widgets/AIChat/components/Chat/index.tsx index f9369df5a..174618960 100644 --- a/src/widgets/AIChat/components/Chat/index.tsx +++ b/src/widgets/AIChat/components/Chat/index.tsx @@ -219,7 +219,7 @@ export const Chat = ({ setIsRequestLoading(true); }, onFinish: (data) => { - console.log('finish', data); + // console.log('finish', data); }, onError: (error) => console.log('error', error), }); diff --git a/src/widgets/AIChat/hooks/useStreaming.ts b/src/widgets/AIChat/hooks/useStreaming.ts index 3c0959efd..8eb7e8ed7 100644 --- a/src/widgets/AIChat/hooks/useStreaming.ts +++ b/src/widgets/AIChat/hooks/useStreaming.ts @@ -92,7 +92,7 @@ export const useStreaming = ({ } catch (error) { // Request was aborted by user // if (error.name === ABORT_ERROR) return handleAbort(chat, reader); - console.log(error.name); + // console.log(error.name); throw error; } } diff --git a/src/widgets/ManageCodeMie/components/CodemieProjectSettings/fields/index.ts b/src/widgets/ManageCodeMie/components/CodemieProjectSettings/fields/index.ts index c829faf6f..e7a5e334d 100644 --- a/src/widgets/ManageCodeMie/components/CodemieProjectSettings/fields/index.ts +++ b/src/widgets/ManageCodeMie/components/CodemieProjectSettings/fields/index.ts @@ -2,4 +2,3 @@ export * from './Alias'; export * from './TokenName'; export * from './Type'; export * from './URL'; - diff --git a/src/widgets/ManageCodeMie/components/CodemieProjectSettingsSecret/fields/index.ts b/src/widgets/ManageCodeMie/components/CodemieProjectSettingsSecret/fields/index.ts index 71ee9f1ca..c467462a8 100644 --- a/src/widgets/ManageCodeMie/components/CodemieProjectSettingsSecret/fields/index.ts +++ b/src/widgets/ManageCodeMie/components/CodemieProjectSettingsSecret/fields/index.ts @@ -1,2 +1 @@ export * from './Token'; -