2023-06-06 13:18:44 -05:00
|
|
|
import { MenuItem } from 'shared/components/workbench/menus/shared/menu-item.mjs'
|
|
|
|
import { WorkbenchMenu } from 'shared/components/workbench/menus/shared/index.mjs'
|
|
|
|
import {
|
|
|
|
emojis,
|
|
|
|
ns as designMenuNs,
|
|
|
|
} from 'shared/components/workbench/menus/design-options/index.mjs'
|
|
|
|
import { OptionsIcon } from 'shared/components/icons.mjs'
|
|
|
|
import { optionsMenuStructure, optionType } from 'shared/utils.mjs'
|
|
|
|
|
2023-06-06 14:31:27 -05:00
|
|
|
export const ns = ['test-view', ...designMenuNs]
|
|
|
|
|
|
|
|
const SampleInput = ({ changed, name, t, updateFunc, type }) => {
|
2023-06-06 13:18:44 -05:00
|
|
|
return (
|
|
|
|
<>
|
2023-06-06 14:31:27 -05:00
|
|
|
<p>{t([`${name}.d`, ''])}</p>
|
2023-06-06 13:18:44 -05:00
|
|
|
<div className="text-center">
|
|
|
|
<button
|
|
|
|
className={`btn btn-primary`}
|
|
|
|
disabled={changed}
|
|
|
|
onClick={() => updateFunc([name], true)}
|
|
|
|
>
|
2023-06-06 14:31:27 -05:00
|
|
|
{t(`testThis.${type}`)}
|
2023-06-06 13:18:44 -05:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2023-06-06 14:31:27 -05:00
|
|
|
|
|
|
|
export const SampleItem = ({ name, passProps, ...rest }) => {
|
2023-06-06 13:18:44 -05:00
|
|
|
return (
|
|
|
|
<MenuItem
|
|
|
|
{...{
|
|
|
|
...rest,
|
|
|
|
name,
|
|
|
|
passProps,
|
2023-06-06 14:31:27 -05:00
|
|
|
changed: passProps.settings.sample?.[passProps.type] === name,
|
|
|
|
Input: SampleInput,
|
2023-06-06 13:18:44 -05:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export const TestOptions = ({
|
|
|
|
design,
|
|
|
|
patternConfig,
|
|
|
|
settings,
|
|
|
|
update,
|
|
|
|
language,
|
|
|
|
account,
|
|
|
|
isFirst = true,
|
|
|
|
DynamicDocs = false,
|
|
|
|
}) => {
|
|
|
|
const menuNs = [`o_${design}`, ...ns]
|
|
|
|
const optionsMenu = optionsMenuStructure(patternConfig.options)
|
|
|
|
const getDocsPath = (option) =>
|
2023-06-06 14:31:27 -05:00
|
|
|
`designs/${design}/options${option ? '/' + option.toLowerCase() : ''}`
|
2023-06-06 13:18:44 -05:00
|
|
|
return (
|
|
|
|
<WorkbenchMenu
|
|
|
|
{...{
|
|
|
|
config: optionsMenu,
|
|
|
|
control: account.control,
|
|
|
|
DynamicDocs,
|
|
|
|
emojis,
|
|
|
|
getDocsPath,
|
|
|
|
Icon: OptionsIcon,
|
2023-06-06 14:31:27 -05:00
|
|
|
Item: SampleItem,
|
2023-06-06 13:18:44 -05:00
|
|
|
isFirst,
|
2023-06-06 14:31:27 -05:00
|
|
|
name: 'designOptions',
|
2023-06-06 13:18:44 -05:00
|
|
|
language,
|
|
|
|
ns: menuNs,
|
2023-06-06 14:31:27 -05:00
|
|
|
passProps: { settings, type: 'option' },
|
2023-06-06 13:18:44 -05:00
|
|
|
updateFunc: (path, value) => {
|
|
|
|
if (value) update.settings(['sample'], { type: 'option', option: path[0] })
|
|
|
|
else update.settings(['sample'])
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|