mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Display "renderer" and "secretsmanager" plugin types under plugin catalog "Application" filter (#55597)
* convert plugin filter options to use a type instead of string * add secrets manager and renderer to app plugin filter * update frontend tests * more test updates * fix function to handle all cases
This commit is contained in:
@@ -4,7 +4,7 @@ import { PluginError } from '@grafana/data';
|
||||
import { useDispatch, useSelector } from 'app/types';
|
||||
|
||||
import { sortPlugins, Sorters } from '../helpers';
|
||||
import { CatalogPlugin, PluginListDisplayMode } from '../types';
|
||||
import { CatalogPlugin, PluginListDisplayMode, PluginTypeFilterOption } from '../types';
|
||||
|
||||
import { fetchAll, fetchDetails, fetchRemotePlugins, install, uninstall } from './actions';
|
||||
import { setDisplayMode } from './reducer';
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
type Filters = {
|
||||
query?: string; // Note: this will be an escaped regex string as it comes from `FilterInput`
|
||||
filterBy?: string;
|
||||
filterByType?: string;
|
||||
filterByType?: PluginTypeFilterOption;
|
||||
sortBy?: Sorters;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
|
||||
import { PluginError, PluginErrorCode, unEscapeStringFromRegex } from '@grafana/data';
|
||||
import { PluginError, PluginErrorCode, PluginType, unEscapeStringFromRegex } from '@grafana/data';
|
||||
|
||||
import { RequestStatus, PluginCatalogStoreState } from '../types';
|
||||
import { RequestStatus, PluginCatalogStoreState, PluginTypeFilterOption } from '../types';
|
||||
|
||||
import { pluginsAdapter } from './reducer';
|
||||
|
||||
@@ -19,11 +19,20 @@ const selectInstalled = (filterBy: string) =>
|
||||
plugins.filter((plugin) => (filterBy === 'installed' ? plugin.isInstalled : !plugin.isCore))
|
||||
);
|
||||
|
||||
const findByInstallAndType = (filterBy: string, filterByType: string) =>
|
||||
const findByInstallAndType = (filterBy: string, filterByType: PluginTypeFilterOption) =>
|
||||
createSelector(selectInstalled(filterBy), (plugins) =>
|
||||
plugins.filter((plugin) => filterByType === 'all' || plugin.type === filterByType)
|
||||
plugins.filter(
|
||||
(plugin) =>
|
||||
filterByType === 'all' ||
|
||||
plugin.type === filterByType ||
|
||||
(filterByType === 'app' && isAppPluginType(plugin.type))
|
||||
)
|
||||
);
|
||||
|
||||
const isAppPluginType = (type: PluginType | undefined) => {
|
||||
return type === PluginType.renderer || type === PluginType.secretsmanager || type === PluginType.app;
|
||||
};
|
||||
|
||||
const findByKeyword = (searchBy: string) =>
|
||||
createSelector(selectAll, (plugins) => {
|
||||
if (searchBy === '') {
|
||||
@@ -44,7 +53,7 @@ const findByKeyword = (searchBy: string) =>
|
||||
});
|
||||
});
|
||||
|
||||
export const find = (searchBy: string, filterBy: string, filterByType: string) =>
|
||||
export const find = (searchBy: string, filterBy: string, filterByType: PluginTypeFilterOption) =>
|
||||
createSelector(
|
||||
findByInstallAndType(filterBy, filterByType),
|
||||
findByKeyword(searchBy),
|
||||
|
||||
Reference in New Issue
Block a user