Skip to content

fix: duplicate workspace update entries #4513

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

Merged
merged 6 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
keep diffs with 0 changes
  • Loading branch information
Kira-Pilot committed Oct 14, 2022
commit e259eba0b78fa6324c8ff71e75a806ca73042c0c
2 changes: 1 addition & 1 deletion coderd/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ func (a *MockAuditor) Export(_ context.Context, alog database.AuditLog) error {
}

func (*MockAuditor) diff(any, any) Map {
return Map{"ttl": {"3600000000000", "7200000000000", false}}
return Map{}
}
4 changes: 0 additions & 4 deletions coderd/audit/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ func InitRequest[T Auditable](w http.ResponseWriter, p *RequestParams) (*Request
if sw.Status < 400 {
diff := Diff(p.Audit, req.Old, req.New)

if len(diff) == 0 {
return
}

var err error
diffRaw, err = json.Marshal(diff)
if err != nil {
Expand Down
17 changes: 0 additions & 17 deletions site/src/pages/AuditPage/AuditPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,6 @@ describe("AuditPage", () => {
screen.getByTestId(`audit-log-row-${MockAuditLog2.id}`)
})

it("filters out audit logs with empty diffs", async () => {
server.use(
rest.get(`/api/v2/audit`, (_, res, ctx) => {
return res(ctx.status(200), ctx.json(MockAuditLogWithEmptyDiff))
}),
)

// When
render(<AuditPage />)

// Then
const logRow = screen.queryByTestId(
`audit-log-row-${MockAuditLogWithEmptyDiff.id}`,
)
expect(logRow).not.toBeInTheDocument()
})

describe("Filtering", () => {
it("filters by typing", async () => {
const getAuditLogsSpy = jest
Expand Down
20 changes: 0 additions & 20 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,26 +912,6 @@ export const MockAuditLog2: TypesGen.AuditLog = {
},
}

export const MockAuditLogWithEmptyDiff: TypesGen.AuditLog = {
id: "958d5bdc-d034-4857-891e-33393ba07e55",
request_id: "0585f890-2659-4761-bcb4-3bbca1fe4ab7",
time: "2022-10-12T13:36:31.682107Z",
organization_id: "fc0774ce-cc9e-48d4-80ae-88f7a4d4a8b0",
ip: "127.0.0.1",
user_agent:
'"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"',
resource_type: "workspace",
resource_id: "ef8d1cf4-82de-4fd9-8980-047dad6d06b5",
resource_target: "bruno-dev",
resource_icon: "",
action: "create",
diff: {},
status_code: 200,
additional_fields: "",
description: "{user} updated workspace {target}",
user: MockUser,
}

export const MockWorkspaceQuota: TypesGen.WorkspaceQuota = {
user_workspace_count: 0,
user_workspace_limit: 100,
Expand Down
6 changes: 1 addition & 5 deletions site/src/xServices/audit/auditXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,8 @@ export const auditMachine = createMachine(
}).then((data) => data.count),
])

// Filter out any logs that don't have an actual diff to present to the user
const filteredLogs = auditLogs.filter(
(log) => Object.entries(log.diff).length > 0,
)
return {
auditLogs: filteredLogs,
auditLogs,
count,
}
},
Expand Down