mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
/*
|
|
* 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 { makeObservable, observable } from 'mobx';
|
|
|
|
import { injectable } from '@cloudbeaver/core-di';
|
|
import { CachedDataResource } from '@cloudbeaver/core-resource';
|
|
import { GraphQLService, WebFeatureSet } from '@cloudbeaver/core-sdk';
|
|
|
|
import { EAdminPermission } from './EAdminPermission';
|
|
import { SessionPermissionsResource } from './SessionPermissionsResource';
|
|
|
|
export type ApplicationFeature = WebFeatureSet;
|
|
|
|
@injectable()
|
|
export class FeaturesResource extends CachedDataResource<ApplicationFeature[]> {
|
|
private baseFeatures: string[];
|
|
constructor(
|
|
private readonly graphQLService: GraphQLService,
|
|
permissionsResource: SessionPermissionsResource,
|
|
) {
|
|
super(() => []);
|
|
|
|
this.baseFeatures = [];
|
|
permissionsResource.require(this, EAdminPermission.admin).outdateResource(this);
|
|
|
|
makeObservable<this, 'baseFeatures'>(this, {
|
|
baseFeatures: observable,
|
|
});
|
|
}
|
|
|
|
isBase(id: string) {
|
|
return this.baseFeatures.includes(id);
|
|
}
|
|
|
|
setBaseFeatures(features: string[]) {
|
|
this.baseFeatures = features;
|
|
}
|
|
|
|
protected async loader(): Promise<ApplicationFeature[]> {
|
|
const { features } = await this.graphQLService.sdk.listFeatureSets();
|
|
|
|
return features;
|
|
}
|
|
}
|