Skip to content

Commit

Permalink
Introduce changes to the volumes list
Browse files Browse the repository at this point in the history
This will show network volumes on the volumes list
  • Loading branch information
Philipp Hinrichsen committed Apr 7, 2016
1 parent ee96e01 commit 4f488a7
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 18 deletions.
7 changes: 5 additions & 2 deletions src/js/components/AppListComponent.jsx
Expand Up @@ -159,7 +159,8 @@ var AppListComponent = React.createClass({
}
filterCounts.appsStatusesCount[item.status]++;
if (item.container != null &&
item.container.volumes.filter(item => item.persistent != null)
item.container.volumes.filter(item => item.persistent != null ||
item.external != null)
.length > 0) {
filterCounts.appsVolumesCount++;
}
Expand Down Expand Up @@ -216,7 +217,9 @@ var AppListComponent = React.createClass({
return false;
}

return item.container.volumes.filter(item => item.persistent != null)
return item.container.volumes.filter(item =>
item.persistent != null ||
item.external != null)
.length > 0;
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/AppPageComponent.jsx
Expand Up @@ -304,7 +304,7 @@ var AppPageComponent = React.createClass({
var {appId, volumeId} = this.state;
var volume = AppsStore.getVolumeById(appId, volumeId);

if (volume == null) {
if (volume == null || volumeId == null) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions src/js/components/AppVolumesListItemComponent.jsx
Expand Up @@ -29,14 +29,14 @@ var AppVolumesListItemComponent = React.createClass({

var params = {
appId: encodeURIComponent(volume.appId),
volumeId: encodeURIComponent(volume.persistenceId)
volumeId: encodeURIComponent(volume.persistenceId || volume.external.name)
};

return (
<tr>
<td className={this.getHighlight("id")}>
<Link to="volumeView" params={params}>
{volume.persistenceId}
{volume.persistenceId || volume.external.name}
</Link>
</td>
<td className={this.getHighlight("host")}>
Expand Down
52 changes: 42 additions & 10 deletions src/js/components/VolumeDetailsComponent.jsx
Expand Up @@ -5,6 +5,45 @@ export default React.createClass({
propTypes: {
volume: React.PropTypes.object
},
getTask: function (volume) {
if (volume.taskId == null) {
return null;
}
return (
<div>
<dt>Task Id</dt>
<dd>
<a href={volume.taskURI}>{volume.taskId}</a>
</dd>
</div>
);
},
getSize: function (volume) {
var size = volume.persistent && volume.persistent.size ||
volume.external && volume.external.size;
if (size == null) {
return null;
}
return (
<div>
<dt>Size (MiB)</dt>
<dd>{size}</dd>
</div>
);
},
getHost: function (volume) {
if (volume.host == null) {
return null;
}
return (
<div>
<dt>Host</dt>
<dd>
{volume.host}
</dd>
</div>
);
},
render: function () {
const {volume} = this.props;
if (volume == null) {
Expand All @@ -17,20 +56,13 @@ export default React.createClass({
<dd>{volume.containerPath}</dd>
<dt>Mode</dt>
<dd>{volume.mode}</dd>
<dt>Size (MiB)</dt>
<dd>{volume.persistent.size}</dd>
{this.getSize(volume)}
<dt>Application</dt>
<dd>
<a href={volume.appURI}>{volume.appId}</a>
</dd>
<dt>Task Id</dt>
<dd>
<a href={volume.taskURI}>{volume.taskId}</a>
</dd>
<dt>Host</dt>
<dd>
{volume.host}
</dd>
{this.getTask(volume)}
{this.getHost(volume)}
</dl>
);
}
Expand Down
22 changes: 19 additions & 3 deletions src/js/stores/AppsStore.js
Expand Up @@ -302,7 +302,8 @@ var AppsStore = Util.extendObject(EventEmitter.prototype, {
return null;
}

return volumes.find((volume) => volume.persistenceId === volumeId);
return volumes.find((volume) => volume.persistenceId === volumeId ||
volume.external.name === volumeId);
},

getVolumes: function (appId) {
Expand All @@ -313,7 +314,22 @@ var AppsStore = Util.extendObject(EventEmitter.prototype, {
return null;
}

return tasks
var networkVolumes = [];

if (app.container != null && app.container.volumes != null) {
networkVolumes = app.container.volumes.filter(
volume => volume.external != null
).map(
volume => {
volume.appId = appId;
volume.id = volume.external.name;
volume.status = VolumesConstants.STATUS.ATTACHED;
return volume;
}
);
}

return networkVolumes.concat(tasks
// Get the first volume from a task with the same id as provided
// by the router. This should be unique.
.reduce((memo, task) => {
Expand All @@ -338,7 +354,7 @@ var AppsStore = Util.extendObject(EventEmitter.prototype, {
: VolumesConstants.STATUS.ATTACHED;
return volume;
}));
}, []);
}, []));
}
});

Expand Down

0 comments on commit 4f488a7

Please sign in to comment.