Skip to content
This repository was archived by the owner on May 2, 2022. It is now read-only.

Commit a95c1a7

Browse files
authored
Add details/app open shortcuts to snack bars (#1493)
1 parent b2d64dd commit a95c1a7

File tree

5 files changed

+132
-85
lines changed

5 files changed

+132
-85
lines changed

main-src/libs/listeners.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ const loadListeners = () => {
152152
send(e.sender, 'enqueue-snackbar', `Failed to uninstall ${name} as the application is in use.`, 'error');
153153
} else {
154154
captureException(error);
155-
send(e.sender, 'enqueue-snackbar', `Failed to uninstall ${name}.`, 'error');
155+
const actionData = error ? { type: 'show-details', text: error.stack } : undefined;
156+
send(e.sender, 'enqueue-snackbar', `Failed to uninstall ${name}.`, 'error', actionData);
156157
}
157158
send(e.sender, 'set-app', id, {
158159
status: 'INSTALLED',
@@ -193,7 +194,8 @@ const loadListeners = () => {
193194
status: 'INSTALLED',
194195
registered: getPreference('registered'),
195196
});
196-
send(e.sender, 'enqueue-snackbar', `${name} is installed successfully.`, 'success');
197+
const actionData = { type: 'open-app', id, name };
198+
send(e.sender, 'enqueue-snackbar', `${name} is installed successfully.`, 'success', actionData);
197199
delete promiseFuncMap[id];
198200
})
199201
.catch((error) => {
@@ -205,7 +207,8 @@ const loadListeners = () => {
205207
send(e.sender, 'enqueue-snackbar', error.message, 'error');
206208
} else {
207209
captureException(error);
208-
send(e.sender, 'enqueue-snackbar', `Failed to install ${name}.`, 'error');
210+
const actionData = error ? { type: 'show-details', text: error.stack } : undefined;
211+
send(e.sender, 'enqueue-snackbar', `Failed to install ${name}.`, 'error', actionData);
209212
}
210213
send(e.sender, 'remove-app', id);
211214
delete promiseFuncMap[id];
@@ -279,7 +282,8 @@ const loadListeners = () => {
279282
} else if (error && error.message && error.message.startsWith('WebCatalog is outdated')) {
280283
send(e.sender, 'enqueue-snackbar', error.message, 'error');
281284
} else {
282-
send(e.sender, 'enqueue-snackbar', `Failed to update ${name}.`, 'error');
285+
const actionData = error ? { type: 'show-details', text: error.stack } : undefined;
286+
send(e.sender, 'enqueue-snackbar', `Failed to update ${name}.`, 'error', actionData);
283287
captureException(error);
284288
}
285289
send(e.sender, 'set-app', id, {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@material-ui/icons": "4.11.2",
3636
"@material-ui/lab": "4.0.0-alpha.57",
3737
"@sentry/electron": "2.5.1",
38-
"amplitude-js": "8.4.0",
38+
"amplitude-js": "8.5.0",
3939
"auto-launch": "5.0.5",
4040
"axios": "0.21.1",
4141
"babel-eslint": "10.1.0",
@@ -51,7 +51,7 @@
5151
"copy-webpack-plugin": "6.4.1",
5252
"cross-env": "7.0.3",
5353
"decompress": "4.2.1",
54-
"electron": "13.1.8",
54+
"electron": "13.1.9",
5555
"electron-builder": "22.11.11",
5656
"electron-context-menu": "3.1.1",
5757
"electron-notarize": "1.1.0",
@@ -68,7 +68,7 @@
6868
"eslint-plugin-react": "7.24.0",
6969
"eslint-plugin-react-hooks": "1.7.0",
7070
"file-saver": "2.0.5",
71-
"firebase": "8.9.0",
71+
"firebase": "8.9.1",
7272
"follow-redirects": "1.14.1",
7373
"fs-extra": "10.0.0",
7474
"gravatar": "1.8.1",

public/open-source-notices.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10288,7 +10288,7 @@ THE SOFTWARE.
1028810288

1028910289
-----
1029010290

10291-
The following software may be included in this product: es-to-primitive, is-boolean-object, is-callable, is-date-object, is-number-object, is-string, is-symbol, object.entries, object.getownpropertydescriptors, object.values, string.prototype.matchall. A copy of the source code may be downloaded from git://github.com/ljharb/es-to-primitive.git (es-to-primitive), git://github.com/inspect-js/is-boolean-object.git (is-boolean-object), git://github.com/ljharb/is-callable.git (is-callable), git://github.com/inspect-js/is-date-object.git (is-date-object), git://github.com/inspect-js/is-number-object.git (is-number-object), git://github.com/ljharb/is-string.git (is-string), git://github.com/inspect-js/is-symbol.git (is-symbol), git://github.com/es-shims/Object.entries.git (object.entries), git://github.com/es-shims/object.getownpropertydescriptors.git (object.getownpropertydescriptors), git://github.com/es-shims/Object.values.git (object.values), git+https://github.com/es-shims/String.prototype.matchAll.git (string.prototype.matchall). This software contains the following license and notice below:
10291+
The following software may be included in this product: es-to-primitive, is-boolean-object, is-callable, is-date-object, is-number-object, is-string, is-symbol, object.entries, object.getownpropertydescriptors, object.values, string.prototype.matchall. A copy of the source code may be downloaded from git://github.com/ljharb/es-to-primitive.git (es-to-primitive), git://github.com/inspect-js/is-boolean-object.git (is-boolean-object), git://github.com/inspect-js/is-callable.git (is-callable), git://github.com/inspect-js/is-date-object.git (is-date-object), git://github.com/inspect-js/is-number-object.git (is-number-object), git://github.com/ljharb/is-string.git (is-string), git://github.com/inspect-js/is-symbol.git (is-symbol), git://github.com/es-shims/Object.entries.git (object.entries), git://github.com/es-shims/object.getownpropertydescriptors.git (object.getownpropertydescriptors), git://github.com/es-shims/Object.values.git (object.values), git+https://github.com/es-shims/String.prototype.matchAll.git (string.prototype.matchall). This software contains the following license and notice below:
1029210292

1029310293
The MIT License (MIT)
1029410294

@@ -10515,7 +10515,7 @@ SOFTWARE.
1051510515

1051610516
-----
1051710517

10518-
The following software may be included in this product: eslint-import-resolver-node, eslint-module-utils, eslint-plugin-import. A copy of the source code may be downloaded from https://github.com/benmosher/eslint-plugin-import (eslint-import-resolver-node), git+https://github.com/benmosher/eslint-plugin-import.git (eslint-module-utils), https://github.com/benmosher/eslint-plugin-import (eslint-plugin-import). This software contains the following license and notice below:
10518+
The following software may be included in this product: eslint-import-resolver-node, eslint-module-utils, eslint-plugin-import. A copy of the source code may be downloaded from https://github.com/import-js/eslint-plugin-import (eslint-import-resolver-node), git+https://github.com/import-js/eslint-plugin-import.git (eslint-module-utils), https://github.com/benmosher/eslint-plugin-import (eslint-plugin-import). This software contains the following license and notice below:
1051910519

1052010520
The MIT License (MIT)
1052110521

src/components/root/snackbar-trigger/inner.js

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Button from '@material-ui/core/Button';
88
import { useSnackbar } from 'notistack';
99

1010
import {
11+
requestOpenApp,
1112
requestRestart,
1213
} from '../../../senders';
1314

@@ -16,13 +17,53 @@ const SnackbarTriggerInner = () => {
1617

1718
useEffect(() => {
1819
window.ipcRenderer.removeAllListeners('enqueue-snackbar');
19-
window.ipcRenderer.on('enqueue-snackbar', (_, message, variant) => {
20-
enqueueSnackbar(message, { variant, autoHideDuration: 10000 });
20+
window.ipcRenderer.on('enqueue-snackbar', (_, message, variant, actionData) => {
21+
let action;
22+
if (actionData) {
23+
switch (actionData.type) {
24+
case 'open-app': {
25+
action = (key) => (
26+
<>
27+
<Button color="inherit" onClick={() => requestOpenApp(actionData.id, actionData.name)}>
28+
Open
29+
</Button>
30+
<Button color="inherit" onClick={() => closeSnackbar(key)}>
31+
Dismiss
32+
</Button>
33+
</>
34+
);
35+
break;
36+
}
37+
case 'show-details': {
38+
action = (key) => (
39+
<>
40+
<Button
41+
color="inherit"
42+
onClick={() => {
43+
window.remote.dialog.showMessageBox(window.remote.getCurrentWindow(), {
44+
message: actionData.text,
45+
}).catch(console.log); // eslint-disable-line
46+
}}
47+
>
48+
Show Details
49+
</Button>
50+
<Button color="inherit" onClick={() => closeSnackbar(key)}>
51+
Dismiss
52+
</Button>
53+
</>
54+
);
55+
break;
56+
}
57+
default: break;
58+
}
59+
}
60+
61+
enqueueSnackbar(message, { variant, autoHideDuration: 10000, action });
2162
});
2263
return () => {
2364
window.ipcRenderer.removeAllListeners('enqueue-snackbar');
2465
};
25-
}, [enqueueSnackbar]);
66+
}, [enqueueSnackbar, closeSnackbar]);
2667

2768
const showRequestRestartSnackbar = useCallback(() => {
2869
enqueueSnackbar('You need to restart the app for the changes to take effect.', {

0 commit comments

Comments
 (0)