From 75a426437a4182e21da13684066966dd5bf8fc5e Mon Sep 17 00:00:00 2001 From: sct Date: Sun, 27 Dec 2020 10:05:54 +0000 Subject: [PATCH] feat: status checker to prompt users to reload their frontend when app version changes --- next.config.js | 3 ++ overseerr-api.yml | 20 ++++++++ package.json | 2 +- server/routes/index.ts | 9 ++++ src/components/Layout/Sidebar/index.tsx | 16 +++---- src/components/StatusChacker/index.tsx | 62 +++++++++++++++++++++++++ src/pages/_app.tsx | 2 + 7 files changed, 103 insertions(+), 11 deletions(-) create mode 100644 src/components/StatusChacker/index.tsx diff --git a/next.config.js b/next.config.js index a6ea87dfb..8c1766af8 100644 --- a/next.config.js +++ b/next.config.js @@ -1,4 +1,7 @@ module.exports = { + env: { + commitTag: process.env.COMMIT_TAG || 'local', + }, webpack(config) { config.module.rules.push({ test: /\.svg$/, diff --git a/overseerr-api.yml b/overseerr-api.yml index cac66b2b7..dccd60ba6 100644 --- a/overseerr-api.yml +++ b/overseerr-api.yml @@ -1102,6 +1102,26 @@ components: name: X-Api-Key paths: + /status: + get: + summary: Return Overseerr version + description: Returns the current Overseerr version in JSON format + security: [] + tags: + - public + responses: + '200': + description: Returned version + content: + application/json: + schema: + type: object + properties: + version: + type: string + example: 1.0.0 + commitTag: + type: string /settings/main: get: summary: Returns main settings diff --git a/package.json b/package.json index ac3414c12..093f314d8 100644 --- a/package.json +++ b/package.json @@ -171,7 +171,7 @@ [ "@semantic-release/exec", { - "prepareCmd": "docker build -t sctx/overseerr ." + "prepareCmd": "docker build --build-arg COMMIT_TAG=$GITHUB_SHA -t sctx/overseerr ." } ], "semantic-release-docker", diff --git a/server/routes/index.ts b/server/routes/index.ts index bf094ec08..d03ddb696 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -13,10 +13,19 @@ import tvRoutes from './tv'; import mediaRoutes from './media'; import personRoutes from './person'; import collectionRoutes from './collection'; +import { getAppVersion } from '../utils/appVersion'; const router = Router(); router.use(checkUser); + +router.get('/status', (req, res) => { + return res.status(200).json({ + version: getAppVersion(), + commitTag: process.env.COMMIT_TAG || 'local', + }); +}); + router.use('/user', isAuthenticated(Permission.MANAGE_USERS), user); router.get('/settings/public', (_req, res) => { const settings = getSettings(); diff --git a/src/components/Layout/Sidebar/index.tsx b/src/components/Layout/Sidebar/index.tsx index b6e44f37d..c85727a9b 100644 --- a/src/components/Layout/Sidebar/index.tsx +++ b/src/components/Layout/Sidebar/index.tsx @@ -175,11 +175,9 @@ const Sidebar: React.FC = ({ open, setClosed }) => { >
- - - Overseerr Logo - - + + Overseerr Logo +