diff options
author | Ian Wienand <iwienand@redhat.com> | 2022-09-15 09:41:55 +1000 |
---|---|---|
committer | Ian Wienand <iwienand@redhat.com> | 2022-09-15 09:41:55 +1000 |
commit | bb71a0d133aa74e0668e1fadb0b57d4b4c2ffe72 (patch) | |
tree | ef72a9e4add1fa72e008f68ab441f818d62168b3 | |
parent | 80facd106781b460d528b60d7bb2f7bb94bf2f3e (diff) | |
download | zuul-bb71a0d133aa74e0668e1fadb0b57d4b4c2ffe72.tar.gz |
web: refactor console item generation
A small refactor on the item generation to only create either an
expandable version or not; not both.
Change-Id: Ifabbd6775b516ca5829a691f5a19e325c30a786c
-rw-r--r-- | web/src/containers/build/Console.jsx | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/web/src/containers/build/Console.jsx b/web/src/containers/build/Console.jsx index 96ccb95e9..cf3ab841a 100644 --- a/web/src/containers/build/Console.jsx +++ b/web/src/containers/build/Console.jsx @@ -215,7 +215,7 @@ class HostTask extends React.Component { // their results that show command output, etc. These plays get // an expansion that shows these values without having to click // and bring up the full insepction modal. - const interestingKeys = hasInterestingKeys(this.props.host, INTERESTING_KEYS) + const interestingKeys = hasInterestingKeys(host, INTERESTING_KEYS) let name = task.task.name if (!name) { @@ -302,27 +302,28 @@ class HostTask extends React.Component { const content = <TaskOutput data={this.props.host} include={INTERESTING_KEYS}/> - const expandableItem = <DataListItem isExpanded={this.state.expanded}> - <DataListItemRow> - <DataListToggle - onClick={() => {this.setState({expanded: !this.state.expanded})}} - isExpanded={this.state.expanded} - /> - <DataListItemCells dataListCells={ dataListCells } /> - </DataListItemRow> - <DataListContent - isHidden={!this.state.expanded}> - { content } - </DataListContent> - </DataListItem> - - const regularItem = <DataListItem> - <DataListItemRow> - <DataListItemCells dataListCells={ dataListCells } /> - </DataListItemRow> - </DataListItem> - - const item = interestingKeys ? expandableItem : regularItem + let item = null + if (interestingKeys) { + item = <DataListItem isExpanded={this.state.expanded}> + <DataListItemRow> + <DataListToggle + onClick={() => {this.setState({expanded: !this.state.expanded})}} + isExpanded={this.state.expanded} + /> + <DataListItemCells dataListCells={ dataListCells } /> + </DataListItemRow> + <DataListContent + isHidden={!this.state.expanded}> + { content } + </DataListContent> + </DataListItem> + } else { + item = <DataListItem> + <DataListItemRow> + <DataListItemCells dataListCells={ dataListCells } /> + </DataListItemRow> + </DataListItem> + } const modalDescription = <Flex> <FlexItem>{label}</FlexItem> |