Skip to content

Commit

Permalink
feat(asset): use getvariableoptions util
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Aradei committed Oct 21, 2024
1 parent 5e91c40 commit 1f7f546
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/datasources/asset/data-sources/AssetDataSourceBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { QueryBuilderOption, Workspace } from "../../../core/types";
import { ExpressionTransformFunction } from "../../../core/query-builder.utils";
import { QueryBuilderOperations } from "../../../core/query-builder.constants";
import { AllFieldNames } from "../constants/constants";
import { getVariableOptions } from "core/utils";

export abstract class AssetDataSourceBase extends DataSourceBase<AssetQuery, AssetDataSourceOptions> {
private systemsLoaded!: () => void;
Expand All @@ -21,11 +22,6 @@ export abstract class AssetDataSourceBase extends DataSourceBase<AssetQuery, Ass
public readonly systemAliasCache = new Map<string, SystemMetadata>([]);
public readonly workspacesCache = new Map<string, Workspace>([]);

public readonly globalVariableOptions = (): QueryBuilderOption[] => {
return this.templateSrv.getVariables()
.filter(({ state }) => state === 'Done')
.map(({ name }) => ({ label: `$${name}`, value: `$${name}` })) || []
};

abstract runQuery(query: AssetQuery, options: DataQueryRequest): Promise<DataFrameDTO>;

Expand Down Expand Up @@ -57,6 +53,8 @@ export abstract class AssetDataSourceBase extends DataSourceBase<AssetQuery, Ass
return Array.from(this.workspacesCache.values());
}

public readonly globalVariableOptions = (): QueryBuilderOption[] => getVariableOptions(this);

public async loadDependencies(): Promise<void> {
this.error = '';

Expand Down

0 comments on commit 1f7f546

Please sign in to comment.