From 733bf61c5f244e6aa38bc0dfd8fcfd5d0e92a16c Mon Sep 17 00:00:00 2001 From: Koza Date: Wed, 13 Mar 2024 16:44:30 +0100 Subject: [PATCH] WIP: Improve "Project does not exists" popup with a Remove all button to clean up the unreachable projects --- spec/atom-environment-spec.js | 7 ++++++- src/atom-environment.js | 31 ++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/spec/atom-environment-spec.js b/spec/atom-environment-spec.js index 2a44b24042..4a896ec51d 100644 --- a/spec/atom-environment-spec.js +++ b/spec/atom-environment-spec.js @@ -764,7 +764,12 @@ describe('AtomEnvironment', () => { expect(atom.notifications.addWarning).toHaveBeenCalledWith( 'Unable to open project folders', { - description: `The directories \`${nonExistent}\` and \`${existingFile}\` do not exist.` + description: `The directories \`${nonExistent}\` and \`${existingFile}\` do not exist.`, + dismissable: true, + buttons: [ + { text: 'Remove all', onDidClick: jasmine.any(Function) }, + { text: 'Skip for now', onDidClick: jasmine.any(Function) } + ] } ); }); diff --git a/src/atom-environment.js b/src/atom-environment.js index 510970615c..3cc535de51 100644 --- a/src/atom-environment.js +++ b/src/atom-environment.js @@ -1739,7 +1739,36 @@ or use Pane::saveItemAs for programmatic saving.`); '` do not exist.'; } - this.notifications.addWarning(message, { description }); + let notification; + + let removeMissingPaths = async () => { + this.applicationDelegate.setProjectRoots(this.project.getPaths()); + + for (const missingFolder of missingFolders) { + const { pathToOpen } = missingFolder; + + this.notifications.addWarning(`Removed ${pathToOpen}`); + } + + if (notification) { + notification.dismiss(); + } + }; + + let skipRemove = () => { + if (notification) { + notification.dismiss(); + } + } + + notification = this.notifications.addWarning(message, { + description, + dismissable: true, + buttons: [ + { text: 'Remove all', onDidClick: removeMissingPaths }, + { text: 'Skip for now', onDidClick: skipRemove } + ] + }); } ipcRenderer.send('window-command', 'window:locations-opened');