Skip to content

Commit

Permalink
Merge branch 'develop' into split-delta-handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
huwshimi authored Sep 21, 2018
2 parents 75b03d3 + a5d6a63 commit bdab6ac
Show file tree
Hide file tree
Showing 25 changed files with 755 additions and 657 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,32 @@ exports[`StatusApplicationList renders 1`] = `
"content": <span>
<img
className="status-view__icon"
src="django.svg"
src="v5/~containers/etcd-126/icon.svg"
/>
django
etcd
</span>,
},
Object {
"columnSize": 2,
"content": "1.10",
"content": "",
},
Object {
"columnSize": 2,
"content": <StatusLabel
status="active"
status="waiting"
/>,
},
Object {
"columnSize": 1,
"content": 0,
"content": 1,
},
Object {
"columnSize": 2,
"content": <a
className="status-view__link"
onClick={[Function]}
>
u/who/django/xenial
u/containers/etcd
</a>,
},
Object {
Expand All @@ -81,11 +81,11 @@ exports[`StatusApplicationList renders 1`] = `
},
Object {
"columnSize": 1,
"content": 42,
"content": 126,
},
],
"extraData": "ok",
"key": "django",
"key": "etcd",
"onClick": [Function],
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ const PropTypes = require('prop-types');
const React = require('react');
const { urls } = require('jaaslib');

const maracaPropTypes = require('../../../../maraca/prop-types');
const StatusLabel = require('../label/label');
const StatusTable = require('../table/table');

