diff --git a/ui/src/common/BaseStore.ts b/ui/src/common/BaseStore.ts index 6b9a73d..4b2b4ee 100644 --- a/ui/src/common/BaseStore.ts +++ b/ui/src/common/BaseStore.ts @@ -30,6 +30,13 @@ export abstract class BaseStore implements IClearable { this.items = await this.requestItems().then((items) => items || []); }; + @action + public refreshIfMissing = async (id: number): Promise => { + if (this.getByIDOrUndefined(id) === undefined) { + await this.refresh(); + } + }; + public getByID = (id: number): T => { const item = this.getByIDOrUndefined(id); if (item === undefined) { diff --git a/ui/src/plugin/PluginDetailView.tsx b/ui/src/plugin/PluginDetailView.tsx index 0a27fad..7c83877 100644 --- a/ui/src/plugin/PluginDetailView.tsx +++ b/ui/src/plugin/PluginDetailView.tsx @@ -16,6 +16,7 @@ import * as config from '../config'; import Container from '../common/Container'; import {inject, Stores} from '../inject'; import {IPlugin} from '../types'; +import LoadingSpinner from '../common/LoadingSpinner'; type IProps = RouteComponentProps<{id: string}>; @@ -42,8 +43,9 @@ class PluginDetailView extends Component, IState> this.refreshFeatures(); } - private refreshFeatures() { - return Promise.all([this.refreshConfigurer(), this.refreshDisplayer()]); + private async refreshFeatures() { + await this.props.pluginStore.refreshIfMissing(this.pluginID); + return await Promise.all([this.refreshConfigurer(), this.refreshDisplayer()]); } private async refreshConfigurer() { @@ -67,14 +69,16 @@ class PluginDetailView extends Component, IState> } public render() { - const pluginInfo = this.pluginInfo(); - const {name, capabilities} = pluginInfo; + const pluginInfo = this.props.pluginStore.getByIDOrUndefined(this.pluginID); + if (pluginInfo === undefined) { + return ; + } return ( - + - {capabilities.indexOf('configurer') !== -1 ? ( + {pluginInfo.capabilities.indexOf('configurer') !== -1 ? ( , IState> /> ) : null}{' '} - {capabilities.indexOf('displayer') !== -1 ? ( + {pluginInfo.capabilities.indexOf('displayer') !== -1 ? (