Skip to content

Commit d1ffcce

Browse files
committed
status selections
1 parent 54a9784 commit d1ffcce

File tree

3 files changed

+61
-15
lines changed

3 files changed

+61
-15
lines changed

web/src/components/forms/flowCollector-status.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const FlowCollectorStatus: FC<FlowCollectorStatusProps> = props => {
1515
console.log('FlowCollectorStatus', props);
1616

1717
const { t } = useTranslation('plugin__netobserv-plugin');
18+
const [selectedTypes, setSelectedTypes] = React.useState<string[]>([]);
1819

1920
return (
2021
<DynamicLoader>
@@ -31,11 +32,18 @@ export const FlowCollectorStatus: FC<FlowCollectorStatusProps> = props => {
3132
<Flex className="status-container" direction={{ default: 'column' }}>
3233
{existing && (
3334
<FlexItem flex={{ default: 'flex_1' }}>
34-
<Pipeline existing={existing} />
35+
<Pipeline existing={existing} selectedTypes={selectedTypes} setSelectedTypes={setSelectedTypes} />
3536
</FlexItem>
3637
)}
3738
<FlexItem className="status-list-container" flex={{ default: 'flex_1' }}>
38-
<ResourceStatus group={group} version={version} kind={kind} existing={existing} />
39+
<ResourceStatus
40+
group={group}
41+
version={version}
42+
kind={kind}
43+
existing={existing}
44+
selectedTypes={selectedTypes}
45+
setSelectedTypes={setSelectedTypes}
46+
/>
3947
</FlexItem>
4048
</Flex>
4149
</PageSection>

web/src/components/forms/pipeline.tsx

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const StepNode: React.FunctionComponent<StepProps> = ({ element }) => {
5858
) : null;
5959

6060
return (
61-
<TaskNode element={element} status={data?.status}>
61+
<TaskNode element={element} selected={data?.selected} status={data?.status} onSelect={() => data?.onSelect?.()}>
6262
{whenDecorator}
6363
</TaskNode>
6464
);
@@ -89,9 +89,11 @@ const pipelineComponentFactory = (kind: ModelKind, type: string) => {
8989

9090
export type FlowCollectorPipelineProps = {
9191
existing: K8sResourceKind | null;
92+
selectedTypes: string[];
93+
setSelectedTypes: (types: string[]) => void;
9294
};
9395

94-
export const Pipeline: React.FC<FlowCollectorPipelineProps> = ({ existing }) => {
96+
export const Pipeline: React.FC<FlowCollectorPipelineProps> = ({ existing, selectedTypes, setSelectedTypes }) => {
9597
const containerRef = React.createRef<HTMLDivElement>();
9698
const [controller, setController] = React.useState<Visualization>();
9799

@@ -128,23 +130,32 @@ export const Pipeline: React.FC<FlowCollectorPipelineProps> = ({ existing }) =>
128130
const steps: Step[] = [];
129131

130132
if (existing?.spec?.agent?.type === 'eBPF') {
133+
const types = ['Ready'];
131134
steps.push({
132135
id: 'ebpf',
133136
label: 'eBPF agents',
134137
data: {
135-
status: getStatus(['Ready'], K8sResourceConditionStatus.True)
138+
status: getStatus(types, K8sResourceConditionStatus.True),
139+
selected: _.some(selectedTypes, t => types.includes(t)),
140+
onSelect: () => setSelectedTypes(types)
136141
}
137142
});
138143
}
139144

140145
const flpStatuses = ['WaitingFLPParent', 'WaitingFLPMonolith'];
141146
if (existing?.spec?.deploymentModel === 'Kafka') {
147+
const types = ['WaitingFLPTransformer'];
142148
steps.push({
143149
id: 'kafka',
144150
label: 'Kafka',
145-
runAfterTasks: ['ebpf']
151+
runAfterTasks: ['ebpf'],
152+
data: {
153+
status: getStatus(types, K8sResourceConditionStatus.False),
154+
selected: _.some(selectedTypes, t => types.includes(t)),
155+
onSelect: () => setSelectedTypes(types)
156+
}
146157
});
147-
flpStatuses.push('WaitingFLPTransformer');
158+
flpStatuses.push(...types);
148159
}
149160

150161
if (existing?.spec) {
@@ -153,19 +164,24 @@ export const Pipeline: React.FC<FlowCollectorPipelineProps> = ({ existing }) =>
153164
label: 'Flowlogs pipeline',
154165
runAfterTasks: [_.last(steps)!.id],
155166
data: {
156-
status: getStatus(flpStatuses, K8sResourceConditionStatus.False)
167+
status: getStatus(flpStatuses, K8sResourceConditionStatus.False),
168+
selected: _.some(selectedTypes, t => flpStatuses.includes(t)),
169+
onSelect: () => setSelectedTypes(flpStatuses)
157170
}
158171
});
159172
}
160173

161174
const cpRunAfter: string[] = [];
162175
if (existing?.spec?.loki?.enable) {
176+
const types = ['LokiIssue'];
163177
steps.push({
164178
id: 'loki',
165179
label: 'Loki',
166180
runAfterTasks: ['flp'],
167181
data: {
168-
status: getStatus(['LokiIssue'], 'NoIssue') // TODO: NoIssue / Unknown is not a valid status. That should be False.
182+
status: getStatus(types, 'NoIssue'), // TODO: NoIssue / Unknown is not a valid status. That should be False.
183+
selected: _.some(selectedTypes, t => types.includes(t)),
184+
onSelect: () => setSelectedTypes(types)
169185
}
170186
});
171187
cpRunAfter.push('loki');
@@ -175,7 +191,10 @@ export const Pipeline: React.FC<FlowCollectorPipelineProps> = ({ existing }) =>
175191
steps.push({
176192
id: 'prom',
177193
label: 'Prometheus',
178-
runAfterTasks: ['flp']
194+
runAfterTasks: ['flp'],
195+
data: {
196+
onSelect: () => setSelectedTypes([])
197+
}
179198
});
180199
cpRunAfter.push('prom');
181200
}
@@ -185,7 +204,10 @@ export const Pipeline: React.FC<FlowCollectorPipelineProps> = ({ existing }) =>
185204
steps.push({
186205
id: `exporter-${i}`,
187206
label: exporter.type || t('Unknown'),
188-
runAfterTasks: ['flp']
207+
runAfterTasks: ['flp'],
208+
data: {
209+
onSelect: () => setSelectedTypes([])
210+
}
189211
});
190212
});
191213
}
@@ -194,7 +216,10 @@ export const Pipeline: React.FC<FlowCollectorPipelineProps> = ({ existing }) =>
194216
steps.push({
195217
id: 'plugin',
196218
label: 'Console plugin',
197-
runAfterTasks: cpRunAfter
219+
runAfterTasks: cpRunAfter,
220+
data: {
221+
onSelect: () => setSelectedTypes([])
222+
}
198223
});
199224
}
200225

