Add parameterized builds (web)
This implements the web interface portion of the parameterized builds spec: * Enqueue page * Display of parameters on buildset page (and re-enqueue) Change-Id: Ic89182108e703bbb235b430cd6e22de3b50d9f57
This commit is contained in:
1 parent
9a748ac777
commit
7521f39876
6 files changed
+596
-4
No files matched your search
+1
-1
@@ -410,7 +410,7 @@ class AppComponent extends React.Component {
|
||||
const { isKebabDropdownOpen } = this.state
|
||||
const { notifications, tenantStatus, tenant, info, auth } = this.props
|
||||
|
||||
const menu = routes(auth.info)
|
||||
const menu = routes(auth.info, this.props.user)
|
||||
const nav = this.renderMenu(menu)
|
||||
|
||||
const kebabDropdownItems = []
|
||||
|
||||
+13
-1
@@ -395,7 +395,7 @@ function enqueue(apiPrefix, projectName, pipeline, change) {
|
||||
)
|
||||
}
|
||||
|
||||
function enqueue_ref(apiPrefix, projectName, pipeline, ref, oldrev, newrev) {
|
||||
function enqueue_ref(apiPrefix, projectName, pipeline, ref, oldrev, newrev, params) {
|
||||
return makeRequest(
|
||||
apiPrefix + 'project/' + projectName + '/enqueue',
|
||||
'post',
|
||||
@@ -404,6 +404,7 @@ function enqueue_ref(apiPrefix, projectName, pipeline, ref, oldrev, newrev) {
|
||||
ref: ref,
|
||||
oldrev: oldrev,
|
||||
newrev: newrev,
|
||||
parameters: params,
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -442,6 +443,16 @@ function promote(apiPrefix, pipeline, changes) {
|
||||
)
|
||||
}
|
||||
|
||||
function freezePipeline(apiPrefix, pipeline, project, ref) {
|
||||
return makeRequest(
|
||||
apiPrefix + 'project/' + project + '/freeze-pipeline',
|
||||
'post',
|
||||
{
|
||||
pipeline: pipeline,
|
||||
ref: ref,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
apiUrl,
|
||||
@@ -496,4 +507,5 @@ export {
|
||||
setNodeState,
|
||||
setTenantState,
|
||||
validateImageUpload,
|
||||
freezePipeline,
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import React, { useState } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect, useDispatch } from 'react-redux'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { JSONTree } from 'react-json-tree'
|
||||
import {
|
||||
Button,
|
||||
CodeBlock,
|
||||
@@ -31,6 +32,7 @@ import {
|
||||
ModalVariant,
|
||||
} from '@patternfly/react-core'
|
||||
import {
|
||||
CodeIcon,
|
||||
CodeBranchIcon,
|
||||
OutlinedCommentDotsIcon,
|
||||
FingerprintIcon,
|
||||
@@ -219,7 +221,7 @@ function Buildset({ buildset, timezone, tenant, user, preferences }) {
|
||||
setShowEnqueueModal(false)
|
||||
if (ref.change === null) {
|
||||
enqueue_ref(tenant.apiPrefix, ref.project, buildset.pipeline,
|
||||
ref.ref, ref.oldrev, ref.newrev)
|
||||
ref.ref, ref.oldrev, ref.newrev, buildset.parameters)
|
||||
.then(() => {
|
||||
dispatch(addNotification(
|
||||
{
|
||||
@@ -343,9 +345,34 @@ function Buildset({ buildset, timezone, tenant, user, preferences }) {
|
||||
<span>
|
||||
<strong>UUID </strong> {buildset.uuid} <br />
|
||||
<strong>Event ID </strong> {buildset.event_id} <br />
|
||||
{buildset.user_id && (
|
||||
<>
|
||||
<strong>User ID </strong> {buildset.user_id} <br />
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
{buildset.parameters && (
|
||||
<IconProperty
|
||||
WrapElement={ListItem}
|
||||
icon={<CodeIcon />}
|
||||
value={
|
||||
<>
|
||||
<strong>Parameters </strong>
|
||||
<span style={{whiteSpace: 'pre-wrap'}}>
|
||||
<JSONTree
|
||||
data={buildset.parameters}
|
||||
hideRoot={true}
|
||||
sortObjectKeys={true}
|
||||
theme="default"
|
||||
invertTheme={!preferences.darkMode}
|
||||
shouldExpandNodeInitially={() => true}
|
||||
/>
|
||||
</span>
|
||||
</>
|
||||
}
|
||||
/>)}
|
||||
</List>
|
||||
</FlexItem>
|
||||
</Flex>
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
// Copyright 2020 BMW Group
|
||||
// Copyright 2022, 2026 Acme Gating, LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
// not use this file except in compliance with the License. You may obtain
|
||||
// a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
// License for the specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import {
|
||||
Button,
|
||||
TextInput,
|
||||
Dropdown,
|
||||
DropdownItem,
|
||||
DropdownPosition,
|
||||
DropdownToggle,
|
||||
Toolbar,
|
||||
ToolbarContent,
|
||||
ToolbarGroup,
|
||||
ToolbarItem,
|
||||
ToolbarToggleGroup,
|
||||
} from '@patternfly/react-core'
|
||||
|
||||
import { fetchPipelinesIfNeeded } from '../../actions/pipelines'
|
||||
|
||||
function FreezePipelineToolbar(props) {
|
||||
const { tenant, fetchPipelinesIfNeeded } = props
|
||||
|
||||
useEffect(() => {
|
||||
fetchPipelinesIfNeeded(tenant)
|
||||
}, [fetchPipelinesIfNeeded, tenant])
|
||||
|
||||
const tenantPipelines = props.pipelines.pipelines[tenant.name]
|
||||
const pipelines = tenantPipelines ? tenantPipelines.map(p => { return p.name }) : []
|
||||
|
||||
const [isPipelineOpen, setIsPipelineOpen] = useState(false)
|
||||
const [isRefTypeOpen, setIsRefTypeOpen] = useState(false)
|
||||
const [currentPipeline, setCurrentPipeline] = useState(props.defaultPipeline || '')
|
||||
const [currentProject, setCurrentProject] = useState(props.defaultProject || '')
|
||||
const [currentRefType, setCurrentRefType] = useState(props.defaultRefType || 'Branch')
|
||||
const [currentRef, setCurrentRef] = useState(props.defaultRef || '')
|
||||
|
||||
if (!currentPipeline && pipelines.length) {
|
||||
// We may have gotten a list of pipelines after we loaded the page
|
||||
setCurrentPipeline(pipelines[0])
|
||||
}
|
||||
|
||||
function handlePipelineSelect(event) {
|
||||
setCurrentPipeline(event.target.innerText)
|
||||
setIsPipelineOpen(false)
|
||||
}
|
||||
|
||||
function handlePipelineToggle(isOpen) {
|
||||
setIsPipelineOpen(isOpen)
|
||||
}
|
||||
|
||||
function handleRefTypeSelect(event) {
|
||||
setCurrentRefType(event.target.innerText)
|
||||
setIsRefTypeOpen(false)
|
||||
}
|
||||
|
||||
function handleRefTypeToggle(isOpen) {
|
||||
setIsRefTypeOpen(isOpen)
|
||||
}
|
||||
|
||||
function handleProjectChange(newValue) {
|
||||
setCurrentProject(newValue)
|
||||
}
|
||||
|
||||
function handleRefChange(newValue) {
|
||||
setCurrentRef(newValue)
|
||||
}
|
||||
|
||||
function handleInputSend(event) {
|
||||
// In case the event comes from a key press, only accept "Enter"
|
||||
if (event.key && event.key !== 'Enter') {
|
||||
return
|
||||
}
|
||||
|
||||
// Ignore empty values
|
||||
if (!currentRef || !currentProject) {
|
||||
return
|
||||
}
|
||||
|
||||
// Notify the parent component about the filter change
|
||||
props.onChange(currentPipeline, currentProject, currentRefType, currentRef)
|
||||
}
|
||||
|
||||
function renderFreezePipelineToolbar () {
|
||||
const buttonText = props.buttonText || 'Freeze Pipeline'
|
||||
return <>
|
||||
<Toolbar collapseListedFiltersBreakpoint="md">
|
||||
<ToolbarContent>
|
||||
<ToolbarToggleGroup breakpoint="md">
|
||||
<ToolbarGroup variant="filter-group">
|
||||
|
||||
<ToolbarItem key="pipeline">
|
||||
<Dropdown
|
||||
onSelect={handlePipelineSelect}
|
||||
position={DropdownPosition.left}
|
||||
toggle={
|
||||
<DropdownToggle
|
||||
onToggle={handlePipelineToggle}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
Pipeline: {currentPipeline}
|
||||
</DropdownToggle>
|
||||
}
|
||||
isOpen={isPipelineOpen}
|
||||
dropdownItems={pipelines.map((pipeline) => (
|
||||
<DropdownItem key={pipeline}>{pipeline}</DropdownItem>
|
||||
))}
|
||||
style={{ width: '100%' }}
|
||||
menuAppendTo={document.body}
|
||||
/>
|
||||
</ToolbarItem>
|
||||
|
||||
<ToolbarItem key="project">
|
||||
<TextInput
|
||||
name="project"
|
||||
id="project-input"
|
||||
type="search"
|
||||
placeholder="Project"
|
||||
defaultValue={props.defaultProject}
|
||||
onChange={handleProjectChange}
|
||||
onKeyDown={(event) => handleInputSend(event)}
|
||||
/>
|
||||
</ToolbarItem>
|
||||
|
||||
<ToolbarItem key="ref_type">
|
||||
<Dropdown
|
||||
onSelect={handleRefTypeSelect}
|
||||
position={DropdownPosition.left}
|
||||
toggle={
|
||||
<DropdownToggle
|
||||
onToggle={handleRefTypeToggle}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
{currentRefType}
|
||||
</DropdownToggle>
|
||||
}
|
||||
isOpen={isRefTypeOpen}
|
||||
dropdownItems={[
|
||||
<DropdownItem key="Branch">Branch</DropdownItem>,
|
||||
<DropdownItem key="Tag">Tag</DropdownItem>,
|
||||
]}
|
||||
style={{ width: '100%' }}
|
||||
menuAppendTo={document.body}
|
||||
/>
|
||||
</ToolbarItem>
|
||||
|
||||
<ToolbarItem key="ref">
|
||||
<TextInput
|
||||
name="ref"
|
||||
id="ref-input"
|
||||
type="search"
|
||||
placeholder={`${currentRefType} name`}
|
||||
defaultValue={props.defaultRef}
|
||||
onChange={handleRefChange}
|
||||
onKeyDown={(event) => handleInputSend(event)}
|
||||
/>
|
||||
</ToolbarItem>
|
||||
|
||||
<ToolbarItem key="button">
|
||||
<Button
|
||||
onClick={(event) => handleInputSend(event)}
|
||||
>
|
||||
{buttonText}
|
||||
</Button>
|
||||
</ToolbarItem>
|
||||
|
||||
</ToolbarGroup>
|
||||
</ToolbarToggleGroup>
|
||||
</ToolbarContent>
|
||||
</Toolbar>
|
||||
</>
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{renderFreezePipelineToolbar()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
FreezePipelineToolbar.propTypes = {
|
||||
fetchPipelinesIfNeeded: PropTypes.func,
|
||||
tenant: PropTypes.object,
|
||||
pipelines: PropTypes.object,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
defaultPipeline: PropTypes.string,
|
||||
defaultProject: PropTypes.string,
|
||||
defaultRef: PropTypes.string,
|
||||
defaultRefType: PropTypes.string,
|
||||
buttonText: PropTypes.string,
|
||||
}
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
tenant: state.tenant,
|
||||
pipelines: state.pipelines,
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = {
|
||||
fetchPipelinesIfNeeded
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(FreezePipelineToolbar)
|
||||
@@ -0,0 +1,322 @@
|
||||
// Copyright 2022, 2026 Acme Gating, LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
// not use this file except in compliance with the License. You may obtain
|
||||
// a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
// License for the specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
import React, { useEffect, useState, useCallback } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect, useDispatch } from 'react-redux'
|
||||
import { useHistory, useLocation } from 'react-router-dom'
|
||||
import {
|
||||
PageSection,
|
||||
PageSectionVariants,
|
||||
Text,
|
||||
TextContent,
|
||||
Select,
|
||||
SelectOption,
|
||||
SelectVariant,
|
||||
Form,
|
||||
FormGroup,
|
||||
TextInput,
|
||||
Checkbox,
|
||||
ActionGroup,
|
||||
Button,
|
||||
} from '@patternfly/react-core'
|
||||
|
||||
import { enqueue_ref, freezePipeline } from '../api'
|
||||
import { addNotification, addApiError } from '../actions/notifications'
|
||||
|
||||
import FreezePipelineToolbar from '../containers/enqueue/FreezePipelineToolbar'
|
||||
|
||||
function EnqueuePage(props) {
|
||||
const { tenant } = props
|
||||
|
||||
const dispatch = useDispatch()
|
||||
const [currentPipeline, setCurrentPipeline] = useState()
|
||||
const [currentProject, setCurrentProject] = useState()
|
||||
const [currentRefType, setCurrentRefType] = useState()
|
||||
const [currentRef, setCurrentRef] = useState()
|
||||
const [parameterList, setParameterList] = useState()
|
||||
const history = useHistory()
|
||||
const location = useLocation()
|
||||
const [paramState, setParamState] = useState({})
|
||||
|
||||
if (!currentRef) {
|
||||
const urlParams = new URLSearchParams(location.search)
|
||||
const pipeline = urlParams.get('pipeline')
|
||||
const project = urlParams.get('project')
|
||||
const refType = urlParams.get('ref_type')
|
||||
const ref = urlParams.get('ref')
|
||||
if (pipeline && refType && ref && project) {
|
||||
setCurrentPipeline(pipeline)
|
||||
setCurrentProject(project)
|
||||
setCurrentRefType(refType)
|
||||
setCurrentRef(ref)
|
||||
}
|
||||
}
|
||||
|
||||
const updateData = useCallback(() => {
|
||||
const ref = (currentRefType === 'Branch') ?
|
||||
`refs/heads/${currentRef}` : (currentRefType === 'Tag') ?
|
||||
`refs/tags/${currentRef}` : undefined
|
||||
|
||||
freezePipeline(tenant.apiPrefix, currentPipeline, currentProject, ref).then((response) => {
|
||||
setParameterList(response.data.parameters)
|
||||
})
|
||||
}, [currentPipeline, currentProject,
|
||||
currentRefType, currentRef, tenant.apiPrefix])
|
||||
|
||||
useEffect(() => {
|
||||
document.title = 'Zuul Enqueue'
|
||||
if (currentPipeline && currentProject && currentRefType && currentRef) {
|
||||
updateData()
|
||||
}
|
||||
}, [updateData, tenant, currentPipeline, currentProject, currentRefType, currentRef, dispatch])
|
||||
|
||||
function onChange(pipeline, project, refType, ref) {
|
||||
setCurrentPipeline(pipeline)
|
||||
setCurrentProject(project)
|
||||
setCurrentRefType(refType)
|
||||
setCurrentRef(ref)
|
||||
|
||||
const searchParams = new URLSearchParams('')
|
||||
searchParams.append('pipeline', pipeline)
|
||||
searchParams.append('project', project)
|
||||
searchParams.append('ref_type', refType)
|
||||
searchParams.append('ref', ref)
|
||||
history.push({
|
||||
pathname: location.pathname,
|
||||
search: searchParams.toString(),
|
||||
})
|
||||
}
|
||||
|
||||
const getParamState = useCallback(((param, key) => {
|
||||
if (paramState[param.name] === undefined) {
|
||||
return undefined
|
||||
}
|
||||
return paramState[param.name][key]
|
||||
}), [paramState])
|
||||
|
||||
function updateParamState(param, update) {
|
||||
setParamState(prevState => ({
|
||||
...prevState,
|
||||
[param.name]: {...prevState[param.name], ...update}
|
||||
}))
|
||||
}
|
||||
|
||||
function renderSelection(param) {
|
||||
return (
|
||||
<FormGroup
|
||||
label={param.name}
|
||||
helperText={param.description}
|
||||
isRequired={param.required}
|
||||
>
|
||||
<Select
|
||||
id={param.name}
|
||||
isOpen={getParamState(param, 'isOpen')}
|
||||
validated={getParamState(param, 'validated')}
|
||||
onToggle={(isOpen) =>
|
||||
updateParamState(param, {'isOpen': isOpen})
|
||||
}
|
||||
selections={getParamState(param, 'value')}
|
||||
onSelect={(event, selection) =>
|
||||
updateParamState(param, {'isOpen': false, 'value': selection})
|
||||
}
|
||||
>
|
||||
{param.values.map((value, index) => (
|
||||
<SelectOption key={index} value={value} label={value}/>
|
||||
))}
|
||||
</Select>
|
||||
</FormGroup>
|
||||
)
|
||||
}
|
||||
|
||||
function renderMultipleSelection(param) {
|
||||
|
||||
function onSelect(event, selection) {
|
||||
const prev = getParamState(param, 'value')
|
||||
const selected = prev === undefined ? [] : prev
|
||||
if (selected && selected.includes(selection)) {
|
||||
updateParamState(param, {
|
||||
'isOpen': false,
|
||||
'value': selected.filter(x => x !== selection)
|
||||
})
|
||||
} else {
|
||||
updateParamState(param, {
|
||||
'isOpen': false,
|
||||
'value': [...selected, selection],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<FormGroup
|
||||
label={param.name}
|
||||
helperText={param.description}
|
||||
isRequired={param.required}
|
||||
>
|
||||
<Select
|
||||
id={param.name}
|
||||
variant={SelectVariant.typeaheadMulti}
|
||||
validated={getParamState(param, 'validated')}
|
||||
isOpen={getParamState(param, 'isOpen')}
|
||||
onToggle={(isOpen) =>
|
||||
updateParamState(param, {'isOpen': isOpen})
|
||||
}
|
||||
selections={getParamState(param, 'value')}
|
||||
onSelect={onSelect}
|
||||
>
|
||||
{param.values.map((value, index) => (
|
||||
<SelectOption key={index} value={value} label={value}/>
|
||||
))}
|
||||
</Select>
|
||||
</FormGroup>
|
||||
)
|
||||
}
|
||||
|
||||
function renderText(param) {
|
||||
return (
|
||||
<FormGroup
|
||||
label={param.name}
|
||||
helperText={param.description}
|
||||
isRequired={param.required}
|
||||
>
|
||||
<TextInput
|
||||
id={param.name}
|
||||
type="text"
|
||||
value={getParamState(param, 'value')}
|
||||
validated={getParamState(param, 'validated')}
|
||||
onChange={(value) =>
|
||||
updateParamState(param, {'value': value})
|
||||
}
|
||||
/>
|
||||
</FormGroup>
|
||||
)
|
||||
}
|
||||
|
||||
function renderCheckbox(param) {
|
||||
return (
|
||||
<FormGroup
|
||||
helperText={param.description}
|
||||
>
|
||||
<Checkbox
|
||||
id={param.name}
|
||||
label={param.name}
|
||||
isChecked={getParamState(param, 'value')}
|
||||
onChange={(value) =>
|
||||
updateParamState(param, {'value': value})
|
||||
}
|
||||
/>
|
||||
</FormGroup>
|
||||
)
|
||||
}
|
||||
|
||||
function renderParameters(parameters) {
|
||||
const widgets = []
|
||||
const loop = parameters ? parameters : []
|
||||
loop.forEach((param) => {
|
||||
if (param.default !== null &&
|
||||
getParamState(param, 'value') === undefined) {
|
||||
updateParamState(param, {'value': param.default})
|
||||
}
|
||||
if (param.type === 'selection') {
|
||||
widgets.push(renderSelection(param))
|
||||
} else if (param.type === 'multiple-selection') {
|
||||
widgets.push(renderMultipleSelection(param))
|
||||
} else if (param.type === 'string') {
|
||||
widgets.push(renderText(param))
|
||||
} else if (param.type === 'bool') {
|
||||
widgets.push(renderCheckbox(param))
|
||||
}
|
||||
})
|
||||
return widgets
|
||||
}
|
||||
|
||||
const submitEnqueue = useCallback(() => {
|
||||
const parameters = {}
|
||||
const loop = parameterList ? parameterList : []
|
||||
let error = false
|
||||
loop.forEach((param) => {
|
||||
const val = getParamState(param, 'value')
|
||||
if (param.required && !val) {
|
||||
error = true
|
||||
updateParamState(param, {'validated': 'error'})
|
||||
} else {
|
||||
updateParamState(param, {'validated': 'default'})
|
||||
}
|
||||
parameters[param.name] = val
|
||||
})
|
||||
if (!error) {
|
||||
const ref = (currentRefType === 'Branch') ?
|
||||
`refs/heads/${currentRef}` : (currentRefType === 'Tag') ?
|
||||
`refs/tags/${currentRef}` : undefined
|
||||
|
||||
enqueue_ref(tenant.apiPrefix, currentProject, currentPipeline,
|
||||
ref, null, null, parameters).then(() => {
|
||||
dispatch(addNotification(
|
||||
{
|
||||
text: 'Enqueue successful.',
|
||||
type: 'success',
|
||||
status: '',
|
||||
url: '',
|
||||
}))
|
||||
})
|
||||
.catch(error => {
|
||||
dispatch(addApiError(error))
|
||||
})
|
||||
}
|
||||
}, [currentPipeline, currentProject, getParamState,
|
||||
currentRefType, currentRef, tenant.apiPrefix, parameterList, dispatch])
|
||||
|
||||
const parameterWidgets = renderParameters(parameterList)
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageSection variant={PageSectionVariants.light}>
|
||||
<TextContent>
|
||||
<Text component="h1">Enqueue</Text>
|
||||
</TextContent>
|
||||
<FreezePipelineToolbar
|
||||
onChange={onChange}
|
||||
defaultPipeline={currentPipeline}
|
||||
defaultProject={currentProject}
|
||||
defaultRefType={currentRefType}
|
||||
defaultRef={currentRef}
|
||||
buttonText="Fetch"
|
||||
/>
|
||||
<Form style={{maxWidth: "40em"}}>
|
||||
{parameterWidgets}
|
||||
<ActionGroup>
|
||||
<Button
|
||||
variant="primary"
|
||||
onClick={submitEnqueue}
|
||||
>
|
||||
Enqueue
|
||||
</Button>
|
||||
</ActionGroup>
|
||||
</Form>
|
||||
</PageSection>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
EnqueuePage.propTypes = {
|
||||
tenant: PropTypes.object,
|
||||
}
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
tenant: state.tenant,
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(EnqueuePage)
|
||||
+14
-1
@@ -21,6 +21,7 @@ import BuildsetsPage from './pages/Buildsets'
|
||||
import ChangeStatusPage from './pages/ChangeStatus'
|
||||
import ComponentsPage from './pages/Components'
|
||||
import ConfigErrorsPage from './pages/ConfigErrors'
|
||||
import EnqueuePage from './pages/Enqueue'
|
||||
import SystemEventsPage from './pages/SystemEvents'
|
||||
import FreezeJobPage from './pages/FreezeJob'
|
||||
import JobPage from './pages/Job'
|
||||
@@ -44,12 +45,15 @@ import SemaphorePage from './pages/Semaphore'
|
||||
import SemaphoresPage from './pages/Semaphores'
|
||||
import StreamPage from './pages/Stream'
|
||||
import TenantsPage from './pages/Tenants'
|
||||
import {
|
||||
isAuthorized,
|
||||
} from './Misc'
|
||||
|
||||
// The Route object are created in the App component.
|
||||
// Object with a title are created in the menu.
|
||||
// Object with globalRoute are not tenant scoped.
|
||||
// Remember to update the api getHomepageUrl subDir list for route with params
|
||||
const routes = (info) => {
|
||||
const routes = (info, user) => {
|
||||
const ret = [
|
||||
{
|
||||
title: 'Status',
|
||||
@@ -213,6 +217,15 @@ const routes = (info) => {
|
||||
}
|
||||
)
|
||||
}
|
||||
if (user && isAuthorized(user, 'enqueue')) {
|
||||
ret.push(
|
||||
{
|
||||
title: 'Enqueue',
|
||||
to: '/enqueue',
|
||||
component: EnqueuePage
|
||||
},
|
||||
)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user