Skip to content

Commit f92a05b

Browse files
codemonkey800claudeczi-github-helper[bot]Copilot
authored
feat: add core feature flag parameter handling (#1894)
* feat: add core feature flag parameter handling - Add EnableFeature and DisableFeature query parameters - Create SYSTEM_PARAMS constant for feature flag preservation - Enhance carryOverFilterParams to preserve system parameters - Prevent duplication of parameters during navigation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: add feature flag parameter preservation for internal links - Add preserveFeatureFlagParams utility function to maintain feature flags across navigation - Update Link component to automatically preserve feature flag parameters - Add comprehensive test coverage for feature flag parameter handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: Updated [rdev] values.yaml image tags to sha-a522005 * Update frontend/packages/data-portal/app/state/filterHistory.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Updated [rdev] values.yaml image tags to sha-0bbce09 * fix: resolve TypeScript error in feature flag parameter handling - Change SYSTEM_PARAMS from 'as const' to 'as QueryParams[]' to fix type compatibility - Auto-format SYSTEM_PARAMS.includes() call in filterHistory.ts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: Updated [rdev] values.yaml image tags to sha-1246611 --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: czi-github-helper[bot] <+czi-github-helper[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent e0093eb commit f92a05b

File tree

9 files changed

+471
-40
lines changed

9 files changed

+471
-40
lines changed

.infra/rdev/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ stack:
22
services:
33
frontend:
44
image:
5-
tag: sha-b628ed0
5+
tag: sha-1246611
66
replicaCount: 1
77
env:
88
- name: API_URL_V2

frontend/packages/data-portal/app/components/BrowseData/BrowseDataTabs.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useLocation, useNavigate } from '@remix-run/react'
1+
import { useLocation, useNavigate, useSearchParams } from '@remix-run/react'
22
import { useTypedLoaderData } from 'remix-typedjson'
33

44
import { GetToolbarDataQuery } from 'app/__generated_v2__/graphql'
@@ -12,13 +12,15 @@ export function BrowseDataTabs() {
1212
const { t } = useI18n()
1313
const navigate = useNavigate()
1414
const { pathname } = useLocation()
15+
const [searchParams] = useSearchParams()
1516
const data = useTypedLoaderData<GetToolbarDataQuery>()
1617

1718
return (
1819
<Tabs
1920
onChange={(nextTab) => {
2021
plausible(Events.ClickBrowseDataTab, { tab: nextTab })
21-
navigate(`/browse-data/${nextTab}`)
22+
const search = searchParams.toString()
23+
navigate(`/browse-data/${nextTab}${search ? `?${search}` : ''}`)
2224
}}
2325
value={
2426
pathname.includes('/browse-data/depositions')

frontend/packages/data-portal/app/components/BrowseData/DepositionTable.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { cnsNoMerge } from 'app/utils/cns'
3434
import { useFeatureFlag } from 'app/utils/featureFlags'
3535
import { sendLogs } from 'app/utils/logging'
3636
import { getErrorMessage } from 'app/utils/string'
37+
import { carryOverFilterParams, createUrl } from 'app/utils/url'
3738

3839
const LOADING_DEPOSITIONS = range(0, MAX_PER_PAGE).map(
3940
(value) =>
@@ -392,7 +393,13 @@ export function DepositionTable() {
392393
columns={columns}
393394
onTableRowClick={(row) => {
394395
plausible(Events.ClickDeposition, { id: row.original.id })
395-
navigate(`/depositions/${row.original.id}`)
396+
const url = createUrl(`/depositions/${row.original.id}`)
397+
carryOverFilterParams({
398+
filters: [],
399+
params: url.searchParams,
400+
prevParams: searchParams,
401+
})
402+
navigate(`${url.pathname}${url.search}`)
396403
}}
397404
hoverType="group"
398405
/>

frontend/packages/data-portal/app/components/Link/Link.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Link as RemixLink, LinkProps } from '@remix-run/react'
1+
import { Link as RemixLink, LinkProps, useSearchParams } from '@remix-run/react'
22
import { ForwardedRef, forwardRef } from 'react'
33

44
import {
55
DASHED_BORDERED_CLASSES,
66
DASHED_UNDERLINED_CLASSES,
77
} from 'app/utils/classNames'
88
import { cnsNoMerge } from 'app/utils/cns'
9-
import { isExternalUrl } from 'app/utils/url'
9+
import { isExternalUrl, preserveFeatureFlagParams } from 'app/utils/url'
1010

1111
export type VariantLinkProps = LinkProps & {
1212
newTab?: boolean
@@ -26,8 +26,15 @@ function BaseLink(
2626
}: VariantLinkProps & { href?: string },
2727
ref: ForwardedRef<HTMLAnchorElement>,
2828
) {
29+
const [searchParams] = useSearchParams()
2930
let newTabProps: Partial<LinkProps> = {}
30-
const url = href ?? to
31+
const originalUrl = href ?? to
32+
33+
// Preserve feature flag parameters for internal links
34+
const url =
35+
typeof originalUrl === 'string'
36+
? preserveFeatureFlagParams(originalUrl, searchParams)
37+
: originalUrl
3138

3239
if (newTab || (typeof url === 'string' && isExternalUrl(url))) {
3340
// For new tabs, add rel=noreferrer for security:

frontend/packages/data-portal/app/constants/filterQueryParams.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ export const DEPOSITION_FILTERS = [
5050
...COMMON_DATASET_FILTERS,
5151
QueryParams.ObjectId,
5252
] as const
53+
54+
export const SYSTEM_PARAMS = [
55+
QueryParams.EnableFeature,
56+
QueryParams.DisableFeature,
57+
] as QueryParams[]

frontend/packages/data-portal/app/constants/query.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ export enum QueryParams {
4242
TomogramProcessing = 'tomogram-processing',
4343
TomogramSampling = 'tomogram-sampling',
4444
TomogramsPage = 'tomograms-page',
45+
EnableFeature = 'enable-feature',
46+
DisableFeature = 'disable-feature',
4547
}

frontend/packages/data-portal/app/state/filterHistory.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useSearchParams } from '@remix-run/react'
22
import { atom, useAtom } from 'jotai'
33
import { useEffect } from 'react'
44

5+
import { SYSTEM_PARAMS } from 'app/constants/filterQueryParams'
56
import { QueryParams } from 'app/constants/query'
67

78
export const previousBrowseDatasetParamsAtom = atom('')
@@ -64,8 +65,12 @@ export function useSyncParamsWithState({
6465
useEffect(() => {
6566
const newParams = new URLSearchParams(searchParams)
6667

68+
// Keep only allowed filters and system parameters
6769
for (const key of newParams.keys()) {
68-
if (!filters.includes(key as QueryParams)) {
70+
const isAllowedFilter = filters.includes(key as QueryParams)
71+
const isSystemParam = SYSTEM_PARAMS.includes(key as QueryParams)
72+
73+
if (!isAllowedFilter && !isSystemParam) {
6974
newParams.delete(key)
7075
}
7176
}

0 commit comments

Comments
 (0)