generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Style timeline page and add filter panel (#380)
<img width="1582" alt="Screenshot 2023-09-13 at 9 52 39 AM" src="https://github.com/TBD54566975/ftl/assets/51647/0fa4ac8a-c34b-4d31-bd4a-8b93e5b7fe1e"> <img width="1582" alt="Screenshot 2023-09-13 at 9 52 42 AM" src="https://github.com/TBD54566975/ftl/assets/51647/fef61b76-30bb-494a-863d-8ae7cc563be6">
- Loading branch information
1 parent
79a1025
commit 4b3b74e
Showing
14 changed files
with
332 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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 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 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,21 @@ | ||
import { panelColor } from '../utils' | ||
|
||
interface Props { | ||
icon?: React.ReactNode | ||
title?: string | ||
children?: React.ReactNode | ||
} | ||
|
||
export const PageHeader = ({ icon, title, children }: Props) => { | ||
return ( | ||
<div | ||
className={`sticky top-0 z-10 ${panelColor} shadow dark:shadow-md flex justify-between items-center py-2 px-4 text-gray-70`} | ||
> | ||
<div className='flex items-center'> | ||
<span className='-mt-0.5 text-indigo-500 pr-1'>{icon}</span> | ||
<span className='text-lg'>{title}</span> | ||
</div> | ||
{children} | ||
</div> | ||
) | ||
} |
This file contains 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 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,14 @@ | ||
import { ViewModuleRounded } from '@mui/icons-material' | ||
import { PageHeader } from '../../components/PageHeader' | ||
import { ModulesList } from './ModulesList' | ||
|
||
export const ModulesPage = () => { | ||
return ( | ||
<> | ||
<div className='w-full m-0'> | ||
<PageHeader icon={<ViewModuleRounded />} title='Modules' /> | ||
<ModulesList /> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains 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 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,21 @@ | ||
import { Timeline as TimelineIcon } from '@mui/icons-material' | ||
import { PageHeader } from '../../components/PageHeader' | ||
import { Timeline } from './Timeline' | ||
import { TimelineFilterPanel } from './filters/TimelineFilterPanel' | ||
import { TimelineTimeControls } from './filters/TimelineTimeControls' | ||
|
||
export const TimelinePage = () => { | ||
return ( | ||
<> | ||
<PageHeader icon={<TimelineIcon />} title='Events'> | ||
<TimelineTimeControls /> | ||
</PageHeader> | ||
<div className='flex h-full'> | ||
<TimelineFilterPanel /> | ||
<div className='flex-grow'> | ||
<Timeline /> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} |
127 changes: 127 additions & 0 deletions
127
console/client/src/features/timeline/filters/TimelineFilterPanel.tsx
This file contains 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,127 @@ | ||
import { Disclosure } from '@headlessui/react' | ||
import { ChevronUpIcon } from '@heroicons/react/20/solid' | ||
import React from 'react' | ||
import { modulesContext } from '../../../providers/modules-provider' | ||
import { textColor } from '../../../utils' | ||
|
||
const EVENT_TYPES: Record<string, string> = { | ||
call: 'Call', | ||
log: 'Log', | ||
deployment: 'Deployment', | ||
} | ||
|
||
const headerStyles = 'bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600' | ||
|
||
export const TimelineFilterPanel = () => { | ||
const modules = React.useContext(modulesContext) | ||
const [selectedEventTypes, setSelectedEventTypes] = React.useState<string[]>(Object.keys(EVENT_TYPES)) | ||
const [selectedModules, setSelectedModules] = React.useState<string[]>([]) | ||
|
||
React.useEffect(() => { | ||
if (selectedModules.length === 0) { | ||
setSelectedModules(modules.modules.map((module) => module.name)) | ||
} | ||
console.log(modules) | ||
}, [modules]) | ||
|
||
const handleTypeChanged = (eventType: string, checked: boolean) => { | ||
if (checked) { | ||
setSelectedEventTypes((prev) => [...prev, eventType]) | ||
} else { | ||
setSelectedEventTypes((prev) => prev.filter((filter) => filter !== eventType)) | ||
} | ||
} | ||
|
||
const handleModuleChanged = (moduleName: string, checked: boolean) => { | ||
if (checked) { | ||
setSelectedModules((prev) => [...prev, moduleName]) | ||
} else { | ||
setSelectedModules((prev) => prev.filter((filter) => filter !== moduleName)) | ||
} | ||
} | ||
|
||
return ( | ||
<div className='flex-shrink-0 w-52'> | ||
<div className='w-full'> | ||
<div className='mx-auto w-full max-w-md p-2'> | ||
<Disclosure defaultOpen={true}> | ||
{({ open }) => ( | ||
<> | ||
<Disclosure.Button | ||
className={`flex w-full justify-between rounded-md ${headerStyles} py-1 px-2 text-left text-sm font-medium ${textColor} focus:outline-none focus-visible:ring focus-visible:ring-gray-500 focus-visible:ring-opacity-75`} | ||
> | ||
<span>Event types</span> | ||
<ChevronUpIcon className={`${open ? 'rotate-180 transform' : ''} h-5 w-5 text-gray-500`} /> | ||
</Disclosure.Button> | ||
<Disclosure.Panel className={`px-2 py-2 text-sm ${textColor}`}> | ||
<fieldset> | ||
<legend className='sr-only'>Event types</legend> | ||
<div className='space-y-0.5'> | ||
{Object.keys(EVENT_TYPES).map((key) => ( | ||
<div key={key} className='relative flex items-start'> | ||
<div className='flex h-6 items-center'> | ||
<input | ||
id={`event-type-${key}`} | ||
name={`event-type-${key}`} | ||
type='checkbox' | ||
checked={selectedEventTypes.includes(key)} | ||
onChange={(e) => handleTypeChanged(key, e.target.checked)} | ||
className='h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600 cursor-pointer' | ||
/> | ||
</div> | ||
<div className='ml-2 text-sm leading-6'> | ||
<label htmlFor={`event-type-${key}`} className={`${textColor}`}> | ||
{EVENT_TYPES[key]} | ||
</label> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</fieldset> | ||
</Disclosure.Panel> | ||
</> | ||
)} | ||
</Disclosure> | ||
<Disclosure as='div' className='mt-2' defaultOpen={true}> | ||
{({ open }) => ( | ||
<> | ||
<Disclosure.Button | ||
className={`flex w-full justify-between rounded-md ${headerStyles} py-1 px-2 text-left text-sm font-medium ${textColor} hover:bg-gray-200 focus:outline-none focus-visible:ring focus-visible:ring-gray-500 focus-visible:ring-opacity-75`} | ||
> | ||
<span>Modules</span> | ||
<ChevronUpIcon className={`${open ? 'rotate-180 transform' : ''} h-5 w-5 text-gray-500`} /> | ||
</Disclosure.Button> | ||
<Disclosure.Panel className='px-2 py-2 text-sm text-gray-500'> | ||
<fieldset> | ||
<legend className='sr-only'>Modules</legend> | ||
<div className='space-y-0.5'> | ||
{modules.modules.map((module) => ( | ||
<div key={module.name} className='relative flex items-start'> | ||
<div className='flex h-6 items-center'> | ||
<input | ||
id={`module-${module}`} | ||
name={`module-${module}`} | ||
type='checkbox' | ||
checked={selectedModules.includes(module.name)} | ||
onChange={(e) => handleModuleChanged(module.name, e.target.checked)} | ||
className='h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600 cursor-pointer' | ||
/> | ||
</div> | ||
<div className='ml-2 text-sm leading-6'> | ||
<label htmlFor={`module-${module.name}`} className={`${textColor}`}> | ||
{module.name} | ||
</label> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</fieldset> | ||
</Disclosure.Panel> | ||
</> | ||
)} | ||
</Disclosure> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.