const utils = require('../../../../init/utils');
const {
getRealUnits,
getStatusClass,
normaliseStatus
} = require('../../utils');
Expand All @@ -21,28 +22,29 @@ class StatusApplicationList extends React.Component {
@returns {Array} The list of rows.
*/
_generateRows() {
return this.props.applications.map(application => {
// TODO: the passed in applications should be plain objects instead of YUI models.
const app = application.getAttrs();
const charm = urls.URL.fromLegacyString(app.charm);
const {applications} = this.props;
return Object.keys(this.props.applications).map(key => {
const app = applications[key];
const charm = urls.URL.fromLegacyString(app.charmURL);
const store = charm.schema === 'cs' ? 'jujucharms' : 'local';
const revision = charm.revision;
const charmId = charm.path();
const units = getRealUnits(app.units);
const units = Object.keys(this.props.units).filter(key =>
this.props.units[key].application === app.name);
// Set the revision to null so that it's not included when calling
// charm.path() below.
charm.revision = null;
return {
classes: [getStatusClass(
'status-table__row--', app.status.current)],
onClick: this.props.generateApplicationOnClick(app.id),
clickURL: this.props.generateApplicationURL(app.id),
onClick: this.props.generateApplicationOnClick(app.name),
clickURL: this.props.generateApplicationURL(app.name),
columns: [{
columnSize: 2,
content: (
<span>
<img className="status-view__icon"
src={app.icon} />
src={utils.getIconPath(app.charmURL, false)} />
{app.name}
</span>)
}, {
Expand Down Expand Up @@ -109,12 +111,13 @@ class StatusApplicationList extends React.Component {
};

StatusApplicationList.propTypes = {
applications: PropTypes.array.isRequired,
applications: maracaPropTypes.applications,
generateApplicationOnClick: PropTypes.func.isRequired,
generateApplicationURL: PropTypes.func.isRequired,
generateCharmURL: PropTypes.func.isRequired,
onCharmClick: PropTypes.func.isRequired,
statusFilter: PropTypes.string
statusFilter: PropTypes.string,
units: maracaPropTypes.units
};

module.exports = StatusApplicationList;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const enzyme = require('enzyme');
const StatusApplicationList = require('./application-list');

describe('StatusApplicationList', () => {
let applications;
let applications, units;

const renderComponent = (options = {}) => enzyme.shallow(
<StatusApplicationList
Expand All @@ -18,23 +18,70 @@ describe('StatusApplicationList', () => {
options.generateApplicationURL || sinon.stub().returns('http://example.com')}
generateCharmURL={options.generateCharmURL || sinon.stub()}
onCharmClick={options.onCharmClick || sinon.stub()}
statusFilter={options.statusFilter} />
statusFilter={options.statusFilter}
units={options.units || units} />
);

beforeEach(() => {
applications = [{
getAttrs: sinon.stub().returns({
charm: '~who/xenial/django-42',
exposed: true,
icon: 'django.svg',
id: 'django',
name: 'django',
pending: false,
status: {current: 'active'},
units: [],
workloadVersion: '1.10'
})
}];
applications = {
etcd: {
modelUUID: '32c9c2db-0955-459a-8201-539657ef0da1',
name: 'etcd',
exposed: false,
charmURL: 'cs:~containers/etcd-126',
ownerTag: '',
life: 'alive',
minUnits: 0,
constraints: {
'root-disk': 8192
},
config: {
channel: '3.2/stable'
},
subordinate: false,
status: {
current: 'waiting',
message: 'waiting for machine',
since: '2018-09-18T12:31:14.763574172Z',
version: ''
},
workloadVersion: ''
}
};
units = {
'etcd/0': {
modelUUID: '32c9c2db-0955-459a-8201-539657ef0da1',
name: 'etcd/0',
application: 'etcd',
series: 'xenial',
charmURL: 'cs:~containers/etcd-126',
publicAddress: '13.211.141.188',
privateAddress: '172.31.6.46',
machineID: '2',
ports: [{
protocol: 'tcp',
number: 2379
}],
portRanges: [{
fromPort: 2379,
toPort: 2379,
protocol: 'tcp'
}],
subordinate: false,
workloadStatus: {
current: 'active',
message: 'Healthy with 3 known peers',
since: '2018-09-18T12:37:52.738056612Z',
version: ''
},
agentStatus: {
current: 'idle',
message: '',
since: '2018-09-18T12:43:05.056981166Z',
version: '2.4.3'
}
}
};
});

it('renders', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,6 @@ exports[`StatusMachineList renders 1`] = `
}
rows={
Array [
Object {
"classes": Array [
"status-table__row--pending",
],
"clickURL": "http://example.com",
"columns": Array [
Object {
"columnSize": 1,
"content": "1",
},
Object {
"columnSize": 2,
"content": <StatusLabel
status="pending"
/>,
},
Object {
"columnSize": 2,
"content": "1.2.3.6",
},
Object {
"columnSize": 3,
"content": "machine-1",
},
Object {
"columnSize": 1,
"content": "zesty",
},
Object {
"columnSize": 3,
"content": "",
},
],
"extraData": "pending",
"key": "m1",
"onClick": [Function],
},
Object {
"classes": Array [
"status-table__row--ok",
Expand All @@ -77,7 +40,7 @@ exports[`StatusMachineList renders 1`] = `
"columns": Array [
Object {
"columnSize": 1,
"content": "2",
"content": "0",
},
Object {
"columnSize": 2,
Expand All @@ -87,58 +50,23 @@ exports[`StatusMachineList renders 1`] = `
},
Object {
"columnSize": 2,
"content": "1.2.3.7",
"content": "13.210.238.155",
},
Object {
"columnSize": 3,
"content": "machine-2",
},
Object {
"columnSize": 1,
"content": "trusty",
},
Object {
"columnSize": 3,
"content": "yes, I am started",
},
],
"extraData": "ok",
"key": "m2",
"onClick": [Function],
},
Object {
"classes": Array [
"",
],
"clickURL": "http://example.com",
"columns": Array [
Object {
"columnSize": 1,
"content": "3",
},
Object {
"columnSize": 2,
"content": null,
},
Object {
"columnSize": 2,
"content": "",
},
Object {
"columnSize": 3,
"content": "",
"content": "i-06d8e73e06dcddb38",
},
Object {
"columnSize": 1,
"content": "trusty",
"content": "xenial",
},
Object {
"columnSize": 3,
"content": "",
},
],
"extraData": "ok",
"key": "new1",
"key": "0",
"onClick": [Function],
},
]
Expand Down
Loading

0 comments on commit bdab6ac

Please sign in to comment.