Skip to content

Commit

Permalink
audit-logs: make sidebar sections collapsible
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Jun 29, 2023
1 parent ed85a14 commit b75b017
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
12 changes: 12 additions & 0 deletions frontend/src/components/common/AuditLogSearch/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
justify-content: space-between;
}

.form :global input[type="text"] {
width: 100%;
}

.submitStrip {
margin: 0.75rem 0;
}

.section {
margin-bottom: 0.5rem;
}

.resetButton {
font-size: 1rem;
font-weight: normal;
Expand Down
26 changes: 17 additions & 9 deletions frontend/src/components/common/AuditLogSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useState } from "react";
import { useCallback } from "react";
import { useEffect } from "react";
import { Checkbox } from "src/components/common/Checkbox";
import { Collapsible } from "src/components/common/Collapsible";
import { Link } from "src/components/common/Link";
import { SectionHeader } from "src/components/common/Section";
import { CheckboxFormField } from "src/components/formfields/CheckboxFormField";
Expand All @@ -20,6 +21,7 @@ interface StateSearchSectionItem {

interface StateSearchSection {
title: string;
storageKey: string;
searchModel: string;
searchList: StateSearchSectionItem[];
}
Expand Down Expand Up @@ -92,6 +94,7 @@ const isSearchTermPresent = (
const StateSearches: StateSearchSection[] = [
{
title: "User States",
storageKey: `auditLogUserStatus`,
searchModel: "user",
searchList: [
{ title: "Created", searchState: "created" },
Expand All @@ -104,6 +107,7 @@ const StateSearches: StateSearchSection[] = [
},
{
title: "Level States",
storageKey: `auditLogLevelStatus`,
searchModel: "level",
searchList: [
{ title: "Created", searchState: "created" },
Expand All @@ -115,6 +119,7 @@ const StateSearches: StateSearchSection[] = [
},
{
title: "Review States",
storageKey: `auditLogReviewStatus`,
searchModel: "levelreview",
searchList: [
{ title: "Posted", searchState: "created" },
Expand All @@ -123,6 +128,7 @@ const StateSearches: StateSearchSection[] = [
},
{
title: "Tag States",
storageKey: `auditLogTagStatus`,
searchModel: "tag",
searchList: [
{ title: "Created", searchState: "created" },
Expand All @@ -132,6 +138,7 @@ const StateSearches: StateSearchSection[] = [
},
{
title: "Walkthrough States",
storageKey: `auditLogWalkthroughStatus`,
searchModel: "walkthrough",
searchList: [
{ title: "Created", searchState: "created" },
Expand Down Expand Up @@ -242,7 +249,7 @@ const AuditLogSearch = ({
</Link>
</SectionHeader>

<div>
<div className={styles.form}>
<CheckboxFormField
onChange={() => {
submitForm();
Expand All @@ -253,19 +260,20 @@ const AuditLogSearch = ({

<TextFormField label="Search user" name="userSearch" />
<TextFormField label="Search object" name="objectSearch" />
<div className="FormField">
<div className={styles.submitStrip}>
<SubmitButton onClick={submitForm} icon={<IconSearch />}>
Search
</SubmitButton>
</div>
</div>

{StateSearches.map((section, sectionNum) => (
<>
<SectionHeader key={sectionNum} className={styles.header}>
{section.title}
</SectionHeader>
<div>
<div className={styles.section}>
<Collapsible
key={section.storageKey}
storageKey={section.storageKey}
title={section.title}
>
{section.searchList.map((sectionItem, searchNum) => (
<Checkbox
key={searchNum}
Expand All @@ -280,8 +288,8 @@ const AuditLogSearch = ({
checked={isStateSearchCheckboxChecked(section, sectionItem)}
/>
))}
</div>
</>
</Collapsible>
</div>
))}
</Form>
)}
Expand Down

0 comments on commit b75b017

Please sign in to comment.