Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dashboards/src/context/DatasourceStoreProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export function DatasourceStoreProvider(props: DatasourceStoreProviderProps): Re
const ctxValue: DatasourceStore = useMemo(
() =>
({
project,
getDatasource,
getDatasourceClient,
getDatasourceSpecSync,
Expand All @@ -246,6 +247,7 @@ export function DatasourceStoreProvider(props: DatasourceStoreProviderProps): Re
listDatasourceSelectItems,
}) as DatasourceStore,
[
project,
getDatasource,
getDatasourceClient,
getDatasourceSpecSync,
Expand Down
12 changes: 9 additions & 3 deletions plugin-system/src/runtime/datasources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import { useQuery } from '@tanstack/react-query';
import { createContext, useContext } from 'react';

export interface DatasourceStore {
/**
* Project whose datasources are listed alongside global ones. Undefined for a global-only scope.
*/
project?: string;

// TODO: Do we even need this method?
getDatasource(selector: DatasourceSelector): Promise<DatasourceSpec>;

Expand Down Expand Up @@ -101,10 +106,11 @@ export function useListDatasourceSelectItems(
datasourcePluginName: string,
project?: string,
): UseQueryResult<DatasourceSelectItemGroup[]> {
const { listDatasourceSelectItems } = useDatasourceStore();
const store = useDatasourceStore();
// Results are scoped by the store's project; the explicit parameter only remains as a fallback discriminator.
return useQuery<DatasourceSelectItemGroup[]>({
queryKey: ['listDatasourceSelectItems', datasourcePluginName, project],
queryFn: () => listDatasourceSelectItems(datasourcePluginName),
queryKey: ['listDatasourceSelectItems', datasourcePluginName, store.project ?? project],
queryFn: () => store.listDatasourceSelectItems(datasourcePluginName),
});
}

Expand Down
Loading