Provisioning: Skip requests if feature toggle is not enabled (#108165)
* Provisioning: Skip request if feature toggle is not enabled * Add check to provisioning page
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { css } from '@emotion/css';
|
||||
import { skipToken } from '@reduxjs/toolkit/query';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { Alert, Stack, useStyles2 } from '@grafana/ui';
|
||||
import { useGetFrontendSettingsQuery, Repository } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import provisioningSvg from 'img/provisioning/provisioning.svg';
|
||||
@@ -121,7 +123,10 @@ interface Props {
|
||||
|
||||
export default function GettingStarted({ items }: Props) {
|
||||
const styles = useStyles2(getStyles);
|
||||
const settingsQuery = useGetFrontendSettingsQuery(undefined, { refetchOnMountOrArgChange: true });
|
||||
const settingsArg = config.featureToggles.provisioning ? undefined : skipToken;
|
||||
const settingsQuery = useGetFrontendSettingsQuery(settingsArg, {
|
||||
refetchOnMountOrArgChange: true,
|
||||
});
|
||||
const legacyStorage = settingsQuery.data?.legacyStorage;
|
||||
const hasItems = Boolean(settingsQuery.data?.items?.length);
|
||||
const { hasPublicAccess, hasImageRenderer, hasRequiredFeatures } = getConfigurationStatus();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { skipToken } from '@reduxjs/toolkit/query/react';
|
||||
|
||||
import { config } from '@grafana/runtime';
|
||||
import { Folder, useGetFolderQuery } from 'app/api/clients/folder/v1beta1';
|
||||
import { RepositoryView, useGetFrontendSettingsQuery } from 'app/api/clients/provisioning/v0alpha1';
|
||||
import { AnnoKeyManagerIdentity } from 'app/features/apiserver/types';
|
||||
@@ -18,12 +19,19 @@ interface RepositoryViewData {
|
||||
|
||||
// This is safe to call as a viewer (you do not need full access to the Repository configs)
|
||||
export const useGetResourceRepositoryView = ({ name, folderName }: GetResourceRepositoryArgs): RepositoryViewData => {
|
||||
const { data: settingsData, isLoading: isSettingsLoading } = useGetFrontendSettingsQuery();
|
||||
const skipFolderQuery = !folderName;
|
||||
const provisioningEnabled = config.featureToggles.provisioning;
|
||||
const { data: settingsData, isLoading: isSettingsLoading } = useGetFrontendSettingsQuery(
|
||||
!provisioningEnabled ? skipToken : undefined
|
||||
);
|
||||
const skipFolderQuery = !folderName || !provisioningEnabled;
|
||||
const { data: folder, isLoading: isFolderLoading } = useGetFolderQuery(
|
||||
skipFolderQuery ? skipToken : { name: folderName }
|
||||
);
|
||||
|
||||
if (!provisioningEnabled) {
|
||||
return { isLoading: false, isInstanceManaged: false };
|
||||
}
|
||||
|
||||
if (isSettingsLoading || isFolderLoading) {
|
||||
return { isLoading: true, isInstanceManaged: false };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user