@@ -207,7 +232,7 @@ export const Pipeline: React.FC<FlowCollectorPipelineProps> = ({ existing }) =>
207232
},
208233
...s
209234
})) as PipelineNodeModel[];
210-
}, [existing, getStatus]);
235+
}, [existing, getStatus, selectedTypes, setSelectedTypes]);
211236

212237
React.useEffect(() => {
213238
if (containerRef.current) {

web/src/components/forms/resource-status.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,18 @@ export type ResourceStatusProps = {
1010
version: string;
1111
kind: string;
1212
existing: K8sResourceKind | null;
13+
selectedTypes: string[];
14+
setSelectedTypes: (types: string[]) => void;
1315
};
1416

15-
export const ResourceStatus: FC<ResourceStatusProps> = ({ group, version, kind, existing }) => {
17+
export const ResourceStatus: FC<ResourceStatusProps> = ({
18+
group,
19+
version,
20+
kind,
21+
existing,
22+
selectedTypes,
23+
setSelectedTypes
24+
}) => {
1625
const { t } = useTranslation('plugin__netobserv-plugin');
1726

1827
if (!existing) {
@@ -44,7 +53,11 @@ export const ResourceStatus: FC<ResourceStatusProps> = ({ group, version, kind,
4453
</Thead>
4554
<Tbody>
4655
{conditions.map((condition, i) => (
47-
<Tr key={i}>
56+
<Tr
57+
key={i}
58+
isRowSelected={selectedTypes.includes(condition.type)}
59+
onClick={() => setSelectedTypes([condition.type])}
60+
>
4861
<Td>{condition.type}</Td>
4962
<Td>{condition.status}</Td>
5063
<Td>{condition.reason}</Td>

0 commit comments

Comments
 (0)