From 5347b8fa39b9d04b1adc740ae57b22c3a0d7bfa6 Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Sun, 29 Dec 2024 14:37:02 +0100 Subject: [PATCH] fix: remove nlp import dialog --- .../src/components/nlp/NlpImportDialog.tsx | 105 ------------------ .../components/nlp/components/NlpSample.tsx | 3 - 2 files changed, 108 deletions(-) delete mode 100644 frontend/src/components/nlp/NlpImportDialog.tsx diff --git a/frontend/src/components/nlp/NlpImportDialog.tsx b/frontend/src/components/nlp/NlpImportDialog.tsx deleted file mode 100644 index c539c580..00000000 --- a/frontend/src/components/nlp/NlpImportDialog.tsx +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright © 2024 Hexastack. All rights reserved. - * - * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: - * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. - * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). - */ - -import CloseIcon from "@mui/icons-material/Close"; -import { Button, Dialog, DialogActions, DialogContent } from "@mui/material"; -import { FC, useState } from "react"; -import { useMutation, useQueryClient } from "react-query"; - -import AttachmentInput from "@/app-components/attachment/AttachmentInput"; -import { DialogTitle } from "@/app-components/dialogs/DialogTitle"; -import { ContentContainer } from "@/app-components/dialogs/layouts/ContentContainer"; -import { ContentItem } from "@/app-components/dialogs/layouts/ContentItem"; -import { isSameEntity } from "@/hooks/crud/helpers"; -import { useApiClient } from "@/hooks/useApiClient"; -import { DialogControlProps } from "@/hooks/useDialog"; -import { useToast } from "@/hooks/useToast"; -import { useTranslate } from "@/hooks/useTranslate"; -import { EntityType, QueryType } from "@/services/types"; - -export type NlpImportDialogProps = DialogControlProps; - -export const NlpImportDialog: FC = ({ - open, - closeDialog, - ...rest -}) => { - const [attachmentId, setAttachmentId] = useState(null); - const { t } = useTranslate(); - const queryClient = useQueryClient(); - const { toast } = useToast(); - const { apiClient } = useApiClient(); - const { mutateAsync: importNlpSamples, isLoading: isImporting } = useMutation( - { - mutationFn: async (attachmentId: string | null) => { - attachmentId && (await apiClient.importNlpSamples(attachmentId)); - }, - onSuccess: () => { - queryClient.removeQueries({ - predicate: ({ queryKey }) => { - const [qType, qEntity] = queryKey; - - return ( - ((qType === QueryType.count || qType === QueryType.collection) && - isSameEntity(qEntity, EntityType.NLP_SAMPLE)) || - isSameEntity(qEntity, EntityType.NLP_SAMPLE_ENTITY) || - isSameEntity(qEntity, EntityType.NLP_ENTITY) || - isSameEntity(qEntity, EntityType.NLP_VALUE) - ); - }, - }); - handleCloseDialog(); - toast.success(t("message.success_save")); - }, - onError() { - toast.error(t("message.internal_server_error")); - }, - }, - ); - const handleCloseDialog = () => { - closeDialog(); - setAttachmentId(null); - }; - - return ( - - {t("title.import")} - - - - { - setAttachmentId(id); - }} - label="" - value={attachmentId} - /> - - - - - - - - - ); -}; diff --git a/frontend/src/components/nlp/components/NlpSample.tsx b/frontend/src/components/nlp/components/NlpSample.tsx index 201ef022..b29adcc8 100644 --- a/frontend/src/components/nlp/components/NlpSample.tsx +++ b/frontend/src/components/nlp/components/NlpSample.tsx @@ -62,7 +62,6 @@ import { PermissionAction } from "@/types/permission.types"; import { getDateTimeFormatter } from "@/utils/date"; import { buildURL } from "@/utils/URL"; -import { NlpImportDialog } from "../NlpImportDialog"; import { NlpSampleDialog } from "../NlpSampleDialog"; const NLP_SAMPLE_TYPE_COLORS = { @@ -150,7 +149,6 @@ export default function NlpSample() { ); const deleteDialogCtl = useDialog(false); const editDialogCtl = useDialog(false); - const importDialogCtl = useDialog(false); const actionColumns = getActionsColumn( [ { @@ -315,7 +313,6 @@ export default function NlpSample() { } }} /> -