feat: update button run scripts
ci-front / build (push) Successful in 2m35s

This commit is contained in:
nikita
2026-04-05 04:57:16 +03:00
parent f14490c076
commit d6512d6c97
5 changed files with 87 additions and 38 deletions
@@ -1,19 +1,23 @@
import { create } from "zustand";
import { scriptsApi } from "../api/scripts.api";
interface FilePickerState {
selectedPaths: Set<string>;
expandedFolders: Set<string>;
runningScripts: Map<string, { id: number; status: string }>;
toggleSelection: (path: string) => void;
selectAll: (paths: string[]) => void;
clearSelection: () => void;
toggleFolder: (path: string) => void;
getSelectedPaths: () => string[];
runScript: (path: string) => Promise<void>;
}
export const useFilePickerStore = create<FilePickerState>((set, get) => ({
selectedPaths: new Set(),
expandedFolders: new Set(),
runningScripts: new Map(),
toggleSelection: (path: string) => {
set((state) => {
@@ -54,4 +58,17 @@ export const useFilePickerStore = create<FilePickerState>((set, get) => ({
getSelectedPaths: () => {
return Array.from(get().selectedPaths);
},
runScript: async (path: string) => {
try {
const result = await scriptsApi.run(path);
set((state) => {
const newMap = new Map(state.runningScripts);
newMap.set(path, result);
return { runningScripts: newMap };
});
} catch (e) {
console.error("Failed to run script:", e);
}
},
}));