mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: apply feedback updates
This commit is contained in:
@@ -11,9 +11,7 @@ export const deleteCallbackHandler =
|
||||
deleteOne: (id: string) => Promise<string>,
|
||||
deleteMany?: (ids: string[]) => Promise<string>,
|
||||
) =>
|
||||
async (data: string = ""): Promise<void> => {
|
||||
const selectedIds = data.split(",");
|
||||
|
||||
if (selectedIds.length === 1) await deleteOne(selectedIds[0]);
|
||||
else if (selectedIds.length > 1) await deleteMany?.(selectedIds);
|
||||
async (data: string[] = []): Promise<void> => {
|
||||
if (data.length === 1) await deleteOne(data[0]);
|
||||
else if (data.length > 1) await deleteMany?.(data);
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ export const Categories = () => {
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<ICategory>(false);
|
||||
const editDialogCtl = useDialog<ICategory>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const hasPermission = useHasPermission();
|
||||
const { onSearch, searchPayload } = useSearch<ICategory>({
|
||||
$iLike: ["label"],
|
||||
@@ -82,7 +82,7 @@ export const Categories = () => {
|
||||
},
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
},
|
||||
],
|
||||
@@ -123,9 +123,7 @@ export const Categories = () => {
|
||||
actionColumns,
|
||||
];
|
||||
const handleSelectionChange = (selection: GridRowSelectionModel) =>
|
||||
deleteDialogCtl.saveData?.(
|
||||
selection.length ? selection.toString() : undefined,
|
||||
);
|
||||
deleteDialogCtl.saveData?.(selection as string[]);
|
||||
|
||||
return (
|
||||
<Grid container gap={3} flexDirection="column">
|
||||
@@ -160,7 +158,7 @@ export const Categories = () => {
|
||||
</Button>
|
||||
</Grid>
|
||||
) : null}
|
||||
{deleteDialogCtl?.data && (
|
||||
{deleteDialogCtl?.data?.length && (
|
||||
<Grid item>
|
||||
<Button
|
||||
startIcon={<DeleteIcon />}
|
||||
|
||||
@@ -42,7 +42,7 @@ export const ContentTypes = () => {
|
||||
const router = useRouter();
|
||||
// Dialog Controls
|
||||
const addDialogCtl = useDialog<IContentType>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const fieldsDialogCtl = useDialog<IContentType>(false);
|
||||
// data fetching
|
||||
const { onSearch, searchPayload } = useSearch<IContentType>({
|
||||
@@ -81,7 +81,7 @@ export const ContentTypes = () => {
|
||||
},
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -55,7 +55,7 @@ export const Contents = () => {
|
||||
content?: IContent;
|
||||
contentType?: IContentType;
|
||||
}>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
// data fetching
|
||||
const { onSearch, searchPayload } = useSearch<IContent>({
|
||||
$eq: [{ entity: String(query.id) }],
|
||||
@@ -103,7 +103,7 @@ export const Contents = () => {
|
||||
},
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (content) => deleteDialogCtl.openDialog(content.id),
|
||||
action: (content) => deleteDialogCtl.openDialog([content.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -43,7 +43,7 @@ export const ContextVars = () => {
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<IContextVar>(false);
|
||||
const editDialogCtl = useDialog<IContextVar>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const hasPermission = useHasPermission();
|
||||
const { onSearch, searchPayload } = useSearch<IContextVar>({
|
||||
$iLike: ["label"],
|
||||
@@ -93,7 +93,7 @@ export const ContextVars = () => {
|
||||
},
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
},
|
||||
],
|
||||
@@ -158,9 +158,7 @@ export const ContextVars = () => {
|
||||
actionColumns,
|
||||
];
|
||||
const handleSelectionChange = (selection: GridRowSelectionModel) =>
|
||||
deleteDialogCtl.saveData?.(
|
||||
selection.length ? selection.toString() : undefined,
|
||||
);
|
||||
deleteDialogCtl.saveData?.(selection as string[]);
|
||||
|
||||
return (
|
||||
<Grid container gap={3} flexDirection="column">
|
||||
@@ -195,7 +193,7 @@ export const ContextVars = () => {
|
||||
</Button>
|
||||
</Grid>
|
||||
) : null}
|
||||
{deleteDialogCtl?.data && (
|
||||
{deleteDialogCtl?.data?.length && (
|
||||
<Grid item>
|
||||
<Button
|
||||
startIcon={<DeleteIcon />}
|
||||
|
||||
@@ -40,7 +40,7 @@ export const Labels = () => {
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<ILabel>(false);
|
||||
const editDialogCtl = useDialog<ILabel>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const hasPermission = useHasPermission();
|
||||
const { onSearch, searchPayload } = useSearch<ILabel>({
|
||||
$or: ["name", "title"],
|
||||
@@ -70,7 +70,7 @@ export const Labels = () => {
|
||||
},
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -43,7 +43,7 @@ export const Languages = () => {
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<ILanguage>(false);
|
||||
const editDialogCtl = useDialog<ILanguage>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const queryClient = useQueryClient();
|
||||
const hasPermission = useHasPermission();
|
||||
const { onSearch, searchPayload } = useSearch<ILanguage>({
|
||||
@@ -100,7 +100,7 @@ export const Languages = () => {
|
||||
},
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
isDisabled: (row) => row.isDefault,
|
||||
},
|
||||
|
||||
@@ -47,7 +47,7 @@ type MediaLibraryProps = {
|
||||
export const MediaLibrary = ({ onSelect, accept }: MediaLibraryProps) => {
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const formatFileSize = useFormattedFileSize();
|
||||
const { onSearch, searchPayload } = useSearch<IAttachment>({
|
||||
$iLike: ["name"],
|
||||
@@ -91,7 +91,7 @@ export const MediaLibrary = ({ onSelect, accept }: MediaLibraryProps) => {
|
||||
[
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -40,7 +40,7 @@ const NlpEntity = () => {
|
||||
const router = useRouter();
|
||||
const addDialogCtl = useDialog<INlpEntity>(false);
|
||||
const editDialogCtl = useDialog<INlpEntity>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const hasPermission = useHasPermission();
|
||||
const { mutateAsync: deleteNlpEntity } = useDelete(EntityType.NLP_ENTITY, {
|
||||
onError: () => {
|
||||
@@ -103,7 +103,7 @@ const NlpEntity = () => {
|
||||
},
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
},
|
||||
],
|
||||
@@ -170,9 +170,7 @@ const NlpEntity = () => {
|
||||
actionEntityColumns,
|
||||
];
|
||||
const handleSelectionChange = (selection: GridRowSelectionModel) =>
|
||||
deleteDialogCtl.saveData?.(
|
||||
selection.length ? selection.toString() : undefined,
|
||||
);
|
||||
deleteDialogCtl.saveData?.(selection as string[]);
|
||||
|
||||
return (
|
||||
<Grid item xs={12}>
|
||||
@@ -204,7 +202,7 @@ const NlpEntity = () => {
|
||||
</Button>
|
||||
</Grid>
|
||||
) : null}
|
||||
{deleteDialogCtl?.data && (
|
||||
{deleteDialogCtl?.data?.length && (
|
||||
<Grid item>
|
||||
<Button
|
||||
startIcon={<DeleteIcon />}
|
||||
|
||||
@@ -77,7 +77,7 @@ export default function NlpSample() {
|
||||
const { t } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const editDialogCtl = useDialog<INlpDatasetSample>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const queryClient = useQueryClient();
|
||||
const [type, setType] = useState<NlpSampleType | "all">("all");
|
||||
const [language, setLanguage] = useState<string | undefined>(undefined);
|
||||
@@ -178,7 +178,7 @@ export default function NlpSample() {
|
||||
},
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
},
|
||||
],
|
||||
@@ -291,9 +291,7 @@ export default function NlpSample() {
|
||||
actionColumns,
|
||||
];
|
||||
const handleSelectionChange = (selection: GridRowSelectionModel) =>
|
||||
deleteDialogCtl.saveData?.(
|
||||
selection.length ? selection.toString() : undefined,
|
||||
);
|
||||
deleteDialogCtl.saveData?.(selection as string[]);
|
||||
const handleImportChange = async (file: File) => {
|
||||
await importDataset(file);
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ export const NlpValues = ({ entityId }: { entityId: string }) => {
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<INlpValue>(false);
|
||||
const editDialogCtl = useDialog<INlpValue>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const hasPermission = useHasPermission();
|
||||
const [direction, setDirection] = useState<"up" | "down">("up");
|
||||
const { data: nlpEntity, refetch: refetchEntity } = useGet(entityId, {
|
||||
@@ -93,7 +93,7 @@ export const NlpValues = ({ entityId }: { entityId: string }) => {
|
||||
},
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
},
|
||||
],
|
||||
t("label.operations"),
|
||||
@@ -151,9 +151,7 @@ export const NlpValues = ({ entityId }: { entityId: string }) => {
|
||||
|
||||
const canHaveSynonyms = nlpEntity?.lookups?.[0] === NlpLookups.keywords;
|
||||
const handleSelectionChange = (selection: GridRowSelectionModel) =>
|
||||
deleteDialogCtl.saveData?.(
|
||||
selection.length ? selection.toString() : undefined,
|
||||
);
|
||||
deleteDialogCtl.saveData?.(selection as string[]);
|
||||
|
||||
return (
|
||||
<Grid container gap={2} flexDirection="column">
|
||||
@@ -204,7 +202,7 @@ export const NlpValues = ({ entityId }: { entityId: string }) => {
|
||||
{t("button.add")}
|
||||
</Button>
|
||||
) : null}
|
||||
{deleteDialogCtl?.data && (
|
||||
{deleteDialogCtl?.data?.length && (
|
||||
<Grid item>
|
||||
<Button
|
||||
startIcon={<DeleteIcon />}
|
||||
|
||||
@@ -41,7 +41,7 @@ export const Roles = () => {
|
||||
const { toast } = useToast();
|
||||
const addDialogCtl = useDialog<IRole>(false);
|
||||
const editDialogCtl = useDialog<IRole>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const permissionDialogCtl = useDialog<{
|
||||
role: IRole;
|
||||
}>(false);
|
||||
@@ -82,7 +82,7 @@ export const Roles = () => {
|
||||
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -45,7 +45,7 @@ export const Translations = () => {
|
||||
},
|
||||
);
|
||||
const editDialogCtl = useDialog<ITranslation>(false);
|
||||
const deleteDialogCtl = useDialog<string>(false);
|
||||
const deleteDialogCtl = useDialog<string[]>(false);
|
||||
const { onSearch, searchPayload } = useSearch<ITranslation>({
|
||||
$iLike: ["str"],
|
||||
});
|
||||
@@ -84,7 +84,7 @@ export const Translations = () => {
|
||||
},
|
||||
{
|
||||
label: ActionColumnLabel.Delete,
|
||||
action: (row) => deleteDialogCtl.openDialog(row.id),
|
||||
action: (row) => deleteDialogCtl.openDialog([row.id]),
|
||||
requires: [PermissionAction.DELETE],
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user