Skip to content

Commit

Permalink
fix: use app hub id instead of name and org for update matching [DHIS…
Browse files Browse the repository at this point in the history
…2-10859] (#218)
  • Loading branch information
amcgee authored Apr 11, 2021
1 parent d869c6f commit 1417a84
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions d2.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const config = {
type: 'app',
id: '28823170-1203-46d1-81d5-eea67abae41c',
name: 'app-management',
title: 'App Management',
coreApp: true,
Expand Down
11 changes: 9 additions & 2 deletions src/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const pkg = require('../package.json')
const version = pkg.version
const cfg = require('../d2.config.js')

module.exports = {
plugins: [
Expand All @@ -11,9 +11,16 @@ module.exports = {
identifierName: '__VERSION__',
replacement: {
type: 'stringLiteral',
value: version,
value: pkg.version,
},
},
{
identifierName: '__APP_HUB_ID__',
replacement: {
type: 'stringLiteral',
value: cfg.id || '',
},
}
],
},
],
Expand Down
10 changes: 4 additions & 6 deletions src/components/SelfUpdateNoticeBox.component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global __VERSION__ */
/* global __VERSION__,__APP_HUB_ID__ */

import i18n from '@dhis2/d2-i18n'
import { NoticeBox, Button } from '@dhis2/ui'
Expand All @@ -8,16 +8,14 @@ import actions from '../actions'
import { getTargetVersion } from '../utils/versions'

const currentVersion = __VERSION__
const appManagementAppOrg = 'DHIS2'
const appManagementAppName = 'App Management'
const appManagementAppId = __APP_HUB_ID__

export const SelfUpdateNoticeBox = ({ appHub }) => {
if (!appHub.apps) return null

// TODO: Fetch app management app from App Hub directly (by id)
const appManagementApp = appHub.apps.find(
app =>
app.developer.organisation === appManagementAppOrg &&
app.name === appManagementAppName
app => app.id === appManagementAppId
)

const targetVersion = getTargetVersion(
Expand Down

0 comments on commit 1417a84

Please sign in to comment.