Skip to content

Commit

Permalink
[GEN-1485] fix: num of selected app bug (#1581)
Browse files Browse the repository at this point in the history
This pull request includes changes to update UI labels, improve data
filtering logic, and standardize code formatting. The most important
changes include modifying the title in the `SelectSourcesContainer`,
updating the filtering logic in `useSectionData`, and enhancing the
`EMPTY_SOURCE` message.

UI Label Updates:

*
[`frontend/webapp/containers/main/sources/choose.sources/index.tsx`](diffhunk://#diff-5eba8e65b9945f09d70123675f6205d939f20cbc54ae21ff29dda89f6b63cfadL18-R18):
Changed the title in `OverviewHeader` from `OVERVIEW.MENU.SOURCES` to
`OVERVIEW.ADD_NEW_SOURCE`.
*
[`frontend/webapp/utils/constants/string.tsx`](diffhunk://#diff-6b7ecf63c9f57c564b2f2f5d7998fd2cc45aee9e4dfc71aeeeb8361a39ba66cbL78-R78):
Updated the `EMPTY_SOURCE` message to be more descriptive by adding "in
this namespace".

Data Filtering Logic:

*
[`frontend/webapp/hooks/useSectionData.tsx`](diffhunk://#diff-4be3e790a193b5fb82050c23380608aef1b9b0ea3f0a201ea87e2cb8e620f7daL10-R15):
Enhanced the filtering logic in `useSectionData` to exclude items with
`app_instrumentation_labeled` set to true.

Code Formatting:

*
[`frontend/webapp/hooks/useSectionData.tsx`](diffhunk://#diff-4be3e790a193b5fb82050c23380608aef1b9b0ea3f0a201ea87e2cb8e620f7daL1-R1):
Standardized import statements to use single quotes instead of double
quotes.
  • Loading branch information
alonkeyval authored Oct 10, 2024
1 parent e516a90 commit 1a60cd4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function SelectSourcesContainer() {
return (
<div style={{ height: '100vh' }}>
<OverviewHeader
title={OVERVIEW.MENU.SOURCES}
title={OVERVIEW.ADD_NEW_SOURCE}
onBackClick={() => router.back()}
/>
<NewSourcesList onSuccess={onNewSourceSuccess} />
Expand Down
7 changes: 5 additions & 2 deletions frontend/webapp/hooks/useSectionData.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo, useState } from "react";
import { useMemo, useState } from 'react';

export function useSectionData(initialData) {
const [sectionData, setSectionData] = useState(initialData);
Expand All @@ -7,9 +7,12 @@ export function useSectionData(initialData) {
let total = 0;
for (const key in sectionData) {
const apps = sectionData[key]?.objects;
const counter = apps?.filter((item) => item.selected)?.length;
const counter = apps?.filter(
(item) => item.selected && !item.app_instrumentation_labeled
)?.length;
total += counter;
}

return total;
}, [JSON.stringify(sectionData)]);

Expand Down
2 changes: 1 addition & 1 deletion frontend/webapp/utils/constants/string.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const OVERVIEW = {
ADD_NEW_ACTION: 'Add New Action',
EMPTY_DESTINATION: 'No destinations found',
EMPTY_ACTION: 'No actions found',
EMPTY_SOURCE: 'No sources found',
EMPTY_SOURCE: 'No sources found in this namespace',
DESTINATION_UPDATE_SUCCESS: 'Destination updated successfully',
DESTINATION_CREATED_SUCCESS: 'Destination created successfully',
DESTINATION_DELETED_SUCCESS: 'Destination deleted successfully',
Expand Down

0 comments on commit 1a60cd4

Please sign in to comment.