Skip to content

Commit

Permalink
[desk-tool] Make document pane's footer bar full width
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard authored and rexxars committed Oct 6, 2020
1 parent a42e94e commit c3a16f2
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/no-explicit-any */

import {useDocumentOperationEvent} from '@sanity/react-hooks'
import Snackbar from 'part:@sanity/components/snackbar/default'
import React from 'react'
Expand Down
16 changes: 16 additions & 0 deletions packages/@sanity/desk-tool/src/panes/documentPane/documentPane.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@

.root {
display: flex;
flex-direction: column;
height: 100%;
outline: none;
}

.documentAndChangesContainer {
flex: 1;
min-height: 0;
display: flex;
position: relative;
}

.footerContainer {
background: var(--component-bg);
border-top: 1px solid var(--hairline-color);

@nest .isCollapsed & {
display: none;
}
}

.isDisabled {
display: none; /* hide on mobile */

Expand Down
99 changes: 59 additions & 40 deletions packages/@sanity/desk-tool/src/panes/documentPane/documentPane.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ClickOutside} from 'part:@sanity/components/click-outside'
import {Popover} from 'part:@sanity/components/popover'
import Snackbar from 'part:@sanity/components/snackbar/default'
import * as PathUtils from '@sanity/util/paths'
import classNames from 'classnames'
import React, {useCallback, useRef, useState} from 'react'
Expand All @@ -9,8 +10,10 @@ import {useDeskToolFeatures} from '../../features'
import {ChangesPanel} from './changesPanel'
import {useDocumentHistory} from './documentHistory'
import {DocumentPanel, getProductionPreviewItem} from './documentPanel'
import {DocumentOperationResults} from './documentOperationResults'
import {InspectDialog} from './inspectDialog'
import {DocumentActionShortcuts, isInspectHotkey, isPreviewHotkey} from './keyboardShortcuts'
import {DocumentStatusBar} from './statusBar'
import {Timeline, sinceTimelineProps, revTimelineProps} from './timeline'
import {Doc, DocumentViewType, MenuItemGroup} from './types'

Expand Down Expand Up @@ -207,54 +210,70 @@ export function DocumentPane(props: DocumentPaneProps) {
isSelected ? styles.isActive : styles.isDisabled
])}
>
<div className={styles.documentContainer}>
{isInspectOpen && <InspectDialog value={value} onClose={handleInspectClose} />}
<div className={styles.documentAndChangesContainer}>
<div className={styles.documentContainer}>
{isInspectOpen && <InspectDialog value={value} onClose={handleInspectClose} />}

<DocumentPanel
activeViewId={activeViewId}
connectionState={connectionState}
documentId={documentId}
documentType={documentType}
idPrefix={paneKey}
initialFocusPath={initialFocusPath}
initialValue={initialValue}
isClosable={isClosable}
isCollapsed={isCollapsed}
isHistoryOpen={isChangesOpen}
isTimelineOpen={isTimelineOpen}
markers={markers}
menuItemGroups={menuItemGroups}
onChange={onChange}
onCloseView={handleClosePane}
onCollapse={onCollapse}
onExpand={onExpand}
onSetActiveView={handleSetActiveView}
onSplitPane={handleSplitPane}
onTimelineOpen={handleTimelineRev}
paneTitle={paneTitle}
schemaType={schemaType}
timelineMode={timelineMode}
toggleInspect={toggleInspect}
value={value}
versionSelectRef={versionSelectRef}
views={views}
/>
</div>

