Skip to content

Commit

Permalink
Display all Maintainers/Developers names on the addon page
Browse files Browse the repository at this point in the history
  • Loading branch information
Charpell committed Feb 1, 2018
1 parent a716539 commit bce2de0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 15 deletions.
33 changes: 19 additions & 14 deletions app/js/components/manageApps/Addon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -330,7 +336,7 @@ class Addon extends Component {
<div className="title-container">
<h3 id="addon-name">{app.name}</h3>
<p id="addon-description">{app.description}</p>
{app.uuid ?
{app.uid ?
<p id="addon-description">NOTE: Adding, removing, or starting modules will restart OpenMRS, meaning that all scheduled tasks and background processes will be interrupted.</p>
:
null
Expand All @@ -354,7 +360,11 @@ class Addon extends Component {
</tr>
<tr>
<td className="row-title">Version:</td>
<td>{app.version}</td>
<td>
{
app.version || app.latestVersion
}
</td>
</tr>
<tr>
<td className="row-title">Type:</td>
Expand All @@ -368,12 +378,7 @@ class Addon extends Component {
<td className="row-title">Maintainers/Developers:</td>
<td>
{
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
}
</td>
</tr>
Expand Down
31 changes: 30 additions & 1 deletion tests/components/Addon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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('<Addon />', () => {
Expand Down Expand Up @@ -71,6 +79,27 @@ describe('<Addon />', () => {
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('<StartErrorModal />', () => {
Expand Down

0 comments on commit bce2de0

Please sign in to comment.