From af33fa043b2f757b5699006a17da868c2870168f Mon Sep 17 00:00:00 2001 From: yongsikgi Date: Tue, 23 Nov 2021 15:24:12 +0900 Subject: [PATCH] modify bug in Infrastructure page and windows os filter in Agent Configuration page --- .../components/AgentConfigurationTable.tsx | 19 ++--- frontend/src/hosts/containers/HostsPage.tsx | 78 ++++++++++--------- .../hosts/containers/InventoryTopology.tsx | 12 ++- 3 files changed, 61 insertions(+), 48 deletions(-) diff --git a/frontend/src/agent_admin/components/AgentConfigurationTable.tsx b/frontend/src/agent_admin/components/AgentConfigurationTable.tsx index 6764421b..94651073 100644 --- a/frontend/src/agent_admin/components/AgentConfigurationTable.tsx +++ b/frontend/src/agent_admin/components/AgentConfigurationTable.tsx @@ -294,15 +294,16 @@ class AgentConfigurationTable extends PureComponent { {sortedHosts.length > 0 ? ( ( - - ) + (m: Minion, i: number): JSX.Element => + m.os && m.os.toLocaleLowerCase() !== 'windows' ? ( + + ) : null )} className="hosts-table--tbody" /> diff --git a/frontend/src/hosts/containers/HostsPage.tsx b/frontend/src/hosts/containers/HostsPage.tsx index bf26af88..0f65cb34 100644 --- a/frontend/src/hosts/containers/HostsPage.tsx +++ b/frontend/src/hosts/containers/HostsPage.tsx @@ -235,12 +235,14 @@ export class HostsPage extends PureComponent { defaultState, }) + const initActivateTab = !this.isUsingAWS + ? 'Host' + : _.isEmpty(hostsPage['activeCspTab']) + ? 'Host' + : hostsPage['activeCspTab'] + this.setState({ - activeCspTab: !this.isUsingAWS - ? 'Host' - : _.isEmpty(hostsPage['activeCspTab']) - ? 'Host' - : hostsPage['activeCspTab'], + activeCspTab: initActivateTab, }) const hostID = hostsPage.focusedHost @@ -273,20 +275,26 @@ export class HostsPage extends PureComponent { this.setState({ layouts, proportions: convertProportions, - focusedInstance: getFocusedInstance, selectedAgent: 'ALL', focusedHost: hostID, }) } else { - this.setState({ - layouts, - proportions: convertProportions, - focusedHost: hostID, - focusedInstance: getFocusedInstance, - selectedAgent: _.isEmpty(hostsPage['selectedAgent']) - ? 'ALL' - : hostsPage['selectedAgent'], - }) + if (initActivateTab === 'Host') { + this.setState({ + layouts, + proportions: convertProportions, + focusedHost: hostID, + }) + } else { + this.setState({ + layouts, + proportions: convertProportions, + focusedInstance: getFocusedInstance, + selectedAgent: _.isEmpty(hostsPage['selectedAgent']) + ? 'ALL' + : hostsPage['selectedAgent'], + }) + } } } @@ -326,31 +334,13 @@ export class HostsPage extends PureComponent { if (activeCspTab === 'aws') { const {filteredLayouts} = await this.getLayoutsforInstance( layouts, - _.isEmpty(this.state.cloudHostsObject) - ? {provider: '', region: '', instanceid: '', instancename: ''} - : focusedInstance + focusedInstance ) this.setState({filteredLayouts}) } } - if ( - _.isEmpty(prevState.cloudHostsObject) && - !_.isEmpty(this.state.cloudHostsObject) && - this.state.cloudHostsObject !== prevState.cloudHostsObject && - activeCspTab === 'aws' - ) { - const {filteredLayouts} = await this.getLayoutsforInstance( - layouts, - focusedInstance - ? focusedInstance - : this.getFirstCloudHost(this.state.cloudHostsObject) - ) - - this.setState({filteredLayouts}) - } - if (prevState.selectedAgent !== selectedAgent && focusedInstance) { const {filteredLayouts} = await this.getLayoutsforInstance( layouts, @@ -990,9 +980,7 @@ export class HostsPage extends PureComponent { hostsPageStatus: RemoteDataState.Done, }) } else { - if ( - !_.includes(_.keys(_.values(hostsObject)), this.state.focusedHost) - ) { + if (!_.includes(_.keys(newHosts), this.state.focusedHost)) { this.setState({ focusedHost: this.getFirstHost(newHosts), hostsObject: newHosts, @@ -1129,6 +1117,10 @@ export class HostsPage extends PureComponent { const {id, organization, provider, region} = accessCsp let csp = [] + if (_.isEmpty(getSaltCSPs[index])) { + return + } + if ( Object.keys(getSaltCSPs[index]).includes('error') || typeof getSaltCSPs[index] === 'string' @@ -1147,6 +1139,16 @@ export class HostsPage extends PureComponent { newCSPs.push(csp) }) + if (_.isEmpty(newCSPs)) { + this.setState({ + cloudAccessInfos: [], + cloudHostsObject: {}, + // filteredLayouts: [], + awsPageStatus: RemoteDataState.Done, + }) + return + } + const envVars = await getEnv(links.environment) const telegrafSystemInterval = getDeep( envVars, @@ -1177,7 +1179,7 @@ export class HostsPage extends PureComponent { tempVars ) - if (_.isEmpty(this.state.focusedInstance)) { + if (_.isEmpty(this.state.focusedInstance.provider)) { this.setState({ focusedInstance: this.getFirstCloudHost(newCloudHostsObject), cloudAccessInfos: dbResp, diff --git a/frontend/src/hosts/containers/InventoryTopology.tsx b/frontend/src/hosts/containers/InventoryTopology.tsx index eff68d34..c2478210 100644 --- a/frontend/src/hosts/containers/InventoryTopology.tsx +++ b/frontend/src/hosts/containers/InventoryTopology.tsx @@ -474,6 +474,13 @@ class InventoryTopology extends PureComponent { addon => addon.name === AddonType.salt ) + private isUsingAWS = + _.get( + _.find(this.props.links.addons, addon => addon.name === AddonType.aws), + 'url', + 'off' + ) === 'on' + private configureStylesheet = configureStylesheet private getAllCells = getAllCells private openSensorData = openSensorData @@ -496,7 +503,10 @@ class InventoryTopology extends PureComponent { layouts, }) - await this.handleLoadCsps() + if (this.isUsingAWS) { + await this.handleLoadCsps() + } + await this.getInventoryTopology() await this.getHostData() await this.getIpmiTargetList()