-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add demo dialog when no config ID
* chore(config): move test and dev configs to hosted * chore(project): fix time mock for live channels tests * chore(project): fix time mock for live channels tests, fix config query param * chore(project): fix live and seo tests * chore(project): fix live channel test to support GMT * chore: remove console statements * chore(project): move fixture files out of src * chore(project): only include epg channel data when env variable set * feat(config): add dialog when no config ID found * feat(config): finish dialog for missing config * fix(config): run demo in production env * chore: make confirm dialog functions required again * chore: fix footer styling, fix run scripts * chore: fix dialog props * chore: fix missing script
- Loading branch information
Showing
24 changed files
with
342 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
APP_CONFIG_DEFAULT_SOURCE= | ||
APP_UNSAFE_ALLOW_DYNAMIC_CONFIG=1 | ||
APP_DEMO_DEFAULT_CONFIG_ID=225tvq1i |
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
48 changes: 48 additions & 0 deletions
48
src/components/DemoConfigDialog/DemoConfigDialog.module.scss
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,48 @@ | ||
@use '../../styles/variables'; | ||
@use '../../styles/theme'; | ||
|
||
.controls { | ||
margin-top: variables.$base-spacing; | ||
|
||
> button { | ||
margin-right: 8px; | ||
} | ||
} | ||
|
||
.configModal { | ||
position: absolute; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
background: var(--body-background-color); | ||
|
||
p { | ||
max-width: 400px; | ||
margin-bottom: 0; | ||
color: theme.$text-field-resting-color; | ||
font-size: 14px; | ||
line-height: 18px; | ||
} | ||
|
||
a { | ||
color: theme.$text-field-resting-color; | ||
font-weight: var(--body-font-weight-bold); | ||
text-decoration: underline; | ||
} | ||
} | ||
|
||
.note { | ||
padding: variables.$base-spacing; | ||
text-align: center; | ||
|
||
a { | ||
text-decoration: underline; | ||
cursor: pointer; | ||
} | ||
|
||
* { | ||
margin-top: calc(#{variables.$base-spacing} / 2); | ||
color: theme.$text-field-resting-color; | ||
font-weight: var(--body-font-weight-bold); | ||
} | ||
} |
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,18 @@ | ||
import React from 'react'; | ||
|
||
import { renderWithRouter } from '#test/testUtils'; | ||
import DemoConfigDialog from '#src/components/DemoConfigDialog/DemoConfigDialog'; | ||
|
||
describe('<DemoConfigDialog>', () => { | ||
test('renders and matches snapshot', () => { | ||
const { container } = renderWithRouter(<DemoConfigDialog configLocation={''} />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
test('renders and matches snapshot with ID', () => { | ||
const { container } = renderWithRouter(<DemoConfigDialog configLocation={'gnnuzabk'} />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
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,81 @@ | ||
import React, { MouseEventHandler, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import styles from './DemoConfigDialog.module.scss'; | ||
|
||
import ErrorPage from '#src/components/ErrorPage/ErrorPage'; | ||
import TextField from '#src/components/TextField/TextField'; | ||
import Button from '#src/components/Button/Button'; | ||
import { addConfigQueryParam, clearStoredConfig, getConfigLocation } from '#src/utils/configOverride'; | ||
import Link from '#src/components/Link/Link'; | ||
import ConfirmationDialog from '#src/components/ConfirmationDialog/ConfirmationDialog'; | ||
|
||
const fallbackConfig = import.meta.env.APP_DEMO_DEFAULT_CONFIG_ID; | ||
|
||
interface Props { | ||
configLocation?: string; | ||
} | ||
|
||
const DemoConfigDialog = ({ configLocation = getConfigLocation() }: Props) => { | ||
const { t } = useTranslation('demo'); | ||
const [showDemoWarning, setShowWarning] = useState(false); | ||
|
||
const clearConfig = () => { | ||
clearStoredConfig(); | ||
window.location.reload(); | ||
}; | ||
|
||
if (configLocation) { | ||
return ( | ||
<div className={styles.note}> | ||
<div>{t('currently_previewing_config', { configLocation })}</div> | ||
<Link onClick={clearConfig}>{t('click_to_unselect_config')}</Link> | ||
</div> | ||
); | ||
} | ||
|
||
const cancelConfigClick: MouseEventHandler<HTMLButtonElement> = (event) => { | ||
event.preventDefault(); | ||
|
||
if (fallbackConfig) { | ||
setShowWarning(true); | ||
} | ||
}; | ||
|
||
const confirmDemoClick = () => { | ||
addConfigQueryParam(fallbackConfig); | ||
window.location.reload(); | ||
}; | ||
|
||
const cancelDemoClick = () => setShowWarning(false); | ||
|
||
return ( | ||
<div className={styles.configModal}> | ||
<ErrorPage title={t('app_config_not_found')}> | ||
<form method="GET" action="/"> | ||
<TextField required placeholder={t('please_enter_config_id')} name="app-config" /> | ||
<div className={styles.controls}> | ||
<Button label={t('submit_config_id')} type={'submit'} /> | ||
{fallbackConfig && <Button label={t('cancel_config_id')} onClick={cancelConfigClick} />} | ||
</div> | ||
</form> | ||
<p> | ||
{t('use_the_jwp_dashboard')} | ||
<span> </span> | ||
<Link href={'https://docs.jwplayer.com/platform/docs/ott-create-an-app-config'} target={'_blank'}> | ||
{t('learn_more')} | ||
</Link> | ||
</p> | ||
</ErrorPage> | ||
<ConfirmationDialog | ||
open={showDemoWarning} | ||
title={t('view_generic_demo')} | ||
body={t('viewing_config_demo')} | ||
onConfirm={confirmDemoClick} | ||
onClose={cancelDemoClick} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DemoConfigDialog; |
98 changes: 98 additions & 0 deletions
98
src/components/DemoConfigDialog/__snapshots__/DemoConfigDialog.test.tsx.snap
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,98 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`<DemoConfigDialog> > renders and matches snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="_configModal_561a54" | ||
> | ||
<div | ||
class="_errorPage_8c5621" | ||
> | ||
<div | ||
class="_box_8c5621" | ||
> | ||
<header> | ||
<h1 | ||
class="_title_8c5621" | ||
> | ||
app_config_not_found | ||
</h1> | ||
</header> | ||
<main | ||
class="_main_8c5621" | ||
> | ||
<form | ||
action="/" | ||
method="GET" | ||
> | ||
<div | ||
class="_textField_e16c1b" | ||
> | ||
<label | ||
class="_label_e16c1b" | ||
for="text-field_1235_app-config" | ||
/> | ||
<div | ||
class="_container_e16c1b" | ||
> | ||
<input | ||
class="_input_e16c1b" | ||
id="text-field_1235_app-config" | ||
name="app-config" | ||
placeholder="please_enter_config_id" | ||
required="" | ||
type="text" | ||
value="" | ||
/> | ||
</div> | ||
</div> | ||
<div | ||
class="_controls_561a54" | ||
> | ||
<button | ||
class="_button_f8f296 _default_f8f296 _outlined_f8f296" | ||
type="submit" | ||
> | ||
<span> | ||
submit_config_id | ||
</span> | ||
</button> | ||
</div> | ||
</form> | ||
<p> | ||
use_the_jwp_dashboard | ||
<span> | ||
</span> | ||
<a | ||
class="_link_a14c64" | ||
href="https://docs.jwplayer.com/platform/docs/ott-create-an-app-config" | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
learn_more | ||
</a> | ||
</p> | ||
</main> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
exports[`<DemoConfigDialog> > renders and matches snapshot with ID 1`] = ` | ||
<div> | ||
<div | ||
class="_note_561a54" | ||
> | ||
<div> | ||
currently_previewing_config | ||
</div> | ||
<a | ||
class="_link_a14c64" | ||
> | ||
click_to_unselect_config | ||
</a> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
} | ||
|
||
.box { | ||
max-width: 500px; | ||
max-width: 600px; | ||
padding: 12px; | ||
} | ||
|
||
|
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.