Skip to content

feat(site): add new filter to audit logs #7878

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 7 commits into from
Jun 7, 2023
Merged
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
Fix stories
  • Loading branch information
BrunoQuaresma committed Jun 7, 2023
commit b86831f861f13ea4671c9381dc3a2c7f2bf57ea3
102 changes: 71 additions & 31 deletions site/src/pages/AuditPage/AuditPageView.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,91 @@
import { ComponentMeta, Story } from "@storybook/react"
import { createPaginationRef } from "components/PaginationWidget/utils"
import { MockAuditLog, MockAuditLog2 } from "testHelpers/entities"
import { AuditPageView, AuditPageViewProps } from "./AuditPageView"
/* eslint-disable eslint-comments/disable-enable-pair -- ignore */
/* eslint-disable @typescript-eslint/no-explicit-any -- We don't care about any here */
import { Meta, StoryObj } from "@storybook/react"
import { MockAuditLog, MockAuditLog2, MockUser } from "testHelpers/entities"
import { AuditPageView } from "./AuditPageView"
import { action } from "@storybook/addon-actions"
import { WorkspacesPageView } from "pages/WorkspacesPage/WorkspacesPageView"
import { ComponentProps } from "react"

export default {
const mockMenu = {
initialOption: undefined,
isInitializing: false,
isSearching: false,
query: "",
searchOptions: [],
selectedOption: undefined,
selectOption: action("selectOption"),
setQuery: action("updateQuery"),
}

const defaultFilterProps = {
filter: {
query: `owner:me`,
update: () => action("update"),
debounceUpdate: action("debounce") as any,
used: false,
values: {
username: MockUser.username,
action: undefined,
resource_type: undefined,
},
},
menus: {
user: mockMenu,
action: mockMenu,
resourceType: mockMenu,
},
} as ComponentProps<typeof AuditPageView>["filterProps"]

const meta: Meta<typeof AuditPageView> = {
title: "pages/AuditPageView",
component: AuditPageView,
args: {
auditLogs: [MockAuditLog, MockAuditLog2],
count: 1000,
paginationRef: createPaginationRef({ page: 1, limit: 25 }),
page: 1,
limit: 25,
isAuditLogVisible: true,
filterProps: defaultFilterProps,
},
} as ComponentMeta<typeof AuditPageView>
}

const Template: Story<AuditPageViewProps> = (args) => (
<AuditPageView {...args} />
)
export default meta
type Story = StoryObj<typeof WorkspacesPageView>

export const AuditPage = Template.bind({})
export const AuditPage: Story = {}

export const Loading = Template.bind({})
Loading.args = {
auditLogs: undefined,
count: undefined,
isNonInitialPage: false,
export const Loading = {
args: {
auditLogs: undefined,
count: undefined,
isNonInitialPage: false,
},
}

export const EmptyPage = Template.bind({})
EmptyPage.args = {
auditLogs: [],
isNonInitialPage: true,
export const EmptyPage = {
args: {
auditLogs: [],
isNonInitialPage: true,
},
}

export const NoLogs = Template.bind({})
NoLogs.args = {
auditLogs: [],
count: 0,
isNonInitialPage: false,
export const NoLogs = {
args: {
auditLogs: [],
count: 0,
isNonInitialPage: false,
},
}

export const NotVisible = Template.bind({})
NotVisible.args = {
isAuditLogVisible: false,
export const NotVisible = {
args: {
isAuditLogVisible: false,
},
}

export const AuditPageSmallViewport = Template.bind({})
AuditPageSmallViewport.parameters = {
chromatic: { viewports: [600] },
export const AuditPageSmallViewport = {
parameters: {
chromatic: { viewports: [600] },
},
}