mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +00:00
feat(sidebar): implement trash functionality for project management
- Added a new `trashItem` method in the Electron API to move projects to the system trash. - Enhanced the sidebar component to include a trash button and manage trashed projects. - Implemented functionality to restore and permanently delete projects from the trash. - Updated the application state to track trashed projects and provide user feedback through toast notifications. This update significantly improves project management by allowing users to easily manage deleted projects without permanent loss.
This commit is contained in:
@@ -89,6 +89,7 @@ export interface ElectronAPI {
|
||||
exists: (filePath: string) => Promise<boolean>;
|
||||
stat: (filePath: string) => Promise<StatResult>;
|
||||
deleteFile: (filePath: string) => Promise<WriteResult>;
|
||||
trashItem?: (filePath: string) => Promise<WriteResult>;
|
||||
getPath: (name: string) => Promise<string>;
|
||||
saveImageToTemp?: (data: string, filename: string, mimeType: string) => Promise<SaveImageResult>;
|
||||
autoMode?: AutoModeAPI;
|
||||
@@ -115,6 +116,7 @@ const mockFeatures = [
|
||||
const STORAGE_KEYS = {
|
||||
PROJECTS: "automaker_projects",
|
||||
CURRENT_PROJECT: "automaker_current_project",
|
||||
TRASHED_PROJECTS: "automaker_trashed_projects",
|
||||
} as const;
|
||||
|
||||
// Mock file system using localStorage
|
||||
@@ -335,6 +337,10 @@ export const getElectronAPI = (): ElectronAPI => {
|
||||
return { success: true };
|
||||
},
|
||||
|
||||
trashItem: async () => {
|
||||
return { success: true };
|
||||
},
|
||||
|
||||
getPath: async (name: string) => {
|
||||
if (name === "userData") {
|
||||
return "/mock/userData";
|
||||
@@ -771,6 +777,11 @@ export interface Project {
|
||||
lastOpened?: string;
|
||||
}
|
||||
|
||||
export interface TrashedProject extends Project {
|
||||
trashedAt: string;
|
||||
deletedFromDisk?: boolean;
|
||||
}
|
||||
|
||||
export const getStoredProjects = (): Project[] => {
|
||||
if (typeof window === "undefined") return [];
|
||||
const stored = localStorage.getItem(STORAGE_KEYS.PROJECTS);
|
||||
@@ -812,3 +823,14 @@ export const removeProject = (projectId: string): void => {
|
||||
const projects = getStoredProjects().filter((p) => p.id !== projectId);
|
||||
saveProjects(projects);
|
||||
};
|
||||
|
||||
export const getStoredTrashedProjects = (): TrashedProject[] => {
|
||||
if (typeof window === "undefined") return [];
|
||||
const stored = localStorage.getItem(STORAGE_KEYS.TRASHED_PROJECTS);
|
||||
return stored ? JSON.parse(stored) : [];
|
||||
};
|
||||
|
||||
export const saveTrashedProjects = (projects: TrashedProject[]): void => {
|
||||
if (typeof window === "undefined") return;
|
||||
localStorage.setItem(STORAGE_KEYS.TRASHED_PROJECTS, JSON.stringify(projects));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user