Plugin Catalog: support Grafana instances that cannot communicate with gcom (#39638)

* added possibility to track if remote plugins could be fetched.

* adding hook to detect if remote plugins are available.

* feat(catalog): disable installed/all filter if remote plugins are unavailable

* feat(Plugins/Admin): hide the install controls if GCOM is not available

* refactor(Plugins/Admin): group `@grafana` dependencies

* fix(Plugins/Admin): don't show an error alert if a remote plugin is not available

* feat(Plugins/Admin): prefer to use the local version of the readme

* chore(Plugins/Admin): type the mocked state properly

* test(Plugins/Admin): add tests for the Plugin Details when GCOM is not available

* test(Plugins/Admin): add tests for the Browse when GCOM is not available

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
This commit is contained in:
Jack Westbrook
2021-09-28 16:46:29 +02:00
committed by GitHub
parent 5d0d7dcb3a
commit fffcee7c1f
9 changed files with 202 additions and 51 deletions

View File

@@ -1,6 +1,6 @@
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { fetchAll, fetchDetails, install, uninstall } from './actions';
import { fetchAll, fetchDetails, fetchRemotePlugins, install, uninstall } from './actions';
import { CatalogPlugin, PluginCatalogStoreState } from '../types';
import {
find,
@@ -63,6 +63,11 @@ export const useUninstall = () => {
return (id: string) => dispatch(uninstall(id));
};
export const useIsRemotePluginsAvailable = () => {
const error = useSelector(selectRequestError(fetchRemotePlugins.typePrefix));
return error === null;
};
export const useFetchStatus = () => {
const isLoading = useSelector(selectIsRequestPending(fetchAll.typePrefix));
const error = useSelector(selectRequestError(fetchAll.typePrefix));