From 1eba71fa8c835fa08468e93d0c52b4ed648a826d Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Fri, 10 Dec 2021 18:31:50 +0100 Subject: [PATCH] changelog + show update message --- app/src/electron.js | 1 + packages/api/src/controllers/config.js | 7 ++++ packages/web/src/commands/stdCommands.ts | 14 +++++++ packages/web/src/tabs/ChangelogTab.svelte | 41 +++++++++++++++++++ packages/web/src/tabs/index.js | 2 + .../web/src/utility/OpenTabsOnStartup.svelte | 14 ++++++- 6 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 packages/web/src/tabs/ChangelogTab.svelte diff --git a/app/src/electron.js b/app/src/electron.js index 7387652b..23f1992c 100644 --- a/app/src/electron.js +++ b/app/src/electron.js @@ -120,6 +120,7 @@ function buildMenu() { require('electron').shell.openExternal('https://github.com/dbgate/dbgate/issues/new'); }, }, + commandItem('tabs.changelog'), commandItem('about.show'), ], }, diff --git a/packages/api/src/controllers/config.js b/packages/api/src/controllers/config.js index f813912b..b86f6746 100644 --- a/packages/api/src/controllers/config.js +++ b/packages/api/src/controllers/config.js @@ -1,5 +1,6 @@ const fs = require('fs-extra'); const path = require('path'); +const axios = require('axios'); const { datadir } = require('../utility/directories'); const hasPermission = require('../utility/hasPermission'); const socket = require('../utility/socket'); @@ -58,4 +59,10 @@ module.exports = { return false; } }, + + changelog_meta: 'get', + async changelog() { + const resp = await axios.default.get('https://raw.githubusercontent.com/dbgate/dbgate/master/CHANGELOG.md'); + return resp.data; + }, }; diff --git a/packages/web/src/commands/stdCommands.ts b/packages/web/src/commands/stdCommands.ts index 963f5183..a55a2b2e 100644 --- a/packages/web/src/commands/stdCommands.ts +++ b/packages/web/src/commands/stdCommands.ts @@ -266,6 +266,20 @@ registerCommand({ }, }); +registerCommand({ + id: 'tabs.changelog', + category: 'Tabs', + name: 'Changelog', + onClick: () => { + openNewTab({ + title: 'ChangeLog', + icon: 'img markdown', + tabComponent: 'ChangelogTab', + props: {}, + }); + }, +}); + registerCommand({ id: 'group.save', category: null, diff --git a/packages/web/src/tabs/ChangelogTab.svelte b/packages/web/src/tabs/ChangelogTab.svelte new file mode 100644 index 00000000..575cff2c --- /dev/null +++ b/packages/web/src/tabs/ChangelogTab.svelte @@ -0,0 +1,41 @@ + + + + +{#if isLoading} + +{:else} +
+ +
+{/if} + + diff --git a/packages/web/src/tabs/index.js b/packages/web/src/tabs/index.js index 7bf572df..7e682483 100644 --- a/packages/web/src/tabs/index.js +++ b/packages/web/src/tabs/index.js @@ -17,6 +17,7 @@ import * as CommandListTab from './CommandListTab.svelte'; import * as YamlEditorTab from './YamlEditorTab.svelte'; import * as CompareModelTab from './CompareModelTab.svelte'; import * as JsonTab from './JsonTab.svelte'; +import * as ChangelogTab from './ChangelogTab.svelte'; export default { TableDataTab, @@ -38,4 +39,5 @@ export default { YamlEditorTab, CompareModelTab, JsonTab, + ChangelogTab, }; diff --git a/packages/web/src/utility/OpenTabsOnStartup.svelte b/packages/web/src/utility/OpenTabsOnStartup.svelte index 580a31aa..ff762584 100644 --- a/packages/web/src/utility/OpenTabsOnStartup.svelte +++ b/packages/web/src/utility/OpenTabsOnStartup.svelte @@ -1,11 +1,13 @@