forked from blakeblackshear/frigate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): Delete events from Event page and API (blakeblackshear#991)
Co-authored-by: Scott Roach <[email protected]> Co-authored-by: Paul Armstrong <[email protected]>
- Loading branch information
1 parent
482399d
commit ebb6d34
Showing
11 changed files
with
225 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ RUN pip3 wheel --wheel-dir=/wheels \ | |
click \ | ||
setproctitle \ | ||
peewee \ | ||
gevent | ||
gevent | ||
|
||
FROM scratch | ||
|
||
|
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
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,47 @@ | ||
import { h, Fragment } from 'preact'; | ||
import Button from './Button'; | ||
import Heading from './Heading'; | ||
import { createPortal } from 'preact/compat'; | ||
import { useState, useEffect } from 'preact/hooks'; | ||
|
||
export default function Dialog({ actions = [], portalRootID = 'dialogs', title, text }) { | ||
const portalRoot = portalRootID && document.getElementById(portalRootID); | ||
const [show, setShow] = useState(false); | ||
|
||
useEffect(() => { | ||
window.requestAnimationFrame(() => { | ||
setShow(true); | ||
}); | ||
}, []); | ||
|
||
const dialog = ( | ||
<Fragment> | ||
<div | ||
data-testid="scrim" | ||
key="scrim" | ||
className="absolute inset-0 z-10 flex justify-center items-center bg-black bg-opacity-40" | ||
> | ||
<div | ||
role="modal" | ||
className={`absolute rounded shadow-2xl bg-white dark:bg-gray-700 max-w-sm text-gray-900 dark:text-white transition-transform transition-opacity duration-75 transform scale-90 opacity-0 ${ | ||
show ? 'scale-100 opacity-100' : '' | ||
}`} | ||
> | ||
<div className="p-4"> | ||
<Heading size="lg">{title}</Heading> | ||
<p>{text}</p> | ||
</div> | ||
<div className="p-2 flex justify-start flex-row-reverse space-x-2"> | ||
{actions.map(({ color, text, onClick, ...props }, i) => ( | ||
<Button className="ml-2" color={color} key={i} onClick={onClick} type="text" {...props}> | ||
{text} | ||
</Button> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
</Fragment> | ||
); | ||
|
||
return portalRoot ? createPortal(dialog, portalRoot) : dialog; | ||
} |
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,38 @@ | ||
import { h } from 'preact'; | ||
import Dialog from '../Dialog'; | ||
import { fireEvent, render, screen } from '@testing-library/preact'; | ||
|
||
describe('Dialog', () => { | ||
let portal; | ||
|
||
beforeAll(() => { | ||
portal = document.createElement('div'); | ||
portal.id = 'dialogs'; | ||
document.body.appendChild(portal); | ||
}); | ||
|
||
afterAll(() => { | ||
document.body.removeChild(portal); | ||
}); | ||
|
||
test('renders to a portal', async () => { | ||
render(<Dialog title="Tacos" text="This is the dialog" />); | ||
expect(screen.getByText('Tacos')).toBeInTheDocument(); | ||
expect(screen.getByRole('modal').closest('#dialogs')).not.toBeNull(); | ||
}); | ||
|
||
test('renders action buttons', async () => { | ||
const handleClick = jest.fn(); | ||
render( | ||
<Dialog | ||
actions={[ | ||
{ color: 'red', text: 'Delete' }, | ||
{ text: 'Okay', onClick: handleClick }, | ||
]} | ||
title="Tacos" | ||
/> | ||
); | ||
fireEvent.click(screen.getByRole('button', { name: 'Okay' })); | ||
expect(handleClick).toHaveBeenCalled(); | ||
}); | ||
}); |
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,13 @@ | ||
import { h } from 'preact'; | ||
import { memo } from 'preact/compat'; | ||
|
||
export function Delete({ className = '' }) { | ||
return ( | ||
<svg className={`fill-current ${className}`} viewBox="0 0 24 24"> | ||
<path d="M0 0h24v24H0V0z" fill="none" /> | ||
<path d="M6 21h12V7H6v14zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" /> | ||
</svg> | ||
); | ||
} | ||
|
||
export default memo(Delete); |
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
Oops, something went wrong.