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(versioning): send live from when creating versions for change requests #4116

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
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
Loading