Fixed global variables disappearing after refresh (#1954)
This commit is contained in:
parent
349443c4cc
commit
8813f4e5c3
4 changed files with 11 additions and 8 deletions
|
|
@ -34,6 +34,7 @@ export default function InputGlobalComponent({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data.node?.template[name])
|
if (data.node?.template[name])
|
||||||
if (
|
if (
|
||||||
|
globalVariablesEntries &&
|
||||||
!globalVariablesEntries.includes(data.node?.template[name].value) &&
|
!globalVariablesEntries.includes(data.node?.template[name].value) &&
|
||||||
data.node?.template[name].load_from_db
|
data.node?.template[name].load_from_db
|
||||||
) {
|
) {
|
||||||
|
|
@ -138,6 +139,7 @@ export default function InputGlobalComponent({
|
||||||
)}
|
)}
|
||||||
selectedOption={
|
selectedOption={
|
||||||
data?.node?.template[name].load_from_db &&
|
data?.node?.template[name].load_from_db &&
|
||||||
|
globalVariablesEntries &&
|
||||||
globalVariablesEntries.includes(data?.node?.template[name].value ?? "")
|
globalVariablesEntries.includes(data?.node?.template[name].value ?? "")
|
||||||
? data?.node?.template[name].value
|
? data?.node?.template[name].value
|
||||||
: ""
|
: ""
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ import { cn } from "../../../../utils/utils";
|
||||||
|
|
||||||
export default function GlobalVariablesPage() {
|
export default function GlobalVariablesPage() {
|
||||||
const globalVariablesEntries = useGlobalVariablesStore(
|
const globalVariablesEntries = useGlobalVariablesStore(
|
||||||
(state) => state.globalVariablesEntries
|
(state) => state.globalVariablesEntries,
|
||||||
);
|
);
|
||||||
const removeGlobalVariable = useGlobalVariablesStore(
|
const removeGlobalVariable = useGlobalVariablesStore(
|
||||||
(state) => state.removeGlobalVariable
|
(state) => state.removeGlobalVariable,
|
||||||
);
|
);
|
||||||
const globalVariables = useGlobalVariablesStore(
|
const globalVariables = useGlobalVariablesStore(
|
||||||
(state) => state.globalVariables
|
(state) => state.globalVariables,
|
||||||
);
|
);
|
||||||
const setErrorData = useAlertStore((state) => state.setErrorData);
|
const setErrorData = useAlertStore((state) => state.setErrorData);
|
||||||
const getVariableId = useGlobalVariablesStore((state) => state.getVariableId);
|
const getVariableId = useGlobalVariablesStore((state) => state.getVariableId);
|
||||||
|
|
@ -55,6 +55,7 @@ export default function GlobalVariablesPage() {
|
||||||
name: string;
|
name: string;
|
||||||
default_fields: string | undefined;
|
default_fields: string | undefined;
|
||||||
}> = [];
|
}> = [];
|
||||||
|
if (globalVariablesEntries === undefined) return;
|
||||||
globalVariablesEntries.forEach((entrie) => {
|
globalVariablesEntries.forEach((entrie) => {
|
||||||
const globalVariableObj = globalVariables[entrie];
|
const globalVariableObj = globalVariables[entrie];
|
||||||
rows.push({
|
rows.push({
|
||||||
|
|
@ -156,7 +157,7 @@ export default function GlobalVariablesPage() {
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name="Trash2"
|
name="Trash2"
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-5 w-5 text-destructive group-disabled:text-primary"
|
"h-5 w-5 text-destructive group-disabled:text-primary",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -176,7 +177,7 @@ export default function GlobalVariablesPage() {
|
||||||
overlayNoRowsTemplate="No data available"
|
overlayNoRowsTemplate="No data available"
|
||||||
onSelectionChanged={(event: SelectionChangedEvent) => {
|
onSelectionChanged={(event: SelectionChangedEvent) => {
|
||||||
setSelectedRows(
|
setSelectedRows(
|
||||||
event.api.getSelectedRows().map((row) => row.name)
|
event.api.getSelectedRows().map((row) => row.name),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
rowSelection="multiple"
|
rowSelection="multiple"
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export const useGlobalVariablesStore = create<GlobalVariablesStore>(
|
||||||
delete newFields[field];
|
delete newFields[field];
|
||||||
set({ unavaliableFields: newFields });
|
set({ unavaliableFields: newFields });
|
||||||
},
|
},
|
||||||
globalVariablesEntries: [],
|
globalVariablesEntries: undefined,
|
||||||
globalVariables: {},
|
globalVariables: {},
|
||||||
setGlobalVariables: (variables) => {
|
setGlobalVariables: (variables) => {
|
||||||
set({
|
set({
|
||||||
|
|
@ -45,5 +45,5 @@ export const useGlobalVariablesStore = create<GlobalVariablesStore>(
|
||||||
getVariableId: (name) => {
|
getVariableId: (name) => {
|
||||||
return get().globalVariables[name]?.id;
|
return get().globalVariables[name]?.id;
|
||||||
},
|
},
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
export type GlobalVariablesStore = {
|
export type GlobalVariablesStore = {
|
||||||
globalVariablesEntries: Array<string>;
|
globalVariablesEntries: Array<string> | undefined;
|
||||||
globalVariables: {
|
globalVariables: {
|
||||||
[name: string]: {
|
[name: string]: {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue