CB-3287 update database auth dialog, use isHidden (#1572)

This commit is contained in:
Tatiana Fokina
2023-03-30 15:56:16 +03:00
committed by GitHub
parent 78e16f3ffc
commit a6284343b1
3 changed files with 14 additions and 3 deletions
@@ -92,6 +92,7 @@ export class ConnectionAuthService extends Dependency {
const result = await this.commonDialogService.open(DatabaseAuthDialog, {
connection: key,
networkHandlers,
resetCredentials,
});
if (resetCredentials && isConnectedInitially && result === DialogueStateResult.Rejected) {
@@ -196,7 +196,16 @@ export class ConnectionMenuBootstrap extends Bootstrap {
}
if (action === ACTION_CONNECTION_CHANGE_CREDENTIALS) {
return this.serverConfigResource.distributed && connection.credentialsSaved === true;
return this.serverConfigResource.distributed;
}
return false;
},
isHidden: (context, action) => {
const connection = context.tryGet(DATA_CONTEXT_CONNECTION);
if (action === ACTION_CONNECTION_CHANGE_CREDENTIALS) {
return !connection?.credentialsSaved;
}
return false;
@@ -45,6 +45,7 @@ const styles = css`
interface Payload {
connection: IConnectionInfoParams;
networkHandlers: string[];
resetCredentials?: boolean;
}
export const DatabaseAuthDialog: DialogComponent<Payload> = observer(function DatabaseAuthDialog({
@@ -62,8 +63,8 @@ export const DatabaseAuthDialog: DialogComponent<Payload> = observer(function Da
let authModelId: string | null = null;
if (connection.connectionInfo?.authNeeded) {
authModelId = connection.connectionInfo.authModel || driver?.defaultAuthModel || null;
if (connection.connectionInfo?.authNeeded || payload.resetCredentials) {
authModelId = connection.connectionInfo?.authModel || driver?.defaultAuthModel || null;
}
return styled(useStyles(styles))(