-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: annotation table updates (#481)
#432 - Adds rudimentary feature flagging module that can be controlled via code or query parameter - Updates the annotation table to match the updated design - Implements but hides method type column ## Demo https://dev-jeremy-anno-table.cryoet.dev.si.czi.technology/runs/242 <img width="1728" alt="image" src="https://github.com/chanzuckerberg/cryoet-data-portal/assets/2176050/9dc55804-956e-4766-8536-f50951f50c62"> ### With Method Type <img width="1728" alt="image" src="https://github.com/chanzuckerberg/cryoet-data-portal/assets/2176050/696f5b96-efda-47fb-b9fb-2b0f98d88be5">
- Loading branch information
1 parent
7730efb
commit 097e271
Showing
7 changed files
with
175 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { Annotation } from 'app/state/annotation' | ||
|
||
export function getAnnotationTitle(annotation: Annotation | undefined | null) { | ||
return annotation?.s3_path?.split('/').at(-1) ?? '--' | ||
if (!annotation) { | ||
return '--' | ||
} | ||
|
||
return `${annotation.id} - ${annotation.object_name}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useSearchParams } from '@remix-run/react' | ||
|
||
import { useEnvironment } from 'app/context/Environment.context' | ||
|
||
export type FeatureFlagEnvironment = typeof process.env.ENV | ||
|
||
export const FEATURE_FLAGS = { | ||
methodType: 'dev', | ||
} as const | ||
|
||
export type FeatureFlagKey = keyof typeof FEATURE_FLAGS | ||
|
||
const ENABLE_FEATURE_PARAM = 'enable-feature' | ||
const DISABLE_FEATURE_PARAM = 'disable-feature' | ||
|
||
export function getFeatureFlag({ | ||
env, | ||
key, | ||
params = new URLSearchParams(), | ||
}: { | ||
env: FeatureFlagEnvironment | ||
key: FeatureFlagKey | ||
params?: URLSearchParams | ||
}): boolean { | ||
if (params.getAll(DISABLE_FEATURE_PARAM).includes(key)) { | ||
return false | ||
} | ||
|
||
if (params.getAll(ENABLE_FEATURE_PARAM).includes(key)) { | ||
return true | ||
} | ||
|
||
return FEATURE_FLAGS[key] === env | ||
} | ||
|
||
export function useFeatureFlag(key: FeatureFlagKey): boolean { | ||
const [params] = useSearchParams() | ||
const { ENV } = useEnvironment() | ||
|
||
return getFeatureFlag({ | ||
key, | ||
params, | ||
env: ENV, | ||
}) | ||
} |
Oops, something went wrong.