Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GEN-1389] feat: filter sources by status and message #1492

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
196 commits
Select commit Hold shift + click to select a range
95b7e2a
WIP
alonkeyval Jul 30, 2023
91375ca
Merge branch 'main' of github.com:alonkeyval/odigos into TASK-149-ove…
alonkeyval Jul 30, 2023
3f0700a
WIP
alonkeyval Jul 30, 2023
9e4a5ac
source manage card
alonkeyval Jul 30, 2023
e03bf92
Merge pull request #344 from alonkeyval/TASK-149-overview-container
alonkeyval Jul 30, 2023
0c4b42e
fixed pr comments
alonkeyval Jul 30, 2023
d5fe630
fixed pr comments
alonkeyval Jul 30, 2023
fbaa04c
Merge branch 'main' of github.com:alonkeyval/odigos into TASK-142-dis…
alonkeyval Jul 30, 2023
5504348
sources list display
alonkeyval Jul 30, 2023
ae80c0a
change image url to cloud front
alonkeyval Jul 30, 2023
79f2c53
fixed pr comments
alonkeyval Jul 30, 2023
8267a10
Merge pull request #346 from alonkeyval/TASK-107-overview-sources-card
alonkeyval Jul 30, 2023
5fffc40
add new action menu
alonkeyval Jul 30, 2023
18cd5c4
on add btn click
alonkeyval Jul 30, 2023
3ac58d1
Merge pull request #347 from alonkeyval/TASK-142-display-source-manag…
alonkeyval Jul 30, 2023
ab642bd
WIP
alonkeyval Jul 30, 2023
b6287db
Merge pull request #348 from alonkeyval/TASK-143-add-new-source-btn
alonkeyval Jul 31, 2023
64c31c4
restructe source filter option
alonkeyval Jul 31, 2023
4192289
filters
alonkeyval Jul 31, 2023
1006d44
WIP
alonkeyval Jul 31, 2023
537aa75
new back button
alonkeyval Jul 31, 2023
ab32b46
WIP
alonkeyval Jul 31, 2023
d1c9029
Merge pull request #359 from alonkeyval/TASK-145-handle-new-sources-c…
alonkeyval Jul 31, 2023
042cb10
Merge branch 'main' of github.com:alonkeyval/odigos into overview-sou…
alonkeyval Jul 31, 2023
0d97d64
filter instromented apps
alonkeyval Jul 31, 2023
f38568b
WIP
alonkeyval Jul 31, 2023
d57d024
WIP
alonkeyval Jul 31, 2023
6b1a812
WIP
alonkeyval Jul 31, 2023
d6e9f6f
WIP
alonkeyval Jul 31, 2023
7c655a0
WIP
alonkeyval Jul 31, 2023
fbe5504
WIP
alonkeyval Aug 1, 2023
8a93e8a
fixed pr comments
alonkeyval Aug 1, 2023
d9958c8
fixed pr comments
alonkeyval Aug 1, 2023
89dc8ae
Task 158 back button (#360)
alonkeyval Aug 1, 2023
5d5bf9b
fixed pr comments
alonkeyval Aug 1, 2023
a682311
Merge remote-tracking branch 'upstream/main' into TASK-141-sources-ov…
alonkeyval Aug 1, 2023
15ba9c3
Merge remote-tracking branch 'upstream/TASK-141-sources-overview' int…
alonkeyval Aug 1, 2023
a131614
fixed pr comments
alonkeyval Aug 1, 2023
180fd5d
hide checkboxs
alonkeyval Aug 1, 2023
d4d5211
WIP
alonkeyval Aug 1, 2023
97e1983
Merge branch 'main' of github.com:alonkeyval/odigos into TASK-161-zer…
alonkeyval Aug 1, 2023
61fc2fc
WIP
alonkeyval Aug 1, 2023
49f6983
fixed pr comments
alonkeyval Aug 1, 2023
b1f12e7
remove scrollbars
alonkeyval Aug 1, 2023
f81d618
WIP
alonkeyval Aug 1, 2023
5e68cdd
added quick help
alonkeyval Aug 2, 2023
32bec3d
WIP
alonkeyval Aug 2, 2023
e368ede
Merge remote-tracking branch 'upstream/main' into TASK-141-sources-ov…
alonkeyval Aug 2, 2023
4d7b99d
Merge remote-tracking branch 'upstream/TASK-141-sources-overview' int…
alonkeyval Aug 2, 2023
f91d357
create destinaion flow match url
alonkeyval Aug 2, 2023
f0e6d64
new dest flow
alonkeyval Aug 2, 2023
0a30a23
manage dest flow
alonkeyval Aug 2, 2023
71e52b7
fixed pr comments
alonkeyval Aug 2, 2023
55cae09
Overview sources (#364)
alonkeyval Aug 2, 2023
60a61ee
WIP
alonkeyval Aug 2, 2023
c44837e
WIP
alonkeyval Aug 2, 2023
6253cbc
Merge branch 'main' into TASK-141-sources-overview
alonkeyval Aug 2, 2023
59029f1
Merge branch 'TASK-141-sources-overview' into TASK-156-match-url-to-a…
alonkeyval Aug 2, 2023
924cee2
fixed pr comments
alonkeyval Aug 2, 2023
004ca63
restruce file system
alonkeyval Aug 2, 2023
cf77635
wip
alonkeyval Aug 2, 2023
4616dcf
add pen icon and danger zone
alonkeyval Aug 2, 2023
5d85d7c
manage delete source
alonkeyval Aug 3, 2023
b655e18
WIP
alonkeyval Aug 3, 2023
592be7e
WIP
alonkeyval Aug 3, 2023
ef93cc6
WIP
alonkeyval Aug 3, 2023
9e322bf
WIP
alonkeyval Aug 3, 2023
5ad8d1d
WIP
alonkeyval Aug 3, 2023
26033f7
Task 165 manage source (#368)
alonkeyval Aug 3, 2023
4e02ce6
WIP
alonkeyval Aug 3, 2023
b49275e
delete files
alonkeyval Aug 3, 2023
beb029f
WIP
alonkeyval Aug 3, 2023
4c28472
move page logic to container
alonkeyval Aug 3, 2023
5eb7361
move page logic to container
alonkeyval Aug 3, 2023
5fe763a
WIP
alonkeyval Aug 3, 2023
bfb54d8
Task 168 refactor (#370)
alonkeyval Aug 3, 2023
0662844
Merge branch 'TASK-141-sources-overview' into main
alonkeyval Aug 3, 2023
f15d28d
WIP
alonkeyval Aug 3, 2023
cfbfc2a
Merge remote-tracking branch 'upstream/main'
alonkeyval Aug 6, 2023
c9d170e
edit resource name
alonkeyval Aug 6, 2023
3b8983c
refactor sources|
alonkeyval Aug 6, 2023
0dbc53d
change files names
alonkeyval Aug 7, 2023
bb9c9d5
change files names
alonkeyval Aug 7, 2023
c2e13cd
delete dest fixed
alonkeyval Aug 7, 2023
61183a4
WIP
alonkeyval Aug 7, 2023
c374b8e
refactor services
alonkeyval Aug 7, 2023
55be5ce
Merge branch 'main' of github.com:alonkeyval/odigos
alonkeyval Aug 7, 2023
f1618a5
WIP
alonkeyval Aug 7, 2023
fd269a6
change file names
alonkeyval Aug 7, 2023
8769e67
WIP
alonkeyval Aug 7, 2023
f5220c5
WIP
alonkeyval Aug 7, 2023
7626088
add contact button
alonkeyval Aug 8, 2023
cef20f6
WIP
alonkeyval Aug 9, 2023
52f92f0
fixed setup source and destinations list wrapping
alonkeyval Aug 9, 2023
6095f4d
manage destination list set up
alonkeyval Aug 9, 2023
960f16d
remove unused code
alonkeyval Aug 10, 2023
d62193b
fixed repeat numbers
alonkeyval Aug 10, 2023
ac1b8f9
remove comments
alonkeyval Aug 10, 2023
419d22c
Merge branch 'TASK-217-centerlize-lists' into TASK-218-remove-next-stop
alonkeyval Aug 10, 2023
68ffb8c
Merge branch 'keyval-dev:main' into main
alonkeyval Aug 10, 2023
5bb8c42
Merge branch 'main' of github.com:alonkeyval/odigos into TASK-218-rem…
alonkeyval Aug 10, 2023
883d21b
WIP
alonkeyval Aug 10, 2023
d6f4127
focus on hover
alonkeyval Aug 10, 2023
7c0e27a
types
alonkeyval Aug 10, 2023
d2ae596
fixed focus issue
alonkeyval Aug 10, 2023
0d38d2a
remove scroll bar on firefox
alonkeyval Aug 10, 2023
0a35b8c
fixed focus issue
alonkeyval Aug 10, 2023
fec0da9
WIP
alonkeyval Aug 10, 2023
41f1d1d
WIP
alonkeyval Aug 10, 2023
41d9ec0
WIP
alonkeyval Aug 10, 2023
b91dcfc
Merge branch 'keyval-dev:main' into main
alonkeyval Aug 10, 2023
0581273
Merge branch 'keyval-dev:main' into main
alonkeyval Aug 16, 2023
7f83013
Merge branch 'keyval-dev:main' into main
alonkeyval Aug 16, 2023
764b34e
Merge branch 'keyval-dev:main' into main
alonkeyval Aug 17, 2023
aae797f
Merge branch 'keyval-dev:main' into main
alonkeyval Aug 24, 2023
eccae08
WIP
alonkeyval Aug 24, 2023
cbc404c
chore: merge master
alonkeyval Sep 13, 2023
4133dbd
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Oct 24, 2023
0e20d78
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Oct 25, 2023
0e03acd
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Nov 12, 2023
792fa0e
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Nov 28, 2023
dc00780
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Dec 25, 2023
5ea8080
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Dec 25, 2023
af2c604
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Dec 26, 2023
a5458e1
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jan 3, 2024
f59a287
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jan 8, 2024
88b0f44
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jan 8, 2024
d5b91f9
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jan 29, 2024
692e8de
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 4, 2024
6d2aa66
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 5, 2024
10bdc06
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 8, 2024
fcbd0a9
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 8, 2024
87aec56
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 11, 2024
ea0a726
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 18, 2024
f0c48c9
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 20, 2024
5729525
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 20, 2024
197a7f9
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 21, 2024
442499f
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 22, 2024
daaf4bd
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 26, 2024
0a5e45d
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Feb 29, 2024
d77bd9c
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 3, 2024
37df88e
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 6, 2024
1f8d7ef
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 7, 2024
b84263e
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 7, 2024
25a6e7a
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 10, 2024
caa3fa7
chore: wip
alonkeyval Mar 10, 2024
06afb46
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 11, 2024
da00e35
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 12, 2024
54f669f
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 12, 2024
d89a229
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 12, 2024
16815d7
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 13, 2024
21096f4
chore: wip
alonkeyval Mar 13, 2024
99bac3f
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 14, 2024
8290402
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Mar 18, 2024
82e6b80
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Apr 18, 2024
8b8f4f1
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Apr 25, 2024
285a13b
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 8, 2024
e91e7cc
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 9, 2024
a53e048
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 16, 2024
596be25
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 16, 2024
8188793
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 19, 2024
9488eb0
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 21, 2024
798ea80
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 22, 2024
0fd5f20
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 22, 2024
fcc88a1
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 23, 2024
12395d6
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 30, 2024
ffab60d
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval May 30, 2024
c743c28
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jun 5, 2024
2546917
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jun 10, 2024
c84d281
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jun 26, 2024
841a5d0
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jun 27, 2024
940d60d
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jun 27, 2024
ca5117d
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jun 30, 2024
e2742d6
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 1, 2024
ae64828
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 4, 2024
9fb66bc
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 8, 2024
e5e537b
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 10, 2024
db087de
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 10, 2024
0905d78
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 10, 2024
0423cde
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 15, 2024
a973fba
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 16, 2024
175153b
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 17, 2024
5e0c295
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 21, 2024
9c9e33c
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 22, 2024
6338070
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Jul 28, 2024
af913bc
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Aug 12, 2024
6cfbc67
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Aug 14, 2024
ca7c4b9
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Aug 27, 2024
65b5f8b
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Sep 2, 2024
0a6e9b8
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Sep 3, 2024
3791c99
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Sep 3, 2024
16ba495
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Sep 5, 2024
dd14984
Merge branch 'main' of github.com:keyval-dev/odigos
alonkeyval Sep 8, 2024
97b23bb
chore: wip
alonkeyval Sep 9, 2024
1b06719
cchore: change label
alonkeyval Sep 9, 2024
af404c0
Merge branch 'main' into gen-1389-filter-sources-by-status
alonkeyval Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SourcesTableRow } from './sources.table.row';
import { SourcesTableHeader } from './sources.table.header';
import { EmptyList } from '@/components/lists';
import { OVERVIEW } from '@/utils';
import { ConnectionsIcons, DeleteSource } from '@/components';

import { ModalPositionX, ModalPositionY } from '@/design.system/modal/types';

type TableProps = {
Expand All @@ -16,8 +16,9 @@ type TableProps = {
filterSourcesByKind?: (kinds: string[]) => void;
filterSourcesByNamespace?: (namespaces: string[]) => void;
filterSourcesByLanguage?: (languages: string[]) => void;
toggleActionStatus?: (ids: string[], disabled: boolean) => void;
deleteSourcesHandler?: (sources: ManagedSource[]) => void;
filterByConditionStatus?: (status: 'All' | 'True' | 'False') => void;
filterByConditionMessage: (message: string[]) => void;
};

const SELECT_ALL_CHECKBOX = 'select_all';
Expand All @@ -27,11 +28,12 @@ export const ManagedSourcesTable: React.FC<TableProps> = ({
namespaces,
onRowClick,
sortSources,
toggleActionStatus,
filterSourcesByKind,
deleteSourcesHandler,
filterSourcesByNamespace,
filterSourcesByLanguage,
filterByConditionStatus,
filterByConditionMessage,
}) => {
const [selectedCheckbox, setSelectedCheckbox] = useState<string[]>([]);
const [showModal, setShowModal] = useState(false);
Expand Down Expand Up @@ -94,13 +96,14 @@ export const ManagedSourcesTable: React.FC<TableProps> = ({
data={data}
namespaces={namespaces}
sortSources={sortSources}
toggleActionStatus={toggleActionStatus}
filterSourcesByKind={filterSourcesByKind}
filterSourcesByNamespace={filterSourcesByNamespace}
filterSourcesByLanguage={filterSourcesByLanguage}
selectedCheckbox={selectedCheckbox}
onSelectedCheckboxChange={onSelectedCheckboxChange}
deleteSourcesHandler={() => setShowModal(true)}
filterByConditionStatus={filterByConditionStatus}
filterByConditionMessage={filterByConditionMessage}
/>
{showModal && (
<KeyvalModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import {
ActionsGroup,
KeyvalCheckbox,
KeyvalLink,
KeyvalSwitch,
KeyvalText,
} from '@/design.system';
import { ManagedSource, Namespace } from '@/types';
import { UnFocusSourcesIcon } from '@keyval-dev/design-system';
import { useSources } from '@/hooks';

enum K8SSourceTypes {
DEPLOYMENT = 'deployment',
Expand Down Expand Up @@ -55,11 +57,12 @@ interface ActionsTableHeaderProps {
sortSources?: (condition: string) => void;
filterSourcesByKind?: (kinds: string[]) => void;
filterSourcesByNamespace?: (namespaces: string[]) => void;
toggleActionStatus?: (ids: string[], disabled: boolean) => void;
selectedCheckbox: string[];
onSelectedCheckboxChange: (id: string) => void;
deleteSourcesHandler: () => void;
filterSourcesByLanguage?: (languages: string[]) => void;
filterByConditionStatus?: (status: 'All' | 'True' | 'False') => void;
filterByConditionMessage: (message: string[]) => void;
}

export function SourcesTableHeader({
Expand All @@ -72,9 +75,13 @@ export function SourcesTableHeader({
deleteSourcesHandler,
selectedCheckbox,
onSelectedCheckboxChange,
filterByConditionStatus,
filterByConditionMessage,
}: ActionsTableHeaderProps) {
const [currentSortId, setCurrentSortId] = useState('');
const [groupNamespaces, setGroupNamespaces] = useState<string[]>([]);
const [showSourcesWithIssues, setShowSourcesWithIssues] = useState(false);
const [groupErrorMessage, setGroupErrorMessage] = useState<string[]>([]);
const [groupLanguages, setGroupLanguages] = useState<string[]>([
'javascript',
'python',
Expand All @@ -88,6 +95,20 @@ export function SourcesTableHeader({
K8SSourceTypes.DAEMON_SET,
]);

const { groupErrorMessages } = useSources();

useEffect(() => {
if (!filterByConditionStatus) {
return;
}

setGroupErrorMessage(groupErrorMessages());

showSourcesWithIssues
? filterByConditionStatus('False')
: filterByConditionStatus('All');
}, [showSourcesWithIssues, data]);

useEffect(() => {
if (namespaces) {
setGroupNamespaces(
Expand Down Expand Up @@ -140,6 +161,21 @@ export function SourcesTableHeader({
filterSourcesByLanguage && filterSourcesByLanguage(newGroup);
}

function onErrorClick(message: string) {
let newGroup: string[] = [];
if (groupErrorMessage.includes(message)) {
setGroupErrorMessage(
groupErrorMessage.filter((item) => item !== message)
);
newGroup = groupErrorMessage.filter((item) => item !== message);
} else {
setGroupErrorMessage([...groupErrorMessage, message]);
newGroup = [...groupErrorMessage, message];
}

filterByConditionMessage(newGroup);
}

const sourcesGroups = useMemo(() => {
if (!namespaces) return [];

Expand All @@ -161,7 +197,7 @@ export function SourcesTableHeader({
totalNamespacesWithApps === 1,
}));

return [
const actionsGroup = [
{
label: 'Language',
subTitle: 'Filter',
Expand Down Expand Up @@ -323,6 +359,24 @@ export function SourcesTableHeader({
condition: true,
},
];

if (showSourcesWithIssues) {
actionsGroup.unshift({
label: 'Error',
subTitle: 'Filter by error message',
condition: true,
items: groupErrorMessages().map((item) => ({
label: item,
onClick: () => onErrorClick(item),
id: item,
selected: groupErrorMessage.includes(item),
disabled:
groupErrorMessage.length === 1 && groupErrorMessage.includes(item),
})),
});
}

return actionsGroup;
}, [namespaces, groupNamespaces, data]);

return (
Expand All @@ -336,6 +390,16 @@ export function SourcesTableHeader({
<KeyvalText size={14} weight={600} color={theme.text.white}>
{`${data.length} ${OVERVIEW.MENU.SOURCES}`}
</KeyvalText>

{groupErrorMessage.length > 0 && (
<KeyvalSwitch
toggle={showSourcesWithIssues}
handleToggleChange={() =>
setShowSourcesWithIssues(!showSourcesWithIssues)
}
label={'Show Sources with Errors'}
/>
)}
{selectedCheckbox.length > 0 && (
<KeyvalLink
onClick={deleteSourcesHandler}
Expand Down
8 changes: 6 additions & 2 deletions frontend/webapp/containers/main/sources/managed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export function ManagedSourcesContainer() {
filterSourcesByLanguage,
instrumentedNamespaces,
filterSourcesByNamespace,
filterByConditionStatus,
filterByConditionMessage,
} = useSources();

useEffect(() => {
Expand Down Expand Up @@ -119,12 +121,14 @@ export function ManagedSourcesContainer() {
<ManagedSourcesTable
sortSources={sortSources}
onRowClick={handleEditSource}
deleteSourcesHandler={deleteSourcesHandler}
namespaces={instrumentedNamespaces}
filterSourcesByKind={filterSourcesByKind}
filterSourcesByLanguage={filterSourcesByLanguage}
filterByConditionStatus={filterByConditionStatus}
deleteSourcesHandler={deleteSourcesHandler}
data={searchInput ? filterSources() : sources}
filterSourcesByLanguage={filterSourcesByLanguage}
filterSourcesByNamespace={filterSourcesByNamespace}
filterByConditionMessage={filterByConditionMessage}
/>
</Content>
</SourcesContainer>
Expand Down
48 changes: 48 additions & 0 deletions frontend/webapp/hooks/sources/useSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,51 @@ export function useSources() {
setSortedSources(filtered);
}

function filterByConditionMessage(message: string[]) {
const sourcesWithCondition = sources?.filter((deployment) =>
deployment.instrumented_application_details.conditions.some(
(condition) => condition.status === 'False'
)
);

const filteredSources = sourcesWithCondition?.filter((deployment) =>
deployment.instrumented_application_details.conditions.some((condition) =>
message.includes(condition.message)
)
);

setSortedSources(filteredSources || []);
}

const filterByConditionStatus = (status: 'All' | 'True' | 'False') => {
if (status === 'All') {
setSortedSources(sources);
return;
}

const filteredSources = sources?.filter((deployment) =>
deployment.instrumented_application_details.conditions.some(
(condition) => condition.status === status
)
);

setSortedSources(filteredSources || []);
};

const groupErrorMessages = (): string[] => {
const errorMessagesSet: Set<string> = new Set();

sources?.forEach((deployment) => {
deployment.instrumented_application_details?.conditions
.filter((condition) => condition.status === 'False')
.forEach((condition) => {
errorMessagesSet.add(condition.message); // Using Set to avoid duplicates
});
});

return Array.from(errorMessagesSet);
};

return {
upsertSources,
refetchSources,
Expand All @@ -187,5 +232,8 @@ export function useSources() {
instrumentedNamespaces,
namespaces: namespaces?.namespaces || [],
deleteSourcesHandler,
filterByConditionStatus,
groupErrorMessages,
filterByConditionMessage,
};
}
Loading