|
|
@@ -19,58 +19,107 @@ function IconCheckmark({ iconFor, pdfLayout, view }) {
|
|
|
return <Icon type="" modifier="fw" />
|
|
|
}
|
|
|
|
|
|
-function LayoutDropdownButton({ handleChangeLayout, pdfLayout, view }) {
|
|
|
+function LayoutDropdownButton({
|
|
|
+ reattach,
|
|
|
+ detach,
|
|
|
+ handleChangeLayout,
|
|
|
+ detachMode,
|
|
|
+ detachRole,
|
|
|
+ pdfLayout,
|
|
|
+ view,
|
|
|
+}) {
|
|
|
const { t } = useTranslation()
|
|
|
+
|
|
|
// bsStyle is required for Dropdown.Toggle, but we will override style
|
|
|
return (
|
|
|
- <ControlledDropdown id="layout-dropdown" className="toolbar-item">
|
|
|
- <Dropdown.Toggle className="btn-full-height" bsStyle="link">
|
|
|
- <Icon type="columns" modifier="fw" />
|
|
|
- <span className="toolbar-label">{t('layout')}</span>
|
|
|
- </Dropdown.Toggle>
|
|
|
- <Dropdown.Menu id="layout-dropdown-list">
|
|
|
- <MenuItem header>{t('layout')}</MenuItem>
|
|
|
- <MenuItem onSelect={() => handleChangeLayout('sideBySide')}>
|
|
|
- <IconCheckmark
|
|
|
- iconFor="sideBySide"
|
|
|
- pdfLayout={pdfLayout}
|
|
|
- view={view}
|
|
|
- />
|
|
|
- <Icon type="columns" />
|
|
|
- {t('editor_and_pdf')}
|
|
|
- </MenuItem>
|
|
|
- <MenuItem
|
|
|
- onSelect={() => handleChangeLayout('flat', 'editor')}
|
|
|
- className="menu-item-with-svg"
|
|
|
- >
|
|
|
- <IconCheckmark
|
|
|
- iconFor="editorOnly"
|
|
|
- pdfLayout={pdfLayout}
|
|
|
- view={view}
|
|
|
- />
|
|
|
- <IconEditorOnly />
|
|
|
- <Trans
|
|
|
- i18nKey="editor_only_hide_pdf"
|
|
|
- components={[
|
|
|
- <span key="editor_only_hide_pdf" className="subdued" />,
|
|
|
- ]}
|
|
|
- />
|
|
|
- </MenuItem>
|
|
|
- <MenuItem
|
|
|
- onSelect={() => handleChangeLayout('flat', 'pdf')}
|
|
|
- className="menu-item-with-svg"
|
|
|
- >
|
|
|
- <IconCheckmark iconFor="pdfOnly" pdfLayout={pdfLayout} view={view} />
|
|
|
- <IconPdfOnly />
|
|
|
- <Trans
|
|
|
- i18nKey="pdf_only_hide_editor"
|
|
|
- components={[
|
|
|
- <span key="pdf_only_hide_editor" className="subdued" />,
|
|
|
- ]}
|
|
|
- />
|
|
|
- </MenuItem>
|
|
|
- </Dropdown.Menu>
|
|
|
- </ControlledDropdown>
|
|
|
+ <>
|
|
|
+ {detachMode === 'detaching' && (
|
|
|
+ <div aria-live="assertive" className="sr-only">
|
|
|
+ {t('layout_processing')}
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ <ControlledDropdown
|
|
|
+ id="layout-dropdown"
|
|
|
+ className="toolbar-item"
|
|
|
+ disabled={detachMode === 'detaching'}
|
|
|
+ >
|
|
|
+ <Dropdown.Toggle className="btn-full-height" bsStyle="link">
|
|
|
+ {detachMode === 'detaching' ? (
|
|
|
+ <Icon type="refresh" modifier="fw" spin />
|
|
|
+ ) : (
|
|
|
+ <Icon type="columns" modifier="fw" />
|
|
|
+ )}
|
|
|
+ <span className="toolbar-label">{t('layout')}</span>
|
|
|
+ </Dropdown.Toggle>
|
|
|
+ <Dropdown.Menu id="layout-dropdown-list">
|
|
|
+ <MenuItem header>{t('layout')}</MenuItem>
|
|
|
+
|
|
|
+ <MenuItem
|
|
|
+ disabled={detachRole === 'detacher'}
|
|
|
+ onSelect={() => handleChangeLayout('sideBySide')}
|
|
|
+ >
|
|
|
+ <IconCheckmark
|
|
|
+ iconFor="sideBySide"
|
|
|
+ pdfLayout={pdfLayout}
|
|
|
+ view={view}
|
|
|
+ />
|
|
|
+ <Icon type="columns" />
|
|
|
+ {t('editor_and_pdf')}
|
|
|
+ </MenuItem>
|
|
|
+
|
|
|
+ <MenuItem
|
|
|
+ onSelect={() => handleChangeLayout('flat', 'editor')}
|
|
|
+ className="menu-item-with-svg"
|
|
|
+ >
|
|
|
+ <IconCheckmark
|
|
|
+ iconFor="editorOnly"
|
|
|
+ pdfLayout={pdfLayout}
|
|
|
+ view={view}
|
|
|
+ />
|
|
|
+ <IconEditorOnly />
|
|
|
+ <Trans
|
|
|
+ i18nKey="editor_only_hide_pdf"
|
|
|
+ components={[
|
|
|
+ <span key="editor_only_hide_pdf" className="subdued" />,
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ </MenuItem>
|
|
|
+
|
|
|
+ <MenuItem
|
|
|
+ disabled={detachRole === 'detacher'}
|
|
|
+ onSelect={() => handleChangeLayout('flat', 'pdf')}
|
|
|
+ className="menu-item-with-svg"
|
|
|
+ >
|
|
|
+ <IconCheckmark
|
|
|
+ iconFor="pdfOnly"
|
|
|
+ pdfLayout={pdfLayout}
|
|
|
+ view={view}
|
|
|
+ />
|
|
|
+ <IconPdfOnly />
|
|
|
+ <Trans
|
|
|
+ i18nKey="pdf_only_hide_editor"
|
|
|
+ components={[
|
|
|
+ <span key="pdf_only_hide_editor" className="subdued" />,
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ </MenuItem>
|
|
|
+
|
|
|
+ <MenuItem divider />
|
|
|
+
|
|
|
+ {detachRole === 'detacher' ? (
|
|
|
+ <MenuItem onSelect={() => reattach()}>
|
|
|
+ <Icon type="window-restore" modifier="fw" />
|
|
|
+ {t('bring_pdf_back_to_tab')}
|
|
|
+ </MenuItem>
|
|
|
+ ) : (
|
|
|
+ <MenuItem onSelect={() => detach()}>
|
|
|
+ <Icon type="window-restore" modifier="fw" />
|
|
|
+ {t('open_pdf_in_new_tab')}
|
|
|
+ </MenuItem>
|
|
|
+ )}
|
|
|
+ </Dropdown.Menu>
|
|
|
+ </ControlledDropdown>
|
|
|
+ </>
|
|
|
)
|
|
|
}
|
|
|
|
|
|
@@ -83,7 +132,11 @@ IconCheckmark.propTypes = {
|
|
|
}
|
|
|
|
|
|
LayoutDropdownButton.propTypes = {
|
|
|
+ reattach: PropTypes.func.isRequired,
|
|
|
+ detach: PropTypes.func.isRequired,
|
|
|
handleChangeLayout: PropTypes.func.isRequired,
|
|
|
+ detachMode: PropTypes.string,
|
|
|
+ detachRole: PropTypes.string,
|
|
|
pdfLayout: PropTypes.string.isRequired,
|
|
|
view: PropTypes.string,
|
|
|
}
|