Browse Source

Merge pull request #1679 from mertmit/fix-release-info

refactor: renew old fetchReleaseInfo
pull/1685/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
b31f2638ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      packages/nc-gui/components/releaseInfo.vue
  2. 11
      packages/nc-gui/plugins/projectLoader.js
  3. 6
      packages/nc-gui/store/app.js
  4. 16
      packages/nocodb-sdk/src/lib/Api.ts
  5. 11
      packages/nocodb/src/lib/noco/meta/api/utilApis.ts
  6. 21
      scripts/sdk/swagger.json

9
packages/nc-gui/components/releaseInfo.vue

@ -3,7 +3,7 @@
<template #activator="{on}">
<transition name="release">
<v-btn
v-if="releaseAlert"
v-show="releaseAlert"
text
small
class="mb-0 mr-2 py-0 "
@ -54,10 +54,13 @@ export default {
computed: {
releaseAlert: {
get() {
return !this.loading && this.$store.state.app.releaseVersion && this.$store.state.app.releaseVersion !== this.$store.state.app.hiddenRelease
return !this.loading && this.$store.state.app.releaseVersion &&
this.$store.state.app.latestRelease &&
this.$store.state.app.releaseVersion !== this.$store.state.app.latestRelease &&
this.$store.state.app.latestRelease !== this.$store.state.app.hiddenRelease
},
set(val) {
return this.$store.commit('app/MutHiddenRelease', val ? null : this.$store.state.app.releaseVersion)
return this.$store.commit('app/MutHiddenRelease', val ? null : this.$store.state.app.latestRelease)
}
},
releaseVersion() {

11
packages/nc-gui/plugins/projectLoader.js

@ -1,4 +1,4 @@
export default async({ store, redirect, $axios, $toast, route }) => {
export default async({ store, redirect, $axios, $toast, $api, route }) => {
// if (!route.path || !route.path.startsWith('/nc/')) { await store.dispatch('plugins/pluginPostInstall', 'Branding') }
if (window.location.search &&
/\bscope=|\bstate=/.test(window.location.search) &&
@ -63,11 +63,14 @@ export default async({ store, redirect, $axios, $toast, route }) => {
// fetch latest release info
const fetchReleaseInfo = async() => {
try {
const releaseInfo = await store.dispatch('sqlMgr/ActSqlOp', [null, 'xcRelease'])
if (releaseInfo && releaseInfo.docker && releaseInfo.docker.upgrade) {
store.commit('app/MutReleaseVersion', releaseInfo.docker.name)
const releaseInfo = await $api.utils.appInfo()
const latestRelease = await $api.utils.appVersion()
if (releaseInfo && latestRelease && releaseInfo.version) {
store.commit('app/MutReleaseVersion', releaseInfo.version)
store.commit('app/MutLatestRelease', latestRelease.releaseVersion || null)
} else {
store.commit('app/MutReleaseVersion', null)
store.commit('app/MutLatestRelease', null)
}
} catch (e) {
// ignore

6
packages/nc-gui/store/app.js

@ -1,6 +1,7 @@
export const state = () => ({
releaseVersion: null,
hiddenRelease: null
hiddenRelease: null,
latestRelease: null
})
export const mutations = {
@ -9,6 +10,9 @@ export const mutations = {
},
MutHiddenRelease(state, hiddenRelease) {
state.hiddenRelease = hiddenRelease
},
MutLatestRelease(state, latestRelease) {
state.latestRelease = latestRelease
}
}

16
packages/nocodb-sdk/src/lib/Api.ts

@ -2945,6 +2945,22 @@ export class Api<
...params,
}),
/**
* No description
*
* @tags Utils
* @name AppVersion
* @request GET:/api/v1/db/meta/nocodb/version
* @response `200` `any` OK
*/
appVersion: (params: RequestParams = {}) =>
this.request<any, any>({
path: `/api/v1/db/meta/nocodb/version`,
method: 'GET',
format: 'json',
...params,
}),
/**
* @description Get All K/V pairs in NocoCache
*

11
packages/nocodb/src/lib/noco/meta/api/utilApis.ts

@ -7,6 +7,7 @@ import SqlMgrv2 from '../../../sqlMgr/v2/SqlMgrv2';
import { defaultConnectionConfig } from '../../../utils/NcConfigFactory';
import User from '../../../noco-models/User';
import catchError from '../helpers/catchError';
import axios from 'axios';
export async function testConnection(req: Request, res: Response) {
res.json(await SqlMgrv2.testConnection(req.body));
@ -43,10 +44,20 @@ export async function appInfo(_req: Request, res: Response) {
res.json(result);
}
export async function releaseVersion(_req: Request, res: Response) {
const result = await axios.get('https://github.com/nocodb/nocodb/releases/latest')
.then((response) => {
return { releaseVersion: response.request.res.responseUrl.replace('https://github.com/nocodb/nocodb/releases/tag/', '') }
})
res.json(result);
}
export default router => {
router.post(
'/api/v1/db/meta/connection/test',
ncMetaAclMw(testConnection, 'testConnection')
);
router.get('/api/v1/db/meta/nocodb/info', catchError(appInfo));
router.get('/api/v1/db/meta/nocodb/version', catchError(releaseVersion));
};

21
scripts/sdk/swagger.json

@ -4434,6 +4434,27 @@
"description": ""
}
},
"/api/v1/db/meta/nocodb/version": {
"parameters": [],
"get": {
"summary": "",
"operationId": "utils-app-version",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {}
}
}
}
},
"tags": [
"Utils"
],
"description": ""
}
},
"/api/v1/db/meta/cache": {
"get": {
"summary": "Your GET endpoint",

Loading…
Cancel
Save