2023-06-06 14:43:23 -05:00
|
|
|
import { useTranslation } from 'next-i18next'
|
2023-06-06 13:18:44 -05:00
|
|
|
import { PanZoomPattern } from 'shared/components/workbench/pan-zoom-pattern.mjs'
|
|
|
|
import { TestMenu, ns as menuNs } from './menu.mjs'
|
2023-06-23 17:45:50 -05:00
|
|
|
import { PatternWithMenu, ns as wrapperNs } from '../pattern-with-menu.mjs'
|
2023-06-06 13:18:44 -05:00
|
|
|
|
2023-06-23 17:45:50 -05:00
|
|
|
export const ns = [...menuNs, wrapperNs]
|
2023-06-06 13:18:44 -05:00
|
|
|
|
|
|
|
export const TestView = ({
|
|
|
|
design,
|
|
|
|
pattern,
|
|
|
|
settings,
|
2023-06-24 15:00:46 -05:00
|
|
|
setSettings,
|
2023-06-06 13:18:44 -05:00
|
|
|
ui,
|
|
|
|
update,
|
|
|
|
language,
|
|
|
|
account,
|
|
|
|
DynamicDocs,
|
|
|
|
}) => {
|
2023-06-06 14:43:23 -05:00
|
|
|
const { t } = useTranslation(ns)
|
2023-06-06 13:18:44 -05:00
|
|
|
if (!pattern) return null
|
|
|
|
if (settings.sample) pattern.sample()
|
|
|
|
else pattern.draft()
|
|
|
|
|
|
|
|
const renderProps = pattern.getRenderProps()
|
|
|
|
const patternConfig = pattern.getConfig()
|
2023-06-06 14:43:23 -05:00
|
|
|
|
2023-08-28 15:00:59 +02:00
|
|
|
/*
|
|
|
|
* Translation of the title needs some work
|
|
|
|
*/
|
|
|
|
let title = t('workbench:testDesignOption', {
|
|
|
|
design,
|
2023-08-28 16:34:23 +02:00
|
|
|
option: t(`${design}:${settings.sample?.option}.t`),
|
2023-08-28 15:00:59 +02:00
|
|
|
})
|
2023-08-28 16:34:23 +02:00
|
|
|
if (settings.sample?.type === 'measurement')
|
2023-08-28 15:00:59 +02:00
|
|
|
title = t('workbench:testDesignMeasurement', {
|
|
|
|
design,
|
2023-08-28 16:34:23 +02:00
|
|
|
measurement: t(`measurements:${settings.sample?.measurement}`),
|
2023-08-28 15:00:59 +02:00
|
|
|
})
|
2023-08-28 16:34:23 +02:00
|
|
|
else if (settings.sample?.type === 'sets')
|
2023-08-28 15:00:59 +02:00
|
|
|
title = t('workbench:testDesignSets', {
|
|
|
|
design,
|
|
|
|
thing: 'fixme views/test/index.mjs',
|
|
|
|
})
|
|
|
|
|
2023-06-06 13:18:44 -05:00
|
|
|
return (
|
2023-06-23 17:45:50 -05:00
|
|
|
<PatternWithMenu
|
|
|
|
{...{
|
|
|
|
settings,
|
|
|
|
ui,
|
|
|
|
update,
|
|
|
|
control: account.control,
|
|
|
|
setSettings,
|
2023-08-28 15:00:59 +02:00
|
|
|
title: <h2>{title}</h2>,
|
2023-06-23 17:45:50 -05:00
|
|
|
pattern: <PanZoomPattern {...{ renderProps }} />,
|
|
|
|
menu: (
|
|
|
|
<TestMenu
|
|
|
|
{...{
|
|
|
|
design,
|
|
|
|
pattern,
|
|
|
|
patternConfig,
|
|
|
|
settings,
|
2023-06-26 11:41:56 -05:00
|
|
|
setSettings,
|
2023-06-23 17:45:50 -05:00
|
|
|
ui,
|
|
|
|
update,
|
|
|
|
language,
|
|
|
|
account,
|
|
|
|
DynamicDocs,
|
|
|
|
renderProps,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
}}
|
|
|
|
/>
|
2023-06-06 13:18:44 -05:00
|
|
|
)
|
|
|
|
}
|