Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pipeline-creation-assistant
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
grid5000
pipeline-creation-assistant
Commits
701ab981
Verified
Commit
701ab981
authored
5 months ago
by
Philippe Virouleau
Browse files
Options
Downloads
Patches
Plain Diff
Create the ENV_VERSION textfield
parent
4e6febcc
No related branches found
No related tags found
No related merge requests found
Pipeline
#1099139
passed
5 months ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/CreatePipeline.tsx
+33
-3
33 additions, 3 deletions
src/components/CreatePipeline.tsx
with
33 additions
and
3 deletions
src/components/CreatePipeline.tsx
+
33
−
3
View file @
701ab981
'
use client
'
;
'
use client
'
;
import
{
Dispatch
,
SetStateAction
,
useState
}
from
'
react
'
;
import
{
ChangeEvent
,
Dispatch
,
SetStateAction
,
useState
}
from
'
react
'
;
import
{
GenState
,
TestState
,
getEnabledElements
,
getValidSelectedClusters
}
from
'
@/lib/generation
'
;
import
{
GenState
,
TestState
,
getEnabledElements
,
getValidSelectedClusters
}
from
'
@/lib/generation
'
;
import
{
AppRouterInstance
}
from
'
next/dist/shared/lib/app-router-context.shared-runtime
'
;
import
{
AppRouterInstance
}
from
'
next/dist/shared/lib/app-router-context.shared-runtime
'
;
...
@@ -13,6 +13,7 @@ import RemoteBranchSelector from './RemoteBranchSelector';
...
@@ -13,6 +13,7 @@ import RemoteBranchSelector from './RemoteBranchSelector';
import
Tab
from
'
@mui/material/Tab
'
;
import
Tab
from
'
@mui/material/Tab
'
;
import
Tabs
from
'
@mui/material/Tabs
'
;
import
Tabs
from
'
@mui/material/Tabs
'
;
import
TestImagesTabContent
from
'
./TestImagesTabContent
'
;
import
TestImagesTabContent
from
'
./TestImagesTabContent
'
;
import
TextField
from
'
@mui/material/TextField
'
;
import
config
from
'
@/lib/config
'
;
import
config
from
'
@/lib/config
'
;
import
{
useAuth
}
from
'
react-oidc-context
'
;
import
{
useAuth
}
from
'
react-oidc-context
'
;
...
@@ -56,6 +57,7 @@ type Pipeline = {
...
@@ -56,6 +57,7 @@ type Pipeline = {
// FIXME: can we do something like typeof(useRouter()) ?
// FIXME: can we do something like typeof(useRouter()) ?
function
createPipelineAction
(
generations
:
GenState
,
clusters
:
TestState
,
function
createPipelineAction
(
generations
:
GenState
,
clusters
:
TestState
,
ref
:
string
,
refApiBranch
:
string
,
postinstallBranch
:
string
|
null
,
ref
:
string
,
refApiBranch
:
string
,
postinstallBranch
:
string
|
null
,
envVersion
:
string
,
token
:
string
|
undefined
,
token
:
string
|
undefined
,
router
:
AppRouterInstance
,
router
:
AppRouterInstance
,
setLoading
:
Dispatch
<
SetStateAction
<
boolean
>>
)
{
setLoading
:
Dispatch
<
SetStateAction
<
boolean
>>
)
{
...
@@ -70,6 +72,7 @@ function createPipelineAction(generations: GenState, clusters: TestState,
...
@@ -70,6 +72,7 @@ function createPipelineAction(generations: GenState, clusters: TestState,
// that doesn't match, to avoid this hack.
// that doesn't match, to avoid this hack.
{
key
:
'
ENVIRONMENTS
'
,
value
:
'
none
'
},
{
key
:
'
ENVIRONMENTS
'
,
value
:
'
none
'
},
{
key
:
'
REFREPO_BRANCH
'
,
value
:
refApiBranch
},
{
key
:
'
REFREPO_BRANCH
'
,
value
:
refApiBranch
},
{
key
:
'
ENV_VERSION
'
,
value
:
envVersion
},
{
key
:
'
ENVIRONMENTS_LIST
'
,
value
:
getEnabledElements
(
generations
).
join
(
'
,
'
)},
{
key
:
'
ENVIRONMENTS_LIST
'
,
value
:
getEnabledElements
(
generations
).
join
(
'
,
'
)},
{
key
:
'
CLUSTERS
'
,
value
:
getValidSelectedClusters
(
generations
,
clusters
).
join
(
'
,
'
)},
{
key
:
'
CLUSTERS
'
,
value
:
getValidSelectedClusters
(
generations
,
clusters
).
join
(
'
,
'
)},
]
]
...
@@ -94,18 +97,33 @@ function createPipelineAction(generations: GenState, clusters: TestState,
...
@@ -94,18 +97,33 @@ function createPipelineAction(generations: GenState, clusters: TestState,
});
});
}
}
function
createCurrentVersion
()
{
const
pad
=
(
n
:
number
):
string
=>
n
<
10
?
`0
${
n
}
`
:
`
${
n
}
`
;
const
currentDate
=
new
Date
();
const
month
=
pad
(
currentDate
.
getMonth
()
+
1
);
const
date
=
pad
(
currentDate
.
getDate
());
const
hour
=
pad
(
currentDate
.
getHours
());
return
`
${
currentDate
.
getFullYear
()}${
month
}${
date
}${
hour
}
`
;
}
function
validVersion
(
date
:
string
):
boolean
{
return
date
.
match
(
/
\d{10}
/
)
!==
null
;
}
function
CreatePipelineButton
({
function
CreatePipelineButton
({
generations
,
generations
,
clusters
,
clusters
,
branch
,
branch
,
refApiBranch
,
refApiBranch
,
postinstallBranch
,
postinstallBranch
,
envVersion
,
}:
{
}:
{
branch
:
string
|
null
,
branch
:
string
|
null
,
refApiBranch
:
string
|
null
,
refApiBranch
:
string
|
null
,
postinstallBranch
:
string
|
null
,
postinstallBranch
:
string
|
null
,
generations
:
GenState
,
generations
:
GenState
,
clusters
:
TestState
,
clusters
:
TestState
,
envVersion
:
string
,
})
{
})
{
const
enabledEnvs
=
getEnabledElements
(
generations
);
const
enabledEnvs
=
getEnabledElements
(
generations
);
const
auth
=
useAuth
();
const
auth
=
useAuth
();
...
@@ -116,13 +134,15 @@ function CreatePipelineButton({
...
@@ -116,13 +134,15 @@ function CreatePipelineButton({
component
=
"label"
component
=
"label"
role
=
{
undefined
}
role
=
{
undefined
}
variant
=
"contained"
variant
=
"contained"
disabled
=
{
enabledEnvs
.
length
===
0
||
branch
===
null
||
refApiBranch
===
null
||
loading
}
disabled
=
{
enabledEnvs
.
length
===
0
||
branch
===
null
||
refApiBranch
===
null
||
loading
||
!
validVersion
(
envVersion
)
}
color
=
"success"
color
=
"success"
onClick
=
{
()
=>
{
onClick
=
{
()
=>
{
if
(
branch
===
null
||
refApiBranch
===
null
)
{
if
(
branch
===
null
||
refApiBranch
===
null
)
{
return
;
return
;
}
}
createPipelineAction
(
generations
,
clusters
,
branch
,
refApiBranch
,
postinstallBranch
,
auth
.
user
?.
access_token
,
router
,
setLoading
)
createPipelineAction
(
generations
,
clusters
,
branch
,
refApiBranch
,
postinstallBranch
,
envVersion
,
auth
.
user
?.
access_token
,
router
,
setLoading
);
}
}
}
}
sx
=
{
{
ml
:
'
auto
'
}
}
sx
=
{
{
ml
:
'
auto
'
}
}
>
>
...
@@ -153,6 +173,8 @@ export default function CreatePipeline() {
...
@@ -153,6 +173,8 @@ export default function CreatePipeline() {
const
[
branch
,
setBranch
]
=
useState
<
string
|
null
>
(
null
);
const
[
branch
,
setBranch
]
=
useState
<
string
|
null
>
(
null
);
const
[
refApiBranch
,
setRefApiBranch
]
=
useState
<
string
|
null
>
(
null
);
const
[
refApiBranch
,
setRefApiBranch
]
=
useState
<
string
|
null
>
(
null
);
const
[
postinstallBranch
,
setPostinstallBranch
]
=
useState
<
string
|
null
>
(
null
);
const
[
postinstallBranch
,
setPostinstallBranch
]
=
useState
<
string
|
null
>
(
null
);
const
[
envVersion
,
setEnvVersion
]
=
useState
<
string
>
(
createCurrentVersion
());
const
validEnvVersion
=
validVersion
(
envVersion
);
return
(
return
(
<
Container
maxWidth
=
"xl"
>
<
Container
maxWidth
=
"xl"
>
...
@@ -166,6 +188,13 @@ export default function CreatePipeline() {
...
@@ -166,6 +188,13 @@ export default function CreatePipeline() {
useDefault
useDefault
/>
/>
</
Box
>
</
Box
>
<
TextField
value
=
{
envVersion
}
error
=
{
!
validEnvVersion
}
helperText
=
{
validEnvVersion
?
null
:
'
Version must match YYYYMMDDHH
'
}
onChange
=
{
(
ev
:
ChangeEvent
<
HTMLInputElement
>
)
=>
setEnvVersion
(
ev
.
target
.
value
)
}
label
=
"Environment version"
/>
<
Box
sx
=
{
{
borderBottom
:
1
,
borderColor
:
'
divider
'
,
mb
:
2
}
}
>
<
Box
sx
=
{
{
borderBottom
:
1
,
borderColor
:
'
divider
'
,
mb
:
2
}
}
>
<
Tabs
value
=
{
value
}
onChange
=
{
handleChange
}
>
<
Tabs
value
=
{
value
}
onChange
=
{
handleChange
}
>
<
Tab
label
=
"Generation"
/>
<
Tab
label
=
"Generation"
/>
...
@@ -176,6 +205,7 @@ export default function CreatePipeline() {
...
@@ -176,6 +205,7 @@ export default function CreatePipeline() {
postinstallBranch
=
{
postinstallBranch
}
postinstallBranch
=
{
postinstallBranch
}
generations
=
{
generations
}
generations
=
{
generations
}
clusters
=
{
clusters
}
clusters
=
{
clusters
}
envVersion
=
{
envVersion
}
/>
/>
</
Tabs
>
</
Tabs
>
</
Box
>
</
Box
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment