aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorLibravatar André Oliveira <37463445+SpecialAro@users.noreply.github.com>2022-06-30 14:35:45 +0100
committerLibravatar GitHub <noreply@github.com>2022-06-30 13:35:45 +0000
commit13c51fdf5b9fd42a244bc1620e7e96c80a080f66 (patch)
tree739b9f24cad3f12183c974947f25a9a37c099285 /src/lib
parentfix: don't break when when service is undefined on adding a new service (#400) (diff)
downloadferdium-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.js57
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';
10import { autorun, observable } from 'mobx'; 10import { autorun, observable } from 'mobx';
11import { defineMessages } from 'react-intl'; 11import { defineMessages } from 'react-intl';
12import osName from 'os-name';
12import { 13import {
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';
31import { aboutAppDetails, ferdiumVersion } from '../environment-remote'; 36import { ferdiumVersion } from '../environment-remote';
32import { todoActions } from '../features/todos/actions'; 37import { todoActions } from '../features/todos/actions';
33import { workspaceActions } from '../features/workspaces/actions'; 38import { workspaceActions } from '../features/workspaces/actions';
34import { workspaceStore } from '../features/workspaces/index'; 39import { workspaceStore } from '../features/workspaces/index';
@@ -36,6 +41,9 @@ import apiBase, { serverBase } from '../api/apiBase';
36import { openExternalUrl } from '../helpers/url-helpers'; 41import { openExternalUrl } from '../helpers/url-helpers';
37import globalMessages from '../i18n/globalMessages'; 42import globalMessages from '../i18n/globalMessages';
38 43
44// @ts-expect-error Cannot find module '../buildInfo.json' or its corresponding type declarations.
45import * as buildInfo from '../buildInfo.json';
46
39const menuItems = defineMessages({ 47const 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
330function getActiveService() { 346function 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 {