Merge pull request #1702 from ClemMakesApps/add-container-id

Add container ID to sidebar
This commit is contained in:
French Ben 2016-06-01 18:20:16 -07:00
commit 0436f5f968
2 changed files with 65 additions and 9 deletions

View File

@ -1,7 +1,7 @@
import _ from 'underscore'; import _ from 'underscore';
import React from 'react/addons'; import React from 'react/addons';
import metrics from '../utils/MetricsUtil'; import metrics from '../utils/MetricsUtil';
import electron from 'electron'; import electron, { clipboard } from 'electron';
const remote = electron.remote; const remote = electron.remote;
const dialog = remote.dialog; const dialog = remote.dialog;
import ContainerUtil from '../utils/ContainerUtil'; import ContainerUtil from '../utils/ContainerUtil';
@ -26,6 +26,7 @@ var ContainerSettingsGeneral = React.createClass({
return { return {
slugName: null, slugName: null,
nameError: null, nameError: null,
copiedId: false,
env: env env: env
}; };
}, },
@ -60,6 +61,20 @@ var ContainerSettingsGeneral = React.createClass({
} }
}, },
handleCopyContainerId: function() {
clipboard.writeText(this.props.container.Id);
this.setState({
copiedId: true
});
var _this = this;
setTimeout(function() {
_this.setState({
copiedId: false
});
}, 5000);
},
handleSaveContainerName: function () { handleSaveContainerName: function () {
var newName = this.state.slugName; var newName = this.state.slugName;
if (newName === this.props.container.Name) { if (newName === this.props.container.Name) {
@ -154,6 +169,7 @@ var ContainerSettingsGeneral = React.createClass({
return false; return false;
} }
var clipboardStatus;
var willBeRenamedAs; var willBeRenamedAs;
var btnSaveName = ( var btnSaveName = (
<a className="btn btn-action" onClick={this.handleSaveContainerName} disabled="disabled">Save</a> <a className="btn btn-action" onClick={this.handleSaveContainerName} disabled="disabled">Save</a>
@ -171,14 +187,27 @@ var ContainerSettingsGeneral = React.createClass({
); );
} }
let rename = ( if (this.state.copiedId) {
clipboardStatus = (
<p className="fadeOut"><strong>Copied to Clipboard</strong></p>
);
}
let containerInfo = (
<div className="settings-section"> <div className="settings-section">
<h3>Container Name</h3> <h3>Container Info</h3>
<div className="container-name"> <div className="container-info-row">
<div className="label-id">ID</div>
<input type="text" className="line disabled" defaultValue={this.props.container.Id} disabled></input>
<a className="btn btn-action btn-copy" onClick={this.handleCopyContainerId}>Copy</a>
{clipboardStatus}
</div>
<div className="container-info-row">
<div className="label-name">NAME</div>
<input id="input-container-name" type="text" className="line" placeholder="Container Name" defaultValue={this.props.container.Name} onChange={this.handleNameChange} onKeyUp={this.handleNameOnKeyUp}></input> <input id="input-container-name" type="text" className="line" placeholder="Container Name" defaultValue={this.props.container.Name} onChange={this.handleNameChange} onKeyUp={this.handleNameOnKeyUp}></input>
{btnSaveName}
{willBeRenamedAs} {willBeRenamedAs}
</div> </div>
{btnSaveName}
</div> </div>
); );
@ -202,7 +231,7 @@ var ContainerSettingsGeneral = React.createClass({
return ( return (
<div className="settings-panel"> <div className="settings-panel">
{rename} {containerInfo}
<div className="settings-section"> <div className="settings-section">
<h3>Environment Variables</h3> <h3>Environment Variables</h3>
<div className="env-vars-labels"> <div className="env-vars-labels">

View File

@ -61,12 +61,37 @@
.settings-section { .settings-section {
margin-bottom: 4rem; margin-bottom: 4rem;
} }
.container-name { .container-info-row {
margin-bottom: 2rem; margin-bottom: 5px;
.label-id, .label-name {
.env-vars-labels;
display: inline-block;
width: 5%;
min-width: 75px;
}
a {
margin-left: 10px;
}
input { input {
width: 100%; width: 55%;
max-width: 500px; max-width: 500px;
} }
.btn-copy {
border: none;
margin-left: 11px;
}
.disabled {
border-bottom: none;
}
.fadeOut {
animation: fade-out 5s ease-in-out forwards;
}
@keyframes fade-out {
0% { opacity: 0; }
10% { opacity: 1; }
85% { opacity: 1; }
100% { opacity: 0; }
}
p { p {
font-weight: 300; font-weight: 300;
margin-top: 5px; margin-top: 5px;
@ -75,6 +100,8 @@
strong { strong {
font-weight: 500; font-weight: 500;
} }
margin-left: 75px;
padding-left: 10px;
} }
} }
.env-vars-labels { .env-vars-labels {