Added fields to request for creating new variable
This commit is contained in:
parent
a556f686e2
commit
e773227e4a
3 changed files with 8 additions and 7 deletions
|
|
@ -26,15 +26,16 @@ export default function AddNewVariableButton({ children }): JSX.Element {
|
||||||
(state) => state.addGlobalVariable
|
(state) => state.addGlobalVariable
|
||||||
);
|
);
|
||||||
function handleSaveVariable() {
|
function handleSaveVariable() {
|
||||||
let data: { name: string; value: string; type?: string } = {
|
let data: { name: string; value: string; type?: string; default_fields?: string[] } = {
|
||||||
name: key,
|
name: key,
|
||||||
type,
|
type,
|
||||||
value,
|
value,
|
||||||
|
default_fields: fields
|
||||||
};
|
};
|
||||||
registerGlobalVariable(data)
|
registerGlobalVariable(data)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const { name, id, type } = res.data;
|
const { name, id, type } = res.data;
|
||||||
addGlobalVariable(name, id, type);
|
addGlobalVariable(name, id, type, fields);
|
||||||
setKey("");
|
setKey("");
|
||||||
setValue("");
|
setValue("");
|
||||||
setType("");
|
setType("");
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ export const useGlobalVariablesStore = create<GlobalVariablesStore>(
|
||||||
globalVariablesEntries: Object.keys(variables),
|
globalVariablesEntries: Object.keys(variables),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addGlobalVariable: (name, id, type) => {
|
addGlobalVariable: (name, id, type, default_fields) => {
|
||||||
const data = { id, type };
|
const data = { id, type, default_fields };
|
||||||
const newVariables = { ...get().globalVariables, [name]: data };
|
const newVariables = { ...get().globalVariables, [name]: data };
|
||||||
set({
|
set({
|
||||||
globalVariables: newVariables,
|
globalVariables: newVariables,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
export type GlobalVariablesStore = {
|
export type GlobalVariablesStore = {
|
||||||
globalVariablesEntries: Array<string>;
|
globalVariablesEntries: Array<string>;
|
||||||
globalVariables: { [name: string]: { id: string; type?: string } };
|
globalVariables: { [name: string]: { id: string; type?: string, default_fields?: string[] } };
|
||||||
setGlobalVariables: (variables: {
|
setGlobalVariables: (variables: {
|
||||||
[name: string]: { id: string; type?: string };
|
[name: string]: { id: string; type?: string, default_fields?: string[]};
|
||||||
}) => void;
|
}) => void;
|
||||||
addGlobalVariable: (name: string, id: string, type?: string) => void;
|
addGlobalVariable: (name: string, id: string, type?: string, default_fields?: string[]) => void;
|
||||||
removeGlobalVariable: (name: string) => void;
|
removeGlobalVariable: (name: string) => void;
|
||||||
getVariableId: (name: string) => string | undefined;
|
getVariableId: (name: string) => string | undefined;
|
||||||
unavaliableFields: Set<string>;
|
unavaliableFields: Set<string>;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue