Skip to content

Commit 91d61cc

Browse files
committed
fixup! Border condition for no hooks handled properly
1 parent b0cff57 commit 91d61cc

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

ui/src/views/Hooks/ListHooks/index.jsx

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,36 @@ import ErrorPanel from '../../../components/ErrorPanel';
1717
import Link from '../../../utils/Link';
1818
import hooksQuery from './hooks.graphql';
1919

20+
const TreeItems = ({ groups }) => {
21+
return groups
22+
? groups.map(group => {
23+
const nodes = group.hooks.map(hook => (
24+
<TreeItem
25+
key={hook.hookId}
26+
nodeId={hook.hookId}
27+
label={
28+
<Link
29+
to={`/hooks/${group.hookGroupId}/${encodeURIComponent(
30+
hook.hookId
31+
)}`}>
32+
{hook.hookId}
33+
</Link>
34+
}
35+
/>
36+
));
37+
38+
return (
39+
<TreeItem
40+
key={group.hookGroupId}
41+
nodeId={group.hookGroupId}
42+
label={group.hookGroupId}>
43+
{nodes}
44+
</TreeItem>
45+
);
46+
})
47+
: [];
48+
};
49+
2050
@graphql(hooksQuery, {
2151
options: {
2252
fetchPolicy: 'network-only',
@@ -94,33 +124,7 @@ export default class ListHooks extends Component {
94124
data: { loading, error, hookGroups },
95125
} = this.props;
96126
const { search } = parse(window.location.search.slice(1));
97-
const tree = hookGroups
98-
? hookGroups.map(group => {
99-
const nodes = group.hooks.map(hook => (
100-
<TreeItem
101-
key={hook.hookId}
102-
nodeId={hook.hookId}
103-
label={
104-
<Link
105-
to={`/hooks/${group.hookGroupId}/${encodeURIComponent(
106-
hook.hookId
107-
)}`}>
108-
{hook.hookId}
109-
</Link>
110-
}
111-
/>
112-
));
113-
114-
return (
115-
<TreeItem
116-
key={group.hookGroupId}
117-
nodeId={group.hookGroupId}
118-
label={group.hookGroupId}>
119-
{nodes}
120-
</TreeItem>
121-
);
122-
})
123-
: [];
127+
const tree = <TreeItems groups={hookGroups} />;
124128
const { expanded, selected } = this.state;
125129

126130
return (

0 commit comments

Comments
 (0)