Skip to content

Commit

Permalink
Merge pull request meshery#8314 from theBeginner86/theBeginner86/chor…
Browse files Browse the repository at this point in the history
…e/14

[bug] Fix K8s Ctx Selector
  • Loading branch information
theBeginner86 authored Jul 31, 2023
2 parents 4fa80e2 + a7e1e73 commit ecd4a03
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 28 deletions.
2 changes: 1 addition & 1 deletion ui/components/DashboardComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ class DashboardComponent extends React.Component {
};

render() {
console.info("Rerendering Dashboard")
// console.info("Rerendering Dashboard")
return this.configureTemplate();
}
}
Expand Down
3 changes: 0 additions & 3 deletions ui/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,6 @@ class Header extends React.Component {
this.setState({ capabilityregistryObj : new CapabilityRegistryClass(this.props.capabilitiesRegistry) });
}




}

componentWillUnmount = () => {
Expand Down
2 changes: 1 addition & 1 deletion ui/components/MeshConfigComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ function MesherySettingsNew({ classes, enqueueSnackbar, closeSnackbar, updatePro
return (
<div style={{ display : 'table', tableLayout : 'fixed', width : '100%' }}>
<div className={classes.topToolbar}>
< MesherySettingsEnvButtons/>
<MesherySettingsEnvButtons/>
</div>
<DataTable
columns={columns}
Expand Down
2 changes: 1 addition & 1 deletion ui/components/MesherySettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class MesherySettings extends React.Component {
</Tabs>
</Paper>
{tabVal === 0 && (
<MeshConfigComponent />
<MeshConfigComponent/>
)}
{tabVal === 1 && (
<TabContainer>
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export const updateK8SConfig = ({ k8sConfig }) => dispatch => {
return dispatch({ type : actionTypes.UPDATE_CLUSTER_CONFIG, k8sConfig });
}

export const setK8sContexts = ({ selectedK8sContexts}) => dispatch => {
export const setK8sContexts = ({ selectedK8sContexts }) => dispatch => {
return dispatch({ type : actionTypes.SET_K8S_CONTEXT, selectedK8sContexts });
}

Expand Down
22 changes: 3 additions & 19 deletions ui/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class MesheryApp extends App {

const k8sContextSubscription = (page="", search="", pageSize="10", order="") => {
return subscribeK8sContext((result) => {
this.setState({ k8sContexts : result.k8sContext }, () => this.setActiveContexts("all"))
this.setState({ k8sContexts : result.k8sContext }, () => this.setActiveContexts("all"))
this.props.store.dispatch({ type : actionTypes.UPDATE_CLUSTER_CONFIG, k8sConfig : result.k8sContext.contexts });
},
{
Expand Down Expand Up @@ -245,11 +245,8 @@ class MesheryApp extends App {
activeContexts.push(ctx.id)
);
activeContexts.push("all");
this.setState(state => {
if (state.activeK8sContexts?.includes("all")) return { activeK8sContexts : [] };
return { activeK8sContexts : activeContexts };
},
() => this.activeContextChangeCallback(this.state.activeK8sContexts));
this.setState({ activeK8sContexts : activeContexts },
() => this.activeContextChangeCallback(this.state.activeK8sContexts));
return;
}

Expand Down Expand Up @@ -292,19 +289,6 @@ class MesheryApp extends App {
credentials : 'include',
}, result => {
if (result) {
if (result.k8sConfig && result.k8sConfig.length != 0) {
const kubeConfigs = result.k8sConfig.map(config => Object.assign({
inClusterConfig : false,
k8sfile : "",
name : "",
clusterConfigured : "",
server : "",
created_at : "",
updated_at : "",
ts : new Date()
}, config));
store.dispatch({ type : actionTypes.UPDATE_CLUSTER_CONFIG, k8sConfig : kubeConfigs });
}
if (result.meshAdapters && result.meshAdapters !== null && result.meshAdapters.length > 0) {
store.dispatch({ type : actionTypes.UPDATE_ADAPTERS_INFO, meshAdapters : result.meshAdapters });
}
Expand Down
3 changes: 1 addition & 2 deletions ui/utils/multi-ctx.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ export const getK8sClusterIdsFromCtxId = (selectedContexts, k8sconfig) => {
}

const clusterIds = [];

selectedContexts.forEach(context => {
const clusterId = k8sconfig.find(cfg => cfg.id === context)?.clusterID
const clusterId = k8sconfig.find(cfg => cfg.id === context)?.kubernetes_server_id
if (clusterId) {
clusterIds.push(clusterId)
}
Expand Down

0 comments on commit ecd4a03

Please sign in to comment.