Skip to content
Open
Show file tree
Hide file tree
Changes from 143 commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
3134068
Add segment page
kyle-ssg Aug 5, 2025
5d97da7
Add segment page
kyle-ssg Aug 5, 2025
ea9eef4
add my to breadcrumb
kyle-ssg Aug 5, 2025
df8de68
Migrate feature override row to component
kyle-ssg Aug 12, 2025
c953bec
Update frontend/web/components/Breadcrumb.tsx
kyle-ssg Aug 26, 2025
c77bb77
safe handle url push
kyle-ssg Aug 26, 2025
da52a0d
Merge remote-tracking branch 'origin/feat/segment-page' into feat/seg…
kyle-ssg Aug 26, 2025
a9d3d33
Offset 2
kyle-ssg Aug 26, 2025
ab16a33
Merge branch 'refs/heads/main' into feat/segment-page
matthewelwell Aug 29, 2025
00c331f
Merge branch 'main' into feat/segment-page
kyle-ssg Sep 16, 2025
a438251
Merge remote-tracking branch 'origin/feat/segment-page' into feat/seg…
kyle-ssg Sep 16, 2025
f4fdcf6
Merge branch 'main' into chore/componentise-feature-override-row
kyle-ssg Sep 16, 2025
5fa2c8f
fix feature override import
kyle-ssg Sep 16, 2025
b526540
Fix tests
kyle-ssg Sep 16, 2025
36d5c78
Merge branch 'feat/segment-page' into chore/componentise-feature-over…
kyle-ssg Sep 16, 2025
3b246bd
Fix segment tab classes
kyle-ssg Sep 23, 2025
53f967a
Fix segment tab classes
kyle-ssg Sep 23, 2025
73d31a1
Add toast
kyle-ssg Sep 23, 2025
6e19718
Add manageSegmentsPermission to create segment
kyle-ssg Sep 23, 2025
3c90c18
Refactor remove segment
kyle-ssg Sep 23, 2025
b7826e9
Merge branch 'feat/segment-page' into chore/componentise-feature-over…
kyle-ssg Sep 23, 2025
5bf0aac
Merge branch 'main' into chore/componentise-feature-override-row
kyle-ssg Sep 23, 2025
3d51e9c
Merge branch 'main' into chore/componentise-feature-override-row
kyle-ssg Sep 23, 2025
0633e23
fix identity override
kyle-ssg Sep 23, 2025
b8f706a
Componentise overrides
kyle-ssg Sep 23, 2025
c7fd718
Componentise overrides
kyle-ssg Sep 23, 2025
c5d433a
Refactor
kyle-ssg Sep 30, 2025
ec576fb
Improve feature override row refactoring
kyle-ssg Sep 30, 2025
149fc8c
CTA Feature override
kyle-ssg Sep 30, 2025
596f736
re-add tests
kyle-ssg Sep 30, 2025
022c27d
Refactor
kyle-ssg Sep 30, 2025
480a0a8
Chore/componentise feature override row improved (#6118)
kyle-ssg Sep 30, 2025
9d6f43a
Refactor
kyle-ssg Sep 30, 2025
f91a243
Merge branch 'chore/componentise-feature-override-row-improved' into …
kyle-ssg Sep 30, 2025
661872f
Permission fix
kyle-ssg Sep 30, 2025
162fceb
fix identifier
kyle-ssg Sep 30, 2025
e52f9f9
Fix identityName param
kyle-ssg Sep 30, 2025
0ba5c15
Fix edit permission check
kyle-ssg Sep 30, 2025
80811d5
Componentise feature filters
kyle-ssg Sep 30, 2025
a5dc772
Fix segment override logic
kyle-ssg Sep 30, 2025
4d340e3
Fix identity override logic
kyle-ssg Sep 30, 2025
3ee508e
Fix identity override logic
kyle-ssg Sep 30, 2025
7971ac7
Merge branch 'chore/componentise-feature-override-row' into chore/com…
kyle-ssg Sep 30, 2025
657fd59
QA
kyle-ssg Oct 7, 2025
ce67965
Merge branch 'chore/componentise-feature-override-row' into chore/com…
kyle-ssg Oct 7, 2025
12eee3a
Make filtering consistent across user and features page
kyle-ssg Oct 7, 2025
f061a48
simplify filters
kyle-ssg Oct 7, 2025
2939e21
Merge branch 'main' into chore/componentise-feature-override-row
kyle-ssg Oct 7, 2025
e441e03
Merge branch 'chore/componentise-feature-override-row' into chore/com…
kyle-ssg Oct 7, 2025
10719cb
re-add loading logic
kyle-ssg Oct 7, 2025
b790d58
Simplify loading logic
kyle-ssg Oct 7, 2025
17ea4ba
Don't assume code references exist
kyle-ssg Oct 7, 2025
772e147
Don't assume code references exist
kyle-ssg Oct 7, 2025
f3ba094
fix text wrapping
kyle-ssg Oct 7, 2025
7b18f28
Fix tag filter in url
kyle-ssg Oct 7, 2025
b4724ca
Merge branch 'chore/componentise-feature-filters' into feat/segment-f…
kyle-ssg Oct 7, 2025
eb0be4b
Update frontend/web/components/feature-page/FeatureFilters.tsx
kyle-ssg Oct 14, 2025
6174bd5
Remove releasePipelines
kyle-ssg Oct 14, 2025
9b562f6
Merge remote-tracking branch 'origin/chore/componentise-feature-filte…
kyle-ssg Oct 14, 2025
dbb085a
remove sortToHeader
kyle-ssg Oct 14, 2025
f7e3cff
Merge branch 'main' into chore/componentise-feature-override-row
kyle-ssg Oct 14, 2025
ba3b42e
Claude context
kyle-ssg Oct 14, 2025
9746d13
Claude context
kyle-ssg Oct 14, 2025
5955f25
Claude context
kyle-ssg Oct 14, 2025
efedbdc
Add api-sync / optmimise contexts
kyle-ssg Oct 21, 2025
cae73d7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 21, 2025
23a6495
Add api-sync / optimise contexts
kyle-ssg Oct 21, 2025
af5bfda
Merge remote-tracking branch 'origin/chore/claude-context' into chore…
kyle-ssg Oct 21, 2025
acd5420
Merge branch 'main' into chore/componentise-feature-override-row
kyle-ssg Oct 21, 2025
29bae85
Merge branch 'chore/componentise-feature-override-row' into chore/com…
kyle-ssg Oct 21, 2025
162daef
Fix table value filter
kyle-ssg Oct 21, 2025
8b6d03d
Merge branch 'chore/componentise-feature-filters' into feat/segment-f…
kyle-ssg Oct 21, 2025
2058123
Fixes
kyle-ssg Oct 21, 2025
a1c5d83
Use unified endpoint for segment feature states
kyle-ssg Oct 21, 2025
143f02e
namespace segment tab
kyle-ssg Oct 21, 2025
dcb6632
Merge branch 'feat/segment-feature-state-view' into feat/segment-feat…
kyle-ssg Oct 21, 2025
6934c5f
Tests
kyle-ssg Oct 21, 2025
72e8214
Clean up types
kyle-ssg Oct 21, 2025
21697fe
chore: componentise feature filters (#6119)
kyle-ssg Oct 28, 2025
ee90b70
Merge branch 'chore/componentise-feature-override-row' into feat/segm…
kyle-ssg Oct 28, 2025
ac641db
Update contexts
kyle-ssg Nov 4, 2025
0c03b8f
Update contexts
kyle-ssg Nov 4, 2025
fb2df65
Update contexts
kyle-ssg Nov 4, 2025
b064e81
Update contexts
kyle-ssg Nov 4, 2025
27019de
Update contexts
kyle-ssg Nov 4, 2025
96c81d6
Update contexts
kyle-ssg Nov 4, 2025
4a3bafa
Update contexts
kyle-ssg Nov 4, 2025
4b846d9
Update contexts
kyle-ssg Nov 4, 2025
6cbde85
Merge branch 'main' into chore/claude-context
kyle-ssg Nov 4, 2025
dd7b743
Update contexts
kyle-ssg Nov 10, 2025
6a8f202
Update frontend/web/components/feature-page/FeatureFilters.tsx
kyle-ssg Nov 11, 2025
ad8a35d
Update frontend/web/components/feature-page/FeatureFilters.tsx
kyle-ssg Nov 11, 2025
659abf1
return early if key fields are null
kyle-ssg Nov 11, 2025
a00269e
Merge branch 'main' into chore/componentise-feature-override-row
kyle-ssg Nov 11, 2025
ae76a46
Merge branch 'chore/componentise-feature-override-row' into feat/segm…
kyle-ssg Nov 11, 2025
1b90569
Remove !
kyle-ssg Nov 11, 2025
43e32ad
Remove !
kyle-ssg Nov 11, 2025
7dcb60c
Merge branch 'chore/componentise-feature-override-row' into feat/segm…
kyle-ssg Nov 11, 2025
0ed455b
Unused import
kyle-ssg Nov 11, 2025
1381fb0
Fix sort order types
kyle-ssg Nov 11, 2025
0ac5ded
Re-add remove segment button
kyle-ssg Nov 11, 2025
df85873
Update claude contexts
kyle-ssg Nov 11, 2025
a26b39a
Update claude contexts
kyle-ssg Nov 11, 2025
9ef5383
Fix sortorder functionality
kyle-ssg Nov 11, 2025
2ed1777
QA feedback
kyle-ssg Nov 11, 2025
e800bcc
QA feedback
kyle-ssg Nov 11, 2025
24572d7
Adjust environment select
kyle-ssg Nov 11, 2025
212de78
Adjust fetching and loading logic
kyle-ssg Nov 11, 2025
f55b8ef
Adjust fetching and loading logic
kyle-ssg Nov 11, 2025
4974a76
Prevent toggle feature from segment page
kyle-ssg Nov 16, 2025
68c09cb
Merge branch 'main' into chore/componentise-feature-override-row
kyle-ssg Nov 18, 2025
1a6b706
Merge branch 'chore/componentise-feature-override-row' into feat/segm…
kyle-ssg Nov 18, 2025
62262c1
clean up confirm toggle function
kyle-ssg Nov 18, 2025
5b9588a
fix vertical alignment for feature row
kyle-ssg Nov 18, 2025
189b701
Merge branch 'feat/segment-feature-state-view' into chore/create-flag…
kyle-ssg Nov 18, 2025
102d47a
Create flag migration
kyle-ssg Dec 2, 2025
f443064
Highlight segment when opening a feature
kyle-ssg Dec 2, 2025
aae4428
Merge branch 'main' into chore/componentise-feature-override-row
kyle-ssg Dec 2, 2025
454d9b7
Highlight segment when opening a feature
kyle-ssg Dec 2, 2025
a734a6c
Merge branch 'chore/componentise-feature-override-row' into feat/segm…
kyle-ssg Dec 2, 2025
d4d2f0b
Merge branch 'main' into chore/create-flag-migration
kyle-ssg Dec 2, 2025
01393b4
Merge branch 'refs/heads/feat/segment-feature-state-view' into chore/…
kyle-ssg Dec 2, 2025
142c32e
Migrate tabs
kyle-ssg Dec 2, 2025
752ce06
Add settings and value tabs
kyle-ssg Dec 2, 2025
a4c4c55
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2025
aec8e29
Revert claude changes
kyle-ssg Dec 2, 2025
8c40502
Merge remote-tracking branch 'origin/chore/create-flag-migration' int…
kyle-ssg Dec 2, 2025
fd08db6
Migrate components
kyle-ssg Dec 2, 2025
2732306
Revert changes
kyle-ssg Dec 2, 2025
1c117d7
feat: segment feature state view (#6137)
kyle-ssg Dec 2, 2025
c3ad50e
Fixes
kyle-ssg Dec 3, 2025
b9f4933
Merge branch 'main' into chore/componentise-feature-override-row
kyle-ssg Dec 3, 2025
cf3119b
Fixes
kyle-ssg Dec 3, 2025
14f7c5b
Merge branch 'chore/componentise-feature-override-row' into chore/cre…
kyle-ssg Dec 3, 2025
b2b275b
Fixes
kyle-ssg Dec 3, 2025
984e6e3
Fix merge hell
kyle-ssg Dec 3, 2025
51860b9
Merge branch 'chore/componentise-feature-override-row' into chore/cre…
kyle-ssg Dec 3, 2025
52a2dc7
Fix merge hell
kyle-ssg Dec 3, 2025
2a4a8a5
Fix segment override permission check and project flag cache keys
kyle-ssg Dec 3, 2025
83c5a9f
Merge branch 'chore/componentise-feature-override-row' into chore/cre…
kyle-ssg Dec 3, 2025
13b67d0
Fix has changed check for overrides
kyle-ssg Dec 3, 2025
99a69bb
Fix has changed check for overrides
kyle-ssg Dec 3, 2025
76251b2
Revert unecessary import changes
kyle-ssg Dec 3, 2025
c39b418
chore: Rename CreateFlag (#6388)
kyle-ssg Dec 9, 2025
fa183df
Merge branch 'main' into chore/create-flag-migration
kyle-ssg Dec 9, 2025
9cb2da0
Merge remote-tracking branch 'origin/chore/create-flag-migration' int…
kyle-ssg Dec 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions frontend/common/featureValuesEqual.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { FlagsmithValue } from './types/responses'

export default function featureValuesEqual(
actualValue: FlagsmithValue | undefined,
flagValue: FlagsmithValue | undefined,
) {
const nullFalseyA =
actualValue == null ||
actualValue === '' ||
typeof actualValue === 'undefined'
const nullFalseyB =
flagValue == null || flagValue === '' || typeof flagValue === 'undefined'
return nullFalseyA && nullFalseyB ? true : actualValue === flagValue
}
2 changes: 1 addition & 1 deletion frontend/common/providers/FeatureListProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const FeatureListProvider = class extends React.Component {
multivariate_options: projectFlag.multivariate_options.map((mv) => {
const matching =
environmentFlag.multivariate_feature_state_values.find(
(v) => v.multivariate_feature_option == mv.id,
(v) => v.multivariate_feature_option === mv.id,
)
return {
...mv,
Expand Down
1 change: 1 addition & 0 deletions frontend/common/providers/withSegmentOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default (WrappedComponent) => {

getOverrides = () => {
if (this.props.projectFlag) {
//todo: migrate to useSegmentFeatureState
Promise.all([
data.get(
`${
Expand Down
5 changes: 4 additions & 1 deletion frontend/common/services/useProjectFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export const projectFlagService = service
Req['getProjectFlags']
>({
providesTags: (res, _, req) => [
{ id: req?.project, type: 'ProjectFlag' },
{
id: `${req?.project}-${req?.environment}-${req?.segment}`,
type: 'ProjectFlag',
},
],
queryFn: async (args, _, _2, baseQuery) => {
return await recursivePageGet(
Expand Down
8 changes: 8 additions & 0 deletions frontend/common/services/useSegmentOverride.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Res } from 'common/types/responses'
import { Req } from 'common/types/requests'
import { service } from 'common/service'
import { projectFlagService } from './useProjectFlag'
import { getStore } from 'common/store'

export const segmentOverrideService = service
.enhanceEndpoints({ addTagTypes: ['SegmentOverride'] })
Expand All @@ -16,6 +18,12 @@ export const segmentOverrideService = service
method: 'POST',
url: `environments/${query.environmentId}/features/${query.featureId}/create-segment-override/`,
}),
transformResponse: (res) => {
getStore().dispatch(
projectFlagService.util.invalidateTags(['ProjectFlag']),
)
return res
},
}),
// END OF ENDPOINTS
}),
Expand Down
20 changes: 16 additions & 4 deletions frontend/common/stores/feature-list-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
updateProjectFlag,
} from 'common/services/useProjectFlag'
import OrganisationStore from './organisation-store'
import { SortOrder } from 'common/types/requests'
import {
ChangeRequest,
Environment,
Expand Down Expand Up @@ -170,7 +171,7 @@ const controller = {
if (onComplete) {
onComplete(res)
}
if (store.model) {
if (store.model?.features) {
const index = _.findIndex(store.model.features, { id: flag.id })
store.model.features[index] = controller.parseFlag(flag)
store.model.lastSaved = new Date().valueOf()
Expand Down Expand Up @@ -438,7 +439,7 @@ const controller = {

Promise.all([prom, segmentOverridesRequest])
.then(([res, segmentRes]) => {
if (store.model) {
if (store.model?.keyedEnvironmentFeatures) {
store.model.keyedEnvironmentFeatures[projectFlag.id] = res
if (segmentRes) {
const feature = _.find(
Expand Down Expand Up @@ -729,6 +730,12 @@ const controller = {
if (version.error) {
throw version.error
}
getStore().dispatch(
projectFlagService.util.invalidateTags(['ProjectFlag']),
)
if(!store.model) {
return
}
// Fetch and update the latest environment feature state
return getVersionFeatureState(getStore(), {
environmentId: ProjectStore.getEnvironmentIdFromKey(environmentId),
Expand Down Expand Up @@ -809,7 +816,7 @@ const controller = {
}

prom
.then((res) => {
.then(() => {
if (store.model) {
store.model.lastSaved = new Date().valueOf()
}
Expand Down Expand Up @@ -977,7 +984,12 @@ const store = Object.assign({}, BaseStore, {
},
id: 'features',
paging: {},
sort: { default: true, label: 'Name', sortBy: 'name', sortOrder: 'asc' },
sort: {
default: true,
label: 'Name',
sortBy: 'name',
sortOrder: SortOrder.ASC,
},
})

store.dispatcherIndex = Dispatcher.register(store, (payload) => {
Expand Down
23 changes: 19 additions & 4 deletions frontend/common/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
StageTrigger,
StageActionType,
StageActionBody,
TagStrategy,
} from './responses'
import { UtmsType } from './utms'

Expand Down Expand Up @@ -102,7 +103,10 @@ export type RegisterRequest = {
marketing_consent_given?: boolean
utm_data?: UtmsType
}

export enum SortOrder {
ASC = 'ASC',
DESC = 'DESC',
}
export interface StageActionRequest {
action_type: StageActionType | ''
action_body: StageActionBody
Expand Down Expand Up @@ -340,10 +344,21 @@ export type Req = {
user: string
}
getProjectFlags: {
project: number
environmentId?: string
tags?: string[]
project: string
environment?: number
segment?: number
search?: string | null
releasePipelines?: number[]
page?: number
tag_strategy?: TagStrategy
tags?: string
is_archived?: boolean
value_search?: string | null
is_enabled?: boolean | null
owners?: number[]
group_owners?: number[]
sort_field?: string
sort_direction?: SortOrder
}
getProjectFlag: { project: number; id: number }
getRolesPermissionUsers: { organisation_id: number; role_id: number }
Expand Down
2 changes: 2 additions & 0 deletions frontend/common/types/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ export type ProjectFlag = {
created_date: string
default_enabled: boolean
description?: string
environment_feature_state?: FeatureState
segment_feature_state?: FeatureState
id: number
initial_value: FlagsmithValue
is_archived: boolean
Expand Down
21 changes: 17 additions & 4 deletions frontend/common/utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import AccountStore from 'common/stores/account-store'
import ProjectStore from 'common/stores/project-store'
import Project from 'common/project'
import {
AccountModel,
ContentType,
FeatureState,
FeatureStateValue,
Expand All @@ -29,7 +28,6 @@ import { selectBuildVersion } from 'common/services/useBuildVersion'
import { getStore } from 'common/store'
import { TRACKED_UTMS, UtmsType } from 'common/types/utms'
import { TimeUnit } from 'components/release-pipelines/constants'
import getUserDisplayName from './getUserDisplayName'

const semver = require('semver')

Expand Down Expand Up @@ -244,7 +242,7 @@ const Utils = Object.assign({}, require('./base/_utils'), {

const timeParts = waitFor.split(':')

if (timeParts.length != 3) return
if (timeParts.length !== 3) return

const [hours, minutes, seconds] = timeParts

Expand Down Expand Up @@ -425,6 +423,21 @@ const Utils = Object.assign({}, require('./base/_utils'), {
const organisationId = match?.params?.organisationId
return organisationId ? parseInt(organisationId) : null
},
getOverridePermission: (level: 'identity' | 'segment') => {
switch (level) {
case 'identity':
return {
permission: Utils.getManageFeaturePermission(false),
permissionDescription:
Utils.getManageFeaturePermissionDescription(false),
}
default:
return {
permission: 'MANAGE_SEGMENT_OVERRIDES',
permissionDescription: 'Manage Segment Overrides',
}
}
},
getPlanName: (plan: string) => {
if (plan && plan.includes('free')) {
return planNames.free
Expand Down Expand Up @@ -676,7 +689,7 @@ const Utils = Object.assign({}, require('./base/_utils'), {
},

sanitiseDiffString: (value: FlagsmithValue) => {
if (value === undefined || value == null) {
if (value === undefined || value === null) {
return ''
}
return `${value}`
Expand Down
11 changes: 11 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
"@types/classnames": "^2.3.1",
"@types/color": "^3.0.3",
"@types/dompurify": "^3.0.2",
"@types/rc-switch": "^1.9.5",
"@types/react-router": "^5.1.20",
"@types/react-router-dom": "^5.3.3",
"@types/react-select": "^2.0.3",
Expand Down
1 change: 0 additions & 1 deletion frontend/web/components/AuditLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ const AuditLog: FC<AuditLogType> = (props) => {
id,
log,
project,
related_feature_id,
related_object_type,
related_object_uuid,
}: AuditLogItem) => {
Expand Down
42 changes: 25 additions & 17 deletions frontend/web/components/Breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
import React, { FC } from 'react'
import React, { FC, ReactNode } from 'react'
import { Link } from 'react-router-dom'

type BreadcrumbType = {
items: { title: string; url: string }[]
currentPage: string
currentPage: ReactNode
isCurrentPageMuted?: boolean
}

const Breadcrumb: FC<BreadcrumbType> = ({ currentPage, items }) => {
const Breadcrumb: FC<BreadcrumbType> = ({
currentPage,
isCurrentPageMuted = true,
items,
}) => {
return (
<nav aria-label='breadcrumb'>
<ol className='breadcrumb my-2 py-1'>
{items?.map((item) => (
<li key={item.url} className='breadcrumb-item h6 fs-lg lh-sm'>
<Link className='text-primary' to={item.url}>
{item.title}
</Link>
</li>
))}
<li
className='breadcrumb-item active h6 text-muted lh-sm '
<div className='d-flex align-items-center my-2 py-1'>
{items?.map((item) => (
<>
<Link className='text-primary h6 mb-0' to={item.url}>
{item.title}
</Link>
<div className='text-muted mx-2 h6 mb-0'>/</div>
</>
))}
{isCurrentPageMuted ? (
<div
className='active h6 text-muted lh-sm '
aria-current='page'
style={{ opacity: 0.6 }}
>
{currentPage}
</li>
</ol>
</nav>
</div>
) : (
currentPage
)}
</div>
)
}

Expand Down
14 changes: 9 additions & 5 deletions frontend/web/components/EnvironmentSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { FC, useMemo } from 'react'
import { useGetEnvironmentsQuery } from 'common/services/useEnvironment'
import { Props } from 'react-select/lib/Select'
import { Environment } from 'common/types/responses'

export type EnvironmentSelectType = Partial<Omit<Props, 'value'>> & {
projectId: number
value?: string
label?: string
onChange: (value: string) => void
onChange: (value: string, environment: Environment | null) => void
showAll?: boolean
readOnly?: boolean
idField?: 'id' | 'api_key'
Expand All @@ -30,6 +31,7 @@ const EnvironmentSelect: FC<EnvironmentSelectType> = ({
const environments = useMemo(() => {
return (data?.results || [])
?.map((v) => ({
environment: v,
label: v.name,
value: `${v[idField]}`,
}))
Expand Down Expand Up @@ -66,12 +68,14 @@ const EnvironmentSelect: FC<EnvironmentSelectType> = ({
}
}
options={(showAll
? [{ label: 'All Environments', value: '' }]
? [{ environment: null, label: 'All Environments', value: '' }]
: []
).concat(environments)}
onChange={(value: { value: string; label: string }) =>
onChange(value?.value || '')
}
onChange={(value: {
value: string
label: string
environment: Environment
}) => onChange(value?.value || '', value?.environment)}
/>
</div>
)
Expand Down
Loading
Loading