update: data source
This commit is contained in:
@@ -34,6 +34,16 @@ export type FolderDialogState = {
|
||||
name: string;
|
||||
busy: boolean;
|
||||
};
|
||||
export type DataResourceDialogState = {
|
||||
open: boolean;
|
||||
file: File | null;
|
||||
parentPath: string;
|
||||
resourceName: string;
|
||||
visibility: Visibility;
|
||||
description: string;
|
||||
uploading: boolean;
|
||||
targetPath: string;
|
||||
};
|
||||
|
||||
export type PublishDialogState = {
|
||||
target: ScriptItem | null;
|
||||
@@ -67,6 +77,7 @@ type UiState = {
|
||||
workspaceMenuOpen: boolean;
|
||||
upload: UploadState;
|
||||
publish: PublishDialogState;
|
||||
dataResourceDialog: DataResourceDialogState;
|
||||
|
||||
// toast
|
||||
pushToast: (toast: ToastState) => void;
|
||||
@@ -107,6 +118,14 @@ type UiState = {
|
||||
setPublishing: (publishing: boolean) => void;
|
||||
setPublishedVersion: (version: StableVersion) => void;
|
||||
clearPublishedVersion: () => void;
|
||||
// data resource dialog
|
||||
openDataResourceDialog: (file: File, parentPath?: string) => void;
|
||||
closeDataResourceDialog: () => void;
|
||||
setDataResourceName: (name: string) => void;
|
||||
setDataResourceVisibility: (visibility: Visibility) => void;
|
||||
setDataResourceDescription: (description: string) => void;
|
||||
setDataResourceTargetPath: (path: string) => void;
|
||||
setDataResourceUploading: (uploading: boolean) => void;
|
||||
};
|
||||
|
||||
export const useUiStore = create<UiState>((set) => ({
|
||||
@@ -135,6 +154,16 @@ export const useUiStore = create<UiState>((set) => ({
|
||||
publishing: false,
|
||||
publishedVersion: null,
|
||||
},
|
||||
dataResourceDialog: {
|
||||
open: false,
|
||||
file: null,
|
||||
parentPath: "",
|
||||
resourceName: "",
|
||||
visibility: "workspace",
|
||||
description: "",
|
||||
uploading: false,
|
||||
targetPath: "",
|
||||
},
|
||||
|
||||
pushToast: (toast) => set({ toast }),
|
||||
dismissToast: () => set({ toast: null }),
|
||||
@@ -230,4 +259,33 @@ export const useUiStore = create<UiState>((set) => ({
|
||||
})),
|
||||
clearPublishedVersion: () =>
|
||||
set((state) => ({ publish: { ...state.publish, publishedVersion: null } })),
|
||||
}));
|
||||
openDataResourceDialog: (file, parentPath = "") =>
|
||||
set((state) => ({
|
||||
contextMenu: null,
|
||||
dataResourceDialog: {
|
||||
open: true,
|
||||
file,
|
||||
parentPath,
|
||||
resourceName: file.name.replace(/\.[^/.]+$/, ""),
|
||||
visibility: "workspace",
|
||||
description: "",
|
||||
uploading: false,
|
||||
// 右键"在此处上传"时,把父目录预填进子目录输入框
|
||||
targetPath: parentPath,
|
||||
},
|
||||
})),
|
||||
closeDataResourceDialog: () =>
|
||||
set((state) => ({
|
||||
dataResourceDialog: { ...state.dataResourceDialog, open: false, uploading: false },
|
||||
})),
|
||||
setDataResourceName: (name) =>
|
||||
set((state) => ({ dataResourceDialog: { ...state.dataResourceDialog, resourceName: name } })),
|
||||
setDataResourceVisibility: (visibility) =>
|
||||
set((state) => ({ dataResourceDialog: { ...state.dataResourceDialog, visibility } })),
|
||||
setDataResourceDescription: (description) =>
|
||||
set((state) => ({ dataResourceDialog: { ...state.dataResourceDialog, description } })),
|
||||
setDataResourceTargetPath: (path) =>
|
||||
set((state) => ({ dataResourceDialog: { ...state.dataResourceDialog, targetPath: path } })),
|
||||
setDataResourceUploading: (uploading) =>
|
||||
set((state) => ({ dataResourceDialog: { ...state.dataResourceDialog, uploading } })),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user