mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-5891 User - error after disabling and deleting (#3056)
* CB-5891 on disable user changes form state according to its real state * CB-5891 pr fixes * CB-5891 cleanup * CB-5891 pr fixes --------- Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com>
This commit is contained in:
co-authored by
Evgenia
parent
59c924c3d7
commit
3b9275c00a
+5
-1
@@ -77,7 +77,11 @@ export const AdministrationUserForm = observer<Props>(function AdministrationUse
|
||||
</Container>
|
||||
<Container keepSize noWrap center gap compact>
|
||||
{editing && (
|
||||
<AdministrationUserFormDeleteButton userId={userFormInfoPart.initialState.userId} enabled={userFormInfoPart.initialState.enabled} />
|
||||
<AdministrationUserFormDeleteButton
|
||||
userId={userFormInfoPart.initialState.userId}
|
||||
enabled={userFormInfoPart.initialState.enabled}
|
||||
disableUser={userFormInfoPart.disableUser}
|
||||
/>
|
||||
)}
|
||||
<Button type="button" disabled={state.isDisabled} mod={['outlined']} onClick={onClose}>
|
||||
{translate('ui_processing_cancel')}
|
||||
|
||||
+8
-1
@@ -17,9 +17,15 @@ import { DisableUserDialog } from './DisableUserDialog.js';
|
||||
interface Props extends ButtonProps {
|
||||
userId: string;
|
||||
enabled: boolean;
|
||||
disableUser: () => Promise<void>;
|
||||
}
|
||||
|
||||
export const AdministrationUserFormDeleteButton: React.FC<Props> = function AdministrationUserFormDeleteButton({ userId, enabled, ...rest }) {
|
||||
export const AdministrationUserFormDeleteButton: React.FC<Props> = function AdministrationUserFormDeleteButton({
|
||||
userId,
|
||||
enabled,
|
||||
disableUser,
|
||||
...rest
|
||||
}) {
|
||||
const translate = useTranslate();
|
||||
const commonDialogService = useService(CommonDialogService);
|
||||
const administrationUsersManagementService = useService(AdministrationUsersManagementService);
|
||||
@@ -43,6 +49,7 @@ export const AdministrationUserFormDeleteButton: React.FC<Props> = function Admi
|
||||
await commonDialogService.open(DisableUserDialog, {
|
||||
userId,
|
||||
onDelete: openUserDeleteDialog,
|
||||
disableUser: disableUser,
|
||||
});
|
||||
} else {
|
||||
await openUserDeleteDialog();
|
||||
|
||||
+2
-4
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
import { observer } from 'mobx-react-lite';
|
||||
|
||||
import { UsersResource } from '@cloudbeaver/core-authentication';
|
||||
import {
|
||||
Button,
|
||||
CommonDialogBody,
|
||||
@@ -18,7 +17,6 @@ import {
|
||||
Fill,
|
||||
s,
|
||||
Text,
|
||||
useResource,
|
||||
useS,
|
||||
useTranslate,
|
||||
} from '@cloudbeaver/core-blocks';
|
||||
@@ -31,17 +29,17 @@ import classes from './DisableUserDialog.module.css';
|
||||
interface IPayload {
|
||||
userId: string;
|
||||
onDelete: () => void;
|
||||
disableUser: () => Promise<void>;
|
||||
}
|
||||
|
||||
export const DisableUserDialog: DialogComponent<IPayload> = observer(function DisableUserDialog(props) {
|
||||
const translate = useTranslate();
|
||||
const styles = useS(classes);
|
||||
const notificationService = useService(NotificationService);
|
||||
const usersResource = useResource(DisableUserDialog, UsersResource, null);
|
||||
|
||||
async function disableHandler() {
|
||||
try {
|
||||
await usersResource.resource.enableUser(props.payload.userId, false);
|
||||
await props.payload.disableUser();
|
||||
notificationService.logSuccess({ title: 'authentication_administration_users_disable_user_success', message: props.payload.userId });
|
||||
props.resolveDialog();
|
||||
} catch (exception: any) {
|
||||
|
||||
+8
@@ -34,6 +34,8 @@ export class UserFormInfoPart extends FormPart<IUserFormInfoState, IUserFormStat
|
||||
teams: [],
|
||||
authRole: '',
|
||||
});
|
||||
|
||||
this.disableUser = this.disableUser.bind(this);
|
||||
}
|
||||
|
||||
protected override format(data: IFormState<IUserFormState>, contexts: IExecutionContextProvider<IFormState<IUserFormState>>): void | Promise<void> {
|
||||
@@ -74,6 +76,12 @@ export class UserFormInfoPart extends FormPart<IUserFormInfoState, IUserFormStat
|
||||
return this.loaded;
|
||||
}
|
||||
|
||||
async disableUser() {
|
||||
await this.usersResource.enableUser(this.state.userId, false, true);
|
||||
this.state.enabled = false;
|
||||
this.initialState.enabled = false;
|
||||
}
|
||||
|
||||
override get isChanged(): boolean {
|
||||
if (!this.loaded) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user