summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-12-31 10:13:01 +0000
committerGerrit Code Review <review@openstack.org>2018-12-31 10:13:01 +0000
commit98b1fc77d2248bbdeb9ad102a6ae000d8d09a30e (patch)
treef7227c7d2f613d1b7aa413805d1002b2a7017279
parente6b854d2e5dace9ba78db94987f6c77890646482 (diff)
parent8f8658a3feef5433d8bb5a2a38fa111fa62229ab (diff)
Merge "web: add labels page"
-rw-r--r--web/src/api.js4
-rw-r--r--web/src/pages/Labels.jsx86
-rw-r--r--web/src/routes.js6
3 files changed, 96 insertions, 0 deletions
diff --git a/web/src/api.js b/web/src/api.js
index 51798ca..03dd15b 100644
--- a/web/src/api.js
+++ b/web/src/api.js
@@ -140,6 +140,9 @@ function fetchJob (apiPrefix, jobName) {
140function fetchJobs (apiPrefix) { 140function fetchJobs (apiPrefix) {
141 return Axios.get(apiUrl + apiPrefix + 'jobs') 141 return Axios.get(apiUrl + apiPrefix + 'jobs')
142} 142}
143function fetchLabels (apiPrefix) {
144 return Axios.get(apiUrl + apiPrefix + 'labels')
145}
143 146
144export { 147export {
145 getHomepageUrl, 148 getHomepageUrl,
@@ -153,6 +156,7 @@ export {
153 fetchProjects, 156 fetchProjects,
154 fetchJob, 157 fetchJob,
155 fetchJobs, 158 fetchJobs,
159 fetchLabels,
156 fetchTenants, 160 fetchTenants,
157 fetchInfo 161 fetchInfo
158} 162}
diff --git a/web/src/pages/Labels.jsx b/web/src/pages/Labels.jsx
new file mode 100644
index 0000000..d262c14
--- /dev/null
+++ b/web/src/pages/Labels.jsx
@@ -0,0 +1,86 @@
1// Copyright 2018 Red Hat, Inc
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may
4// not use this file except in compliance with the License. You may obtain
5// a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations
13// under the License.
14
15import * as React from 'react'
16import PropTypes from 'prop-types'
17import { connect } from 'react-redux'
18import { Table } from 'patternfly-react'
19
20import { fetchLabels } from '../api'
21
22
23class LabelsPage extends React.Component {
24 static propTypes = {
25 tenant: PropTypes.object
26 }
27
28 state = {
29 labels: null
30 }
31
32 updateData () {
33 fetchLabels(this.props.tenant.apiPrefix).then(response => {
34 this.setState({labels: response.data})
35 })
36 }
37
38 componentDidMount () {
39 document.title = 'Zuul Labels'
40 if (this.props.tenant.name) {
41 this.updateData()
42 }
43 }
44
45 componentDidUpdate (prevProps) {
46 if (this.props.tenant.name !== prevProps.tenant.name) {
47 this.updateData()
48 }
49 }
50
51 render () {
52 const { labels } = this.state
53 if (!labels) {
54 return (<p>Loading...</p>)
55 }
56
57 const headerFormat = value => <Table.Heading>{value}</Table.Heading>
58 const cellFormat = value => <Table.Cell>{value}</Table.Cell>
59 const columns = []
60 const myColumns = ['name']
61 myColumns.forEach(column => {
62 let formatter = cellFormat
63 let prop = column
64 columns.push({
65 header: {label: column, formatters: [headerFormat]},
66 property: prop,
67 cell: {formatters: [formatter]}
68 })
69 })
70 return (
71 <Table.PfProvider
72 striped
73 bordered
74 hover
75 columns={columns}
76 >
77 <Table.Header/>
78 <Table.Body
79 rows={labels}
80 rowKey="name"
81 />
82 </Table.PfProvider>)
83 }
84}
85
86export default connect(state => ({tenant: state.tenant}))(LabelsPage)
diff --git a/web/src/routes.js b/web/src/routes.js
index cd58dfe..99653ec 100644
--- a/web/src/routes.js
+++ b/web/src/routes.js
@@ -18,6 +18,7 @@ import ProjectPage from './pages/Project'
18import ProjectsPage from './pages/Projects' 18import ProjectsPage from './pages/Projects'
19import JobPage from './pages/Job' 19import JobPage from './pages/Job'
20import JobsPage from './pages/Jobs' 20import JobsPage from './pages/Jobs'
21import LabelsPage from './pages/Labels'
21import BuildPage from './pages/Build' 22import BuildPage from './pages/Build'
22import BuildsPage from './pages/Builds' 23import BuildsPage from './pages/Builds'
23import ConfigErrorsPage from './pages/ConfigErrors' 24import ConfigErrorsPage from './pages/ConfigErrors'
@@ -45,6 +46,11 @@ const routes = () => [
45 component: JobsPage 46 component: JobsPage
46 }, 47 },
47 { 48 {
49 title: 'Labels',
50 to: '/labels',
51 component: LabelsPage
52 },
53 {
48 title: 'Builds', 54 title: 'Builds',
49 to: '/builds', 55 to: '/builds',
50 component: BuildsPage 56 component: BuildsPage