fix(lab): Be explicit about closing navigation on gist updates
This commit is contained in:
parent
c3b9c07236
commit
4d59cf59be
2 changed files with 12 additions and 12 deletions
|
@ -8,54 +8,54 @@ const View = props => {
|
||||||
{
|
{
|
||||||
name: 'measurements',
|
name: 'measurements',
|
||||||
title: t('measurements'),
|
title: t('measurements'),
|
||||||
onClick: () => props.updateGist(['_state', 'view'], 'measurements')
|
onClick: () => props.updateGist(['_state', 'view'], 'measurements', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'draft',
|
name: 'draft',
|
||||||
title: t('draftPattern', { pattern: props.pattern.config.name }),
|
title: t('draftPattern', { pattern: props.pattern.config.name }),
|
||||||
onClick: () => props.updateGist(['_state', 'view'], 'draft')
|
onClick: () => props.updateGist(['_state', 'view'], 'draft', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'test',
|
name: 'test',
|
||||||
title: t('testPattern', { pattern: props.pattern.config.name }),
|
title: t('testPattern', { pattern: props.pattern.config.name }),
|
||||||
onClick: () => props.updateGist(['_state', 'view'], 'test')
|
onClick: () => props.updateGist(['_state', 'view'], 'test', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'printingLayout',
|
name: 'printingLayout',
|
||||||
title: t('layoutThing', { thing: props.pattern.config.name })
|
title: t('layoutThing', { thing: props.pattern.config.name })
|
||||||
+ ': ' + t('forPrinting'),
|
+ ': ' + t('forPrinting'),
|
||||||
onClick: () => props.updateGist(['_state', 'view'], 'printingLayout')
|
onClick: () => props.updateGist(['_state', 'view'], 'printingLayout', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'cuttingLayout',
|
name: 'cuttingLayout',
|
||||||
title: t('layoutThing', { thing: props.pattern.config.name })
|
title: t('layoutThing', { thing: props.pattern.config.name })
|
||||||
+ ': ' + t('forCutting'),
|
+ ': ' + t('forCutting'),
|
||||||
onClick: () => props.updateGist(['_state', 'view'], 'cuttingLayout')
|
onClick: () => props.updateGist(['_state', 'view'], 'cuttingLayout', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'export',
|
name: 'export',
|
||||||
title: t('exportThing', { thing: props.pattern.config.name }),
|
title: t('exportThing', { thing: props.pattern.config.name }),
|
||||||
onClick: () => props.updateGist(['_state', 'view'], 'export')
|
onClick: () => props.updateGist(['_state', 'view'], 'export', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'events',
|
name: 'events',
|
||||||
title: t('events'),
|
title: t('events'),
|
||||||
onClick: () => props.updateGist(['_state', 'view'], 'events')
|
onClick: () => props.updateGist(['_state', 'view'], 'events', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'yaml',
|
name: 'yaml',
|
||||||
title: t('YAML'),
|
title: t('YAML'),
|
||||||
onClick: () => props.updateGist(['_state', 'view'], 'yaml')
|
onClick: () => props.updateGist(['_state', 'view'], 'yaml', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'json',
|
name: 'json',
|
||||||
title: t('JSON'),
|
title: t('JSON'),
|
||||||
onClick: () => props.updateGist(['_state', 'view'], 'json')
|
onClick: () => props.updateGist(['_state', 'view'], 'json', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'edit',
|
name: 'edit',
|
||||||
title: t('editThing', { thing: 'YAML' }),
|
title: t('editThing', { thing: 'YAML' }),
|
||||||
onClick: () => props.updateGist(['_state', 'view'], 'edit')
|
onClick: () => props.updateGist(['_state', 'view'], 'edit', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'clear',
|
name: 'clear',
|
||||||
|
|
|
@ -82,12 +82,12 @@ const WorkbenchWrapper = ({ app, pattern, preload=false, from=false, layout=fals
|
||||||
}, [preload, from])
|
}, [preload, from])
|
||||||
|
|
||||||
// Helper methods to manage the gist state
|
// Helper methods to manage the gist state
|
||||||
const updateGist = (path, content) => {
|
const updateGist = (path, content, closeNav=false) => {
|
||||||
const newGist = {...gist}
|
const newGist = {...gist}
|
||||||
set(newGist, path, content)
|
set(newGist, path, content)
|
||||||
setGist(newGist)
|
setGist(newGist)
|
||||||
// Force close of menu on mobile if it is open
|
// Force close of menu on mobile if it is open
|
||||||
if (app.primaryMenu) app.setPrimaryMenu(false)
|
if (closeNav && app.primaryMenu) app.setPrimaryMenu(false)
|
||||||
}
|
}
|
||||||
const unsetGist = (path) => {
|
const unsetGist = (path) => {
|
||||||
const newGist = {...gist}
|
const newGist = {...gist}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue