Skip to content

Commit

Permalink
fix(versioning): send live from when creating versions for change req…
Browse files Browse the repository at this point in the history
…uests (#4116)
  • Loading branch information
matthewelwell authored Jun 5, 2024
1 parent e90d248 commit 765b12a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions api/features/workflows/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ def prevent_change_request_delete_if_committed(self) -> None:
# feature states, we also want to prevent it at the ORM level.
if self.committed_at and not (
self.environment.deleted_at
or (self._live_from and self._live_from > timezone.now())
or (self.live_from and self.live_from > timezone.now())
):
raise ChangeRequestDeletionError(
"Cannot delete a Change Request that has been committed."
)

@property
def _live_from(self) -> datetime | None:
def live_from(self) -> datetime | None:
# First we check if there are feature states associated with the change request
# and, if so, we return the live_from of the feature state with the earliest
# live_from.
Expand Down
3 changes: 2 additions & 1 deletion frontend/common/services/useFeatureVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const featureVersionService = service
await createFeatureVersion(getStore(), {
environmentId: query.environmentId,
featureId: query.featureId,
liveFrom: query.liveFrom,
})

// Step 2: Get the feature states for the live version
Expand Down Expand Up @@ -161,7 +162,7 @@ export const featureVersionService = service
>({
invalidatesTags: [{ id: 'LIST', type: 'FeatureVersion' }],
query: (query: Req['createFeatureVersion']) => ({
body: {},
body: { live_from: query.liveFrom },
method: 'POST',
url: `environments/${query.environmentId}/features/${query.featureId}/versions/`,
}),
Expand Down
1 change: 1 addition & 0 deletions frontend/common/stores/feature-list-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ const controller = {
featureId: projectFlag.id,
featureStates,
skipPublish: true,
liveFrom: changeRequest.live_from,
})
environment_feature_versions = [version.version_sha]
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/common/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,12 @@ export type Req = {
| 'toRemove'
| 'multivariate_feature_state_values'
>[]
liveFrom?: string
}
createFeatureVersion: {
environmentId: number
featureId: number
liveFrom?: string
}
publishFeatureVersion: {
sha: string
Expand Down

0 comments on commit 765b12a

Please sign in to comment.