зеркало из https://github.com/docker/kitematic.git
Add an image tag names filter (#3782)
* Add an image tag names filter Signed-off-by: Gael Hanquez <hanquez.gael@gmail.com> * Fix overlay shifts
This commit is contained in:
Родитель
20d1a3638a
Коммит
082bfd558a
|
@ -12,6 +12,7 @@ import tagActions from '../actions/TagActions';
|
||||||
import networkActions from '../actions/NetworkActions';
|
import networkActions from '../actions/NetworkActions';
|
||||||
import networkStore from '../stores/NetworkStore';
|
import networkStore from '../stores/NetworkStore';
|
||||||
import numeral from 'numeral';
|
import numeral from 'numeral';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
var ImageCard = React.createClass({
|
var ImageCard = React.createClass({
|
||||||
mixins: [Router.Navigation],
|
mixins: [Router.Navigation],
|
||||||
|
@ -20,7 +21,8 @@ var ImageCard = React.createClass({
|
||||||
tags: this.props.tags || [],
|
tags: this.props.tags || [],
|
||||||
chosenTag: this.props.chosenTag || 'latest',
|
chosenTag: this.props.chosenTag || 'latest',
|
||||||
defaultNetwork: this.props.defaultNetwork || 'bridge',
|
defaultNetwork: this.props.defaultNetwork || 'bridge',
|
||||||
networks: networkStore.all()
|
networks: networkStore.all(),
|
||||||
|
searchTag: ''
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
componentDidMount: function () {
|
componentDidMount: function () {
|
||||||
|
@ -96,6 +98,7 @@ var ImageCard = React.createClass({
|
||||||
} else {
|
} else {
|
||||||
tagActions.tags(this.props.image.namespace + '/' + this.props.image.name);
|
tagActions.tags(this.props.image.namespace + '/' + this.props.image.name);
|
||||||
}
|
}
|
||||||
|
this.focusSearchTagInput();
|
||||||
},
|
},
|
||||||
handleCloseTagOverlay: function () {
|
handleCloseTagOverlay: function () {
|
||||||
let $menuOverlay = $(this.getDOMNode()).find('.menu-overlay');
|
let $menuOverlay = $(this.getDOMNode()).find('.menu-overlay');
|
||||||
|
@ -127,7 +130,15 @@ var ImageCard = React.createClass({
|
||||||
}
|
}
|
||||||
shell.openExternal(repoUri);
|
shell.openExternal(repoUri);
|
||||||
},
|
},
|
||||||
render: function () {
|
searchTag: function(event) {
|
||||||
|
this.setState({ searchTag: event.target.value });
|
||||||
|
},
|
||||||
|
|
||||||
|
focusSearchTagInput: function() {
|
||||||
|
this.refs.searchTagInput.getDOMNode().focus();
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
var name;
|
var name;
|
||||||
if (this.props.image.namespace === 'library') {
|
if (this.props.image.namespace === 'library') {
|
||||||
name = (
|
name = (
|
||||||
|
@ -167,7 +178,7 @@ var ImageCard = React.createClass({
|
||||||
} else if (this.state.tags.length === 0) {
|
} else if (this.state.tags.length === 0) {
|
||||||
tags = <div className="no-items">No Tags</div>;
|
tags = <div className="no-items">No Tags</div>;
|
||||||
} else {
|
} else {
|
||||||
var tagDisplay = this.state.tags.map((tag) => {
|
var tagDisplay = this.state.tags.filter(tag => tag.name.includes(this.state.searchTag)).map((tag) => {
|
||||||
let t = '';
|
let t = '';
|
||||||
if (tag.name) {
|
if (tag.name) {
|
||||||
t = tag.name;
|
t = tag.name;
|
||||||
|
@ -283,11 +294,22 @@ var ImageCard = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let searchTagInputStyle = { outline: 'none', width: 'calc(100% - 30px)' };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="image-item">
|
<div className="image-item">
|
||||||
{overlay}
|
{overlay}
|
||||||
<div className="overlay item-overlay tag-overlay">
|
<div className="overlay item-overlay tag-overlay">
|
||||||
<p>Please select an image tag.</p>
|
<p>
|
||||||
|
<input
|
||||||
|
ref="searchTagInput"
|
||||||
|
style={searchTagInputStyle}
|
||||||
|
type="text"
|
||||||
|
placeholder="Filter image tag."
|
||||||
|
onChange={this.searchTag}
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
{tags}
|
{tags}
|
||||||
<div className="close-overlay" onClick={this.handleCloseTagOverlay}>
|
<div className="close-overlay" onClick={this.handleCloseTagOverlay}>
|
||||||
<a className="btn btn-action circular"><span className="icon icon-delete"></span></a>
|
<a className="btn btn-action circular"><span className="icon icon-delete"></span></a>
|
||||||
|
|
|
@ -202,8 +202,7 @@
|
||||||
flex: 1 0;
|
flex: 1 0;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border-radius: @border-radius;
|
border-radius: @border-radius;
|
||||||
min-width: @image-card-width;
|
width: 100%;
|
||||||
max-width: @image-card-width;
|
|
||||||
height: @image-card-height;
|
height: @image-card-height;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
color: @gray-normal;
|
color: @gray-normal;
|
||||||
|
@ -233,8 +232,8 @@
|
||||||
}
|
}
|
||||||
.close-overlay {
|
.close-overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 1rem;
|
top: 0.5rem;
|
||||||
right: 1rem;
|
right: 0.5rem;
|
||||||
}
|
}
|
||||||
.remove {
|
.remove {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -266,8 +265,8 @@
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
.close-overlay {
|
.close-overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0.6rem;
|
top: 0.5rem;
|
||||||
right: 0.7rem;
|
right: 0.5rem;
|
||||||
}
|
}
|
||||||
p {
|
p {
|
||||||
color: @gray-normal;
|
color: @gray-normal;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче