mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Replace setup-time asynchronicity with spinner when actually showing the data
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
d42a546514
commit
175add91fc
@ -5,14 +5,14 @@
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import type { GroupSelectOption, SelectOption } from "../../select";
|
||||
import lensCreateResourceTemplatesInjectable from "./lens-templates.injectable";
|
||||
import userCreateResourceTemplatesInjectable from "./user-templates.injectable";
|
||||
import lensCreateResourceTemplatesInjectable from "./lens-templates.injectable";
|
||||
|
||||
export type RawTemplates = [group: string, items: [file: string, contents: string][]];
|
||||
|
||||
const createResourceTemplatesInjectable = getInjectable({
|
||||
instantiate: (di) => {
|
||||
const lensResourceTemplates = di.inject(lensCreateResourceTemplatesInjectable);
|
||||
instantiate: async (di) => {
|
||||
const lensResourceTemplates = await di.inject(lensCreateResourceTemplatesInjectable);
|
||||
const userResourceTemplates = di.inject(userCreateResourceTemplatesInjectable);
|
||||
|
||||
return computed(() => {
|
||||
@ -27,6 +27,7 @@ const createResourceTemplatesInjectable = getInjectable({
|
||||
}) as GroupSelectOption<SelectOption<string>>);
|
||||
});
|
||||
},
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
|
||||
@ -5,10 +5,10 @@
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import path from "path";
|
||||
import { hasCorrectExtension } from "./has-correct-extension";
|
||||
import type { RawTemplates } from "./create-resource-templates.injectable";
|
||||
import "../../../../common/vars";
|
||||
import readFileInjectable from "../../../../common/fs/read-file.injectable";
|
||||
import readDirInjectable from "../../../../common/fs/read-dir.injectable";
|
||||
import type { RawTemplates } from "./create-resource-templates.injectable";
|
||||
|
||||
interface Dependencies {
|
||||
readDir: (dirPath: string) => Promise<string[]>;
|
||||
@ -32,16 +32,16 @@ async function getTemplates({ readDir, readFile }: Dependencies) {
|
||||
return templates;
|
||||
}
|
||||
|
||||
let lensTemplatePaths: RawTemplates;
|
||||
|
||||
const lensCreateResourceTemplatesInjectable = getInjectable({
|
||||
setup: async (di) => {
|
||||
lensTemplatePaths = ["lens", await getTemplates({
|
||||
instantiate: async (di): Promise<RawTemplates> => {
|
||||
const templates = await getTemplates({
|
||||
readFile: di.inject(readFileInjectable),
|
||||
readDir: di.inject(readDirInjectable),
|
||||
})];
|
||||
});
|
||||
|
||||
return ["lens", templates];
|
||||
},
|
||||
instantiate: () => lensTemplatePaths,
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ import { navigate } from "../../../navigation";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import createResourceTabStoreInjectable from "./store.injectable";
|
||||
import createResourceTemplatesInjectable from "./create-resource-templates.injectable";
|
||||
import { Spinner } from "../../spinner";
|
||||
|
||||
interface Props {
|
||||
tab: DockTab;
|
||||
@ -143,9 +144,11 @@ class NonInjectedCreateResource extends React.Component<Props & Dependencies> {
|
||||
}
|
||||
|
||||
export const CreateResource = withInjectables<Dependencies, Props>(NonInjectedCreateResource, {
|
||||
getProps: (di, props) => ({
|
||||
getPlaceholder: () => <Spinner center />,
|
||||
|
||||
getProps: async (di, props) => ({
|
||||
createResourceTabStore: di.inject(createResourceTabStoreInjectable),
|
||||
createResourceTemplates: di.inject(createResourceTemplatesInjectable),
|
||||
createResourceTemplates: await di.inject(createResourceTemplatesInjectable),
|
||||
...props,
|
||||
}),
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user