Skip to content

Commit b29b423

Browse files
committed
Merge branch 'file-explorer-rework-final' into staging
2 parents ca8baa8 + d0124ea commit b29b423

File tree

4 files changed

+130
-44
lines changed

4 files changed

+130
-44
lines changed

assets/css/file_views.css

+21-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
width: 100%;
44
flex-direction: column;
55
align-items: center;
6-
height: 300px;
6+
max-height: 300px;
77
overflow-y: auto;
88
margin-bottom: 5px;
9+
border: 2px solid var(--color-light-green);
10+
margin-top: 5px;
11+
margin-bottom: 5px;
912
}
1013

1114
.swal-file-row {
@@ -14,9 +17,24 @@
1417
width: 100%;
1518
align-items: flex-start;
1619
padding: 2px;
17-
border-bottom: 1px solid #eee;
20+
}
21+
/* Add borders to swal file row in swal file list besides the top border for first element and bottom border for last element */
22+
.swal-file-row:not(:first-child) {
23+
border-top: 1px solid #eee;
1824
}
1925

2026
.swal-file-text {
21-
font-size: 14px;
27+
font-size: 12px;
28+
}
29+
30+
.swal-confirm-button {
31+
background-color: var(--color-light-green) !important;
32+
}
33+
34+
.swal-deny-button {
35+
background-color: #757575 !important;
36+
}
37+
38+
.swal-cancel-button {
39+
background-color: red !important;
2240
}

main.js

