-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CB-5123. Added backend part, added new parameter licenseStatus to ser… (
#2831) * CB-5123. Added backend part, added new parameter licenseStatus to server config gql * CB-5123 feat: display license status information * CB-5123 fix: after review * CB-5123. Added version --------- Co-authored-by: Aleksei Potsetsuev <[email protected]> Co-authored-by: Evgenia Bezborodova <[email protected]>
- Loading branch information
1 parent
2d45b29
commit 9254684
Showing
37 changed files
with
487 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
webapp/packages/core-root/src/DefaultNavigatorSettingsResource.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { action, makeObservable, observable } from 'mobx'; | ||
|
||
import { injectable } from '@cloudbeaver/core-di'; | ||
import { CachedDataResource } from '@cloudbeaver/core-resource'; | ||
import { DefaultNavigatorSettingsFragment, GraphQLService, NavigatorSettingsInput } from '@cloudbeaver/core-sdk'; | ||
|
||
import { isNavigatorViewSettingsEqual } from './ConnectionNavigatorViewSettings'; | ||
import { ServerConfigResource } from './ServerConfigResource'; | ||
|
||
export type DefaultNavigatorSettings = DefaultNavigatorSettingsFragment['defaultNavigatorSettings']; | ||
|
||
@injectable() | ||
export class DefaultNavigatorSettingsResource extends CachedDataResource<DefaultNavigatorSettings | null> { | ||
update: NavigatorSettingsInput; | ||
|
||
constructor( | ||
private readonly graphQLService: GraphQLService, | ||
serverConfigResource: ServerConfigResource, | ||
) { | ||
super(() => null, undefined, []); | ||
this.sync(serverConfigResource); | ||
|
||
this.update = getDefaultNavigatorSettings(); | ||
|
||
makeObservable<this, 'syncUpdateData'>(this, { | ||
update: observable, | ||
unlinkUpdate: action, | ||
syncUpdateData: action, | ||
}); | ||
} | ||
|
||
isChanged(): boolean { | ||
if (!this.data) { | ||
return false; | ||
} | ||
|
||
return !isNavigatorViewSettingsEqual(this.data, this.update); | ||
} | ||
|
||
setDataUpdate(update: NavigatorSettingsInput): void { | ||
this.update = update; | ||
} | ||
|
||
resetUpdate(): void { | ||
if (this.data) { | ||
this.syncUpdateData(this.data); | ||
} | ||
} | ||
|
||
unlinkUpdate(): void { | ||
if (this.data) { | ||
Object.assign(this.update, this.data); | ||
} else { | ||
this.update = getDefaultNavigatorSettings(); | ||
} | ||
} | ||
|
||
async save(): Promise<void> { | ||
await this.performUpdate( | ||
undefined, | ||
undefined, | ||
async () => { | ||
await this.graphQLService.sdk.setDefaultNavigatorSettings({ settings: this.update }); | ||
|
||
this.setData(await this.loader()); | ||
|
||
this.onDataOutdated.execute(); | ||
}, | ||
() => !this.isChanged(), | ||
); | ||
} | ||
|
||
protected async loader(): Promise<DefaultNavigatorSettings> { | ||
const { defaultNavigatorSettings } = await this.graphQLService.sdk.getDefaultNavigatorSettings(); | ||
|
||
this.syncUpdateData(defaultNavigatorSettings.defaultNavigatorSettings); | ||
|
||
return defaultNavigatorSettings.defaultNavigatorSettings; | ||
} | ||
|
||
private syncUpdateData(defaultNavigatorSettings: DefaultNavigatorSettings) { | ||
Object.assign(this.update, defaultNavigatorSettings); | ||
} | ||
} | ||
|
||
function getDefaultNavigatorSettings(): NavigatorSettingsInput { | ||
return { | ||
hideFolders: false, | ||
hideSchemas: false, | ||
hideVirtualModel: false, | ||
mergeEntities: false, | ||
showOnlyEntities: false, | ||
showSystemObjects: false, | ||
showUtilityObjects: false, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { injectable } from '@cloudbeaver/core-di'; | ||
import { CachedDataResource } from '@cloudbeaver/core-resource'; | ||
import { GraphQLService, PasswordPolicyFragment } from '@cloudbeaver/core-sdk'; | ||
|
||
import { ServerConfigResource } from './ServerConfigResource'; | ||
|
||
export type PasswordPolicy = PasswordPolicyFragment['passwordPolicyConfiguration']; | ||
|
||
@injectable() | ||
export class PasswordPolicyResource extends CachedDataResource<PasswordPolicy | null> { | ||
constructor( | ||
private readonly graphQLService: GraphQLService, | ||
serverConfigResource: ServerConfigResource, | ||
) { | ||
super(() => null, undefined, []); | ||
this.sync(serverConfigResource); | ||
} | ||
|
||
protected async loader(): Promise<PasswordPolicy> { | ||
const { passwordPolicy } = await this.graphQLService.sdk.getPasswordPolicy(); | ||
|
||
return passwordPolicy.passwordPolicyConfiguration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { injectable } from '@cloudbeaver/core-di'; | ||
import { CachedDataResource } from '@cloudbeaver/core-resource'; | ||
import { GraphQLService, ProductInfoFragment } from '@cloudbeaver/core-sdk'; | ||
|
||
import { ServerConfigResource } from './ServerConfigResource'; | ||
|
||
export type ProductInfo = ProductInfoFragment['productInfo']; | ||
|
||
@injectable() | ||
export class ProductInfoResource extends CachedDataResource<ProductInfo | null> { | ||
constructor( | ||
private readonly graphQLService: GraphQLService, | ||
serverConfigResource: ServerConfigResource, | ||
) { | ||
super(() => null, undefined, []); | ||
this.sync(serverConfigResource); | ||
} | ||
|
||
protected async loader(): Promise<ProductInfo> { | ||
const { productInfo } = await this.graphQLService.sdk.getProductInfo(); | ||
|
||
return productInfo.productInfo; | ||
} | ||
} |
Oops, something went wrong.