mirror of
https://github.com/coder/coder.git
synced 2025-07-21 01:28:49 +00:00
fix: duplicate workspace update entries (#4513)
* fix: duplicate workspace update entries * remove console log * attempting to fix tests * keep diffs with 0 changes * cleaned up test
This commit is contained in:
@ -21,7 +21,9 @@ func (nop) Export(context.Context, database.AuditLog) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nop) diff(any, any) Map { return Map{} }
|
func (nop) diff(any, any) Map {
|
||||||
|
return Map{}
|
||||||
|
}
|
||||||
|
|
||||||
func NewMock() *MockAuditor {
|
func NewMock() *MockAuditor {
|
||||||
return &MockAuditor{}
|
return &MockAuditor{}
|
||||||
@ -36,4 +38,6 @@ func (a *MockAuditor) Export(_ context.Context, alog database.AuditLog) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*MockAuditor) diff(any, any) Map { return Map{} }
|
func (*MockAuditor) diff(any, any) Map {
|
||||||
|
return Map{}
|
||||||
|
}
|
||||||
|
@ -108,7 +108,9 @@ export const WorkspaceSchedulePage: React.FC = () => {
|
|||||||
onSubmit={(values) => {
|
onSubmit={(values) => {
|
||||||
scheduleSend({
|
scheduleSend({
|
||||||
type: "SUBMIT_SCHEDULE",
|
type: "SUBMIT_SCHEDULE",
|
||||||
autoStart: formValuesToAutoStartRequest(values),
|
autoStart: values.autoStartEnabled
|
||||||
|
? formValuesToAutoStartRequest(values)
|
||||||
|
: undefined,
|
||||||
ttl: formValuesToTTLRequest(values),
|
ttl: formValuesToTTLRequest(values),
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
@ -872,7 +872,13 @@ export const MockAuditLog: TypesGen.AuditLog = {
|
|||||||
resource_target: "bruno-dev",
|
resource_target: "bruno-dev",
|
||||||
resource_icon: "",
|
resource_icon: "",
|
||||||
action: "create",
|
action: "create",
|
||||||
diff: {},
|
diff: {
|
||||||
|
ttl: {
|
||||||
|
old: 0,
|
||||||
|
new: 3600000000000,
|
||||||
|
secret: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
status_code: 200,
|
status_code: 200,
|
||||||
additional_fields: "",
|
additional_fields: "",
|
||||||
description: "{user} updated workspace {target}",
|
description: "{user} updated workspace {target}",
|
||||||
|
@ -45,7 +45,7 @@ export type WorkspaceScheduleEvent =
|
|||||||
| { type: "GET_WORKSPACE"; username: string; workspaceName: string }
|
| { type: "GET_WORKSPACE"; username: string; workspaceName: string }
|
||||||
| {
|
| {
|
||||||
type: "SUBMIT_SCHEDULE"
|
type: "SUBMIT_SCHEDULE"
|
||||||
autoStart: TypesGen.UpdateWorkspaceAutostartRequest
|
autoStart: TypesGen.UpdateWorkspaceAutostartRequest | undefined
|
||||||
ttl: TypesGen.UpdateWorkspaceTTLRequest
|
ttl: TypesGen.UpdateWorkspaceTTLRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,10 +195,9 @@ export const workspaceSchedule = createMachine(
|
|||||||
throw new Error("Failed to load workspace.")
|
throw new Error("Failed to load workspace.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// REMARK: These calls are purposefully synchronous because if one
|
if (event.autoStart?.schedule !== undefined) {
|
||||||
// value contradicts the other, we don't want a race condition
|
await API.putWorkspaceAutostart(context.workspace.id, event.autoStart)
|
||||||
// on re-submission.
|
}
|
||||||
await API.putWorkspaceAutostart(context.workspace.id, event.autoStart)
|
|
||||||
await API.putWorkspaceAutostop(context.workspace.id, event.ttl)
|
await API.putWorkspaceAutostop(context.workspace.id, event.ttl)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user