Plugins: Change pageId parameter type in usePluginDetailsTabs (#115612)
* change usePluginDetailsTabs pageId parameter type * add eslint suppressions
This commit is contained in:
@@ -2868,11 +2868,6 @@
|
|||||||
"count": 1
|
"count": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"public/app/features/plugins/admin/components/PluginDetailsPage.tsx": {
|
|
||||||
"@typescript-eslint/consistent-type-assertions": {
|
|
||||||
"count": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"public/app/features/plugins/admin/helpers.ts": {
|
"public/app/features/plugins/admin/helpers.ts": {
|
||||||
"no-restricted-syntax": {
|
"no-restricted-syntax": {
|
||||||
"count": 2
|
"count": 2
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import { PluginDetailsSignature } from '../components/PluginDetailsSignature';
|
|||||||
import { usePluginDetailsTabs } from '../hooks/usePluginDetailsTabs';
|
import { usePluginDetailsTabs } from '../hooks/usePluginDetailsTabs';
|
||||||
import { usePluginPageExtensions } from '../hooks/usePluginPageExtensions';
|
import { usePluginPageExtensions } from '../hooks/usePluginPageExtensions';
|
||||||
import { useGetSingle, useFetchStatus, useFetchDetailsStatus } from '../state/hooks';
|
import { useGetSingle, useFetchStatus, useFetchDetailsStatus } from '../state/hooks';
|
||||||
import { PluginTabIds } from '../types';
|
|
||||||
|
|
||||||
import { PluginDetailsDeprecatedWarning } from './PluginDetailsDeprecatedWarning';
|
import { PluginDetailsDeprecatedWarning } from './PluginDetailsDeprecatedWarning';
|
||||||
|
|
||||||
@@ -50,11 +49,7 @@ export function PluginDetailsPage({
|
|||||||
const queryParams = new URLSearchParams(location.search);
|
const queryParams = new URLSearchParams(location.search);
|
||||||
const plugin = useGetSingle(pluginId); // fetches the plugin settings for this Grafana instance
|
const plugin = useGetSingle(pluginId); // fetches the plugin settings for this Grafana instance
|
||||||
const isNarrowScreen = useMedia('(max-width: 600px)');
|
const isNarrowScreen = useMedia('(max-width: 600px)');
|
||||||
const { navModel, activePageId } = usePluginDetailsTabs(
|
const { navModel, activePageId } = usePluginDetailsTabs(plugin, queryParams.get('page'), isNarrowScreen);
|
||||||
plugin,
|
|
||||||
queryParams.get('page') as PluginTabIds,
|
|
||||||
isNarrowScreen
|
|
||||||
);
|
|
||||||
const { actions, info, subtitle } = usePluginPageExtensions(plugin);
|
const { actions, info, subtitle } = usePluginPageExtensions(plugin);
|
||||||
const { isLoading: isFetchLoading } = useFetchStatus();
|
const { isLoading: isFetchLoading } = useFetchStatus();
|
||||||
const { isLoading: isFetchDetailsLoading } = useFetchDetailsStatus();
|
const { isLoading: isFetchDetailsLoading } = useFetchDetailsStatus();
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ type ReturnType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getCurrentPageId(
|
function getCurrentPageId(
|
||||||
pageId: PluginTabIds | undefined,
|
|
||||||
isNarrowScreen: boolean | undefined,
|
isNarrowScreen: boolean | undefined,
|
||||||
defaultTab: string
|
defaultTab: string,
|
||||||
|
pageId?: PluginTabIds | string | null
|
||||||
): PluginTabIds | string {
|
): PluginTabIds | string {
|
||||||
if (!isNarrowScreen && pageId === PluginTabIds.PLUGINDETAILS) {
|
if (!isNarrowScreen && pageId === PluginTabIds.PLUGINDETAILS) {
|
||||||
return defaultTab;
|
return defaultTab;
|
||||||
@@ -30,7 +30,7 @@ function getCurrentPageId(
|
|||||||
|
|
||||||
export const usePluginDetailsTabs = (
|
export const usePluginDetailsTabs = (
|
||||||
plugin?: CatalogPlugin,
|
plugin?: CatalogPlugin,
|
||||||
pageId?: PluginTabIds,
|
pageId?: PluginTabIds | string | null,
|
||||||
isNarrowScreen?: boolean
|
isNarrowScreen?: boolean
|
||||||
): ReturnType => {
|
): ReturnType => {
|
||||||
const { loading, error, value: pluginConfig } = usePluginConfig(plugin);
|
const { loading, error, value: pluginConfig } = usePluginConfig(plugin);
|
||||||
@@ -38,7 +38,7 @@ export const usePluginDetailsTabs = (
|
|||||||
const defaultTab = useDefaultPage(plugin, pluginConfig);
|
const defaultTab = useDefaultPage(plugin, pluginConfig);
|
||||||
const isPublished = Boolean(plugin?.isPublished);
|
const isPublished = Boolean(plugin?.isPublished);
|
||||||
|
|
||||||
const currentPageId = getCurrentPageId(pageId, isNarrowScreen, defaultTab);
|
const currentPageId = getCurrentPageId(isNarrowScreen, defaultTab, pageId);
|
||||||
|
|
||||||
const navModelChildren = useMemo(() => {
|
const navModelChildren = useMemo(() => {
|
||||||
const canConfigurePlugins = plugin && contextSrv.hasPermissionInMetadata(AccessControlAction.PluginsWrite, plugin);
|
const canConfigurePlugins = plugin && contextSrv.hasPermissionInMetadata(AccessControlAction.PluginsWrite, plugin);
|
||||||
|
|||||||
Reference in New Issue
Block a user