From fedc1cdb11c928d8fef474cb129735c28380e0d7 Mon Sep 17 00:00:00 2001 From: Michael Mandrus <41969079+mmandrus@users.noreply.github.com> Date: Fri, 23 Sep 2022 10:58:57 -0400 Subject: [PATCH] Revert "Plugins: Display "renderer" and "secretsmanager" plugin types under plugin catalog "Application" filter (#55597)" (#55686) This reverts commit e981848026384516e9ac1141e64b6bda1385c676. --- .../plugins/admin/pages/Browse.test.tsx | 18 ------------------ .../features/plugins/admin/pages/Browse.tsx | 8 ++++---- .../app/features/plugins/admin/state/hooks.ts | 4 ++-- .../features/plugins/admin/state/selectors.ts | 19 +++++-------------- public/app/features/plugins/admin/types.ts | 1 - 5 files changed, 11 insertions(+), 39 deletions(-) diff --git a/public/app/features/plugins/admin/pages/Browse.test.tsx b/public/app/features/plugins/admin/pages/Browse.test.tsx index a677314b45b..632d8bcfb18 100644 --- a/public/app/features/plugins/admin/pages/Browse.test.tsx +++ b/public/app/features/plugins/admin/pages/Browse.test.tsx @@ -145,8 +145,6 @@ describe('Browse list of plugins', () => { getCatalogPluginMock({ id: 'plugin-1', name: 'Plugin 1', type: PluginType.app }), getCatalogPluginMock({ id: 'plugin-2', name: 'Plugin 2', type: PluginType.datasource }), getCatalogPluginMock({ id: 'plugin-3', name: 'Plugin 3', type: PluginType.panel }), - getCatalogPluginMock({ id: 'plugin-4', name: 'Plugin 4', type: PluginType.secretsmanager }), - getCatalogPluginMock({ id: 'plugin-5', name: 'Plugin 5', type: PluginType.renderer }), ]); await waitFor(() => expect(queryByText('Plugin 2')).toBeInTheDocument()); @@ -154,8 +152,6 @@ describe('Browse list of plugins', () => { // Other plugin types shouldn't be shown expect(queryByText('Plugin 1')).not.toBeInTheDocument(); expect(queryByText('Plugin 3')).not.toBeInTheDocument(); - expect(queryByText('Plugin 4')).not.toBeInTheDocument(); - expect(queryByText('Plugin 5')).not.toBeInTheDocument(); }); it('should list only panel plugins when filtering by panel', async () => { @@ -163,8 +159,6 @@ describe('Browse list of plugins', () => { getCatalogPluginMock({ id: 'plugin-1', name: 'Plugin 1', type: PluginType.app }), getCatalogPluginMock({ id: 'plugin-2', name: 'Plugin 2', type: PluginType.datasource }), getCatalogPluginMock({ id: 'plugin-3', name: 'Plugin 3', type: PluginType.panel }), - getCatalogPluginMock({ id: 'plugin-4', name: 'Plugin 4', type: PluginType.secretsmanager }), - getCatalogPluginMock({ id: 'plugin-5', name: 'Plugin 5', type: PluginType.renderer }), ]); await waitFor(() => expect(queryByText('Plugin 3')).toBeInTheDocument()); @@ -172,8 +166,6 @@ describe('Browse list of plugins', () => { // Other plugin types shouldn't be shown expect(queryByText('Plugin 1')).not.toBeInTheDocument(); expect(queryByText('Plugin 2')).not.toBeInTheDocument(); - expect(queryByText('Plugin 4')).not.toBeInTheDocument(); - expect(queryByText('Plugin 5')).not.toBeInTheDocument(); }); it('should list only app plugins when filtering by app', async () => { @@ -189,16 +181,6 @@ describe('Browse list of plugins', () => { expect(queryByText('Plugin 2')).not.toBeInTheDocument(); expect(queryByText('Plugin 3')).not.toBeInTheDocument(); }); - - it('should also list secretsmanager and renderer plugins when filtering by app', async () => { - const { queryByText } = renderBrowse('/plugins?filterBy=all&filterByType=app', [ - getCatalogPluginMock({ id: 'plugin-1', name: 'Plugin 1', type: PluginType.secretsmanager }), - getCatalogPluginMock({ id: 'plugin-2', name: 'Plugin 2', type: PluginType.renderer }), - ]); - - await waitFor(() => expect(queryByText('Plugin 1')).toBeInTheDocument()); - await waitFor(() => expect(queryByText('Plugin 2')).toBeInTheDocument()); - }); }); describe('when searching', () => { diff --git a/public/app/features/plugins/admin/pages/Browse.tsx b/public/app/features/plugins/admin/pages/Browse.tsx index d5efbdb9e5f..59eb23f4e76 100644 --- a/public/app/features/plugins/admin/pages/Browse.tsx +++ b/public/app/features/plugins/admin/pages/Browse.tsx @@ -16,7 +16,7 @@ import { SearchField } from '../components/SearchField'; import { Sorters } from '../helpers'; import { useHistory } from '../hooks/useHistory'; import { useGetAllWithFilters, useIsRemotePluginsAvailable, useDisplayMode } from '../state/hooks'; -import { PluginListDisplayMode, PluginTypeFilterOption } from '../types'; +import { PluginListDisplayMode } from '../types'; export default function Browse({ route }: GrafanaRouteComponentProps): ReactElement | null { const location = useLocation(); @@ -28,7 +28,7 @@ export default function Browse({ route }: GrafanaRouteComponentProps): ReactElem const remotePluginsAvailable = useIsRemotePluginsAvailable(); const query = (locationSearch.q as string) || ''; const filterBy = (locationSearch.filterBy as string) || 'installed'; - const filterByType: PluginTypeFilterOption = (locationSearch.filterByType as PluginTypeFilterOption) || 'all'; + const filterByType = (locationSearch.filterByType as string) || 'all'; const sortBy = (locationSearch.sortBy as Sorters) || Sorters.nameAsc; const { isLoading, error, plugins } = useGetAllWithFilters({ query, @@ -49,7 +49,7 @@ export default function Browse({ route }: GrafanaRouteComponentProps): ReactElem history.push({ query: { filterBy: value } }); }; - const onFilterByTypeChange = (value: PluginTypeFilterOption) => { + const onFilterByTypeChange = (value: string) => { history.push({ query: { filterByType: value } }); }; @@ -71,7 +71,7 @@ export default function Browse({ route }: GrafanaRouteComponentProps): ReactElem {/* Filter by type */}
- + plugins.filter((plugin) => (filterBy === 'installed' ? plugin.isInstalled : !plugin.isCore)) ); -const findByInstallAndType = (filterBy: string, filterByType: PluginTypeFilterOption) => +const findByInstallAndType = (filterBy: string, filterByType: string) => createSelector(selectInstalled(filterBy), (plugins) => - plugins.filter( - (plugin) => - filterByType === 'all' || - plugin.type === filterByType || - (filterByType === 'app' && isAppPluginType(plugin.type)) - ) + plugins.filter((plugin) => filterByType === 'all' || plugin.type === filterByType) ); -const isAppPluginType = (type: PluginType | undefined) => { - return type === PluginType.renderer || type === PluginType.secretsmanager || type === PluginType.app; -}; - const findByKeyword = (searchBy: string) => createSelector(selectAll, (plugins) => { if (searchBy === '') { @@ -53,7 +44,7 @@ const findByKeyword = (searchBy: string) => }); }); -export const find = (searchBy: string, filterBy: string, filterByType: PluginTypeFilterOption) => +export const find = (searchBy: string, filterBy: string, filterByType: string) => createSelector( findByInstallAndType(filterBy, filterByType), findByKeyword(searchBy), diff --git a/public/app/features/plugins/admin/types.ts b/public/app/features/plugins/admin/types.ts index 5b410cf85f0..fe400db1ab6 100644 --- a/public/app/features/plugins/admin/types.ts +++ b/public/app/features/plugins/admin/types.ts @@ -12,7 +12,6 @@ import { IconName } from '@grafana/ui'; import { StoreState, PluginsState } from 'app/types'; export type PluginTypeCode = 'app' | 'panel' | 'datasource'; -export type PluginTypeFilterOption = PluginTypeCode | 'all'; export enum PluginListDisplayMode { Grid = 'grid',