Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom resource loading spinner appears above extensions' cluster menus #2344

Merged
merged 3 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/renderer/components/layout/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import "./sidebar.scss";
import type { TabLayoutRoute } from "./tab-layout";

import React from "react";
import { computed } from "mobx";
import { observer } from "mobx-react";
import { NavLink } from "react-router-dom";
import { cssNames } from "../../utils";
Expand Down Expand Up @@ -45,9 +44,13 @@ export class Sidebar extends React.Component<Props> {
crdStore.reloadAll();
}

@computed get crdSubMenus(): React.ReactNode {
if (!crdStore.isLoaded && crdStore.isLoading) {
return <Spinner centerHorizontal/>;
renderCustomResources() {
if (crdStore.isLoading) {
return (
<div className="flex justify-center">
<Spinner />
</div>
);
}

return Object.entries(crdStore.groups).map(([group, crds]) => {
Expand Down Expand Up @@ -268,7 +271,7 @@ export class Sidebar extends React.Component<Props> {
icon={<Icon material="extension"/>}
>
{this.renderTreeFromTabRoutes(CustomResources.tabRoutes)}
{this.crdSubMenus}
{this.renderCustomResources()}
</SidebarItem>
{this.renderRegisteredMenus()}
</div>
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/components/spinner/spinner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@
margin-top: calc(var(--spinner-size) / -2);
}

&.centerHorizontal {
position: absolute;
left: 50%;
margin-left: calc(var(--spinner-size) / -2);
}

@keyframes rotate {
0% {
transform: rotate(0deg);
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/components/spinner/spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { cssNames } from "../../utils";
export interface SpinnerProps extends React.HTMLProps<any> {
singleColor?: boolean;
center?: boolean;
centerHorizontal?: boolean;
}

export class Spinner extends React.Component<SpinnerProps, {}> {
Expand All @@ -16,8 +15,8 @@ export class Spinner extends React.Component<SpinnerProps, {}> {
};

render() {
const { center, singleColor, centerHorizontal, className, ...props } = this.props;
const classNames = cssNames("Spinner", className, { singleColor, center, centerHorizontal });
const { center, singleColor, className, ...props } = this.props;
const classNames = cssNames("Spinner", className, { singleColor, center });

return <div {...props} className={classNames} />;
}
Expand Down