Skip to content

Commit

Permalink
added remote config
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro100 committed Dec 2, 2024
1 parent d897d40 commit dfa0c74
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 29 deletions.
2 changes: 2 additions & 0 deletions web-app/src/app/interface/RemoteConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface RemoteConfigValues extends FirebaseDefaultConfig {
/** GBFS metrics' bucket endpoint */
gbfsMetricsBucketEndpoint: string;
featureFlagBypass: string;
enableFeatureFilterSearch: boolean;
}

const featureByPassDefault: BypassConfig = {
Expand All @@ -46,6 +47,7 @@ export const defaultRemoteConfigValues: RemoteConfigValues = {
gbfsMetricsBucketEndpoint:
'https://storage.googleapis.com/mobilitydata-gbfs-analytics-dev',
featureFlagBypass: JSON.stringify(featureByPassDefault),
enableFeatureFilterSearch: false,
};

remoteConfig.defaultConfig = defaultRemoteConfigValues;
74 changes: 45 additions & 29 deletions web-app/src/app/screens/Feeds/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ import {
getInitialSelectedFeedTypes,
} from './utility';
import { SearchHeader } from './styles';
import { useRemoteConfig } from '../../context/RemoteConfigProvider';

export default function Feed(): React.ReactElement {
const { t } = useTranslation('feeds');
const { config } = useRemoteConfig();
const [searchParams, setSearchParams] = useSearchParams();
const [searchLimit] = useState(20); // leaving possibility to edit in future
const [selectedFeedTypes, setSelectedFeedTypes] = useState(
Expand Down Expand Up @@ -291,7 +293,17 @@ export default function Feed(): React.ReactElement {
spacing={1}
sx={{ flexWrap: { xs: 'wrap', md: 'nowrap' } }}
>
<Grid item xs={12} md={2} sx={{ minWidth: '275px', pr: 2 }}>
<Grid
item
xs={12}
md={2}
sx={{
minWidth: config.enableFeatureFilterSearch
? '275px'
: '220px',
pr: 2,
}}
>
<SearchHeader variant='h6'>{t('dataType')}</SearchHeader>
<NestedCheckboxList
checkboxData={[
Expand All @@ -315,36 +327,40 @@ export default function Feed(): React.ReactElement {
});
}}
></NestedCheckboxList>
<SearchHeader variant='h6'>Features</SearchHeader>
<NestedCheckboxList
checkboxData={featureCheckboxData}
onExpandGroupChange={(checkboxData) => {
const newExpandGroup: Record<string, boolean> = {};
checkboxData.forEach((cd) => {
if (cd.seeChildren !== undefined) {
newExpandGroup[cd.title] = cd.seeChildren;
}
});
setExpandedElements({
...expandedElements,
...newExpandGroup,
});
}}
onCheckboxChange={(checkboxData) => {
const selelectedFeatures: string[] = [];
checkboxData.forEach((checkbox) => {
if (checkbox.children !== undefined) {
checkbox.children.forEach((child) => {
if (child.checked) {
selelectedFeatures.push(child.title);
{config.enableFeatureFilterSearch && (
<>
<SearchHeader variant='h6'>Features</SearchHeader>
<NestedCheckboxList
checkboxData={featureCheckboxData}
onExpandGroupChange={(checkboxData) => {
const newExpandGroup: Record<string, boolean> = {};
checkboxData.forEach((cd) => {
if (cd.seeChildren !== undefined) {
newExpandGroup[cd.title] = cd.seeChildren;
}
});
}
});
setActivePagination(1);
setSelectedFeatures(selelectedFeatures);
}}
/>
setExpandedElements({
...expandedElements,
...newExpandGroup,
});
}}
onCheckboxChange={(checkboxData) => {
const selelectedFeatures: string[] = [];
checkboxData.forEach((checkbox) => {
if (checkbox.children !== undefined) {
checkbox.children.forEach((child) => {
if (child.checked) {
selelectedFeatures.push(child.title);
}
});
}
});
setActivePagination(1);
setSelectedFeatures(selelectedFeatures);
}}
/>
</>
)}
</Grid>

<Grid item xs={12} md={10}>
Expand Down

0 comments on commit dfa0c74

Please sign in to comment.