Skip to content

Commit

Permalink
fix: save empty segment overrides request (#4112)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg authored Jun 5, 2024
1 parent 1852d94 commit 6dbcb4a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
5 changes: 3 additions & 2 deletions frontend/common/services/useFeatureVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ export const featureVersionService = service
}

const ret = {
data: res.map((item) => ({
feature_states: res.map((item) => ({
...item,
version_sha: versionRes.data.uuid,
})),
error: res.find((v) => !!v.error)?.error,
version_sha: versionRes.data.uuid,
}

// Step 5: Publish the feature version
Expand All @@ -151,7 +152,7 @@ export const featureVersionService = service
})
}

return ret as any
return { data: ret } as any
},
}),
createFeatureVersion: builder.mutation<
Expand Down
20 changes: 10 additions & 10 deletions frontend/common/stores/feature-list-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,13 @@ const controller = {
]
}

const version = await createAndSetFeatureVersion(getStore(), {
const { data: version } = await createAndSetFeatureVersion(getStore(), {
environmentId: env.id,
featureId: projectFlag.id,
featureStates,
skipPublish: true,
})
environment_feature_versions = version.data.map((v) => v.version_sha)
environment_feature_versions = [version.version_sha]
}
const prom = data
.get(
Expand Down Expand Up @@ -612,15 +612,15 @@ const controller = {
environmentId: res,
featureId: projectFlag.id,
featureStates,
}).then((res) => {
if (res.error) {
throw res.error
}).then((version) => {
if (version.error) {
throw version.error
}
// Fetch and update the latest environment feature state
return getVersionFeatureState(getStore(), {
environmentId: ProjectStore.getEnvironmentIdFromKey(environmentId),
featureId: projectFlag.id,
sha: res.data[0].version_sha,
sha: version.data.version_sha,
}).then((res) => {
const environmentFeatureState = res.data.find(
(v) => !v.feature_segment,
Expand Down Expand Up @@ -669,11 +669,11 @@ const controller = {
environmentId: res,
featureId: projectFlag.id,
featureStates: [data],
}).then((res) => {
if (res.error) {
throw res.error
}).then((version) => {
if (version.error) {
throw version.error
}
const featureState = res.data[0].data
const featureState = version.data.feature_states[0].data
store.model.keyedEnvironmentFeatures[projectFlag.id] = {
...featureState,
feature_state_value: Utils.featureStateToValue(
Expand Down
8 changes: 5 additions & 3 deletions frontend/web/components/SegmentOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,11 @@ class TheComponent extends Component {
openConfirm({
body: (
<div>
{
'Are you sure you want to delete this segment override? This will be applied when you click Update Segment Overrides and cannot be undone.'
}
{`Are you sure you want to delete this segment override?${
this.props.is4Eyes
? ''
: ' This will be applied when you click Update Segment Overrides and cannot be undone.'
}`}
</div>
),
destructive: true,
Expand Down
1 change: 1 addition & 0 deletions frontend/web/components/modals/CreateFlag.js
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@ const CreateFlag = class extends Component {
return (
<SegmentOverrides
readOnly={isReadOnly}
is4Eyes={is4Eyes}
showEditSegment
showCreateSegment={
this.state
Expand Down

0 comments on commit 6dbcb4a

Please sign in to comment.