-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix StaleFlagWarning Display & Migrate FeatureRow to TypeScript (#…
…5129) Co-authored-by: kyle-ssg <kyle@solidstategroup.com>
- Loading branch information
1 parent
145bf1f
commit a1dcdb8
Showing
17 changed files
with
593 additions
and
595 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 was deleted.
Oops, something went wrong.
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,27 @@ | ||
import { ProjectFlag, Tag } from 'common/types/responses' | ||
import { useGetTagsQuery } from 'common/services/useTag' | ||
|
||
export const useProtectedTags = ( | ||
projectFlag: ProjectFlag, | ||
projectId: string, | ||
skip?: boolean, | ||
): Tag[] | undefined => { | ||
const { data: tags } = useGetTagsQuery( | ||
{ projectId }, | ||
{ skip: skip || !projectId }, | ||
) | ||
|
||
if (!tags) { | ||
return undefined | ||
} | ||
|
||
const protectedFlags = projectFlag.tags.reduce<Tag[]>((acc, id) => { | ||
const tag = tags?.find((t) => t.id === id) | ||
if (tag?.is_permanent) { | ||
acc.push(tag) | ||
} | ||
return acc | ||
}, []) | ||
|
||
return protectedFlags | ||
} |
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 |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import classNames from 'classnames' | ||
import Switch from './Switch' | ||
import { | ||
FeatureListProviderData, | ||
FeatureState, | ||
ProjectFlag, | ||
} from 'common/types/responses' | ||
import FeatureValue from './FeatureValue' | ||
import SegmentOverridesIcon from './SegmentOverridesIcon' | ||
import IdentityOverridesIcon from './IdentityOverridesIcon' | ||
import Constants from 'common/constants' | ||
|
||
export interface CondensedFeatureRowProps { | ||
disableControls?: boolean | ||
readOnly: boolean | ||
projectFlag: ProjectFlag | ||
environmentFlags: FeatureListProviderData['environmentFlags'] | ||
permission?: boolean | ||
editFeature: ( | ||
projectFlag: ProjectFlag, | ||
environmentFlag?: FeatureState, | ||
tab?: string, | ||
) => void | ||
onChange: () => void | ||
style?: React.CSSProperties | ||
className?: string | ||
isCompact?: boolean | ||
fadeEnabled?: boolean | ||
fadeValue?: boolean | ||
index: number | ||
} | ||
|
||
const CondensedFeatureRow: React.FC<CondensedFeatureRowProps> = ({ | ||
className, | ||
disableControls, | ||
editFeature, | ||
environmentFlags, | ||
fadeEnabled, | ||
fadeValue, | ||
index, | ||
isCompact, | ||
onChange, | ||
permission, | ||
projectFlag, | ||
readOnly, | ||
style, | ||
}) => { | ||
const { id } = projectFlag | ||
const showPlusIndicator = | ||
projectFlag?.is_num_identity_overrides_complete === false | ||
|
||
return ( | ||
<Flex | ||
onClick={() => { | ||
if (disableControls) return | ||
!readOnly && editFeature(projectFlag, environmentFlags?.[id]) | ||
}} | ||
style={{ ...style }} | ||
className={classNames('flex-row', { 'fs-small': isCompact }, className)} | ||
> | ||
<div | ||
className={`table-column ${fadeEnabled && 'faded'}`} | ||
style={{ width: '80px' }} | ||
> | ||
<Row> | ||
<Switch | ||
disabled={!permission || readOnly} | ||
data-test={`feature-switch-${index}${ | ||
environmentFlags?.[id].enabled ? '-on' : '-off' | ||
}`} | ||
checked={environmentFlags?.[id]?.enabled} | ||
onChange={onChange} | ||
/> | ||
</Row> | ||
</div> | ||
<Flex className='table-column clickable'> | ||
<Row> | ||
<div | ||
onClick={() => | ||
permission && | ||
!readOnly && | ||
editFeature(projectFlag, environmentFlags?.[id]) | ||
} | ||
className={`flex-fill ${fadeValue ? 'faded' : ''}`} | ||
> | ||
<FeatureValue | ||
value={environmentFlags?.[id]?.feature_state_value ?? null} | ||
data-test={`feature-value-${index}`} | ||
/> | ||
</div> | ||
|
||
<SegmentOverridesIcon | ||
onClick={(e) => { | ||
e.stopPropagation() | ||
editFeature( | ||
projectFlag, | ||
environmentFlags?.[id], | ||
Constants.featurePanelTabs.SEGMENT_OVERRIDES, | ||
) | ||
}} | ||
count={projectFlag.num_segment_overrides} | ||
/> | ||
<IdentityOverridesIcon | ||
onClick={(e) => { | ||
e.stopPropagation() | ||
editFeature( | ||
projectFlag, | ||
environmentFlags?.[id], | ||
Constants.featurePanelTabs.IDENTITY_OVERRIDES, | ||
) | ||
}} | ||
count={projectFlag.num_identity_overrides} | ||
showPlusIndicator={showPlusIndicator} | ||
/> | ||
</Row> | ||
</Flex> | ||
</Flex> | ||
) | ||
} | ||
|
||
export default CondensedFeatureRow |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.