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 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 React from "react";
|
||||
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 { useDelete } from "@/hooks/crud/useDelete";
|
||||
import { useFind } from "@/hooks/crud/useFind";
|
||||
import { useUpdate } from "@/hooks/crud/useUpdate";
|
||||
import { getDisplayDialogs, useDialog } from "@/hooks/useDialog";
|
||||
import { useHasPermission } from "@/hooks/useHasPermission";
|
||||
import { useSearch } from "@/hooks/useSearch";
|
||||
@ -52,6 +53,14 @@ export const ContextVars = () => {
|
||||
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, {
|
||||
onError: () => {
|
||||
toast.error(t("message.internal_server_error"));
|
||||
@ -87,6 +96,27 @@ export const ContextVars = () => {
|
||||
renderHeader,
|
||||
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,
|
||||
field: "createdAt",
|
||||
|
@ -288,6 +288,7 @@
|
||||
"assign_labels": "Assign labels",
|
||||
"replacement_tokens": "Replacement Tokens",
|
||||
"built_in": "Built-in",
|
||||
"permanent": "Permanent",
|
||||
"assign_to": "Takeover By",
|
||||
"assigned_to": "Assigned To",
|
||||
"user_first_name": "First Name",
|
||||
|
@ -289,6 +289,7 @@
|
||||
"assign_labels": "Affecter des étiquettes",
|
||||
"replacement_tokens": "Jetons de remplacement",
|
||||
"built_in": "Intégré",
|
||||
"permanent": "Permanent",
|
||||
"assign_to": "Assigner à",
|
||||
"assigned_to": "Assigné(e) à",
|
||||
"user_first_name": "Prénom",
|
||||
|
@ -14,6 +14,7 @@ import { IBaseSchema, IFormat, OmitPopulate } from "./base.types";
|
||||
export interface IContextVarAttributes {
|
||||
name: string;
|
||||
label: string;
|
||||
permanent: boolean;
|
||||
}
|
||||
|
||||
export interface IContextVarStub
|
||||
@ -21,6 +22,7 @@ export interface IContextVarStub
|
||||
OmitPopulate<IContextVarAttributes, EntityType.CONTEXT_VAR> {
|
||||
name: string;
|
||||
label: string;
|
||||
permanent: boolean;
|
||||
}
|
||||
|
||||
export interface IContextVar extends IContextVarStub, IFormat<Format.BASIC> {}
|
||||
|
Loading…
Reference in New Issue
Block a user