-3
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,6 @@ let user_restart_confirmed = false;
244244
let updatechecked = false;
245245
let window_reloaded = false;
246246
function initialize() {
247-
const checkForAnnouncements = () => {
248-
mainWindow.webContents.send("checkForAnnouncements");
249-
};
250247
sendUserAnalytics();
251248
makeSingleInstance();
252249
loadDemos();

scripts/guided-mode/guided-curate-dataset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7281,7 +7281,7 @@ const guidedGetPageToReturnTo = (sodaJSONObj) => {
72817281
// If the last time the user worked on the progress file was in a previous version of SODA, then force the user to restart from the first page
72827282
return firstPageID;
72837283
}
7284-
console.log(guidedCheckIfUserNeedsToReconfirmAccountDetails());
7284+
72857285
if (guidedCheckIfUserNeedsToReconfirmAccountDetails() === true) {
72867286
return "guided-pennsieve-intro-tab";
72877287
}

scripts/others/renderer.js

+108-37
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,6 @@ contact_us_lottie_observer.observe(contact_section, {
236236

237237
document.getElementById("guided_mode_view").click();
238238

239-
ipcRenderer.on("checkForAnnouncements", () => {
240-
console.log("CHecking for announcements");
241-
});
242-
243239
// check for announcements on startup; if the user is in the auto update workflow do not check for announcements
244240
// Rationale: The auto update workflow involves refreshing the DOM which will cause a re-run of
245241
// the renderer process. One potential outcome of this is the renderer reaches this code block before the refresh
@@ -375,6 +371,16 @@ const notyf = new Notyf({
375371
duration: 3000,
376372
},
377373

374+
{
375+
type: "info-grey",
376+
background: "grey",
377+
icon: {
378+
className: "fas fa-info-circle",
379+
tagName: "i",
380+
color: "white",
381+
},
382+
},
383+
378384
{
379385
type: "app_update_warning",
380386
background: "#fa8c16",
@@ -513,10 +519,7 @@ const startupServerAndApiCheck = async () => {
513519
app.exit();
514520
}
515521

516-
// let nodeStorage = new JSONStorage(app.getPath("userData"));
517-
// launchAnnouncement = nodeStorage.getItem("announcements");
518522
if (launchAnnouncement) {
519-
// nodeStorage.setItem("announcements", false);
520523
console.log("Checking for announcements on base startup");
521524
await checkForAnnouncements("announcements");
522525
launchAnnouncement = false;
@@ -996,11 +999,7 @@ const run_pre_flight_checks = async (check_update = true) => {
996999
}
9971000
}
9981001

999-
// let nodeStorage = new JSONStorage(app.getPath("userData"));
1000-
// launchAnnouncement = nodeStorage.getItem("announcements");
10011002
if (launchAnnouncement) {
1002-
// nodeStorage.setItem("announcements", false);
1003-
console.log("Checking for announcements on base startup");
10041003
await checkForAnnouncements("announcements");
10051004
launchAnnouncement = false;
10061005
}
@@ -1381,7 +1380,6 @@ ipcRenderer.on("update_downloaded", async () => {
13811380
update_downloaded_notification.on("click", async ({ target, event }) => {
13821381
restartApp();
13831382
//a sweet alert will pop up announcing user to manually update if SODA fails to restart
1384-
console.log("Checking for announcements on auto update startup");
13851383
checkForAnnouncements("update");
13861384
});
13871385
});
@@ -4946,7 +4944,7 @@ const swalFileListSingleAction = async (fileList, title, helpText, postActionTex
49464944
});
49474945
};
49484946

4949-
const swalFileListConfirmAction = async (
4947+
const swalFileListDoubleAction = async (
49504948
fileList,
49514949
title,
49524950
helpText,
@@ -4959,7 +4957,11 @@ const swalFileListConfirmAction = async (
49594957
html: `
49604958
${helpText}
49614959
<div class="swal-file-list">
4962-
${fileList.map((file) => `<div class="swal-file-row">${file}</div>`).join("")}
4960+
${fileList
4961+
.map(
4962+
(file) => `<div class="swal-file-row"><span class="swal-file-text">${file}</span></div>`
4963+
)
4964+
.join("")}
49634965
</div>
49644966
<b>${confirmationText}</b>
49654967
`,
@@ -4976,6 +4978,57 @@ const swalFileListConfirmAction = async (
49764978
return action;
49774979
};
49784980

4981+
const swalFileListTripleAction = async (
4982+
fileList,
4983+
title,
4984+
helpText,
4985+
confirmButtonText,
4986+
denyButtonText,
4987+
cancelButtonText,
4988+
confirmationText
4989+
) => {
4990+
const { value: action } = await Swal.fire({
4991+
title: title,
4992+
html: `
4993+
${helpText}
4994+
<div class="swal-file-list">
4995+
${fileList
4996+
.map(
4997+
(file) => `<div class="swal-file-row"><span class="swal-file-text">${file}</span></div>`
4998+
)
4999+
.join("")}
5000+
</div>
5001+
<b>${confirmationText}</b>
5002+
`,
5003+
width: 800,
5004+
heightAuto: false,
5005+
backdrop: "rgba(0,0,0, 0.4)",
5006+
allowOutsideClick: false,
5007+
allowEscapeKey: false,
5008+
showCloseButton: false,
5009+
showCancelButton: true,
5010+
showDenyButton: true,
5011+
confirmButtonText: confirmButtonText,
5012+
denyButtonText: denyButtonText,
5013+
cancelButtonText: cancelButtonText,
5014+
customClass: {
5015+
confirmButton: "swal-confirm-button",
5016+
denyButton: "swal-deny-button",
5017+
cancelButton: "swal-cancel-button",
5018+
},
5019+
});
5020+
if (action === true) {
5021+
console.log("confirmed");
5022+
return "confirm";
5023+
} else if (action === false) {
5024+
console.log("denied");
5025+
return "deny";
5026+
} else {
5027+
console.log("cancelled");
5028+
return "cancel";
5029+
}
5030+
};
5031+
49795032
const namesOfForbiddenFiles = {
49805033
".DS_Store": true,
49815034
"Thumbs.db": true,
@@ -5137,8 +5190,6 @@ const buildDatasetStructureJsonFromImportedData = async (itemPaths, currentFileE
51375190
}
51385191
}
51395192
} catch (error) {
5140-
console.log("Error accessing path", pathToExplore, error);
5141-
// If the path is inaccessible by Node, add it to the inaccessibleItems array
51425193
inaccessibleItems.push(pathToExplore);
51435194
}
51445195
};
@@ -5165,58 +5216,81 @@ const buildDatasetStructureJsonFromImportedData = async (itemPaths, currentFileE
51655216
console.log("forbiddenFileNames", forbiddenFileNames);
51665217
await swalFileListSingleAction(
51675218
forbiddenFileNames.map((file) => file.relativePath),
5168-
"Forbidden file names were found in your import",
5219+
"Forbidden file names detected",
51695220
"The files listed below do not comply with the SPARC data standards and will not be imported:",
51705221
false
51715222
);
51725223
}
51735224

51745225
if (problematicFolderNames.length > 0) {
5175-
const replaceFolderNames = await swalFileListConfirmAction(
5226+
const userResponse = await swalFileListTripleAction(
51765227
problematicFolderNames,
5177-
"<p>Folders that do not comply with the SPARC data standards were found in your import</p>",
5228+
"<p>Folder name modifications</p>",
51785229
`The folders listed below contain the special characters "#", "&", "%", or "+"
51795230
which are typically not recommended per the SPARC data standards.
51805231
You may choose to either keep them as is, or replace the characters with '-'.
51815232
`,
51825233
"Replace the special characters with '-'",
51835234
"Keep the folder names as they are",
5235+
"Cancel import",
51845236
"What would you like to do with the folders with special characters?"
51855237
);
5186-
if (replaceFolderNames) {
5238+
if (userResponse === "confirm") {
51875239
replaceProblematicFoldersWithSDSCompliantNames(datasetStructure);
51885240
}
5241+
// If the userResponse is "deny", nothing needs to be done
5242+
if (userResponse === "cancel") {
5243+
throw new Error("Importation cancelled");
5244+
}
51895245
}
51905246

51915247
if (problematicFileNames.length > 0) {
5192-
const replaceFileNames = await swalFileListConfirmAction(
5248+
const userResponse = await swalFileListTripleAction(
51935249
problematicFileNames.map((file) => file.relativePath),
5194-
"<p>Files that do not comply with the SPARC data standards were found in your import</p>",
5250+
"<p>File name modifications</p>",
51955251
`The files listed below contain the special characters "#", "&", "%", or "+"
51965252
which are typically not recommended per the SPARC data standards.
51975253
You may choose to either keep them as is, or replace the characters with '-'.
51985254
`,
51995255
"Replace the special characters with '-'",
52005256
"Keep the file names as they are",
5257+
"Cancel import",
52015258
"What would you like to do with the files with special characters?"
52025259
);
5203-
if (replaceFileNames) {
5260+
if (userResponse === "confirm") {
52045261
replaceProblematicFilesWithSDSCompliantNames(datasetStructure);
52055262
}
5263+
// If the userResponse is "deny", nothing needs to be done
5264+
if (userResponse === "cancel") {
5265+
throw new Error("Importation cancelled");
5266+
}
52065267
}
52075268

52085269
if (hiddenItems.length > 0) {
5209-
const keepHiddenFiles = await swalFileListConfirmAction(
5270+
const userResponse = await swalFileListTripleAction(
52105271
hiddenItems.map((file) => file.relativePath),
5211-
"<p>Hidden files were found in your import</p>",
5272+
"<p>Hidden files detected</p>",
52125273
`Hidden files are typically not recommend per the SPARC data standards, but you can choose to keep them if you wish.`,
52135274
"Import the hidden files into SODA",
52145275
"Do not import the hidden files",
5276+
"Cancel import",
52155277
"What would you like to do with the hidden files?"
52165278
);
5217-
if (!keepHiddenFiles) {
5279+
// If the userResponse is "confirm", nothing needs to be done
5280+
if (userResponse === "deny") {
52185281
removeHiddenFilesFromDatasetStructure(datasetStructure);
52195282
}
5283+
if (userResponse === "cancel") {
5284+
throw new Error("Importation cancelled");
5285+
}
5286+
}
5287+
5288+
// If the dataset structure is empty after processing the imported files and folders, throw an error
5289+
if (
5290+
Object.keys(datasetStructure?.["folders"]).length === 0 &&
5291+
Object.keys(datasetStructure?.["files"]).length === 0
5292+
) {
5293+
throw new Error("Error building dataset structure");
52205294
}
52215295

52225296
return datasetStructure;
@@ -5283,9 +5357,9 @@ const mergeLocalAndRemoteDatasetStructure = async (
52835357
closeFileImportLoadingSweetAlert();
52845358

52855359
if (duplicateFiles.length > 0) {
5286-
const userConfirmedFileOverwrite = await swalFileListConfirmAction(
5360+
const userConfirmedFileOverwrite = await swalFileListDoubleAction(
52875361
duplicateFiles.map((file) => `${file.virtualFilePath}${file.fileName}`),
5288-
"Some files being imported already exist in your dataset",
5362+
"Duplicate files detected",
52895363
`
52905364
You have two options for the duplicate files:
52915365
<br />
@@ -5372,14 +5446,11 @@ const addDataArrayToDatasetStructureAtPath = async (importedData) => {
53725446
// STEP 1: Build the JSON object from the imported data
53735447
// (This function handles bad folders/files, inaccessible folders/files, etc and returns a clean dataset structure)
53745448
const currentFileExplorerPath = organizeDSglobalPath.value.trim();
5449+
53755450
const builtDatasetStructure = await buildDatasetStructureJsonFromImportedData(
53765451
importedData,
53775452
currentFileExplorerPath
53785453
);
5379-
// Throw if the dataset structure generated does not contain folders or files
5380-
if (!builtDatasetStructure?.["folders"] || !builtDatasetStructure?.["files"]) {
5381-
throw new Error("Error building dataset structure");
5382-
}
53835454

53845455
// Step 2: Add the imported data to the dataset structure (This function handles duplicate files, etc)
53855456
await mergeLocalAndRemoteDatasetStructure(builtDatasetStructure, currentFileExplorerPath);
@@ -5400,11 +5471,10 @@ const addDataArrayToDatasetStructureAtPath = async (importedData) => {
54005471
duration: 3000,
54015472
});
54025473
} catch (error) {
5403-
console.log(error);
54045474
closeFileImportLoadingSweetAlert();
54055475
notyf.open({
5406-
type: "error",
5407-
message: `Error importing data`,
5476+
type: error.message === "Importation cancelled" ? "info-grey" : "error",
5477+
message: error.message || "Error importing data",
54085478
duration: 3000,
54095479
});
54105480
}
@@ -5462,14 +5532,15 @@ const drop = async (ev) => {
54625532
);
54635533
return;
54645534
} else {
5465-
const importAccessibleItemsOnly = await swalFileListConfirmAction(
5466-
inaccessibleItems,
5535+
const importAccessibleItemsOnly = await swalFileListDoubleAction(
5536+
accessibleItems,
54675537
"<p>SODA was unable to import some of your dropped files/folders</p>",
54685538
"A list of the folders/files that SODA was not able to import is shown below:",
54695539
"Yes, continue with the import",
54705540
"No, cancel the import",
54715541
"Would you like to continue the import without these folders/files?"
54725542
);
5543+
54735544
if (!importAccessibleItemsOnly) {
54745545
return;
54755546
}

0 commit comments

Comments
 (0)