Skip to content

Commit

Permalink
modify bug in Infrastructure page and windows os filter in Agent Conf…
Browse files Browse the repository at this point in the history
…iguration page
  • Loading branch information
yongsikgi committed Nov 23, 2021
1 parent 689210c commit af33fa0
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 48 deletions.
19 changes: 10 additions & 9 deletions frontend/src/agent_admin/components/AgentConfigurationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,16 @@ class AgentConfigurationTable extends PureComponent<Props, State> {
{sortedHosts.length > 0 ? (
<FancyScrollbar
children={sortedHosts.map(
(m: Minion, i: number): JSX.Element => (
<AgentConfigurationTableRow
key={i}
minions={m}
onClickTableRow={onClickTableRow}
onClickAction={onClickAction}
focusedHost={focusedHost}
/>
)
(m: Minion, i: number): JSX.Element =>
m.os && m.os.toLocaleLowerCase() !== 'windows' ? (
<AgentConfigurationTableRow
key={i}
minions={m}
onClickTableRow={onClickTableRow}
onClickAction={onClickAction}
focusedHost={focusedHost}
/>
) : null
)}
className="hosts-table--tbody"
/>
Expand Down
78 changes: 40 additions & 38 deletions frontend/src/hosts/containers/HostsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,14 @@ export class HostsPage extends PureComponent<Props, State> {
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
Expand Down Expand Up @@ -273,20 +275,26 @@ export class HostsPage extends PureComponent<Props, State> {
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'],
})
}
}
}

Expand Down Expand Up @@ -326,31 +334,13 @@ export class HostsPage extends PureComponent<Props, State> {
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,
Expand Down Expand Up @@ -990,9 +980,7 @@ export class HostsPage extends PureComponent<Props, State> {
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,
Expand Down Expand Up @@ -1129,6 +1117,10 @@ export class HostsPage extends PureComponent<Props, State> {
const {id, organization, provider, region} = accessCsp
let csp = []

if (_.isEmpty(getSaltCSPs[index])) {
return
}

if (
Object.keys(getSaltCSPs[index]).includes('error') ||
typeof getSaltCSPs[index] === 'string'
Expand All @@ -1147,6 +1139,16 @@ export class HostsPage extends PureComponent<Props, State> {
newCSPs.push(csp)
})

if (_.isEmpty(newCSPs)) {
this.setState({
cloudAccessInfos: [],
cloudHostsObject: {},
// filteredLayouts: [],
awsPageStatus: RemoteDataState.Done,
})
return
}

const envVars = await getEnv(links.environment)
const telegrafSystemInterval = getDeep<string>(
envVars,
Expand Down Expand Up @@ -1177,7 +1179,7 @@ export class HostsPage extends PureComponent<Props, State> {
tempVars
)

if (_.isEmpty(this.state.focusedInstance)) {
if (_.isEmpty(this.state.focusedInstance.provider)) {
this.setState({
focusedInstance: this.getFirstCloudHost(newCloudHostsObject),
cloudAccessInfos: dbResp,
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/hosts/containers/InventoryTopology.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,13 @@ class InventoryTopology extends PureComponent<Props, State> {
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
Expand All @@ -496,7 +503,10 @@ class InventoryTopology extends PureComponent<Props, State> {
layouts,
})

await this.handleLoadCsps()
if (this.isUsingAWS) {
await this.handleLoadCsps()
}

await this.getInventoryTopology()
await this.getHostData()
await this.getIpmiTargetList()
Expand Down

0 comments on commit af33fa0

Please sign in to comment.