-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing: Setup Playwright end-to-end testing and write first tests
Fixes #432
- Loading branch information
Showing
21 changed files
with
262 additions
and
76 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
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,7 @@ | ||
import * as Styled from './VersionSelectorTool.styled' | ||
|
||
const VersionSelectorTool = ({ versions, selected, latest, approved, hero, onChange }) => { | ||
return <Styled.Tools>VersionSelectorTool</Styled.Tools> | ||
} | ||
|
||
export default VersionSelectorTool |
8 changes: 8 additions & 0 deletions
8
src/components/VersionSelectorTool/VersionSelectorTool.styled.js
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,8 @@ | ||
import styled from 'styled-components' | ||
|
||
export const Tools = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
flex: 1; | ||
` |
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,34 @@ | ||
import { Button } from '@ynput/ayon-react-components' | ||
import * as Styled from './Preview.styled' | ||
import VersionSelectorTool from '/src/components/VersionSelectorTool/VersionSelectorTool' | ||
|
||
const Preview = ({ selected = [], entityType, onClose }) => { | ||
// TODO @LudoHolbik: a new services file src/services/preview/getPreview.js should be created for these queries below | ||
|
||
// TODO @Innders: get selected entity data from selected and entityType | ||
|
||
// TODO @LudoHolbik: get selected versions data from selected and entityType | ||
// some entity types won't support this | ||
// look at getActivities.js getEntityVersions [line 64] and getVersions [line 86] for reference | ||
const allVersionsDummyData = [ | ||
{ id: 1, name: 'v001' }, | ||
{ id: 2, name: 'v002' }, | ||
{ id: 3, name: 'v003' }, | ||
{ id: 4, name: 'v004', hero: true }, | ||
{ id: 5, name: 'v005', status: 'approved' }, | ||
] | ||
|
||
return ( | ||
<Styled.Container> | ||
<Styled.Header> | ||
<VersionSelectorTool versions={allVersionsDummyData} selected={selected} /> | ||
<Button onClick={onClose} icon={'close'} /> | ||
</Styled.Header> | ||
<Styled.Content> | ||
<h2>Selected Version: {selected.join(', ')}</h2> | ||
</Styled.Content> | ||
</Styled.Container> | ||
) | ||
} | ||
|
||
export default Preview |
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,22 @@ | ||
import { Toolbar } from '@ynput/ayon-react-components' | ||
import styled from 'styled-components' | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
overflow: hidden; | ||
` | ||
|
||
export const Header = styled(Toolbar)`` | ||
export const Content = styled.div` | ||
flex: 1; | ||
min-height: 80vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
h2 { | ||
font-size: 2rem; | ||
} | ||
` |
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,56 @@ | ||
import { Dialog } from '@ynput/ayon-react-components' | ||
import { useDispatch, useSelector } from 'react-redux' | ||
import { closePreview, openPreview } from '/src/features/preview' | ||
import { useSearchParams } from 'react-router-dom' | ||
import { useEffect } from 'react' | ||
import Preview from './Preview' | ||
import { isEqual } from 'lodash' | ||
import styled from 'styled-components' | ||
|
||
const StyledDialog = styled(Dialog)` | ||
/* hide header and footer */ | ||
.header, | ||
.footer { | ||
display: none; | ||
} | ||
` | ||
|
||
const PreviewDialog = () => { | ||
const dispatch = useDispatch() | ||
// check if dialog is open or not | ||
const { selected, entityType } = useSelector((state) => state.preview) | ||
|
||
const [searchParams, setUrlSearchParams] = useSearchParams() | ||
// usually just one id is passed, but multiple ids can be passed | ||
const selectedIds = searchParams.getAll('preview_id') || [] | ||
// passing undefined to openPreview will default to 'version' | ||
const selectedType = searchParams.get('preview_type') || undefined | ||
// when url has preview_id and preview_type, open the dialog if not already open | ||
|
||
useEffect(() => { | ||
if (!selectedIds.length) return | ||
// check if dialog is already open with same ids | ||
if (isEqual(selected, selectedIds)) return | ||
// open the dialog | ||
dispatch(openPreview({ selected: selectedIds, entityType: selectedType })) | ||
}, [selectedIds, selectedType]) | ||
|
||
if (!selected.length) return null | ||
|
||
const handleClose = () => { | ||
// remove query params preview_id and preview_type from url | ||
searchParams.delete('preview_id') | ||
searchParams.delete('preview_type') | ||
setUrlSearchParams(searchParams) | ||
// close the dialog | ||
dispatch(closePreview()) | ||
} | ||
|
||
return ( | ||
<StyledDialog isOpen hideCancelButton size="full"> | ||
<Preview {...{ selected, entityType }} onClose={handleClose} /> | ||
</StyledDialog> | ||
) | ||
} | ||
|
||
export default PreviewDialog |
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,25 @@ | ||
import { createSlice } from '@reduxjs/toolkit' | ||
|
||
const previewSlice = createSlice({ | ||
name: 'preview', | ||
initialState: { | ||
selected: [], | ||
entityType: null, | ||
}, | ||
reducers: { | ||
openPreview: (state, { payload: { selected, entityType = 'version' } = {} } = {}) => { | ||
state.selected = selected | ||
state.entityType = entityType | ||
}, | ||
updateSelection: (state, { payload: { selected } }) => { | ||
state.selected = selected | ||
}, | ||
closePreview: (state) => { | ||
state.selected = [] | ||
state.entityType = null | ||
}, | ||
}, | ||
}) | ||
|
||
export const { openPreview, updateSelection, closePreview } = previewSlice.actions | ||
export default previewSlice.reducer |
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
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.