-
Notifications
You must be signed in to change notification settings - Fork 904
feat: add audit page title, subtitle, and CLI snippet #3419
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { FC } from "react" | ||
import { HelpTooltip, HelpTooltipText, HelpTooltipTitle } from "./HelpTooltip" | ||
|
||
export const Language = { | ||
title: "What is an audit log?", | ||
body: "An audit log is a record of events and changes made throughout a system.", | ||
} | ||
|
||
export const AuditHelpTooltip: FC = () => { | ||
return ( | ||
<HelpTooltip> | ||
<HelpTooltipTitle>{Language.title}</HelpTooltipTitle> | ||
<HelpTooltipText>{Language.body}</HelpTooltipText> | ||
</HelpTooltip> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { AgentHelpTooltip } from "./AgentHelpTooltip" | ||
export { AuditHelpTooltip } from "./AuditHelpTooltip" | ||
export { OutdatedHelpTooltip } from "./OutdatedHelpTooltip" | ||
export { ResourcesHelpTooltip } from "./ResourcesHelpTooltip" | ||
export { WorkspaceHelpTooltip } from "./WorkspaceHelpTooltip" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { fireEvent, screen } from "@testing-library/react" | ||
import { Language as CopyButtonLanguage } from "components/CopyButton/CopyButton" | ||
import { Language as AuditTooltipLanguage } from "components/Tooltips/AuditHelpTooltip" | ||
import { Language as TooltipLanguage } from "components/Tooltips/HelpTooltip/HelpTooltip" | ||
import { render } from "testHelpers/renderHelpers" | ||
import AuditPage from "./AuditPage" | ||
import { Language as AuditViewLanguage } from "./AuditPageView" | ||
|
||
describe("AuditPage", () => { | ||
it("renders a page with a title and subtitle", async () => { | ||
// When | ||
render(<AuditPage />) | ||
|
||
// Then | ||
await screen.findByText(AuditViewLanguage.title) | ||
await screen.findByText(AuditViewLanguage.subtitle) | ||
const tooltipIcon = await screen.findByRole("button", { name: TooltipLanguage.ariaLabel }) | ||
fireEvent.mouseOver(tooltipIcon) | ||
expect(await screen.findByText(AuditTooltipLanguage.title)).toBeInTheDocument() | ||
}) | ||
|
||
it("describes the CLI command", async () => { | ||
// When | ||
render(<AuditPage />) | ||
|
||
// Then | ||
await screen.findByText("coder audit [organization_ID]") // CLI command; untranslated | ||
const copyIcon = await screen.findByRole("button", { name: CopyButtonLanguage.ariaLabel }) | ||
fireEvent.mouseOver(copyIcon) | ||
expect(await screen.findByText(AuditViewLanguage.tooltipTitle)).toBeInTheDocument() | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { FC } from "react" | ||
import { AuditPageView } from "./AuditPageView" | ||
|
||
// REMARK: This page is in-progress and hidden from users | ||
const AuditPage: FC = () => { | ||
return <div>Audit</div> | ||
return <AuditPageView /> | ||
} | ||
|
||
export default AuditPage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ComponentMeta, Story } from "@storybook/react" | ||
import { AuditPageView } from "./AuditPageView" | ||
|
||
export default { | ||
title: "pages/AuditPageView", | ||
component: AuditPageView, | ||
} as ComponentMeta<typeof AuditPageView> | ||
|
||
const Template: Story = (args) => <AuditPageView {...args} /> | ||
|
||
export const AuditPage = Template.bind({}) | ||
|
||
export const AuditPageSmallViewport = Template.bind({}) | ||
AuditPageSmallViewport.parameters = { | ||
chromatic: { viewports: [600] }, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { makeStyles } from "@material-ui/core/styles" | ||
import { CodeExample } from "components/CodeExample/CodeExample" | ||
import { Margins } from "components/Margins/Margins" | ||
import { PageHeader, PageHeaderSubtitle, PageHeaderTitle } from "components/PageHeader/PageHeader" | ||
import { Stack } from "components/Stack/Stack" | ||
import { AuditHelpTooltip } from "components/Tooltips" | ||
import { FC } from "react" | ||
|
||
export const Language = { | ||
title: "Audit", | ||
subtitle: "View events in your audit log.", | ||
tooltipTitle: "Copy to clipboard and try the Coder CLI", | ||
} | ||
|
||
export const AuditPageView: FC = () => { | ||
const styles = useStyles() | ||
|
||
return ( | ||
<Margins> | ||
<Stack justifyContent="space-between" className={styles.headingContainer}> | ||
<PageHeader className={styles.headingStyles}> | ||
<PageHeaderTitle> | ||
<Stack direction="row" spacing={1} alignItems="center"> | ||
<span>{Language.title}</span> | ||
<AuditHelpTooltip /> | ||
</Stack> | ||
</PageHeaderTitle> | ||
<PageHeaderSubtitle>{Language.subtitle}</PageHeaderSubtitle> | ||
</PageHeader> | ||
<CodeExample | ||
className={styles.codeExampleStyles} | ||
tooltipTitle={Language.tooltipTitle} | ||
code="coder audit [organization_ID]" | ||
/> | ||
</Stack> | ||
</Margins> | ||
) | ||
} | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
headingContainer: { | ||
marginTop: theme.spacing(6), | ||
marginBottom: theme.spacing(5), | ||
flexDirection: "row", | ||
alignItems: "center", | ||
|
||
[theme.breakpoints.down("sm")]: { | ||
flexDirection: "column", | ||
alignItems: "start", | ||
}, | ||
}, | ||
headingStyles: { | ||
paddingTop: "0px", | ||
paddingBottom: "0px", | ||
}, | ||
codeExampleStyles: { | ||
height: "fit-content", | ||
}, | ||
})) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of component nesting here (tooltips)