PluginsList Panel: Redirect to catalog app for updating plugins (#34893)

* feat(pluginlistpanel): if catalog app is enabled redirect user if plugin is upgradable

* refactor(catalog): update copy if plugin is disabled
This commit is contained in:
Jack Westbrook 2021-05-31 13:53:40 +02:00 committed by GitHub
parent 98c849d4cc
commit 8c93899b15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 10 deletions

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { Page } from 'components/Page'; import { Page } from 'components/Page';
import { AppRootProps, NavModelItem } from '@grafana/data'; import { AppRootProps, NavModelItem } from '@grafana/data';
import { css } from '@emotion/css';
export const NotEnabled = ({ onNavChanged }: AppRootProps) => { export const NotEnabled = ({ onNavChanged }: AppRootProps) => {
const node: NavModelItem = { const node: NavModelItem = {
@ -16,8 +17,16 @@ export const NotEnabled = ({ onNavChanged }: AppRootProps) => {
return ( return (
<Page> <Page>
To enabled installing plugins, set the{' '} To enable installing plugins, please refer to the{' '}
<a href="https://grafana.com/docs/grafana/latest/plugins/catalog">Plugin Catalog</a> instructions <a
className={css`
text-decoration: underline;
`}
href="https://grafana.com/docs/grafana/latest/plugins/catalog"
>
Plugin Catalog
</a>{' '}
instructions
</Page> </Page>
); );
}; };

View File

@ -86,7 +86,6 @@ class AppRootPage extends Component<Props, State> {
} }
onNavChanged = (nav: NavModel) => { onNavChanged = (nav: NavModel) => {
console.log('NAV CHANGED!!!', nav);
this.setState({ nav }); this.setState({ nav });
}; };

View File

@ -3,6 +3,7 @@ import { useAsync } from 'react-use';
import { css, cx } from '@emotion/css'; import { css, cx } from '@emotion/css';
import { GrafanaTheme, PanelProps, PluginMeta, PluginType } from '@grafana/data'; import { GrafanaTheme, PanelProps, PluginMeta, PluginType } from '@grafana/data';
import { CustomScrollbar, ModalsController, stylesFactory, Tooltip, useStyles } from '@grafana/ui'; import { CustomScrollbar, ModalsController, stylesFactory, Tooltip, useStyles } from '@grafana/ui';
import { config, locationService } from '@grafana/runtime';
import { contextSrv } from 'app/core/services/context_srv'; import { contextSrv } from 'app/core/services/context_srv';
import { getBackendSrv } from 'app/core/services/backend_srv'; import { getBackendSrv } from 'app/core/services/backend_srv';
import { UpdatePluginModal } from './components/UpdatePluginModal'; import { UpdatePluginModal } from './components/UpdatePluginModal';
@ -48,13 +49,16 @@ export function PluginList(props: PanelProps) {
className={cx(styles.message, styles.messageUpdate)} className={cx(styles.message, styles.messageUpdate)}
onClick={(e) => { onClick={(e) => {
e.preventDefault(); e.preventDefault();
if (config.pluginAdminEnabled) {
showModal(UpdatePluginModal, { locationService.push(`/a/grafana-plugin-admin-app/plugin/${plugin.id}`);
pluginID: plugin.id, } else {
pluginName: plugin.name, showModal(UpdatePluginModal, {
onDismiss: hideModal, pluginID: plugin.id,
isOpen: true, pluginName: plugin.name,
}); onDismiss: hideModal,
isOpen: true,
});
}
}} }}
> >
Update available! Update available!