mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-27 13:56:17 +00:00
new project selector
This commit is contained in:
parent
cc064aafda
commit
08a4e58b8f
@ -0,0 +1,43 @@
|
|||||||
|
.projects-selector {
|
||||||
|
position: relative;
|
||||||
|
width: 300px;
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
&_preview {
|
||||||
|
color: rgba(255, 255, 255, 0.5);
|
||||||
|
padding: 5px 25px 5px 5px;
|
||||||
|
&_text {
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&_input {
|
||||||
|
width: 80%;
|
||||||
|
padding-bottom: 3px;
|
||||||
|
padding-left: 10px;
|
||||||
|
border: none;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
|
||||||
|
background: transparent;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&_items {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
padding: 15px 5px 5px;
|
||||||
|
left: 0;
|
||||||
|
background: #2c3e50;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&_item {
|
||||||
|
padding: 5px 10px;
|
||||||
|
&_run {
|
||||||
|
color: rgba(255, 255, 255, 0.5);
|
||||||
|
&:hover {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,6 @@ define([
|
|||||||
'templates/app/components/app/template'
|
'templates/app/components/app/template'
|
||||||
], function(React, ProjectActions, BuildActions, Projects, Builds, template) {
|
], function(React, ProjectActions, BuildActions, Projects, Builds, template) {
|
||||||
template = template.locals({
|
template = template.locals({
|
||||||
ProjectsList: Projects.List,
|
|
||||||
BuildsList: Builds.List
|
BuildsList: Builds.List
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
.main-row
|
.main-row
|
||||||
.row
|
.row
|
||||||
.col-md-4.col-md-push-8
|
.col-md-8
|
||||||
h2 Projects
|
h2 Active builds
|
||||||
ProjectsList()
|
|
||||||
|
|
||||||
.col-md-8.col-md-pull-4
|
|
||||||
BuildsList()
|
BuildsList()
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
- console.log('builds', items)
|
- console.log('builds', items)
|
||||||
.builds
|
.builds
|
||||||
|
if !items.length
|
||||||
|
p Build queue is empty
|
||||||
each build, index in items
|
each build, index in items
|
||||||
Item(build=build, key=build.id)
|
Item(build=build, key=build.id)
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
define([
|
define([
|
||||||
'react',
|
'react',
|
||||||
'react-router',
|
'react-router',
|
||||||
|
'app/components/projects/selector/index',
|
||||||
'templates/app/components/header/template'
|
'templates/app/components/header/template'
|
||||||
], function(React, Router, template) {
|
], function(React, Router, ProjectsSelector, template) {
|
||||||
template = template.locals({
|
template = template.locals({
|
||||||
Link: Router.Link
|
Link: Router.Link,
|
||||||
|
ProjectsSelector: ProjectsSelector
|
||||||
});
|
});
|
||||||
|
|
||||||
var Component = React.createClass({
|
var Component = React.createClass({
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
.container-fluid
|
.container-fluid
|
||||||
.navbar-header
|
.navbar-header
|
||||||
a.navbar-brand(href="/")
|
a.navbar-brand(href="/")
|
||||||
span Company Brand Name CI
|
span NCI
|
||||||
form.navbar-left.navbar-form
|
.navbar-left.navbar-form(style={paddingTop: "11px"})
|
||||||
.form-group
|
ProjectsSelector()
|
||||||
input.form-control(placeholder="Start typing project name...", style={width: '220px'})
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define([
|
define([
|
||||||
'app/components/projects/item',
|
'app/components/projects/selector/index'
|
||||||
'app/components/projects/list'
|
], function(Selector) {
|
||||||
], function(Item, List) {
|
|
||||||
return {
|
return {
|
||||||
Item: Item,
|
Selector: Selector
|
||||||
List: List
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
li.list-group-item
|
|
||||||
a.pull-right(href="javascript:void(0);", onClick=onProjectSelect(item.name)) start build
|
|
||||||
span= item.name
|
|
@ -1,19 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
define([
|
|
||||||
'react', 'app/actions/project', 'templates/app/components/projects/item',
|
|
||||||
], function(React, ProjectActions, template) {
|
|
||||||
var Component = React.createClass({
|
|
||||||
onProjectSelect: function(projectName) {
|
|
||||||
ProjectActions.run(projectName)
|
|
||||||
},
|
|
||||||
render: function() {
|
|
||||||
return template({
|
|
||||||
item: this.props.item,
|
|
||||||
onProjectSelect: this.onProjectSelect
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return Component;
|
|
||||||
});
|
|
@ -1,3 +0,0 @@
|
|||||||
ul.list-group
|
|
||||||
each project, index in items
|
|
||||||
Item(item=project, key=project.name)
|
|
@ -1,32 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
define([
|
|
||||||
'react',
|
|
||||||
'reflux',
|
|
||||||
'./item',
|
|
||||||
'app/stores/project',
|
|
||||||
'templates/app/components/projects/list'
|
|
||||||
], function(React, Reflux, Item, projectStore, template) {
|
|
||||||
var Component = React.createClass({
|
|
||||||
mixins: [Reflux.ListenerMixin],
|
|
||||||
componentDidMount: function() {
|
|
||||||
this.listenTo(projectStore, this.updateItems);
|
|
||||||
},
|
|
||||||
updateItems: function(items) {
|
|
||||||
this.setState({items: items});
|
|
||||||
},
|
|
||||||
render: function() {
|
|
||||||
return template({
|
|
||||||
Item: Item,
|
|
||||||
items: this.state.items
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getInitialState: function() {
|
|
||||||
return {
|
|
||||||
items: []
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return Component;
|
|
||||||
});
|
|
23
static/js/app/components/projects/selector/index.jade
Normal file
23
static/js/app/components/projects/selector/index.jade
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
.projects-selector(href="javascript:void(0);")
|
||||||
|
if !this.state.showSearch
|
||||||
|
span.projects-selector_preview(onClick=this.onSearchProject)
|
||||||
|
i.fa.fa-fw.fa-bars
|
||||||
|
span.projects-selector_preview_text Select a project...
|
||||||
|
else
|
||||||
|
input.projects-selector_input(
|
||||||
|
type="text",
|
||||||
|
value=this.state.searchQuery,
|
||||||
|
onChange=this.onSearchChange,
|
||||||
|
ref=this.onInputMount,
|
||||||
|
onBlur=this.onBlurSearch
|
||||||
|
)
|
||||||
|
ul.projects-selector_items
|
||||||
|
each project in this.state.projects
|
||||||
|
li.projects-selector_item.row(key=project.name)
|
||||||
|
.col-md-8
|
||||||
|
p= project.name
|
||||||
|
.col-md-4.text-small.text-right
|
||||||
|
a.projects-selector_item_run(href="javascript:void(0);", onMouseDown=this.onRunProject(project.name))
|
||||||
|
i.fa.fa-fw.fa-play
|
||||||
|
|
||||||
|
|
45
static/js/app/components/projects/selector/index.js
Normal file
45
static/js/app/components/projects/selector/index.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
define([
|
||||||
|
'react', 'reflux', 'app/actions/project',
|
||||||
|
'app/stores/project',
|
||||||
|
'templates/app/components/projects/selector/index'
|
||||||
|
], function(React, Reflux, ProjectActions, projectsStore, template) {
|
||||||
|
return React.createClass({
|
||||||
|
mixins: [Reflux.ListenerMixin],
|
||||||
|
componentDidMount: function() {
|
||||||
|
this.listenTo(projectsStore, this.updateItems);
|
||||||
|
},
|
||||||
|
getInitialState: function() {
|
||||||
|
return {
|
||||||
|
showSearch: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
onRunProject: function(projectName) {
|
||||||
|
ProjectActions.run(projectName)
|
||||||
|
this.setState({showSearch: false});
|
||||||
|
},
|
||||||
|
updateItems: function(projects) {
|
||||||
|
console.log(projects);
|
||||||
|
this.setState({projects: projects});
|
||||||
|
},
|
||||||
|
onSearchProject: function() {
|
||||||
|
this.setState({showSearch: true});
|
||||||
|
},
|
||||||
|
onInputMount: function(component) {
|
||||||
|
var node = React.findDOMNode(component);
|
||||||
|
if (node) {
|
||||||
|
node.focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onBlurSearch: function() {
|
||||||
|
this.setState({showSearch: false});
|
||||||
|
},
|
||||||
|
onSearchChange: function(event) {
|
||||||
|
var query = event.target.value;
|
||||||
|
this.setState({searchQuery: query});
|
||||||
|
ProjectActions.readAll({nameQuery: query});
|
||||||
|
},
|
||||||
|
render: template,
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user