changelog + show update message

This commit is contained in:
Jan Prochazka 2021-12-10 18:31:50 +01:00
parent 700571c913
commit 1eba71fa8c
6 changed files with 77 additions and 2 deletions

View File

@ -120,6 +120,7 @@ function buildMenu() {
require('electron').shell.openExternal('https://github.com/dbgate/dbgate/issues/new');
},
},
commandItem('tabs.changelog'),
commandItem('about.show'),
],
},

View File

@ -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;
},
};

View File

@ -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,

View File

@ -0,0 +1,41 @@
<script lang="ts" context="module">
export const matchingProps = [];
</script>
<script lang="ts">
import { onMount } from 'svelte';
import LoadingInfo from '../elements/LoadingInfo.svelte';
import Markdown from '../elements/Markdown.svelte';
import axiosInstance from '../utility/axiosInstance';
let isLoading = false;
let text = null;
const handleLoad = async () => {
isLoading = true;
const resp = await axiosInstance.get('config/changelog');
text = resp.data;
isLoading = false;
};
onMount(() => {
handleLoad();
});
</script>
{#if isLoading}
<LoadingInfo message="Loading changelog" />
{:else}
<div>
<Markdown source={text || ''} />
</div>
{/if}
<style>
div {
padding: 10px;
overflow: auto;
flex: 1;
}
</style>

View File

@ -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,
};

View File

@ -1,11 +1,13 @@
<script lang="ts">
import { onMount } from 'svelte';
import { openFavorite } from '../appobj/FavoriteFileAppObject.svelte';
import runCommand from '../commands/runCommand';
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
import { showModal } from '../modals/modalTools';
import { openedTabs } from '../stores';
import { useFavorites } from './metadataLoaders';
import { getConfig, useFavorites } from './metadataLoaders';
import { showSnackbarInfo } from './snackbar';
$: favorites = useFavorites();
let opened = false;
@ -16,7 +18,7 @@
$: openOnStartup($favorites);
function openOnStartup(list) {
async function openOnStartup(list) {
if (!list) return;
if (opened) return;
@ -45,5 +47,13 @@
openFavorite(favorite);
}
}
const config = await getConfig();
const appVersion = localStorage.getItem('appVersion');
if (appVersion && appVersion != config.version) {
runCommand('tabs.changelog');
showSnackbarInfo(`DbGate upgraded from version ${appVersion} to version ${config.version}`);
}
localStorage.setItem('appVersion', config.version);
}
</script>