Skip to content
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

feat: split nlu pages #647

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion frontend/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"visual_editor": "Visual Editor",
"nlp": "NLU",
"nlp_entities": "NLU Entities",
"nlp_dataset": "NLU Dataset",
"inbox": "Inbox",
"categories": "Flows",
"context_vars": "Context Vars",
Expand Down Expand Up @@ -164,14 +165,15 @@
"regular_blocks": "Regular Blocks",
"advanced_blocks": "Advanced blocks",
"custom_blocks": "Custom blocks",
"nlp": "NLU Samples",
"nlp_datatset": "NLU Dataset",
"nlp_train": "NLU training",
"nlp_entities": "NLU Entities",
"new_nlp_entity": "New NLU Entity",
"edit_nlp_entity": "Edit NLU Entity",
"nlp_entity_values": "NLU Values",
"new_nlp_entity_value": "New NLU Value",
"evaluation_report": "Evaluation Report",
"add_nlp_sample": "Add NLU Sample",
"edit_nlp_sample": "Edit NLU Sample",
"edit_nlp_value": "Edit NLU Value",
"context_vars": "Context Vars",
Expand Down
5 changes: 4 additions & 1 deletion frontend/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"visual_editor": "Editeur Visuel",
"nlp": "NLU",
"nlp_entities": "Entités NLU",
"nlp_dataset": "Données NLU",
"inbox": "Boîte de réception",
"categories": "Catégories",
"context_vars": "Variables contextuelles",
Expand Down Expand Up @@ -164,15 +165,17 @@
"regular_blocks": "Blocs réguliers",
"advanced_blocks": "Blocs avancés",
"custom_blocks": "Blocs spécifiques",
"nlp": "Expressions NLU",
"nlp": "Données NLU",
"nlp_train": "Apprentissage NLU",
"nlp_entities": "Entités NLU",
"nlp_dataset": "Données NLU",
"new_nlp_entity": "Nouvelle entité NLU",
"edit_nlp_entity": "Modifier l'entité NLU",
"edit_nlp_value": "Modifier la valeur NLU",
"nlp_entity_values": "Valeurs NLU",
"new_nlp_entity_value": "Nouvelle valeur NLU",
"evaluation_report": "Rapport d'évaluation",
"add_nlp_sample": "Ajouter l'expression NLU",
"edit_nlp_sample": "Modifier l'expression NLU",
"context_vars": "Variables contextuelles",
"new_context_var": "Nouvelle variable contextuelle",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 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 AddIcon from "@mui/icons-material/Add";
import DatasetLinkedIcon from "@mui/icons-material/DatasetLinked";
import DeleteIcon from "@mui/icons-material/Delete";
import { Button, Chip, Grid } from "@mui/material";
import { Button, Chip, Grid, Paper } from "@mui/material";
import { GridColDef, GridRowSelectionModel } from "@mui/x-data-grid";
import { useRouter } from "next/router";
import { useState } from "react";
Expand All @@ -29,12 +30,13 @@ import { useHasPermission } from "@/hooks/useHasPermission";
import { useSearch } from "@/hooks/useSearch";
import { useToast } from "@/hooks/useToast";
import { useTranslate } from "@/hooks/useTranslate";
import { PageHeader } from "@/layout/content/PageHeader";
import { EntityType, Format } from "@/services/types";
import { INlpEntity } from "@/types/nlp-entity.types";
import { PermissionAction } from "@/types/permission.types";
import { getDateTimeFormatter } from "@/utils/date";

import { NlpEntityDialog } from "../NlpEntityDialog";
import { NlpEntityDialog } from "./NlpEntityDialog";

const NlpEntity = () => {
const router = useRouter();
Expand Down Expand Up @@ -87,7 +89,7 @@ const NlpEntity = () => {
action: (row) =>
router.push(
{
pathname: "/nlp/nlp-entities/[id]/nlpValues",
pathname: "/nlp/entities/[id]/values",
query: { id: row.id },
},
undefined,
Expand Down Expand Up @@ -176,7 +178,7 @@ const NlpEntity = () => {
};

return (
<Grid item xs={12}>
<Grid container gap={3} flexDirection="column">
<NlpEntityDialog {...getDisplayDialogs(addDialogCtl)} />
<NlpEntityDialog {...editEntityDialogCtl} />
<DeleteDialog
Expand All @@ -191,51 +193,54 @@ const NlpEntity = () => {
}
}}
/>

<Grid
justifyContent="flex-end"
gap={1}
container
alignItems="center"
flexShrink={0}
>
<Grid item>
<FilterTextfield onChange={onSearch} />
</Grid>

{hasPermission(EntityType.NLP_ENTITY, PermissionAction.CREATE) ? (
<PageHeader title={t("title.nlp_entities")} icon={DatasetLinkedIcon}>
<Grid
justifyContent="flex-end"
gap={1}
container
alignItems="center"
flexShrink={0}
width="max-content"
>
<Grid item>
<Button
startIcon={<AddIcon />}
variant="contained"
sx={{ float: "right" }}
onClick={() => addDialogCtl.openDialog()}
>
{t("button.add")}
</Button>
<FilterTextfield onChange={onSearch} />
</Grid>
) : null}
{selectedNlpEntities.length > 0 && (
<Grid item>
<Button
startIcon={<DeleteIcon />}
variant="contained"
color="error"
onClick={() => deleteEntityDialogCtl.openDialog(undefined)}
>
{t("button.delete")}
</Button>
</Grid>
)}
</Grid>

<Grid mt={3}>
<DataGrid
columns={nlpEntityColumns}
{...nlpEntityGrid}
checkboxSelection
onRowSelectionModelChange={handleSelectionChange}
/>
{hasPermission(EntityType.NLP_ENTITY, PermissionAction.CREATE) ? (
<Grid item>
<Button
startIcon={<AddIcon />}
variant="contained"
sx={{ float: "right" }}
onClick={() => addDialogCtl.openDialog()}
>
{t("button.add")}
</Button>
</Grid>
) : null}
{selectedNlpEntities.length > 0 && (
<Grid item>
<Button
startIcon={<DeleteIcon />}
variant="contained"
color="error"
onClick={() => deleteEntityDialogCtl.openDialog(undefined)}
>
{t("button.delete")}
</Button>
</Grid>
)}
</Grid>
</PageHeader>
<Grid item xs={12}>
<Paper sx={{ padding: 2 }}>
<DataGrid
columns={nlpEntityColumns}
{...nlpEntityGrid}
checkboxSelection
onRowSelectionModelChange={handleSelectionChange}
/>
</Paper>
</Grid>
</Grid>
);
Expand Down
Loading
Loading