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
0d6aa635
Commit
0d6aa635
authored
1 year ago
by
Imre Toth
Browse files
Options
Downloads
Patches
Plain Diff
CE-2103
: Convert useDeteleIoc hook
parent
930b8cb2
No related branches found
No related tags found
2 merge requests
!407
CE-2141: 3.0.0
,
!378
CE-2103: Convert useDeteleIoc hook
Pipeline
#161489
passed
1 year ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/api/SwaggerApi.js
+0
-16
0 additions, 16 deletions
src/api/SwaggerApi.js
src/components/IOC/IOCDelete/IOCDelete.js
+35
-9
35 additions, 9 deletions
src/components/IOC/IOCDelete/IOCDelete.js
with
35 additions
and
25 deletions
src/api/SwaggerApi.js
+
0
−
16
View file @
0d6aa635
...
...
@@ -341,22 +341,6 @@ export function useAllowedGitProjects() {
return
useAsync
({
fcn
:
method
,
call
:
false
,
init
:
[]
});
}
export
function
useDeleteIOC
(
id
,
onError
)
{
const
api
=
useContext
(
apiContext
);
const
method
=
useCallAndUnpack
(
api
.
apis
.
IOCs
.
deleteIoc
,
unpackDeleteIocResponse
);
const
boundMethod
=
useCallback
(
method
.
bind
(
null
,
{
ioc_id
:
id
}),
[
id
]);
return
useAsync
({
fcn
:
boundMethod
,
call
:
false
,
onError
:
onError
});
}
export
function
unpackDeleteIocResponse
(
_
,
status
)
{
if
(
status
===
204
)
{
return
"
Successful delete
"
;
}
}
export
function
useUpdateIoc
(
id
,
onError
)
{
const
api
=
useContext
(
apiContext
);
const
method
=
useCallAndUnpack
(
...
...
This diff is collapsed.
Click to expand it.
src/components/IOC/IOCDelete/IOCDelete.js
+
35
−
9
View file @
0d6aa635
import
React
,
{
useState
,
useEffect
,
useCallback
}
from
"
react
"
;
import
React
,
{
useState
,
useEffect
,
useCallback
,
useContext
,
useMemo
}
from
"
react
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
Button
,
Typography
,
Grid
,
Tooltip
}
from
"
@mui/material
"
;
import
{
useDeleteIOC
}
from
"
../../../api/SwaggerApi
"
;
import
{
SimpleAccordion
,
ConfirmationDialog
}
from
"
@ess-ics/ce-ui-common
"
;
import
Alert
from
"
@mui/material/Alert
"
;
import
AccessControl
from
"
../../auth/AccessControl
"
;
import
{
apiContext
}
from
"
../../../api/DeployApi
"
;
import
{
useAPIMethod
}
from
"
@ess-ics/ce-ui-common
"
;
export
default
function
IOCDelete
({
ioc
,
buttonDisabled
})
{
const
navigate
=
useNavigate
();
function
onError
(
message
)
{
setError
(
message
);
}
// for the dialog
const
[
error
,
setError
]
=
useState
();
const
[
open
,
setOpen
]
=
useState
(
false
);
const
[
response
,
deleteIOC
]
=
useDeleteIOC
(
ioc
.
id
,
onError
);
const
client
=
useContext
(
apiContext
);
const
params
=
useMemo
(
()
=>
({
ioc_id
:
ioc
?.
id
}),
[
ioc
]
);
const
{
wrapper
:
deleteIOC
,
dataReady
:
dataready
,
error
:
errorResponse
}
=
useAPIMethod
({
fcn
:
client
.
apis
.
IOCs
.
deleteIoc
,
call
:
false
,
params
});
useEffect
(()
=>
{
if
(
errorResponse
)
{
setError
(
errorResponse
?.
message
);
}
},
[
errorResponse
,
setError
]);
useEffect
(()
=>
{
if
(
response
&&
!
error
)
{
if
(
dataready
&&
!
error
)
{
navigate
(
-
1
);
}
},
[
response
,
navigate
,
error
]);
},
[
dataready
,
navigate
,
error
]);
let
disabledButtonTitle
=
""
;
...
...
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