diff options
author | André Oliveira <37463445+SpecialAro@users.noreply.github.com> | 2022-06-30 14:35:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-30 13:35:45 +0000 |
commit | 13c51fdf5b9fd42a244bc1620e7e96c80a080f66 (patch) | |
tree | 739b9f24cad3f12183c974947f25a9a37c099285 /src/lib | |
parent | fix: don't break when when service is undefined on adding a new service (#400) (diff) | |
download | ferdium-app-13c51fdf5b9fd42a244bc1620e7e96c80a080f66.tar.gz ferdium-app-13c51fdf5b9fd42a244bc1620e7e96c80a080f66.tar.zst ferdium-app-13c51fdf5b9fd42a244bc1620e7e96c80a080f66.zip |
Feature: Copy Ferdium info from the 'About' dialog into the clipboard (#402)
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Menu.js | 57 |
1 files changed, 45 insertions, 12 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index d3a3163b9..7b048d3fa 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -9,6 +9,7 @@ import { | |||
9 | } from '@electron/remote'; | 9 | } from '@electron/remote'; |
10 | import { autorun, observable } from 'mobx'; | 10 | import { autorun, observable } from 'mobx'; |
11 | import { defineMessages } from 'react-intl'; | 11 | import { defineMessages } from 'react-intl'; |
12 | import osName from 'os-name'; | ||
12 | import { | 13 | import { |
13 | CUSTOM_WEBSITE_RECIPE_ID, | 14 | CUSTOM_WEBSITE_RECIPE_ID, |
14 | GITHUB_FERDIUM_URL, | 15 | GITHUB_FERDIUM_URL, |
@@ -27,8 +28,12 @@ import { | |||
27 | addNewServiceShortcutKey, | 28 | addNewServiceShortcutKey, |
28 | splitModeToggleShortcutKey, | 29 | splitModeToggleShortcutKey, |
29 | muteFerdiumShortcutKey, | 30 | muteFerdiumShortcutKey, |
31 | electronVersion, | ||
32 | chromeVersion, | ||
33 | nodeVersion, | ||
34 | osArch, | ||
30 | } from '../environment'; | 35 | } from '../environment'; |
31 | import { aboutAppDetails, ferdiumVersion } from '../environment-remote'; | 36 | import { ferdiumVersion } from '../environment-remote'; |
32 | import { todoActions } from '../features/todos/actions'; | 37 | import { todoActions } from '../features/todos/actions'; |
33 | import { workspaceActions } from '../features/workspaces/actions'; | 38 | import { workspaceActions } from '../features/workspaces/actions'; |
34 | import { workspaceStore } from '../features/workspaces/index'; | 39 | import { workspaceStore } from '../features/workspaces/index'; |
@@ -36,6 +41,9 @@ import apiBase, { serverBase } from '../api/apiBase'; | |||
36 | import { openExternalUrl } from '../helpers/url-helpers'; | 41 | import { openExternalUrl } from '../helpers/url-helpers'; |
37 | import globalMessages from '../i18n/globalMessages'; | 42 | import globalMessages from '../i18n/globalMessages'; |
38 | 43 | ||
44 | // @ts-expect-error Cannot find module '../buildInfo.json' or its corresponding type declarations. | ||
45 | import * as buildInfo from '../buildInfo.json'; | ||
46 | |||
39 | const menuItems = defineMessages({ | 47 | const menuItems = defineMessages({ |
40 | edit: { | 48 | edit: { |
41 | id: 'menu.edit', | 49 | id: 'menu.edit', |
@@ -325,6 +333,14 @@ const menuItems = defineMessages({ | |||
325 | id: 'menu.services.goHome', | 333 | id: 'menu.services.goHome', |
326 | defaultMessage: 'Home', | 334 | defaultMessage: 'Home', |
327 | }, | 335 | }, |
336 | ok: { | ||
337 | id: 'global.ok', | ||
338 | defaultMessage: 'Ok', | ||
339 | }, | ||
340 | copyToClipboard: { | ||
341 | id: 'menu.services.copyToClipboard', | ||
342 | defaultMessage: 'Copy to clipboard', | ||
343 | }, | ||
328 | }); | 344 | }); |
329 | 345 | ||
330 | function getActiveService() { | 346 | function getActiveService() { |
@@ -797,10 +813,6 @@ class FranzMenu { | |||
797 | accelerator: `${altKey()}+F`, | 813 | accelerator: `${altKey()}+F`, |
798 | submenu: [ | 814 | submenu: [ |
799 | { | 815 | { |
800 | label: intl.formatMessage(menuItems.about), | ||
801 | role: 'about', | ||
802 | }, | ||
803 | { | ||
804 | type: 'separator', | 816 | type: 'separator', |
805 | }, | 817 | }, |
806 | { | 818 | { |
@@ -856,15 +868,36 @@ class FranzMenu { | |||
856 | ], | 868 | ], |
857 | }); | 869 | }); |
858 | 870 | ||
871 | const aboutAppDetails = [ | ||
872 | `Version: ${ferdiumVersion}`, | ||
873 | `Electron: ${electronVersion}`, | ||
874 | `Chrome: ${chromeVersion}`, | ||
875 | `Node.js: ${nodeVersion}`, | ||
876 | `Platform: ${osName()}`, | ||
877 | `Arch: ${osArch}`, | ||
878 | `Build date: ${new Date(Number(buildInfo.timestamp))}`, | ||
879 | `Git SHA: ${buildInfo.gitHashShort}`, | ||
880 | `Git branch: ${buildInfo.gitBranch}`, | ||
881 | ].join('\n'); | ||
882 | |||
859 | const about = { | 883 | const about = { |
860 | label: intl.formatMessage(menuItems.about), | 884 | label: intl.formatMessage(menuItems.about), |
861 | click: () => { | 885 | click: () => { |
862 | dialog.showMessageBox({ | 886 | dialog |
863 | type: 'info', | 887 | .showMessageBox({ |
864 | title: 'Ferdium', | 888 | type: 'info', |
865 | message: 'Ferdium', | 889 | title: 'Ferdium', |
866 | detail: aboutAppDetails(), | 890 | message: 'Ferdium', |
867 | }); | 891 | detail: aboutAppDetails, |
892 | buttons: [intl.formatMessage(menuItems.copyToClipboard), intl.formatMessage(menuItems.ok)], | ||
893 | }) | ||
894 | .then(result => { | ||
895 | if (result.response === 0) { | ||
896 | clipboard.write({ | ||
897 | text: aboutAppDetails, | ||
898 | }); | ||
899 | } | ||
900 | }); | ||
868 | }, | 901 | }, |
869 | }; | 902 | }; |
870 | 903 | ||
@@ -889,7 +922,7 @@ class FranzMenu { | |||
889 | }, | 922 | }, |
890 | ); | 923 | ); |
891 | 924 | ||
892 | tpl[5].submenu.unshift(about, { | 925 | tpl[0].submenu.unshift(about, { |
893 | type: 'separator', | 926 | type: 'separator', |
894 | }); | 927 | }); |
895 | } else { | 928 | } else { |