mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
properly load workspace cluster store outside of render() (#2320)
also minor bulletproofing for cluster version string Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
5c6a6e14f5
commit
51715b6a8c
@ -252,7 +252,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
* Kubernetes version
|
* Kubernetes version
|
||||||
*/
|
*/
|
||||||
get version(): string {
|
get version(): string {
|
||||||
return String(this.metadata?.version || "");
|
return String(this.metadata?.version ?? "");
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(model: ClusterModel) {
|
constructor(model: ClusterModel) {
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import { clusterViewURL } from "../cluster-manager/cluster-view.route";
|
|||||||
import { WorkspaceClusterMenu } from "./workspace-cluster-menu";
|
import { WorkspaceClusterMenu } from "./workspace-cluster-menu";
|
||||||
import { kebabCase } from "lodash";
|
import { kebabCase } from "lodash";
|
||||||
import { addClusterURL } from "../+add-cluster";
|
import { addClusterURL } from "../+add-cluster";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
workspace: Workspace;
|
workspace: Workspace;
|
||||||
}
|
}
|
||||||
@ -24,6 +23,12 @@ enum sortBy {
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class WorkspaceOverview extends Component<Props> {
|
export class WorkspaceOverview extends Component<Props> {
|
||||||
|
private workspaceClusterStore = new WorkspaceClusterStore(this.props.workspace.id);
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.workspaceClusterStore.loadAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
showCluster = ({ clusterId }: ClusterItem) => {
|
showCluster = ({ clusterId }: ClusterItem) => {
|
||||||
navigate(clusterViewURL({ params: { clusterId } }));
|
navigate(clusterViewURL({ params: { clusterId } }));
|
||||||
@ -31,18 +36,15 @@ export class WorkspaceOverview extends Component<Props> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { workspace } = this.props;
|
const { workspace } = this.props;
|
||||||
const workspaceClusterStore = new WorkspaceClusterStore(workspace.id);
|
|
||||||
|
|
||||||
workspaceClusterStore.loadAll();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemListLayout
|
<ItemListLayout
|
||||||
renderHeaderTitle={<div>Clusters</div>}
|
renderHeaderTitle="Clusters"
|
||||||
isClusterScoped
|
isClusterScoped
|
||||||
isSearchable={false}
|
isSearchable={false}
|
||||||
isSelectable={false}
|
isSelectable={false}
|
||||||
className="WorkspaceOverview"
|
className="WorkspaceOverview"
|
||||||
store={workspaceClusterStore}
|
store={this.workspaceClusterStore}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
[sortBy.name]: (item: ClusterItem) => item.name,
|
[sortBy.name]: (item: ClusterItem) => item.name,
|
||||||
[sortBy.distribution]: (item: ClusterItem) => item.distribution,
|
[sortBy.distribution]: (item: ClusterItem) => item.distribution,
|
||||||
@ -67,7 +69,7 @@ export class WorkspaceOverview extends Component<Props> {
|
|||||||
onAdd: () => navigate(addClusterURL()),
|
onAdd: () => navigate(addClusterURL()),
|
||||||
}}
|
}}
|
||||||
renderItemMenu={(clusterItem: ClusterItem) => (
|
renderItemMenu={(clusterItem: ClusterItem) => (
|
||||||
<WorkspaceClusterMenu clusterItem={clusterItem} workspace={workspace} workspaceClusterStore={workspaceClusterStore}/>
|
<WorkspaceClusterMenu clusterItem={clusterItem} workspace={workspace} workspaceClusterStore={this.workspaceClusterStore}/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user