{features.reviewChanges && !isCollapsed && isChangesOpen && (
<div className={styles.changesContainer}>
<ChangesPanel
changesSinceSelectRef={changesSinceSelectRef}
<DocumentPanel
activeViewId={activeViewId}
connectionState={connectionState}
documentId={documentId}
documentType={documentType}
idPrefix={paneKey}
initialFocusPath={initialFocusPath}
initialValue={initialValue}
isClosable={isClosable}
isCollapsed={isCollapsed}
isHistoryOpen={isChangesOpen}
isTimelineOpen={isTimelineOpen}
loading={historyState === 'loading'}
onTimelineOpen={handleTimelineSince}
markers={markers}
menuItemGroups={menuItemGroups}
onChange={onChange}
onCloseView={handleClosePane}
onCollapse={onCollapse}
onExpand={onExpand}
onSetActiveView={handleSetActiveView}
onSplitPane={handleSplitPane}
onTimelineOpen={handleTimelineRev}
paneTitle={paneTitle}
schemaType={schemaType}
since={historyController.sinceTime}
timelineMode={timelineMode}
toggleInspect={toggleInspect}
value={value}
versionSelectRef={versionSelectRef}
views={views}
/>
</div>

{features.reviewChanges && !isCollapsed && isChangesOpen && (
<div className={styles.changesContainer}>
<ChangesPanel
changesSinceSelectRef={changesSinceSelectRef}
documentId={documentId}
isTimelineOpen={isTimelineOpen}
loading={historyState === 'loading'}
onTimelineOpen={handleTimelineSince}
schemaType={schemaType}
since={historyController.sinceTime}
timelineMode={timelineMode}
/>
</div>
)}
</div>

<div className={styles.footerContainer}>
<DocumentStatusBar
id={documentId}
type={documentType}
lastUpdated={value && value._updatedAt}
/>
</div>

{connectionState === 'reconnecting' && (
<Snackbar kind="warning" isPersisted title="Connection lost. Reconnecting…" />
)}

<DocumentOperationResults id={documentId} type={documentType} />
</DocumentActionShortcuts>
</Popover>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,3 @@
height: 100%;
overflow: auto;
}

.footerContainer {
background: var(--component-bg);
border-top: 1px solid var(--hairline-color);

@nest .isCollapsed & {
display: none;
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import classNames from 'classnames'
import {PortalProvider} from 'part:@sanity/components/portal'
import Snackbar from 'part:@sanity/components/snackbar/default'
import React, {createElement, useCallback, useEffect, useMemo, useRef} from 'react'
import {useDeskToolFeatures} from '../../../features'
import {useDocumentHistory} from '../documentHistory'
import {Doc, DocumentView, MenuItemGroup} from '../types'
import {DocumentOperationResults} from './documentOperationResults'
import {DocumentHeaderTitle} from './header/title'
import {DocumentPanelHeader} from './header/header'
import {getMenuItems} from './menuItems'
import {FormView} from './views'
import {DocumentStatusBar} from './statusBar'

import styles from './documentPanel.css'
import {Chunk} from '@sanity/field/diff'

interface DocumentPanelProps {
activeViewId: string
Expand Down Expand Up @@ -178,20 +174,6 @@ export function DocumentPanel(props: DocumentPanelProps) {
<div data-portal-container ref={portalContainerRef} />
</div>
</PortalProvider>

<div className={styles.footerContainer}>
<DocumentStatusBar
id={props.documentId}
type={props.documentType}
lastUpdated={props.value && props.value._updatedAt}
/>
</div>

{props.connectionState === 'reconnecting' && (
<Snackbar kind="warning" isPersisted title="Connection lost. Reconnecting…" />
)}

<DocumentOperationResults id={props.documentId} type={props.documentType} />
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {RenderActionCollectionState} from 'part:@sanity/base/actions/utils'
import {useEditState} from '@sanity/react-hooks'
import resolveDocumentActions from 'part:@sanity/base/document-actions/resolver'
import isHotkey from 'is-hotkey'
import {ActionStateDialog} from '../documentPanel/statusBar'
import {ActionStateDialog} from '../statusBar'

interface ResponderProps extends React.ComponentProps<'div'> {
states: any[]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */

import React from 'react'
import TimeAgo from '../../../../components/TimeAgo'
import {useDocumentHistory} from '../../documentHistory'
import TimeAgo from '../../../components/TimeAgo'
import {useDocumentHistory} from '../documentHistory'
import styles from './documentStatusBar.css'
import {DocumentStatusBarActions} from './documentStatusBarActions'
import {DocumentStatusBarBadges} from './documentStatusBarBadges'
Expand All @@ -14,7 +14,7 @@ import {RenderBadgeCollectionState} from 'part:@sanity/base/actions/utils'
interface Props {
id: string
type: string
lastUpdated?: string
lastUpdated?: string | null
}

export function DocumentStatusBar(props: Props) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Hotkeys from 'part:@sanity/components/typography/hotkeys'
import {RenderActionCollectionState} from 'part:@sanity/base/actions/utils'
import resolveDocumentActions from 'part:@sanity/base/document-actions/resolver'

import {HistoryRestoreAction} from '../../../../actions/HistoryRestoreAction'
import {HistoryRestoreAction} from '../../../actions/HistoryRestoreAction'
import styles from './documentStatusBarActions.css'
import {ActionMenu} from './actionMenu'
import {ActionStateDialog} from './actionStateDialog'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */

import React from 'react'
import TimeAgo from '../../../../components/TimeAgo'
import TimeAgo from '../../../components/TimeAgo'
import {HistoryStatusBarActions} from './documentStatusBarActions'

import styles from './documentStatusBar.css'
Expand Down

0 comments on commit c3a16f2

Please sign in to comment.