mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat: add permanent option in frontend
This commit is contained in:
parent
d7838951e5
commit
dec568cbfa
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import { faAsterisk } from "@fortawesome/free-solid-svg-icons";
|
import { faAsterisk } from "@fortawesome/free-solid-svg-icons";
|
||||||
import AddIcon from "@mui/icons-material/Add";
|
import AddIcon from "@mui/icons-material/Add";
|
||||||
import { Button, Grid, Paper } from "@mui/material";
|
import { Button, Grid, Paper, Switch } from "@mui/material";
|
||||||
import { GridColDef } from "@mui/x-data-grid";
|
import { GridColDef } from "@mui/x-data-grid";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@ -24,6 +24,7 @@ import { renderHeader } from "@/app-components/tables/columns/renderHeader";
|
|||||||
import { DataGrid } from "@/app-components/tables/DataGrid";
|
import { DataGrid } from "@/app-components/tables/DataGrid";
|
||||||
import { useDelete } from "@/hooks/crud/useDelete";
|
import { useDelete } from "@/hooks/crud/useDelete";
|
||||||
import { useFind } from "@/hooks/crud/useFind";
|
import { useFind } from "@/hooks/crud/useFind";
|
||||||
|
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||||
import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||||
import { useSearch } from "@/hooks/useSearch";
|
import { useSearch } from "@/hooks/useSearch";
|
||||||
@ -52,6 +53,14 @@ export const ContextVars = () => {
|
|||||||
params: searchPayload,
|
params: searchPayload,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
const { mutateAsync: updateContextVar } = useUpdate(EntityType.CONTEXT_VAR, {
|
||||||
|
onError: () => {
|
||||||
|
toast.error(t("message.internal_server_error"));
|
||||||
|
},
|
||||||
|
onSuccess() {
|
||||||
|
toast.success(t("message.success_save"));
|
||||||
|
},
|
||||||
|
});
|
||||||
const { mutateAsync: deleteContextVar } = useDelete(EntityType.CONTEXT_VAR, {
|
const { mutateAsync: deleteContextVar } = useDelete(EntityType.CONTEXT_VAR, {
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t("message.internal_server_error"));
|
toast.error(t("message.internal_server_error"));
|
||||||
@ -87,6 +96,27 @@ export const ContextVars = () => {
|
|||||||
renderHeader,
|
renderHeader,
|
||||||
headerAlign: "left",
|
headerAlign: "left",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
maxWidth: 120,
|
||||||
|
field: "permanent",
|
||||||
|
headerName: t("label.permanent"),
|
||||||
|
disableColumnMenu: true,
|
||||||
|
renderHeader,
|
||||||
|
headerAlign: "left",
|
||||||
|
renderCell: (params) => (
|
||||||
|
<Switch
|
||||||
|
checked={params.value}
|
||||||
|
color="primary"
|
||||||
|
inputProps={{ "aria-label": "primary checkbox" }}
|
||||||
|
onChange={() => {
|
||||||
|
updateContextVar({
|
||||||
|
id: params.row.id,
|
||||||
|
params: { permanent: !params.value },
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
maxWidth: 140,
|
maxWidth: 140,
|
||||||
field: "createdAt",
|
field: "createdAt",
|
||||||
|
@ -288,6 +288,7 @@
|
|||||||
"assign_labels": "Assign labels",
|
"assign_labels": "Assign labels",
|
||||||
"replacement_tokens": "Replacement Tokens",
|
"replacement_tokens": "Replacement Tokens",
|
||||||
"built_in": "Built-in",
|
"built_in": "Built-in",
|
||||||
|
"permanent": "Permanent",
|
||||||
"assign_to": "Takeover By",
|
"assign_to": "Takeover By",
|
||||||
"assigned_to": "Assigned To",
|
"assigned_to": "Assigned To",
|
||||||
"user_first_name": "First Name",
|
"user_first_name": "First Name",
|
||||||
|
@ -289,6 +289,7 @@
|
|||||||
"assign_labels": "Affecter des étiquettes",
|
"assign_labels": "Affecter des étiquettes",
|
||||||
"replacement_tokens": "Jetons de remplacement",
|
"replacement_tokens": "Jetons de remplacement",
|
||||||
"built_in": "Intégré",
|
"built_in": "Intégré",
|
||||||
|
"permanent": "Permanent",
|
||||||
"assign_to": "Assigner à",
|
"assign_to": "Assigner à",
|
||||||
"assigned_to": "Assigné(e) à",
|
"assigned_to": "Assigné(e) à",
|
||||||
"user_first_name": "Prénom",
|
"user_first_name": "Prénom",
|
||||||
|
@ -14,6 +14,7 @@ import { IBaseSchema, IFormat, OmitPopulate } from "./base.types";
|
|||||||
export interface IContextVarAttributes {
|
export interface IContextVarAttributes {
|
||||||
name: string;
|
name: string;
|
||||||
label: string;
|
label: string;
|
||||||
|
permanent: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IContextVarStub
|
export interface IContextVarStub
|
||||||
@ -21,6 +22,7 @@ export interface IContextVarStub
|
|||||||
OmitPopulate<IContextVarAttributes, EntityType.CONTEXT_VAR> {
|
OmitPopulate<IContextVarAttributes, EntityType.CONTEXT_VAR> {
|
||||||
name: string;
|
name: string;
|
||||||
label: string;
|
label: string;
|
||||||
|
permanent: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IContextVar extends IContextVarStub, IFormat<Format.BASIC> {}
|
export interface IContextVar extends IContextVarStub, IFormat<Format.BASIC> {}
|
||||||
|
Loading…
Reference in New Issue
Block a user