From bce2de04818220b8502d9d4522828f7707ebe882 Mon Sep 17 00:00:00 2001 From: Charpell Date: Tue, 30 Jan 2018 12:48:30 +0100 Subject: [PATCH] Display all Maintainers/Developers names on the addon page --- app/js/components/manageApps/Addon.jsx | 33 +++++++++++++++----------- tests/components/Addon.test.js | 31 +++++++++++++++++++++++- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/app/js/components/manageApps/Addon.jsx b/app/js/components/manageApps/Addon.jsx index 208d2ea..5458cc5 100644 --- a/app/js/components/manageApps/Addon.jsx +++ b/app/js/components/manageApps/Addon.jsx @@ -69,12 +69,15 @@ class Addon extends Component { axios.get(`${urlPrefix}/${apiBaseUrl}${this.requestUrl}`) .then(response => { this.getAffectedModules(response.data.uuid); - this.setState({ - app: response.data, - loadingComplete: true, - }); + return axios.get(`${ApiHelper.getAddonUrl()}?modulePackage=${response.data.packageName}`) + .then(response => { + this.setState({ + app: response.data, + loadingComplete: true, + }); + }); }).catch((error) => { - error.response.status === 401 ? location.href = `${location.href.substr(0, location.href.indexOf(location.href.split('/')[4]))}login.htm` : null; + error && error.response && error.response.status === 401 ? location.href = `${location.href.substr(0, location.href.indexOf(location.href.split('/')[4]))}login.htm` : null; this.setState({ loadingComplete: true }); }); @@ -277,7 +280,10 @@ class Addon extends Component { messageBody, messageType, showMessage } = this.state; - + + const developerName = app && app.developer ? app.developer.name : null; + const maintainers = app.maintainers ? app.maintainers : developerName; + const message = app.startupErrorMessage && app.startupErrorMessage.length > 0 ? 'Error starting ' : null; @@ -330,7 +336,7 @@ class Addon extends Component {

{app.name}

{app.description}

- {app.uuid ? + {app.uid ?

NOTE: Adding, removing, or starting modules will restart OpenMRS, meaning that all scheduled tasks and background processes will be interrupted.

: null @@ -354,7 +360,11 @@ class Addon extends Component { Version: - {app.version} + + { + app.version || app.latestVersion + } + Type: @@ -368,12 +378,7 @@ class Addon extends Component { Maintainers/Developers: { - app.uuid ? - app.author : - app.developer ? - app.developer.name : - app.maintainers ? - app.maintainers[0].name : "" + Array.isArray(maintainers) ? maintainers.map(maintainer => maintainer.name).join(', ') : maintainers } diff --git a/tests/components/Addon.test.js b/tests/components/Addon.test.js index 0564aa8..8d64e37 100644 --- a/tests/components/Addon.test.js +++ b/tests/components/Addon.test.js @@ -9,6 +9,13 @@ const app = { "display": "Reference Demo Data Module", "name": "Reference Demo Data Module", "description": "Contains metadata and data required to run an instance of the reference application", + "latestVersion": "1.4.4", + "maintainers": [ + {name: "Daniel Kayiwa", url: null}, + {name: "Wyclif Luyima", url: null}, + {name: "Darius Jazayeri", url: null}, + {name: "Rafal Korytkowski", url: null} + ], "packageName": "org.openmrs.module.referencedemodata", "author": "OpenMRS", "version": "1.4.3", @@ -27,7 +34,8 @@ const app = { { "rel": "action", "uri": "http://localhost:8081/openmrs-standalone/ws/rest/v1/moduleaction" }, { "rel": "self", "uri": "http://localhost:8081/openmrs-standalone/ws/rest/v1/module/referencedemodata" } ], - "resourceVersion": "1.8" + "resourceVersion": "1.8", + "uid": "org.openmrs.module.reference-demo-data-module" } describe('', () => { @@ -71,6 +79,27 @@ describe('', () => { expect(component.find(StartErrorModal)).to.have.length(0); }); + it('should display the uid of the module', () => { + component.setState({ app: app }); + expect(component.state().app.uid).to.equal('org.openmrs.module.reference-demo-data-module'); + }); + + it('should display the latestVersion of the module', () => { + component.setState({ app: app }); + expect(component.state().app.latestVersion).to.equal('1.4.4'); + }); + + it('should display the all the developer/maintainers names', () => { + component.setState({ app: app }); + component.instance().fetchModule('module-referencedemodata'); + expect(component.state().app.maintainers).to.be.deep.eql([ + {name: "Daniel Kayiwa", url: null}, + {name: "Wyclif Luyima", url: null}, + {name: "Darius Jazayeri", url: null}, + {name: "Rafal Korytkowski", url: null} + ]); + }); + }); describe('', () => {