mirror of
https://github.com/OpenMaxIO/openmaxio-object-browser
synced 2026-07-01 07:41:18 -07:00
Remove useAPI from DeleteUser and DeleteIDPConfigurationModal (#3191)
This commit is contained in:
@@ -5268,10 +5268,7 @@ func init() {
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "array",
|
"$ref": "#/definitions/selectedUsers"
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -7988,6 +7985,12 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"selectedUsers": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"serverDrives": {
|
"serverDrives": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -14458,10 +14461,7 @@ func init() {
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "array",
|
"$ref": "#/definitions/selectedUsers"
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -17327,6 +17327,12 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"selectedUsers": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
"serverDrives": {
|
"serverDrives": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ import (
|
|||||||
"github.com/go-openapi/errors"
|
"github.com/go-openapi/errors"
|
||||||
"github.com/go-openapi/runtime"
|
"github.com/go-openapi/runtime"
|
||||||
"github.com/go-openapi/runtime/middleware"
|
"github.com/go-openapi/runtime/middleware"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
|
||||||
|
"github.com/minio/console/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCheckUserServiceAccountsParams creates a new CheckUserServiceAccountsParams object
|
// NewCheckUserServiceAccountsParams creates a new CheckUserServiceAccountsParams object
|
||||||
@@ -52,7 +55,7 @@ type CheckUserServiceAccountsParams struct {
|
|||||||
Required: true
|
Required: true
|
||||||
In: body
|
In: body
|
||||||
*/
|
*/
|
||||||
SelectedUsers []string
|
SelectedUsers models.SelectedUsers
|
||||||
}
|
}
|
||||||
|
|
||||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||||
@@ -66,7 +69,7 @@ func (o *CheckUserServiceAccountsParams) BindRequest(r *http.Request, route *mid
|
|||||||
|
|
||||||
if runtime.HasBody(r) {
|
if runtime.HasBody(r) {
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
var body []string
|
var body models.SelectedUsers
|
||||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
res = append(res, errors.Required("selectedUsers", "body", ""))
|
res = append(res, errors.Required("selectedUsers", "body", ""))
|
||||||
@@ -74,8 +77,19 @@ func (o *CheckUserServiceAccountsParams) BindRequest(r *http.Request, route *mid
|
|||||||
res = append(res, errors.NewParseError("selectedUsers", "body", "", err))
|
res = append(res, errors.NewParseError("selectedUsers", "body", "", err))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no validation required on inline body
|
// validate body object
|
||||||
o.SelectedUsers = body
|
if err := body.Validate(route.Formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := validate.WithOperationRequest(r.Context())
|
||||||
|
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) == 0 {
|
||||||
|
o.SelectedUsers = body
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res = append(res, errors.Required("selectedUsers", "body", ""))
|
res = append(res, errors.Required("selectedUsers", "body", ""))
|
||||||
|
|||||||
44
models/selected_users.go
Normal file
44
models/selected_users.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package models
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SelectedUsers selected users
|
||||||
|
//
|
||||||
|
// swagger:model selectedUsers
|
||||||
|
type SelectedUsers []string
|
||||||
|
|
||||||
|
// Validate validates this selected users
|
||||||
|
func (m SelectedUsers) Validate(formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validates this selected users based on context it is used
|
||||||
|
func (m SelectedUsers) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
44
swagger.yml
44
swagger.yml
@@ -25,7 +25,7 @@ securityDefinitions:
|
|||||||
type: apiKey
|
type: apiKey
|
||||||
# Apply the key security definition to all APIs
|
# Apply the key security definition to all APIs
|
||||||
security:
|
security:
|
||||||
- key: []
|
- key: [ ]
|
||||||
parameters:
|
parameters:
|
||||||
limit:
|
limit:
|
||||||
name: limit
|
name: limit
|
||||||
@@ -54,7 +54,7 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/ApiError"
|
$ref: "#/definitions/ApiError"
|
||||||
# Exclude this API from the authentication requirement
|
# Exclude this API from the authentication requirement
|
||||||
security: []
|
security: [ ]
|
||||||
tags:
|
tags:
|
||||||
- Auth
|
- Auth
|
||||||
post:
|
post:
|
||||||
@@ -74,7 +74,7 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/ApiError"
|
$ref: "#/definitions/ApiError"
|
||||||
# Exclude this API from the authentication requirement
|
# Exclude this API from the authentication requirement
|
||||||
security: []
|
security: [ ]
|
||||||
tags:
|
tags:
|
||||||
- Auth
|
- Auth
|
||||||
/login/oauth2/auth:
|
/login/oauth2/auth:
|
||||||
@@ -94,7 +94,7 @@ paths:
|
|||||||
description: Generic error response.
|
description: Generic error response.
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/ApiError"
|
$ref: "#/definitions/ApiError"
|
||||||
security: []
|
security: [ ]
|
||||||
tags:
|
tags:
|
||||||
- Auth
|
- Auth
|
||||||
|
|
||||||
@@ -295,8 +295,8 @@ paths:
|
|||||||
get:
|
get:
|
||||||
summary: List Objects
|
summary: List Objects
|
||||||
security:
|
security:
|
||||||
- key: []
|
- key: [ ]
|
||||||
- anonymous: []
|
- anonymous: [ ]
|
||||||
operationId: ListObjects
|
operationId: ListObjects
|
||||||
parameters:
|
parameters:
|
||||||
- name: bucket_name
|
- name: bucket_name
|
||||||
@@ -411,8 +411,8 @@ paths:
|
|||||||
post:
|
post:
|
||||||
summary: Uploads an Object.
|
summary: Uploads an Object.
|
||||||
security:
|
security:
|
||||||
- key: []
|
- key: [ ]
|
||||||
- anonymous: []
|
- anonymous: [ ]
|
||||||
consumes:
|
consumes:
|
||||||
- multipart/form-data
|
- multipart/form-data
|
||||||
parameters:
|
parameters:
|
||||||
@@ -438,8 +438,8 @@ paths:
|
|||||||
summary: Download Multiple Objects
|
summary: Download Multiple Objects
|
||||||
operationId: DownloadMultipleObjects
|
operationId: DownloadMultipleObjects
|
||||||
security:
|
security:
|
||||||
- key: []
|
- key: [ ]
|
||||||
- anonymous: []
|
- anonymous: [ ]
|
||||||
produces:
|
produces:
|
||||||
- application/octet-stream
|
- application/octet-stream
|
||||||
parameters:
|
parameters:
|
||||||
@@ -471,8 +471,8 @@ paths:
|
|||||||
summary: Download Object
|
summary: Download Object
|
||||||
operationId: Download Object
|
operationId: Download Object
|
||||||
security:
|
security:
|
||||||
- key: []
|
- key: [ ]
|
||||||
- anonymous: []
|
- anonymous: [ ]
|
||||||
produces:
|
produces:
|
||||||
- application/octet-stream
|
- application/octet-stream
|
||||||
parameters:
|
parameters:
|
||||||
@@ -1546,9 +1546,7 @@ paths:
|
|||||||
in: body
|
in: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: array
|
$ref: "#/definitions/selectedUsers"
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: A successful response.
|
description: A successful response.
|
||||||
@@ -2889,7 +2887,7 @@ paths:
|
|||||||
- name: order
|
- name: order
|
||||||
in: query
|
in: query
|
||||||
type: string
|
type: string
|
||||||
enum: [timeDesc, timeAsc]
|
enum: [ timeDesc, timeAsc ]
|
||||||
default: timeDesc
|
default: timeDesc
|
||||||
- name: timeStart
|
- name: timeStart
|
||||||
in: query
|
in: query
|
||||||
@@ -3766,6 +3764,10 @@ definitions:
|
|||||||
items:
|
items:
|
||||||
$ref: "#/definitions/user"
|
$ref: "#/definitions/user"
|
||||||
title: list of resulting users
|
title: list of resulting users
|
||||||
|
selectedUsers:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
addUserRequest:
|
addUserRequest:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
@@ -4325,7 +4327,7 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
loginStrategy:
|
loginStrategy:
|
||||||
type: string
|
type: string
|
||||||
enum: [form, redirect, service-account, redirect-service-account]
|
enum: [ form, redirect, service-account, redirect-service-account ]
|
||||||
redirectRules:
|
redirectRules:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
@@ -4424,7 +4426,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
status:
|
status:
|
||||||
type: string
|
type: string
|
||||||
enum: [ok]
|
enum: [ ok ]
|
||||||
operator:
|
operator:
|
||||||
type: boolean
|
type: boolean
|
||||||
distributedMode:
|
distributedMode:
|
||||||
@@ -4455,7 +4457,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
values:
|
values:
|
||||||
type: array
|
type: array
|
||||||
items: {}
|
items: { }
|
||||||
resultTarget:
|
resultTarget:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -4911,7 +4913,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
service:
|
service:
|
||||||
type: string
|
type: string
|
||||||
enum: [replication]
|
enum: [ replication ]
|
||||||
syncMode:
|
syncMode:
|
||||||
type: string
|
type: string
|
||||||
bandwidth:
|
bandwidth:
|
||||||
@@ -5110,7 +5112,7 @@ definitions:
|
|||||||
format: int64
|
format: int64
|
||||||
newer_noncurrent_expiration_versions:
|
newer_noncurrent_expiration_versions:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
|
||||||
transitionResponse:
|
transitionResponse:
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ export interface ListUsersResponse {
|
|||||||
users?: User[];
|
users?: User[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type SelectedUsers = string[];
|
||||||
|
|
||||||
export interface AddUserRequest {
|
export interface AddUserRequest {
|
||||||
accessKey: string;
|
accessKey: string;
|
||||||
secretKey: string;
|
secretKey: string;
|
||||||
@@ -3242,7 +3244,7 @@ export class Api<
|
|||||||
* @secure
|
* @secure
|
||||||
*/
|
*/
|
||||||
checkUserServiceAccounts: (
|
checkUserServiceAccounts: (
|
||||||
selectedUsers: string[],
|
selectedUsers: SelectedUsers,
|
||||||
params: RequestParams = {},
|
params: RequestParams = {},
|
||||||
) =>
|
) =>
|
||||||
this.request<UserServiceAccountSummary, ApiError>({
|
this.request<UserServiceAccountSummary, ApiError>({
|
||||||
@@ -3250,6 +3252,7 @@ export class Api<
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
body: selectedUsers,
|
body: selectedUsers,
|
||||||
secure: true,
|
secure: true,
|
||||||
|
type: ContentType.Json,
|
||||||
format: "json",
|
format: "json",
|
||||||
...params,
|
...params,
|
||||||
}),
|
}),
|
||||||
@@ -3635,7 +3638,7 @@ export class Api<
|
|||||||
* @secure
|
* @secure
|
||||||
*/
|
*/
|
||||||
listUsersForPolicy: (policy: string, params: RequestParams = {}) =>
|
listUsersForPolicy: (policy: string, params: RequestParams = {}) =>
|
||||||
this.request<string[], ApiError>({
|
this.request<SelectedUsers, ApiError>({
|
||||||
path: `/policies/${policy}/users`,
|
path: `/policies/${policy}/users`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
secure: true,
|
secure: true,
|
||||||
@@ -3653,7 +3656,7 @@ export class Api<
|
|||||||
* @secure
|
* @secure
|
||||||
*/
|
*/
|
||||||
listGroupsForPolicy: (policy: string, params: RequestParams = {}) =>
|
listGroupsForPolicy: (policy: string, params: RequestParams = {}) =>
|
||||||
this.request<string[], ApiError>({
|
this.request<SelectedUsers, ApiError>({
|
||||||
path: `/policies/${policy}/groups`,
|
path: `/policies/${policy}/groups`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
secure: true,
|
secure: true,
|
||||||
@@ -3805,7 +3808,7 @@ export class Api<
|
|||||||
},
|
},
|
||||||
params: RequestParams = {},
|
params: RequestParams = {},
|
||||||
) =>
|
) =>
|
||||||
this.request<string[], ApiError>({
|
this.request<SelectedUsers, ApiError>({
|
||||||
path: `/bucket-users/${bucket}`,
|
path: `/bucket-users/${bucket}`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
query: query,
|
query: query,
|
||||||
@@ -4566,7 +4569,7 @@ export class Api<
|
|||||||
* @secure
|
* @secure
|
||||||
*/
|
*/
|
||||||
listNodes: (params: RequestParams = {}) =>
|
listNodes: (params: RequestParams = {}) =>
|
||||||
this.request<string[], ApiError>({
|
this.request<SelectedUsers, ApiError>({
|
||||||
path: `/nodes`,
|
path: `/nodes`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
secure: true,
|
secure: true,
|
||||||
|
|||||||
@@ -14,16 +14,17 @@
|
|||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import React, { Fragment } from "react";
|
import React, { Fragment, useState } from "react";
|
||||||
import { ConfirmDeleteIcon } from "mds";
|
import { ConfirmDeleteIcon } from "mds";
|
||||||
import {
|
import {
|
||||||
setErrorSnackMessage,
|
setErrorSnackMessage,
|
||||||
setServerNeedsRestart,
|
setServerNeedsRestart,
|
||||||
} from "../../../systemSlice";
|
} from "../../../systemSlice";
|
||||||
import { useAppDispatch } from "../../../store";
|
import { useAppDispatch } from "../../../store";
|
||||||
import { ErrorResponseHandler } from "../../../common/types";
|
|
||||||
import useApi from "../Common/Hooks/useApi";
|
|
||||||
import ConfirmDialog from "../Common/ModalWrapper/ConfirmDialog";
|
import ConfirmDialog from "../Common/ModalWrapper/ConfirmDialog";
|
||||||
|
import { api } from "api";
|
||||||
|
import { SetIDPResponse } from "../../../api/consoleApi";
|
||||||
|
import { errorToHandler } from "../../../api/errors";
|
||||||
|
|
||||||
interface IDeleteIDPConfigurationModalProps {
|
interface IDeleteIDPConfigurationModalProps {
|
||||||
closeDeleteModalAndRefresh: (refresh: boolean) => void;
|
closeDeleteModalAndRefresh: (refresh: boolean) => void;
|
||||||
@@ -39,22 +40,27 @@ const DeleteIDPConfigurationModal = ({
|
|||||||
idpType,
|
idpType,
|
||||||
}: IDeleteIDPConfigurationModalProps) => {
|
}: IDeleteIDPConfigurationModalProps) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const onDelSuccess = (res: any) => {
|
const onDelSuccess = (res: SetIDPResponse) => {
|
||||||
closeDeleteModalAndRefresh(true);
|
closeDeleteModalAndRefresh(true);
|
||||||
dispatch(setServerNeedsRestart(res.restart === true));
|
dispatch(setServerNeedsRestart(res.restart === true));
|
||||||
};
|
};
|
||||||
const onDelError = (err: ErrorResponseHandler) =>
|
|
||||||
dispatch(setErrorSnackMessage(err));
|
|
||||||
const onClose = () => closeDeleteModalAndRefresh(false);
|
|
||||||
|
|
||||||
const [deleteLoading, invokeDeleteApi] = useApi(onDelSuccess, onDelError);
|
const onClose = () => closeDeleteModalAndRefresh(false);
|
||||||
|
const [deleteLoading, setDeleteLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
if (!idp) {
|
if (!idp) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const onConfirmDelete = () => {
|
const onConfirmDelete = () => {
|
||||||
invokeDeleteApi("DELETE", `/api/v1/idp/${idpType}/${idp}`);
|
setDeleteLoading(true);
|
||||||
|
api.idp
|
||||||
|
.deleteConfiguration(idp, idpType)
|
||||||
|
.then((res) => {
|
||||||
|
onDelSuccess(res.data);
|
||||||
|
})
|
||||||
|
.catch((err) => dispatch(setErrorSnackMessage(errorToHandler(err.error))))
|
||||||
|
.finally(() => setDeleteLoading(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
const displayName = idp === "_" ? "Default" : idp;
|
const displayName = idp === "_" ? "Default" : idp;
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
import React, { Fragment, useEffect, useState } from "react";
|
import React, { Fragment, useEffect, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { setErrorSnackMessage } from "../../../systemSlice";
|
import { setErrorSnackMessage } from "../../../systemSlice";
|
||||||
import { ErrorResponseHandler } from "../../../common/types";
|
|
||||||
import { ConfirmDeleteIcon, DataTable, InformativeMessage, Loader } from "mds";
|
import { ConfirmDeleteIcon, DataTable, InformativeMessage, Loader } from "mds";
|
||||||
import { encodeURLString } from "../../../common/utils";
|
import { encodeURLString } from "../../../common/utils";
|
||||||
import { IAM_PAGES } from "../../../common/SecureComponent/permissions";
|
import { IAM_PAGES } from "../../../common/SecureComponent/permissions";
|
||||||
import useApi from "../Common/Hooks/useApi";
|
|
||||||
import ConfirmDialog from "../Common/ModalWrapper/ConfirmDialog";
|
import ConfirmDialog from "../Common/ModalWrapper/ConfirmDialog";
|
||||||
import api from "../../../common/api";
|
|
||||||
import { useAppDispatch } from "../../../store";
|
import { useAppDispatch } from "../../../store";
|
||||||
|
import { api } from "api";
|
||||||
|
import { UserServiceAccountItem } from "../../../api/consoleApi";
|
||||||
|
import { errorToHandler } from "../../../api/errors";
|
||||||
|
|
||||||
interface IDeleteUserProps {
|
interface IDeleteUserProps {
|
||||||
closeDeleteModalAndRefresh: (refresh: boolean) => void;
|
closeDeleteModalAndRefresh: (refresh: boolean) => void;
|
||||||
@@ -40,33 +40,31 @@ const DeleteUser = ({
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const onDelSuccess = () => closeDeleteModalAndRefresh(true);
|
|
||||||
const onDelError = (err: ErrorResponseHandler) =>
|
|
||||||
dispatch(setErrorSnackMessage(err));
|
|
||||||
const onClose = () => closeDeleteModalAndRefresh(false);
|
const onClose = () => closeDeleteModalAndRefresh(false);
|
||||||
|
|
||||||
const [deleteLoading, invokeDeleteApi] = useApi(onDelSuccess, onDelError);
|
|
||||||
const [loadingSA, setLoadingSA] = useState<boolean>(true);
|
const [loadingSA, setLoadingSA] = useState<boolean>(true);
|
||||||
const [hasSA, setHasSA] = useState<boolean>(false);
|
const [hasSA, setHasSA] = useState<boolean>(false);
|
||||||
const [userSAList, setUserSAList] = useState<userSACount[]>([]);
|
const [userSAList, setUserSAList] = useState<UserServiceAccountItem[]>([]);
|
||||||
|
const [deleteLoading, setDeleteLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
const userLoggedIn = localStorage.getItem("userLoggedIn") || "";
|
const userLoggedIn = localStorage.getItem("userLoggedIn") || "";
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedUsers) {
|
if (selectedUsers) {
|
||||||
api
|
api.users
|
||||||
.invoke("POST", `/api/v1/users/service-accounts`, selectedUsers)
|
.checkUserServiceAccounts(selectedUsers)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setUserSAList(res.userServiceAccountList);
|
if (res.data) {
|
||||||
if (res.hasSA) {
|
setUserSAList(res.data.userServiceAccountList ?? []);
|
||||||
setHasSA(true);
|
if (res.data.hasSA) {
|
||||||
|
setHasSA(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setLoadingSA(false);
|
|
||||||
})
|
})
|
||||||
.catch((err: ErrorResponseHandler) => {
|
.catch((err) =>
|
||||||
dispatch(setErrorSnackMessage(err));
|
dispatch(setErrorSnackMessage(errorToHandler(err.error))),
|
||||||
setLoadingSA(false);
|
)
|
||||||
});
|
.finally(() => setLoadingSA(false));
|
||||||
}
|
}
|
||||||
}, [selectedUsers, dispatch]);
|
}, [selectedUsers, dispatch]);
|
||||||
|
|
||||||
@@ -102,18 +100,17 @@ const DeleteUser = ({
|
|||||||
);
|
);
|
||||||
closeDeleteModalAndRefresh(true);
|
closeDeleteModalAndRefresh(true);
|
||||||
} else {
|
} else {
|
||||||
invokeDeleteApi("DELETE", `/api/v1/user/${encodeURLString(user)}`);
|
api.user
|
||||||
closeDeleteModalAndRefresh(true);
|
.removeUser(encodeURLString(user))
|
||||||
navigate(`${IAM_PAGES.USERS}`);
|
.then((res) => {
|
||||||
|
closeDeleteModalAndRefresh(true);
|
||||||
|
navigate(`${IAM_PAGES.USERS}`);
|
||||||
|
})
|
||||||
|
.finally(() => setDeleteLoading(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
interface userSACount {
|
|
||||||
userName: string;
|
|
||||||
numSAs: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const noSAtext =
|
const noSAtext =
|
||||||
"Are you sure you want to delete the following " +
|
"Are you sure you want to delete the following " +
|
||||||
selectedUsers.length +
|
selectedUsers.length +
|
||||||
|
|||||||
Reference in New Issue
Block a user