Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: save empty segment overrides request #4112

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading