Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ce-deploy-ui
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ccce
dev
ce-deploy-ui
Commits
c7ef4d6e
Commit
c7ef4d6e
authored
2 years ago
by
Zoltan Runyo
Browse files
Options
Downloads
Patches
Plain Diff
ICSHWI-11558
: Redirect to start/stop job details from IOC service controls
parent
da740b3d
No related branches found
No related tags found
2 merge requests
!270
Merging develop branch to master in order to create RC
,
!245
Command details page ICSHWI-11558
Pipeline
#134758
passed with warnings
2 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/IOC/CommandJobStepper.js
+0
-72
0 additions, 72 deletions
src/components/IOC/CommandJobStepper.js
src/components/IOC/IOCService.js
+15
-22
15 additions, 22 deletions
src/components/IOC/IOCService.js
with
15 additions
and
94 deletions
src/components/IOC/CommandJobStepper.js
deleted
100644 → 0
+
0
−
72
View file @
da740b3d
import
React
,
{
useState
,
useEffect
,
useMemo
}
from
"
react
"
;
import
{
ScheduleOutlined
,
RotateRightOutlined
,
CheckCircleOutline
}
from
"
@material-ui/icons
"
;
import
{
useJob
}
from
"
../../api/SwaggerApi
"
;
import
{
StepperWithStyle
}
from
"
../common/stepper/StepperWithStyle
"
;
import
{
useSafePolling
}
from
"
../../hooks/Polling
"
;
import
{
AWXCommandDetails
}
from
"
../../api/DataTypes
"
;
const
POLL_COMMAND_JOB_INTERVAL
=
3000
;
export
function
CommandJobStepper
({
awxCommandId
,
actionType
})
{
const
[
commandJob
,
getCommandJob
/* reset*/
,
,
loading
]
=
useJob
(
awxCommandId
);
const
[
activeStep
,
setActiveStep
]
=
useState
(
0
);
const
[
pollJob
,
setPollJob
]
=
useState
(
true
);
const
commandStatus
=
useMemo
(
()
=>
new
AWXCommandDetails
(
commandJob
),
[
commandJob
]
);
useEffect
(()
=>
{
if
(
commandJob
)
{
if
(
commandStatus
.
notFinished
())
{
if
(
commandStatus
.
isRunning
())
{
setActiveStep
(
1
);
}
}
else
{
if
(
commandStatus
.
wasSuccessful
())
{
setActiveStep
(
3
);
}
if
(
commandStatus
.
wasFailed
())
{
setActiveStep
(
1
);
}
setPollJob
(
false
);
}
}
},
[
commandJob
,
commandStatus
,
getCommandJob
]);
const
icons
=
{
1
:
<
ScheduleOutlined
/>
,
2
:
<
RotateRightOutlined
/>
,
3
:
<
CheckCircleOutline
/>
};
const
steps
=
[
"
Queued
"
,
"
Running
"
,
(
actionType
??
""
)
+
"
Completed
"
];
const
isStepFailed
=
(
step
)
=>
{
if
(
commandStatus
.
wasFailed
())
{
return
step
===
activeStep
;
}
return
false
;
};
return
(
<>
<
StepperWithStyle
steps
=
{
steps
}
activeStep
=
{
activeStep
}
isStepFailed
=
{
isStepFailed
}
icons
=
{
icons
}
/
>
{
pollJob
&&
<
CommandJobWatcher
{...{
getCommandJob
,
loading
}}
/>
}
<
/
>
);
}
function
CommandJobWatcher
({
getCommandJob
,
loading
})
{
useSafePolling
(
getCommandJob
,
loading
,
POLL_COMMAND_JOB_INTERVAL
);
return
null
;
}
This diff is collapsed.
Click to expand it.
src/components/IOC/IOCService.js
+
15
−
22
View file @
c7ef4d6e
...
...
@@ -8,7 +8,6 @@ import {
import
{
makeStyles
}
from
"
@material-ui/core/styles
"
;
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
}
from
"
react
"
;
import
{
useStartIOC
,
useStopIOC
}
from
"
../../api/SwaggerApi
"
;
import
{
CommandJobStepper
}
from
"
./CommandJobStepper
"
;
import
{
SimpleModal
}
from
"
../../components/common/SimpleModal/SimpleModal
"
;
import
{
ConfirmationDialog
}
from
"
../dialog/ConfirmationDialog
"
;
import
{
notificationContext
}
from
"
../../components/common/notification/Notifications
"
;
...
...
@@ -17,6 +16,7 @@ import { theme } from "../../style/Theme";
import
{
initRequestParams
}
from
"
../common/Helper
"
;
import
AccessControl
from
"
../auth/AccessControl
"
;
import
{
essColors
}
from
"
../../style/Palette
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
const
useStyles
=
makeStyles
({
startButton
:
{
...
...
@@ -56,6 +56,7 @@ export function IOCService({
})
{
const
classes
=
useStyles
(
theme
);
const
[
error
,
setError
]
=
useState
();
const
navigate
=
useNavigate
();
function
onError
(
message
)
{
setError
(
message
);
...
...
@@ -64,7 +65,6 @@ export function IOCService({
const
[
startJob
,
startIOC
,
resetStartJob
]
=
useStartIOC
(
ioc
.
id
,
onError
);
const
[
stopJob
,
stopIOC
,
resetStopJob
]
=
useStopIOC
(
ioc
.
id
,
onError
);
const
[
inProgress
,
setInProgress
]
=
useState
(
false
);
const
[
action
,
setAction
]
=
useState
(
null
);
const
[
adHocDialogOpen
,
setAdHocDialogOpen
]
=
useState
(
false
);
const
[
adHocDialogTitle
,
setAdHocDiatlogTitle
]
=
useState
();
const
[
adHocDialogDescription
,
setAdHocDialogDescription
]
=
useState
();
...
...
@@ -75,22 +75,28 @@ export function IOCService({
useEffect
(()
=>
{
if
(
startJob
&&
(
!
command
||
command
.
id
!==
startJob
.
id
))
{
watchCommand
(
startJob
.
id
);
navigate
(
`/jobs/
${
startJob
.
id
}
`
);
setCommand
(
startJob
);
setInProgress
(
false
);
}
else
if
(
stopJob
&&
(
!
command
||
command
.
id
!==
stopJob
.
id
))
{
watchCommand
(
stopJob
.
id
);
navigate
(
`/jobs/
${
stopJob
.
id
}
`
);
setCommand
(
stopJob
);
setInProgress
(
false
);
}
else
if
(
currentCommand
)
{
watchCommand
(
currentCommand
.
id
);
setCommand
(
currentCommand
);
setInProgress
(
false
);
}
},
[
startJob
,
stopJob
,
command
,
watchCommand
,
getCommands
,
currentCommand
]);
},
[
startJob
,
stopJob
,
command
,
watchCommand
,
getCommands
,
currentCommand
,
navigate
]);
function
resetUI
()
{
setCommand
(
null
);
setAction
(
null
);
resetStartJob
();
resetStopJob
();
setError
(
null
);
...
...
@@ -98,10 +104,9 @@ export function IOCService({
const
start
=
async
()
=>
{
resetUI
();
setAction
(
"
Start
"
);
setInProgress
(
true
);
setButtonDisabled
(
true
);
startIOC
();
await
startIOC
();
let
requestParams
=
initRequestParams
(
commandLazyParams
,
null
,
...
...
@@ -113,7 +118,6 @@ export function IOCService({
const
stop
=
async
()
=>
{
resetUI
();
setAction
(
"
Stop
"
);
setInProgress
(
true
);
setButtonDisabled
(
true
);
await
stopIOC
();
...
...
@@ -243,18 +247,7 @@ export function IOCService({
{
error
?
(
<
Alert
severity
=
"
error
"
>
{
error
}
<
/Alert
>
)
:
(
<>
{
command
?
(
<
CommandJobStepper
awxCommandId
=
{
command
.
awxCommandId
}
actionType
=
{
action
}
/
>
)
:
inProgress
?
(
<
LinearProgress
color
=
"
primary
"
/>
)
:
(
<><
/
>
)}
<
/
>
inProgress
&&
<
LinearProgress
color
=
"
primary
"
/>
)}
<
/Grid
>
<
/Grid
>
...
...
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