From c5bfdf3a4722cdfa682ed2e499964e8042c4e83d Mon Sep 17 00:00:00 2001 From: taylorfries Date: Tue, 19 Nov 2024 07:45:40 -0800 Subject: [PATCH 01/12] add buton and dialog to get folder --- .../src/main/fileProcessing/actions/index.ts | 1 + .../fileProcessing/actions/selectDirectory.ts | 23 ++++++++ desktop/src/main/index.ts | 12 ++++- desktop/src/preload/index.d.ts | 1 + desktop/src/preload/index.ts | 1 + .../components/file-list/ContinueButton.tsx | 11 ++++ .../file-list/SelectFolderButton.tsx | 47 ++++++++++++++++ .../src/components/file-list/index.ts | 2 + desktop/src/renderer/src/pages/FileList.tsx | 53 +++++++++++++++---- 9 files changed, 139 insertions(+), 12 deletions(-) create mode 100644 desktop/src/main/fileProcessing/actions/selectDirectory.ts create mode 100644 desktop/src/renderer/src/components/file-list/ContinueButton.tsx create mode 100644 desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx diff --git a/desktop/src/main/fileProcessing/actions/index.ts b/desktop/src/main/fileProcessing/actions/index.ts index 5cd80fc5..1b35a6b6 100644 --- a/desktop/src/main/fileProcessing/actions/index.ts +++ b/desktop/src/main/fileProcessing/actions/index.ts @@ -1,2 +1,3 @@ export * from "./copyFolderAndMetadata"; export * from "./getFolderMetadata"; +export * from "./selectDirectory"; diff --git a/desktop/src/main/fileProcessing/actions/selectDirectory.ts b/desktop/src/main/fileProcessing/actions/selectDirectory.ts new file mode 100644 index 00000000..dc3fe665 --- /dev/null +++ b/desktop/src/main/fileProcessing/actions/selectDirectory.ts @@ -0,0 +1,23 @@ +import { dialog, type BrowserWindow } from "electron"; + +let selectedDir: string[] | undefined; +let dirPathArray: string[]; + +/** + * Opens a (modal) dialog window off the main window for a user to select a directory. + * + * @param win - the main process window. + * @returns A string[] if a directory is selected or undefined if the dialog is closed with no selection. + */ +export const selectDirectory = (win: BrowserWindow): string[] => { + // open a dialog and allow a user to select multiple folders + selectedDir = dialog.showOpenDialogSync(win, { + properties: ["openDirectory", "multiSelections"], + }); + + // if selectedDir is undefined we have no selected path so return an empty array + // otherwise return the array of selected paths + dirPathArray = selectedDir ?? [""]; + + return dirPathArray; +}; diff --git a/desktop/src/main/index.ts b/desktop/src/main/index.ts index df4f7b4a..4f57c5dc 100644 --- a/desktop/src/main/index.ts +++ b/desktop/src/main/index.ts @@ -10,7 +10,11 @@ import { join } from "node:path"; import { is } from "@electron-toolkit/utils"; import icon from "../../resources/icon.png?asset"; import { createWorkerPool } from "./fileProcessing"; -import { copyFolderAndMetadata, getFolderMetadata } from "./fileProcessing/actions"; +import { + copyFolderAndMetadata, + getFolderMetadata, + selectDirectory, +} from "./fileProcessing/actions"; app.setName("Digital Archives Transfer Service"); @@ -191,6 +195,12 @@ ipcMain.handle("get-folder-metadata", async (_, { filePath }: { filePath: string await getFolderMetadata(pool, filePath, is.dev); }); +ipcMain.handle("select-directory", () => { + debug('Beginning "select-directory" of main process.'); + // returns selected folder or undefined if no folder was selected + return selectDirectory(mainWindow); +}); + const clearAuthState = () => { debug("Beginning clearAuthState function of main process."); diff --git a/desktop/src/preload/index.d.ts b/desktop/src/preload/index.d.ts index 700aa72a..0f837baf 100644 --- a/desktop/src/preload/index.d.ts +++ b/desktop/src/preload/index.d.ts @@ -9,6 +9,7 @@ declare global { checkApiStatus: (url: string) => Promise; checkIpRange: () => Promise; getCurrentApiUrl: () => Promise; + selectDirectory: () => Promise; sso: { startLoginProcess: () => Promise; diff --git a/desktop/src/preload/index.ts b/desktop/src/preload/index.ts index a880bba8..830413e8 100644 --- a/desktop/src/preload/index.ts +++ b/desktop/src/preload/index.ts @@ -9,6 +9,7 @@ const api = { checkApiStatus, checkIpRange, getCurrentApiUrl: () => ipcRenderer.invoke("get-current-api-url"), + selectDirectory: () => ipcRenderer.invoke("select-directory"), sso: { getUser, fetchProtectedRoute, diff --git a/desktop/src/renderer/src/components/file-list/ContinueButton.tsx b/desktop/src/renderer/src/components/file-list/ContinueButton.tsx new file mode 100644 index 00000000..3ca08108 --- /dev/null +++ b/desktop/src/renderer/src/components/file-list/ContinueButton.tsx @@ -0,0 +1,11 @@ +export const ContinueButton = (): JSX.Element => { + const handleClick = async () => { + console.log("TODO: THIS"); + }; + + return ( + + ); +}; diff --git a/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx b/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx new file mode 100644 index 00000000..de29fcea --- /dev/null +++ b/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx @@ -0,0 +1,47 @@ +import { useState } from "react"; +import { type FolderRow } from "./FolderDisplayGrid"; + +export const SelectFolderButton = (): JSX.Element => { + const [api] = useState(window.api); // preload scripts + + const pathArrayToFileList = (arrayOfPaths: string[]) => { + const fileRowList: FolderRow[] = []; + for (let i = 0; i < arrayOfPaths.length; i++) { + // for every sring in array convert to folder row and add to new list + const curFolderRow: FolderRow = { + id: i, + folder: arrayOfPaths[i], + schedule: "TestSchedule", + classification: "TestClassification", + file: "TestFILE", + opr: true, + startDate: null, + endDate: null, + soDate: null, + fdDate: null, + progress: 0, + }; + fileRowList.push(curFolderRow); + } + return fileRowList; + }; + const handleClick = async () => { + let fileList: FolderRow[]; + const result = await api.selectDirectory(); + if (result.length === 0) { + // no directory selected + console.log("No folder selected. Carry on"); + fileList = []; + } else { + console.log("folder ", result, " selected."); + fileList = pathArrayToFileList(result); + } + return fileList; + }; + + return ( + + ); +}; diff --git a/desktop/src/renderer/src/components/file-list/index.ts b/desktop/src/renderer/src/components/file-list/index.ts index 30ef9d7b..f9304d0c 100644 --- a/desktop/src/renderer/src/components/file-list/index.ts +++ b/desktop/src/renderer/src/components/file-list/index.ts @@ -1 +1,3 @@ export * from "./FolderDisplayGrid"; +export * from "./SelectFolderButton"; +export * from "./ContinueButton"; diff --git a/desktop/src/renderer/src/pages/FileList.tsx b/desktop/src/renderer/src/pages/FileList.tsx index 7af88ae8..fa5ff888 100644 --- a/desktop/src/renderer/src/pages/FileList.tsx +++ b/desktop/src/renderer/src/pages/FileList.tsx @@ -1,24 +1,55 @@ import { Box, useTheme } from "@mui/material"; -import { FolderDisplayGrid, type FolderRow } from "@renderer/components/file-list"; +import { + FolderDisplayGrid, + type FolderRow, + SelectFolderButton, + ContinueButton, +} from "@renderer/components/file-list"; import { useState } from "react"; export const FileListPage = () => { + //@ts-ignore const [rows, setRows] = useState([]); const theme = useTheme(); const onFolderDelete = (folder: string) => { alert(folder); // TBD }; + const handleRowChange = (fileList: FolderRow[]): FolderRow[] => { + try { + setRows(fileList); + return fileList; + } catch (error) { + setRows([]); + return []; + } + }; + return ( - - - + <> + + + + + + + + ); }; From c786ebe4ddc7f7d553f0130914f866c2edf469c5 Mon Sep 17 00:00:00 2001 From: taylorfries Date: Tue, 19 Nov 2024 07:47:01 -0800 Subject: [PATCH 02/12] add style changes to select directory --- desktop/src/renderer/src/assets/base.css | 1 + desktop/src/renderer/src/assets/main.css | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/desktop/src/renderer/src/assets/base.css b/desktop/src/renderer/src/assets/base.css index c7cf791a..1ea8e1e3 100644 --- a/desktop/src/renderer/src/assets/base.css +++ b/desktop/src/renderer/src/assets/base.css @@ -12,6 +12,7 @@ --ev-c-gray-1: #515c67; --ev-c-gray-2: #414853; --ev-c-gray-3: #32363f; + --ev-c-gray-4: #d9d9d9; --ev-c-text-1: #2c2d30; --ev-c-text-2: rgba(235, 235, 245, 0.6); diff --git a/desktop/src/renderer/src/assets/main.css b/desktop/src/renderer/src/assets/main.css index e8f9c92b..b6f3aa21 100644 --- a/desktop/src/renderer/src/assets/main.css +++ b/desktop/src/renderer/src/assets/main.css @@ -70,6 +70,21 @@ code { font-weight: 600; } +.file-list-button { + background-color: var(--ev-c-white-mute); + color: var(--ev-c-black); + padding: 5px 30px; + text-align: center; + display: inline-block; + font-size: 16px; + border-radius: 6px; + transition-duration: 0.4s; + border: 1.5px solid var(--ev-c-black); +} +.file-list-button:hover { + background-color: var(--ev-c-gray-4); +} + .vpn-popup-overlay { position: fixed; top: 0; From 700269444b68ba2d0854271c573f6c9a055a5bf0 Mon Sep 17 00:00:00 2001 From: taylorfries Date: Tue, 19 Nov 2024 11:13:25 -0800 Subject: [PATCH 03/12] add more directories --- .../file-list/SelectFolderButton.tsx | 25 +++++++++++-------- desktop/src/renderer/src/pages/FileList.tsx | 15 ++--------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx b/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx index de29fcea..96fa69eb 100644 --- a/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx +++ b/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx @@ -1,15 +1,18 @@ import { useState } from "react"; -import { type FolderRow } from "./FolderDisplayGrid"; +import type { FolderRow } from "./FolderDisplayGrid"; -export const SelectFolderButton = (): JSX.Element => { +export const SelectFolderButton = (rows): JSX.Element => { const [api] = useState(window.api); // preload scripts const pathArrayToFileList = (arrayOfPaths: string[]) => { - const fileRowList: FolderRow[] = []; + let newRows: FolderRow[] = []; + if (rows.currentRows.length > 0) newRows = rows.currentRows.slice(); + + let index = rows.currentRows.length; for (let i = 0; i < arrayOfPaths.length; i++) { // for every sring in array convert to folder row and add to new list const curFolderRow: FolderRow = { - id: i, + id: index, folder: arrayOfPaths[i], schedule: "TestSchedule", classification: "TestClassification", @@ -21,21 +24,23 @@ export const SelectFolderButton = (): JSX.Element => { fdDate: null, progress: 0, }; - fileRowList.push(curFolderRow); + index++; + newRows.push(curFolderRow); } - return fileRowList; + return newRows; }; const handleClick = async () => { let fileList: FolderRow[]; const result = await api.selectDirectory(); if (result.length === 0) { - // no directory selected - console.log("No folder selected. Carry on"); - fileList = []; + // no directory selected just return what we already had + fileList = rows.currentRows; } else { - console.log("folder ", result, " selected."); + // add new directory to any current 'rows' fileList = pathArrayToFileList(result); } + + rows.setRows(fileList); return fileList; }; diff --git a/desktop/src/renderer/src/pages/FileList.tsx b/desktop/src/renderer/src/pages/FileList.tsx index fa5ff888..dec2bcd2 100644 --- a/desktop/src/renderer/src/pages/FileList.tsx +++ b/desktop/src/renderer/src/pages/FileList.tsx @@ -8,23 +8,12 @@ import { import { useState } from "react"; export const FileListPage = () => { - //@ts-ignore const [rows, setRows] = useState([]); const theme = useTheme(); const onFolderDelete = (folder: string) => { alert(folder); // TBD }; - const handleRowChange = (fileList: FolderRow[]): FolderRow[] => { - try { - setRows(fileList); - return fileList; - } catch (error) { - setRows([]); - return []; - } - }; - return ( <> { background: `${theme.palette.primary}`, }} > - + { background: `${theme.palette.primary}`, }} > - + ); From 3e6a6d4eb678b5757cf3a9116034f14a304f0e84 Mon Sep 17 00:00:00 2001 From: taylorfries Date: Tue, 19 Nov 2024 15:36:23 -0800 Subject: [PATCH 04/12] make folders actually add and not just break everything --- .../file-list/SelectFolderButton.tsx | 40 ++----------------- desktop/src/renderer/src/pages/FileList.tsx | 32 ++++++++++++++- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx b/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx index 96fa69eb..991517b9 100644 --- a/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx +++ b/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx @@ -1,47 +1,13 @@ import { useState } from "react"; -import type { FolderRow } from "./FolderDisplayGrid"; -export const SelectFolderButton = (rows): JSX.Element => { +export const SelectFolderButton = ({ onRowChange }): JSX.Element => { const [api] = useState(window.api); // preload scripts - const pathArrayToFileList = (arrayOfPaths: string[]) => { - let newRows: FolderRow[] = []; - if (rows.currentRows.length > 0) newRows = rows.currentRows.slice(); - - let index = rows.currentRows.length; - for (let i = 0; i < arrayOfPaths.length; i++) { - // for every sring in array convert to folder row and add to new list - const curFolderRow: FolderRow = { - id: index, - folder: arrayOfPaths[i], - schedule: "TestSchedule", - classification: "TestClassification", - file: "TestFILE", - opr: true, - startDate: null, - endDate: null, - soDate: null, - fdDate: null, - progress: 0, - }; - index++; - newRows.push(curFolderRow); - } - return newRows; - }; const handleClick = async () => { - let fileList: FolderRow[]; const result = await api.selectDirectory(); - if (result.length === 0) { - // no directory selected just return what we already had - fileList = rows.currentRows; - } else { - // add new directory to any current 'rows' - fileList = pathArrayToFileList(result); - } - rows.setRows(fileList); - return fileList; + onRowChange(result); + return result; }; return ( diff --git a/desktop/src/renderer/src/pages/FileList.tsx b/desktop/src/renderer/src/pages/FileList.tsx index dec2bcd2..fe966227 100644 --- a/desktop/src/renderer/src/pages/FileList.tsx +++ b/desktop/src/renderer/src/pages/FileList.tsx @@ -1,3 +1,4 @@ +import { CurrencyBitcoin } from "@mui/icons-material"; import { Box, useTheme } from "@mui/material"; import { FolderDisplayGrid, @@ -8,12 +9,41 @@ import { import { useState } from "react"; export const FileListPage = () => { + //@ts-ignore const [rows, setRows] = useState([]); const theme = useTheme(); const onFolderDelete = (folder: string) => { alert(folder); // TBD }; + function handleAddPathArrayToRows(inPaths) { + const newRows: FolderRow[] = [...rows]; + let index = rows.length; + try { + for (let i = 0; i < inPaths.length; i++) { + const curFolderRow: FolderRow = { + id: index, + folder: inPaths[i], + schedule: "TestSchedule", + classification: "TestClassification", + file: "TestFILE", + opr: true, + startDate: null, + endDate: null, + soDate: null, + fdDate: null, + progress: 0, + }; + index++; + newRows.push(curFolderRow); + } + setRows(newRows); + } catch (error) { + setRows(rows); + console.log("Hit error"); + } + } + return ( <> { background: `${theme.palette.primary}`, }} > - + Date: Tue, 19 Nov 2024 15:36:41 -0800 Subject: [PATCH 05/12] scrollable if main area gets too big --- desktop/src/renderer/src/assets/base.css | 1 - desktop/src/renderer/src/assets/main.css | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/desktop/src/renderer/src/assets/base.css b/desktop/src/renderer/src/assets/base.css index 1ea8e1e3..1fa40b4a 100644 --- a/desktop/src/renderer/src/assets/base.css +++ b/desktop/src/renderer/src/assets/base.css @@ -49,7 +49,6 @@ ul { body { width: 100%; height: 100%; - overflow: hidden; user-select: none; border-top: 1px solid #e3e3e3; min-height: 100vh; diff --git a/desktop/src/renderer/src/assets/main.css b/desktop/src/renderer/src/assets/main.css index b6f3aa21..eb7b5d1a 100644 --- a/desktop/src/renderer/src/assets/main.css +++ b/desktop/src/renderer/src/assets/main.css @@ -5,7 +5,7 @@ body { height: 100%; min-width: 100vh; min-height: 100vh; - overflow: hidden; + overflow: scroll; user-select: none; } From 3c1b9fc73ecf4d4900e4ad03bc3bb9f5371200f5 Mon Sep 17 00:00:00 2001 From: taylorfries Date: Tue, 19 Nov 2024 15:37:31 -0800 Subject: [PATCH 06/12] remove unused import --- desktop/src/renderer/src/pages/FileList.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/desktop/src/renderer/src/pages/FileList.tsx b/desktop/src/renderer/src/pages/FileList.tsx index fe966227..213f1987 100644 --- a/desktop/src/renderer/src/pages/FileList.tsx +++ b/desktop/src/renderer/src/pages/FileList.tsx @@ -1,4 +1,3 @@ -import { CurrencyBitcoin } from "@mui/icons-material"; import { Box, useTheme } from "@mui/material"; import { FolderDisplayGrid, From c735ded28503f9fecfa00795c4366be44aff48fd Mon Sep 17 00:00:00 2001 From: taylorfries Date: Tue, 19 Nov 2024 15:40:53 -0800 Subject: [PATCH 07/12] uSe DeSiGn SyStEm BuTtOn --- .../renderer/src/components/file-list/ContinueButton.tsx | 6 ++++-- .../src/components/file-list/SelectFolderButton.tsx | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/desktop/src/renderer/src/components/file-list/ContinueButton.tsx b/desktop/src/renderer/src/components/file-list/ContinueButton.tsx index 3ca08108..b80da634 100644 --- a/desktop/src/renderer/src/components/file-list/ContinueButton.tsx +++ b/desktop/src/renderer/src/components/file-list/ContinueButton.tsx @@ -1,11 +1,13 @@ +import { Button } from "@bcgov/design-system-react-components"; + export const ContinueButton = (): JSX.Element => { const handleClick = async () => { console.log("TODO: THIS"); }; return ( - + ); }; diff --git a/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx b/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx index 991517b9..af4914f7 100644 --- a/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx +++ b/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx @@ -1,4 +1,5 @@ import { useState } from "react"; +import { Button } from "@bcgov/design-system-react-components"; export const SelectFolderButton = ({ onRowChange }): JSX.Element => { const [api] = useState(window.api); // preload scripts @@ -11,8 +12,8 @@ export const SelectFolderButton = ({ onRowChange }): JSX.Element => { }; return ( - + ); }; From 9679d4c7b38e5596887e11cc1816c1df0ae87ede Mon Sep 17 00:00:00 2001 From: taylorfries Date: Tue, 19 Nov 2024 15:44:56 -0800 Subject: [PATCH 08/12] use correct stylings, remove css classes --- desktop/src/renderer/src/assets/base.css | 1 - desktop/src/renderer/src/assets/main.css | 15 --------------- .../src/components/file-list/ContinueButton.tsx | 6 +++++- .../components/file-list/SelectFolderButton.tsx | 6 +++++- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/desktop/src/renderer/src/assets/base.css b/desktop/src/renderer/src/assets/base.css index 1fa40b4a..7b1be728 100644 --- a/desktop/src/renderer/src/assets/base.css +++ b/desktop/src/renderer/src/assets/base.css @@ -12,7 +12,6 @@ --ev-c-gray-1: #515c67; --ev-c-gray-2: #414853; --ev-c-gray-3: #32363f; - --ev-c-gray-4: #d9d9d9; --ev-c-text-1: #2c2d30; --ev-c-text-2: rgba(235, 235, 245, 0.6); diff --git a/desktop/src/renderer/src/assets/main.css b/desktop/src/renderer/src/assets/main.css index eb7b5d1a..9b2d8ec0 100644 --- a/desktop/src/renderer/src/assets/main.css +++ b/desktop/src/renderer/src/assets/main.css @@ -70,21 +70,6 @@ code { font-weight: 600; } -.file-list-button { - background-color: var(--ev-c-white-mute); - color: var(--ev-c-black); - padding: 5px 30px; - text-align: center; - display: inline-block; - font-size: 16px; - border-radius: 6px; - transition-duration: 0.4s; - border: 1.5px solid var(--ev-c-black); -} -.file-list-button:hover { - background-color: var(--ev-c-gray-4); -} - .vpn-popup-overlay { position: fixed; top: 0; diff --git a/desktop/src/renderer/src/components/file-list/ContinueButton.tsx b/desktop/src/renderer/src/components/file-list/ContinueButton.tsx index b80da634..8a542d71 100644 --- a/desktop/src/renderer/src/components/file-list/ContinueButton.tsx +++ b/desktop/src/renderer/src/components/file-list/ContinueButton.tsx @@ -6,7 +6,11 @@ export const ContinueButton = (): JSX.Element => { }; return ( - ); diff --git a/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx b/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx index af4914f7..c377768f 100644 --- a/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx +++ b/desktop/src/renderer/src/components/file-list/SelectFolderButton.tsx @@ -12,7 +12,11 @@ export const SelectFolderButton = ({ onRowChange }): JSX.Element => { }; return ( - ); From 7b0d642af3d6ecc9f57252fbd167d7d926596262 Mon Sep 17 00:00:00 2001 From: BradyMitch Date: Wed, 20 Nov 2024 09:41:23 -0800 Subject: [PATCH 09/12] Styling and add row changes --- .../file-list/FolderDisplayGrid.tsx | 21 +++++---- .../file-list/SelectFolderButton.tsx | 2 +- desktop/src/renderer/src/pages/FileList.tsx | 43 +++++++++++++------ 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/desktop/src/renderer/src/components/file-list/FolderDisplayGrid.tsx b/desktop/src/renderer/src/components/file-list/FolderDisplayGrid.tsx index 842c6490..81452786 100644 --- a/desktop/src/renderer/src/components/file-list/FolderDisplayGrid.tsx +++ b/desktop/src/renderer/src/components/file-list/FolderDisplayGrid.tsx @@ -3,6 +3,7 @@ import { type GridColDef, useGridApiContext, type GridRenderEditCellParams, + type useGridApiRef, } from "@mui/x-data-grid"; import { HighlightOff as DeleteIcon, @@ -72,9 +73,10 @@ const GridEditDateCell = ({ type Props = { rows: FolderRow[]; onFolderDelete: (folder: string) => Promise | void; + apiRef: ReturnType; }; -export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => { +export const FolderDisplayGrid = ({ rows, onFolderDelete, apiRef }: Props) => { const theme = useTheme(); const columns: GridColDef<(typeof rows)[number]>[] = [ { @@ -94,22 +96,22 @@ export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => { ), }, - { field: "folder", headerName: "Folder", width: 150 }, - { field: "schedule", headerName: "Schedule", width: 90, editable: true }, + { field: "folder", headerName: "Folder", width: 200 }, + { field: "schedule", headerName: "Schedule", width: 110, editable: true }, { field: "classification", headerName: "Primary/Secondary", width: 150, editable: true }, - { field: "file", headerName: "FILE", width: 100, editable: true }, + { field: "file", headerName: "FILE ID", width: 90, editable: true }, { field: "opr", headerName: "OPR", type: "boolean", description: "Office of Primary Responsibility", - width: 80, + width: 60, editable: true, }, { field: "startDate", headerName: "Start Date", - width: 135, + width: 125, editable: true, renderEditCell: (params) => , valueFormatter: (value) => { @@ -122,7 +124,7 @@ export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => { { field: "endDate", headerName: "End Date", - width: 135, + width: 125, editable: true, renderEditCell: (params) => , valueFormatter: (value) => { @@ -135,7 +137,7 @@ export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => { { field: "soDate", headerName: "SO Date", - width: 135, + width: 125, editable: true, renderEditCell: (params) => , valueFormatter: (value) => { @@ -148,7 +150,7 @@ export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => { { field: "fdDate", headerName: "FD Date", - width: 135, + width: 125, editable: true, renderEditCell: (params) => , valueFormatter: (value) => { @@ -182,6 +184,7 @@ export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => { { style={{ justifyContent: "center", width: "15%" }} onPress={handleClick} > - Select Folders + Select Folder(s) ); }; diff --git a/desktop/src/renderer/src/pages/FileList.tsx b/desktop/src/renderer/src/pages/FileList.tsx index 213f1987..12aa67b4 100644 --- a/desktop/src/renderer/src/pages/FileList.tsx +++ b/desktop/src/renderer/src/pages/FileList.tsx @@ -6,42 +6,56 @@ import { ContinueButton, } from "@renderer/components/file-list"; import { useState } from "react"; +import { useGridApiRef } from "@mui/x-data-grid"; export const FileListPage = () => { - //@ts-ignore const [rows, setRows] = useState([]); const theme = useTheme(); + const apiRef = useGridApiRef(); + const onFolderDelete = (folder: string) => { alert(folder); // TBD }; - function handleAddPathArrayToRows(inPaths) { + const handleAddPathArrayToRows = (inputPaths: string[]) => { const newRows: FolderRow[] = [...rows]; - let index = rows.length; + let index = rows.length; // Start IDs based on the current rows + const newRowIds: number[] = []; // Track IDs of the newly added rows + try { - for (let i = 0; i < inPaths.length; i++) { + for (let i = 0; i < inputPaths.length; i++) { const curFolderRow: FolderRow = { - id: index, - folder: inPaths[i], - schedule: "TestSchedule", - classification: "TestClassification", - file: "TestFILE", - opr: true, + id: index, // Unique IDs for new rows + folder: inputPaths[i], + schedule: "", + classification: "", + file: "", + opr: false, startDate: null, endDate: null, soDate: null, fdDate: null, progress: 0, }; + newRowIds.push(index); // Track new row IDs index++; newRows.push(curFolderRow); } setRows(newRows); + + // Set all newly added rows to edit mode + if (apiRef.current && newRowIds.length > 0) { + setTimeout(() => { + newRowIds.forEach((rowId) => { + apiRef.current.startRowEditMode({ id: rowId }); + }); + }); + } } catch (error) { - setRows(rows); - console.log("Hit error"); + setRows(rows); // Revert rows on error + console.log("Hit error:", error); } - } + }; return ( <> @@ -50,6 +64,7 @@ export const FileListPage = () => { minHeight: "7vh", display: "flex", justifyContent: "flex-end", + gap: 1, padding: 2, flexShrink: 0, background: `${theme.palette.primary}`, @@ -66,7 +81,7 @@ export const FileListPage = () => { background: `${theme.palette.primary}`, }} > - + ); From bbaefd376d1b04bbb67f17c20b0bd08e737a4cda Mon Sep 17 00:00:00 2001 From: taylorfries Date: Thu, 21 Nov 2024 08:22:02 -0800 Subject: [PATCH 10/12] on matching file path dont readd --- desktop/src/renderer/src/pages/FileList.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/desktop/src/renderer/src/pages/FileList.tsx b/desktop/src/renderer/src/pages/FileList.tsx index 12aa67b4..81f8a4cf 100644 --- a/desktop/src/renderer/src/pages/FileList.tsx +++ b/desktop/src/renderer/src/pages/FileList.tsx @@ -24,9 +24,19 @@ export const FileListPage = () => { try { for (let i = 0; i < inputPaths.length; i++) { + const currentFolderPath = inputPaths[i]; + let skipFlag = false; + + // check if file path is already in the rows + for (let j = 0; j < rows.length; j++) { + if (currentFolderPath === rows[j].folder) skipFlag = true; + } + // if the path is already in the list, skip it + if (skipFlag === true) continue; + const curFolderRow: FolderRow = { id: index, // Unique IDs for new rows - folder: inputPaths[i], + folder: currentFolderPath, schedule: "", classification: "", file: "", @@ -37,10 +47,13 @@ export const FileListPage = () => { fdDate: null, progress: 0, }; - newRowIds.push(index); // Track new row IDs + // Track new row IDs + newRowIds.push(index); index++; + // add new folder row to list to be displayed newRows.push(curFolderRow); } + // set the new list of folder rows setRows(newRows); // Set all newly added rows to edit mode From adc8c918ce337713a05dc06ffe579a745d6d63a5 Mon Sep 17 00:00:00 2001 From: Brandon Bouchard Date: Thu, 21 Nov 2024 08:33:41 -0800 Subject: [PATCH 11/12] Specifies desktop/package.json in desk app release wf. --- .github/workflows/desktop-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/desktop-release.yaml b/.github/workflows/desktop-release.yaml index df987eee..953806f4 100644 --- a/.github/workflows/desktop-release.yaml +++ b/.github/workflows/desktop-release.yaml @@ -45,7 +45,7 @@ jobs: run: | git config --global user.name "${{ github.actor }}" git config --global user.email "${{ github.actor }}@users.noreply.github.com" - git add package.json + git add desktop/package.json git commit -m "Bumped version to ${{ steps.package_version.outputs.VERSION }}" git remote set-url origin https://x-access-token:${{ secrets.GIT_PAT }}@github.com/${{ github.repository }} git push origin main From 25f4ef23dc269415373934ecfa85749f9de032dc Mon Sep 17 00:00:00 2001 From: Bottle7 Date: Thu, 21 Nov 2024 17:04:35 +0000 Subject: [PATCH 12/12] Bumped version to 0.0.1 --- desktop/package.json | 148 +++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/desktop/package.json b/desktop/package.json index c07da081..8b9e0f21 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -1,76 +1,76 @@ { - "name": "dats", - "version": "0.0.0", - "description": "Digital Archives Transfer Service", - "author": "CITZ IMB/CIRMO", - "main": "./out/main/index.js", - "type": "module", - "build": { - "extraFiles": [ - { - "from": "out/cjs-workers/copyWorker.cjs", - "to": "resources/copyWorker.cjs" - }, - { - "from": "out/cjs-workers/metadataWorker.cjs", - "to": "resources/metadataWorker.cjs" - } - ], - "publish": [ - { - "provider": "github", - "owner": "bcgov", - "repo": "citz-grs-dats" - } - ], - "productName": "DATS" - }, - "scripts": { - "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false", - "typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false", - "typecheck": "npm run typecheck:node && npm run typecheck:web", - "dev": "electron-vite dev", - "build": "npm run typecheck && electron-vite build && npm run build:workers", - "build:workers": "vite build --config es.workers.vite.config.ts && vite build --config cjs.workers.vite.config.ts", - "postinstall": "electron-builder install-app-deps", - "build:unpack": "npm run build && electron-builder --dir", - "build:win": "npm run build && electron-builder --win", - "build:mac": "electron-vite build && electron-builder --mac", - "build:linux": "electron-vite build && electron-builder --linux", - "bump:patch": "node bump-version patch", - "bump:minor": "node bump-version minor", - "bump:major": "node bump-version major" - }, - "dependencies": { - "@bcgov/bc-sans": "2.1.0", - "@bcgov/citz-imb-sso-js-core": "1.0.0", - "@bcgov/design-system-react-components": "0.4.0", - "@electron-toolkit/preload": "3.0.1", - "@electron-toolkit/utils": "3.0.0", - "electron-cookies": "1.1.0", - "electron-updater": "6.3.9", - "@emotion/react": "11.13.3", - "@emotion/styled": "11.13.0", - "@mui/icons-material": "6.1.6", - "@mui/material": "6.1.6", - "@mui/x-data-grid": "7.22.1", - "@mui/x-date-pickers": "7.22.2", - "dayjs": "1.11.13", - "react-router-dom": "6.27.0" - }, - "devDependencies": { - "@biomejs/biome": "1.9.3", - "@electron-toolkit/tsconfig": "1.0.1", - "@types/node": "20.14.8", - "@types/react": "18.3.3", - "@types/react-dom": "18.3.0", - "@vitejs/plugin-react": "4.3.1", - "electron": "31.0.2", - "electron-builder": "24.13.3", - "electron-vite": "2.3.0", - "react": "18.3.1", - "react-dom": "18.3.1", - "typescript": "5.5.2", - "vite": "5.3.1" - } + "name": "dats", + "version": "0.0.1", + "description": "Digital Archives Transfer Service", + "author": "CITZ IMB/CIRMO", + "main": "./out/main/index.js", + "type": "module", + "build": { + "extraFiles": [ + { + "from": "out/cjs-workers/copyWorker.cjs", + "to": "resources/copyWorker.cjs" + }, + { + "from": "out/cjs-workers/metadataWorker.cjs", + "to": "resources/metadataWorker.cjs" + } + ], + "publish": [ + { + "provider": "github", + "owner": "bcgov", + "repo": "citz-grs-dats" + } + ], + "productName": "DATS" + }, + "scripts": { + "typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false", + "typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false", + "typecheck": "npm run typecheck:node && npm run typecheck:web", + "dev": "electron-vite dev", + "build": "npm run typecheck && electron-vite build && npm run build:workers", + "build:workers": "vite build --config es.workers.vite.config.ts && vite build --config cjs.workers.vite.config.ts", + "postinstall": "electron-builder install-app-deps", + "build:unpack": "npm run build && electron-builder --dir", + "build:win": "npm run build && electron-builder --win", + "build:mac": "electron-vite build && electron-builder --mac", + "build:linux": "electron-vite build && electron-builder --linux", + "bump:patch": "node bump-version patch", + "bump:minor": "node bump-version minor", + "bump:major": "node bump-version major" + }, + "dependencies": { + "@bcgov/bc-sans": "2.1.0", + "@bcgov/citz-imb-sso-js-core": "1.0.0", + "@bcgov/design-system-react-components": "0.4.0", + "@electron-toolkit/preload": "3.0.1", + "@electron-toolkit/utils": "3.0.0", + "electron-cookies": "1.1.0", + "electron-updater": "6.3.9", + "@emotion/react": "11.13.3", + "@emotion/styled": "11.13.0", + "@mui/icons-material": "6.1.6", + "@mui/material": "6.1.6", + "@mui/x-data-grid": "7.22.1", + "@mui/x-date-pickers": "7.22.2", + "dayjs": "1.11.13", + "react-router-dom": "6.27.0" + }, + "devDependencies": { + "@biomejs/biome": "1.9.3", + "@electron-toolkit/tsconfig": "1.0.1", + "@types/node": "20.14.8", + "@types/react": "18.3.3", + "@types/react-dom": "18.3.0", + "@vitejs/plugin-react": "4.3.1", + "electron": "31.0.2", + "electron-builder": "24.13.3", + "electron-vite": "2.3.0", + "react": "18.3.1", + "react-dom": "18.3.1", + "typescript": "5.5.2", + "vite": "5.3.1" + } }