Skip to content

Commit

Permalink
Merge branch 'main' into DAP-986-consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyMitch committed Nov 21, 2024
2 parents 8e84c69 + d43c29a commit ac01558
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/desktop-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
148 changes: 74 additions & 74 deletions desktop/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
1 change: 1 addition & 0 deletions desktop/src/main/fileProcessing/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./copyFolderAndMetadata";
export * from "./getFolderMetadata";
export * from "./selectDirectory";
23 changes: 23 additions & 0 deletions desktop/src/main/fileProcessing/actions/selectDirectory.ts
Original file line number Diff line number Diff line change
@@ -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;
};
12 changes: 11 additions & 1 deletion desktop/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { is } from "@electron-toolkit/utils";
import icon from "../../resources/icon.png?asset";
import electronUpdater, { type AppUpdater } from "electron-updater";
import { createWorkerPool } from "./fileProcessing";
import { copyFolderAndMetadata, getFolderMetadata } from "./fileProcessing/actions";
import {
copyFolderAndMetadata,
getFolderMetadata,
selectDirectory,
} from "./fileProcessing/actions";

app.setName("Digital Archives Transfer Service");

Expand Down Expand Up @@ -193,6 +197,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.");

Expand Down
1 change: 1 addition & 0 deletions desktop/src/preload/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare global {
checkApiStatus: (url: string) => Promise<boolean>;
checkIpRange: () => Promise<boolean>;
getCurrentApiUrl: () => Promise<string>;
selectDirectory: () => Promise<string[]>;

sso: {
startLoginProcess: () => Promise<void>;
Expand Down
1 change: 1 addition & 0 deletions desktop/src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const api = {
checkApiStatus,
checkIpRange,
getCurrentApiUrl: () => ipcRenderer.invoke("get-current-api-url"),
selectDirectory: () => ipcRenderer.invoke("select-directory"),
sso: {
getUser,
fetchProtectedRoute,
Expand Down
1 change: 0 additions & 1 deletion desktop/src/renderer/src/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ ul {
body {
width: 100%;
height: 100%;
overflow: hidden;
user-select: none;
border-top: 1px solid #e3e3e3;
min-height: 100vh;
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/renderer/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ body {
height: 100%;
min-width: 100vh;
min-height: 100vh;
overflow: hidden;
overflow: scroll;
user-select: none;
}

Expand Down
17 changes: 17 additions & 0 deletions desktop/src/renderer/src/components/file-list/ContinueButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Button } from "@bcgov/design-system-react-components";

export const ContinueButton = (): JSX.Element => {
const handleClick = async () => {
console.log("TODO: THIS");
};

return (
<Button
variant="primary"
style={{ justifyContent: "center", width: "15%" }}
onPress={handleClick}
>
Continue
</Button>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
type GridColDef,
useGridApiContext,
type GridRenderEditCellParams,
type useGridApiRef,
} from "@mui/x-data-grid";
import {
HighlightOff as DeleteIcon,
Expand Down Expand Up @@ -72,9 +73,10 @@ const GridEditDateCell = ({
type Props = {
rows: FolderRow[];
onFolderDelete: (folder: string) => Promise<void> | void;
apiRef: ReturnType<typeof useGridApiRef>;
};

export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => {
export const FolderDisplayGrid = ({ rows, onFolderDelete, apiRef }: Props) => {
const theme = useTheme();
const columns: GridColDef<(typeof rows)[number]>[] = [
{
Expand All @@ -94,22 +96,22 @@ export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => {
</Box>
),
},
{ 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) => <GridEditDateCell {...params} />,
valueFormatter: (value) => {
Expand All @@ -122,7 +124,7 @@ export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => {
{
field: "endDate",
headerName: "End Date",
width: 135,
width: 125,
editable: true,
renderEditCell: (params) => <GridEditDateCell {...params} />,
valueFormatter: (value) => {
Expand All @@ -135,7 +137,7 @@ export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => {
{
field: "soDate",
headerName: "SO Date",
width: 135,
width: 125,
editable: true,
renderEditCell: (params) => <GridEditDateCell {...params} />,
valueFormatter: (value) => {
Expand All @@ -148,7 +150,7 @@ export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => {
{
field: "fdDate",
headerName: "FD Date",
width: 135,
width: 125,
editable: true,
renderEditCell: (params) => <GridEditDateCell {...params} />,
valueFormatter: (value) => {
Expand Down Expand Up @@ -182,6 +184,7 @@ export const FolderDisplayGrid = ({ rows, onFolderDelete }: Props) => {
<DataGrid
rows={rows}
columns={columns}
apiRef={apiRef}
disableRowSelectionOnClick
disableColumnFilter
disableColumnMenu
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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

const handleClick = async () => {
const result = await api.selectDirectory();

onRowChange(result);
return result;
};

return (
<Button
variant="primary"
style={{ justifyContent: "center", width: "15%" }}
onPress={handleClick}
>
Select Folder(s)
</Button>
);
};
2 changes: 2 additions & 0 deletions desktop/src/renderer/src/components/file-list/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from "./FolderDisplayGrid";
export * from "./SelectFolderButton";
export * from "./ContinueButton";
Loading

0 comments on commit ac01558

Please sign in to comment.