@@ -236,10 +236,6 @@ contact_us_lottie_observer.observe(contact_section, {
236
236
237
237
document . getElementById ( "guided_mode_view" ) . click ( ) ;
238
238
239
- ipcRenderer . on ( "checkForAnnouncements" , ( ) => {
240
- console . log ( "CHecking for announcements" ) ;
241
- } ) ;
242
-
243
239
// check for announcements on startup; if the user is in the auto update workflow do not check for announcements
244
240
// Rationale: The auto update workflow involves refreshing the DOM which will cause a re-run of
245
241
// 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({
375
371
duration : 3000 ,
376
372
} ,
377
373
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
+
378
384
{
379
385
type : "app_update_warning" ,
380
386
background : "#fa8c16" ,
@@ -513,10 +519,7 @@ const startupServerAndApiCheck = async () => {
513
519
app . exit ( ) ;
514
520
}
515
521
516
- // let nodeStorage = new JSONStorage(app.getPath("userData"));
517
- // launchAnnouncement = nodeStorage.getItem("announcements");
518
522
if ( launchAnnouncement ) {
519
- // nodeStorage.setItem("announcements", false);
520
523
console . log ( "Checking for announcements on base startup" ) ;
521
524
await checkForAnnouncements ( "announcements" ) ;
522
525
launchAnnouncement = false ;
@@ -996,11 +999,7 @@ const run_pre_flight_checks = async (check_update = true) => {
996
999
}
997
1000
}
998
1001
999
- // let nodeStorage = new JSONStorage(app.getPath("userData"));
1000
- // launchAnnouncement = nodeStorage.getItem("announcements");
1001
1002
if ( launchAnnouncement ) {
1002
- // nodeStorage.setItem("announcements", false);
1003
- console . log ( "Checking for announcements on base startup" ) ;
1004
1003
await checkForAnnouncements ( "announcements" ) ;
1005
1004
launchAnnouncement = false ;
1006
1005
}
@@ -1381,7 +1380,6 @@ ipcRenderer.on("update_downloaded", async () => {
1381
1380
update_downloaded_notification . on ( "click" , async ( { target, event } ) => {
1382
1381
restartApp ( ) ;
1383
1382
//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" ) ;
1385
1383
checkForAnnouncements ( "update" ) ;
1386
1384
} ) ;
1387
1385
} ) ;
@@ -4946,7 +4944,7 @@ const swalFileListSingleAction = async (fileList, title, helpText, postActionTex
4946
4944
} ) ;
4947
4945
} ;
4948
4946
4949
- const swalFileListConfirmAction = async (
4947
+ const swalFileListDoubleAction = async (
4950
4948
fileList ,
4951
4949
title ,
4952
4950
helpText ,
@@ -4959,7 +4957,11 @@ const swalFileListConfirmAction = async (
4959
4957
html : `
4960
4958
${ helpText }
4961
4959
<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 ( "" ) }
4963
4965
</div>
4964
4966
<b>${ confirmationText } </b>
4965
4967
` ,
@@ -4976,6 +4978,57 @@ const swalFileListConfirmAction = async (
4976
4978
return action ;
4977
4979
} ;
4978
4980
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
+
4979
5032
const namesOfForbiddenFiles = {
4980
5033
".DS_Store" : true ,
4981
5034
"Thumbs.db" : true ,
@@ -5137,8 +5190,6 @@ const buildDatasetStructureJsonFromImportedData = async (itemPaths, currentFileE
5137
5190
}
5138
5191
}
5139
5192
} catch ( error ) {
5140
- console . log ( "Error accessing path" , pathToExplore , error ) ;
5141
- // If the path is inaccessible by Node, add it to the inaccessibleItems array
5142
5193
inaccessibleItems . push ( pathToExplore ) ;
5143
5194
}
5144
5195
} ;
@@ -5165,58 +5216,81 @@ const buildDatasetStructureJsonFromImportedData = async (itemPaths, currentFileE
5165
5216
console . log ( "forbiddenFileNames" , forbiddenFileNames ) ;
5166
5217
await swalFileListSingleAction (
5167
5218
forbiddenFileNames . map ( ( file ) => file . relativePath ) ,
5168
- "Forbidden file names were found in your import " ,
5219
+ "Forbidden file names detected " ,
5169
5220
"The files listed below do not comply with the SPARC data standards and will not be imported:" ,
5170
5221
false
5171
5222
) ;
5172
5223
}
5173
5224
5174
5225
if ( problematicFolderNames . length > 0 ) {
5175
- const replaceFolderNames = await swalFileListConfirmAction (
5226
+ const userResponse = await swalFileListTripleAction (
5176
5227
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>" ,
5178
5229
`The folders listed below contain the special characters "#", "&", "%", or "+"
5179
5230
which are typically not recommended per the SPARC data standards.
5180
5231
You may choose to either keep them as is, or replace the characters with '-'.
5181
5232
` ,
5182
5233
"Replace the special characters with '-'" ,
5183
5234
"Keep the folder names as they are" ,
5235
+ "Cancel import" ,
5184
5236
"What would you like to do with the folders with special characters?"
5185
5237
) ;
5186
- if ( replaceFolderNames ) {
5238
+ if ( userResponse === "confirm" ) {
5187
5239
replaceProblematicFoldersWithSDSCompliantNames ( datasetStructure ) ;
5188
5240
}
5241
+ // If the userResponse is "deny", nothing needs to be done
5242
+ if ( userResponse === "cancel" ) {
5243
+ throw new Error ( "Importation cancelled" ) ;
5244
+ }
5189
5245
}
5190
5246
5191
5247
if ( problematicFileNames . length > 0 ) {
5192
- const replaceFileNames = await swalFileListConfirmAction (
5248
+ const userResponse = await swalFileListTripleAction (
5193
5249
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>" ,
5195
5251
`The files listed below contain the special characters "#", "&", "%", or "+"
5196
5252
which are typically not recommended per the SPARC data standards.
5197
5253
You may choose to either keep them as is, or replace the characters with '-'.
5198
5254
` ,
5199
5255
"Replace the special characters with '-'" ,
5200
5256
"Keep the file names as they are" ,
5257
+ "Cancel import" ,
5201
5258
"What would you like to do with the files with special characters?"
5202
5259
) ;
5203
- if ( replaceFileNames ) {
5260
+ if ( userResponse === "confirm" ) {
5204
5261
replaceProblematicFilesWithSDSCompliantNames ( datasetStructure ) ;
5205
5262
}
5263
+ // If the userResponse is "deny", nothing needs to be done
5264
+ if ( userResponse === "cancel" ) {
5265
+ throw new Error ( "Importation cancelled" ) ;
5266
+ }
5206
5267
}
5207
5268
5208
5269
if ( hiddenItems . length > 0 ) {
5209
- const keepHiddenFiles = await swalFileListConfirmAction (
5270
+ const userResponse = await swalFileListTripleAction (
5210
5271
hiddenItems . map ( ( file ) => file . relativePath ) ,
5211
- "<p>Hidden files were found in your import </p>" ,
5272
+ "<p>Hidden files detected </p>" ,
5212
5273
`Hidden files are typically not recommend per the SPARC data standards, but you can choose to keep them if you wish.` ,
5213
5274
"Import the hidden files into SODA" ,
5214
5275
"Do not import the hidden files" ,
5276
+ "Cancel import" ,
5215
5277
"What would you like to do with the hidden files?"
5216
5278
) ;
5217
- if ( ! keepHiddenFiles ) {
5279
+ // If the userResponse is "confirm", nothing needs to be done
5280
+ if ( userResponse === "deny" ) {
5218
5281
removeHiddenFilesFromDatasetStructure ( datasetStructure ) ;
5219
5282
}
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" ) ;
5220
5294
}
5221
5295
5222
5296
return datasetStructure ;
@@ -5283,9 +5357,9 @@ const mergeLocalAndRemoteDatasetStructure = async (
5283
5357
closeFileImportLoadingSweetAlert ( ) ;
5284
5358
5285
5359
if ( duplicateFiles . length > 0 ) {
5286
- const userConfirmedFileOverwrite = await swalFileListConfirmAction (
5360
+ const userConfirmedFileOverwrite = await swalFileListDoubleAction (
5287
5361
duplicateFiles . map ( ( file ) => `${ file . virtualFilePath } ${ file . fileName } ` ) ,
5288
- "Some files being imported already exist in your dataset " ,
5362
+ "Duplicate files detected " ,
5289
5363
`
5290
5364
You have two options for the duplicate files:
5291
5365
<br />
@@ -5372,14 +5446,11 @@ const addDataArrayToDatasetStructureAtPath = async (importedData) => {
5372
5446
// STEP 1: Build the JSON object from the imported data
5373
5447
// (This function handles bad folders/files, inaccessible folders/files, etc and returns a clean dataset structure)
5374
5448
const currentFileExplorerPath = organizeDSglobalPath . value . trim ( ) ;
5449
+
5375
5450
const builtDatasetStructure = await buildDatasetStructureJsonFromImportedData (
5376
5451
importedData ,
5377
5452
currentFileExplorerPath
5378
5453
) ;
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
- }
5383
5454
5384
5455
// Step 2: Add the imported data to the dataset structure (This function handles duplicate files, etc)
5385
5456
await mergeLocalAndRemoteDatasetStructure ( builtDatasetStructure , currentFileExplorerPath ) ;
@@ -5400,11 +5471,10 @@ const addDataArrayToDatasetStructureAtPath = async (importedData) => {
5400
5471
duration : 3000 ,
5401
5472
} ) ;
5402
5473
} catch ( error ) {
5403
- console . log ( error ) ;
5404
5474
closeFileImportLoadingSweetAlert ( ) ;
5405
5475
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" ,
5408
5478
duration : 3000 ,
5409
5479
} ) ;
5410
5480
}
@@ -5462,14 +5532,15 @@ const drop = async (ev) => {
5462
5532
) ;
5463
5533
return ;
5464
5534
} else {
5465
- const importAccessibleItemsOnly = await swalFileListConfirmAction (
5466
- inaccessibleItems ,
5535
+ const importAccessibleItemsOnly = await swalFileListDoubleAction (
5536
+ accessibleItems ,
5467
5537
"<p>SODA was unable to import some of your dropped files/folders</p>" ,
5468
5538
"A list of the folders/files that SODA was not able to import is shown below:" ,
5469
5539
"Yes, continue with the import" ,
5470
5540
"No, cancel the import" ,
5471
5541
"Would you like to continue the import without these folders/files?"
5472
5542
) ;
5543
+
5473
5544
if ( ! importAccessibleItemsOnly ) {
5474
5545
return ;
5475
5546
}
0 commit comments