mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Refresh plugin info after installation (#75074)
This commit is contained in:
parent
b87279b8d8
commit
6600dd265b
@ -9,7 +9,14 @@ import { useQueryParams } from 'app/core/hooks/useQueryParams';
|
|||||||
import { removePluginFromNavTree } from 'app/core/reducers/navBarTree';
|
import { removePluginFromNavTree } from 'app/core/reducers/navBarTree';
|
||||||
import { useDispatch } from 'app/types';
|
import { useDispatch } from 'app/types';
|
||||||
|
|
||||||
import { useInstallStatus, useUninstallStatus, useInstall, useUninstall, useUnsetInstall } from '../../state/hooks';
|
import {
|
||||||
|
useInstallStatus,
|
||||||
|
useUninstallStatus,
|
||||||
|
useInstall,
|
||||||
|
useUninstall,
|
||||||
|
useUnsetInstall,
|
||||||
|
useFetchDetailsLazy,
|
||||||
|
} from '../../state/hooks';
|
||||||
import { trackPluginInstalled, trackPluginUninstalled } from '../../tracking';
|
import { trackPluginInstalled, trackPluginUninstalled } from '../../tracking';
|
||||||
import { CatalogPlugin, PluginStatus, PluginTabIds, Version } from '../../types';
|
import { CatalogPlugin, PluginStatus, PluginTabIds, Version } from '../../types';
|
||||||
|
|
||||||
@ -36,6 +43,7 @@ export function InstallControlsButton({
|
|||||||
const install = useInstall();
|
const install = useInstall();
|
||||||
const uninstall = useUninstall();
|
const uninstall = useUninstall();
|
||||||
const unsetInstall = useUnsetInstall();
|
const unsetInstall = useUnsetInstall();
|
||||||
|
const fetchDetails = useFetchDetailsLazy();
|
||||||
const [isConfirmModalVisible, setIsConfirmModalVisible] = useState(false);
|
const [isConfirmModalVisible, setIsConfirmModalVisible] = useState(false);
|
||||||
const showConfirmModal = () => setIsConfirmModalVisible(true);
|
const showConfirmModal = () => setIsConfirmModalVisible(true);
|
||||||
const hideConfirmModal = () => setIsConfirmModalVisible(false);
|
const hideConfirmModal = () => setIsConfirmModalVisible(false);
|
||||||
@ -57,6 +65,8 @@ export function InstallControlsButton({
|
|||||||
const onInstall = async () => {
|
const onInstall = async () => {
|
||||||
trackPluginInstalled(trackingProps);
|
trackPluginInstalled(trackingProps);
|
||||||
const result = await install(plugin.id, latestCompatibleVersion?.version);
|
const result = await install(plugin.id, latestCompatibleVersion?.version);
|
||||||
|
// refresh the store to have the new installed plugin
|
||||||
|
await fetchDetails(plugin.id);
|
||||||
if (!errorInstalling && !('error' in result)) {
|
if (!errorInstalling && !('error' in result)) {
|
||||||
appEvents.emit(AppEvents.alertSuccess, [`Installed ${plugin.name}`]);
|
appEvents.emit(AppEvents.alertSuccess, [`Installed ${plugin.name}`]);
|
||||||
if (plugin.type === 'app') {
|
if (plugin.type === 'app') {
|
||||||
|
@ -133,6 +133,12 @@ export const useFetchDetails = (id: string) => {
|
|||||||
}, [plugin]); // eslint-disable-line
|
}, [plugin]); // eslint-disable-line
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useFetchDetailsLazy = () => {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
|
return (id: string) => dispatch(fetchDetails(id));
|
||||||
|
};
|
||||||
|
|
||||||
export const useDisplayMode = () => {
|
export const useDisplayMode = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const displayMode = useSelector(selectDisplayMode);
|
const displayMode = useSelector(selectDisplayMode);
|
||||||
|
Loading…
Reference in New Issue
Block a user