|
@@ -28,13 +28,14 @@ import SeenUserInfo from '../User/SeenUserInfo';
|
|
|
|
|
|
|
|
type WideViewMenuItemProps = AdditionalMenuItemsRendererProps & {
|
|
type WideViewMenuItemProps = AdditionalMenuItemsRendererProps & {
|
|
|
onClickMenuItem: (newValue: boolean) => void,
|
|
onClickMenuItem: (newValue: boolean) => void,
|
|
|
|
|
+ expandContentWidth: boolean,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const WideViewMenuItem = (props: WideViewMenuItemProps): JSX.Element => {
|
|
const WideViewMenuItem = (props: WideViewMenuItemProps): JSX.Element => {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
const {
|
|
const {
|
|
|
- pageInfo, onClickMenuItem,
|
|
|
|
|
|
|
+ pageInfo, onClickMenuItem, expandContentWidth,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
if (!isIPageInfoForEntity(pageInfo)) {
|
|
if (!isIPageInfoForEntity(pageInfo)) {
|
|
@@ -43,7 +44,7 @@ const WideViewMenuItem = (props: WideViewMenuItemProps): JSX.Element => {
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<DropdownItem
|
|
<DropdownItem
|
|
|
- onClick={() => onClickMenuItem(!pageInfo.expandContentWidth)}
|
|
|
|
|
|
|
+ onClick={() => onClickMenuItem(!expandContentWidth)}
|
|
|
className="grw-page-control-dropdown-item"
|
|
className="grw-page-control-dropdown-item"
|
|
|
>
|
|
>
|
|
|
<div className="custom-control custom-switch ml-1">
|
|
<div className="custom-control custom-switch ml-1">
|
|
@@ -51,7 +52,7 @@ const WideViewMenuItem = (props: WideViewMenuItemProps): JSX.Element => {
|
|
|
id="switchContentWidth"
|
|
id="switchContentWidth"
|
|
|
className="custom-control-input"
|
|
className="custom-control-input"
|
|
|
type="checkbox"
|
|
type="checkbox"
|
|
|
- checked={pageInfo.expandContentWidth}
|
|
|
|
|
|
|
+ checked={expandContentWidth}
|
|
|
onChange={() => {}}
|
|
onChange={() => {}}
|
|
|
/>
|
|
/>
|
|
|
<label className="custom-control-label" htmlFor="switchContentWidth">
|
|
<label className="custom-control-label" htmlFor="switchContentWidth">
|
|
@@ -80,12 +81,13 @@ type SubNavButtonsSubstanceProps = CommonProps & {
|
|
|
revisionId: string | null,
|
|
revisionId: string | null,
|
|
|
path?: string | null,
|
|
path?: string | null,
|
|
|
pageInfo: IPageInfoForOperation,
|
|
pageInfo: IPageInfoForOperation,
|
|
|
|
|
+ expandContentWidth?: boolean,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const SubNavButtonsSubstance = (props: SubNavButtonsSubstanceProps): JSX.Element => {
|
|
const SubNavButtonsSubstance = (props: SubNavButtonsSubstanceProps): JSX.Element => {
|
|
|
const {
|
|
const {
|
|
|
pageInfo,
|
|
pageInfo,
|
|
|
- pageId, revisionId, path, shareLinkId,
|
|
|
|
|
|
|
+ pageId, revisionId, path, shareLinkId, expandContentWidth,
|
|
|
isCompactMode, disableSeenUserInfoPopover, showPageControlDropdown, forceHideMenuItems, additionalMenuItemRenderer,
|
|
isCompactMode, disableSeenUserInfoPopover, showPageControlDropdown, forceHideMenuItems, additionalMenuItemRenderer,
|
|
|
onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteMenuItem,
|
|
onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteMenuItem,
|
|
|
} = props;
|
|
} = props;
|
|
@@ -193,6 +195,7 @@ const SubNavButtonsSubstance = (props: SubNavButtonsSubstanceProps): JSX.Element
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
await updateContentWidth(pageId, newValue);
|
|
await updateContentWidth(pageId, newValue);
|
|
|
|
|
+ // TODO: mutate wide view info
|
|
|
mutatePageInfo();
|
|
mutatePageInfo();
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
@@ -204,9 +207,12 @@ const SubNavButtonsSubstance = (props: SubNavButtonsSubstanceProps): JSX.Element
|
|
|
if (!isIPageInfoForEntity(pageInfo)) {
|
|
if (!isIPageInfoForEntity(pageInfo)) {
|
|
|
return undefined;
|
|
return undefined;
|
|
|
}
|
|
}
|
|
|
- const wideviewMenuItemRenderer = (props: WideViewMenuItemProps) => <WideViewMenuItem {...props} onClickMenuItem={switchContentWidthClickHandler} />;
|
|
|
|
|
|
|
+ const wideviewMenuItemRenderer = (props: WideViewMenuItemProps) => {
|
|
|
|
|
+ if (expandContentWidth == null) { return <></> }
|
|
|
|
|
+ return <WideViewMenuItem {...props} onClickMenuItem={switchContentWidthClickHandler} expandContentWidth={expandContentWidth} />;
|
|
|
|
|
+ };
|
|
|
return wideviewMenuItemRenderer;
|
|
return wideviewMenuItemRenderer;
|
|
|
- }, [pageInfo, switchContentWidthClickHandler]);
|
|
|
|
|
|
|
+ }, [pageInfo, switchContentWidthClickHandler, expandContentWidth]);
|
|
|
|
|
|
|
|
if (!isIPageInfoForOperation(pageInfo)) {
|
|
if (!isIPageInfoForOperation(pageInfo)) {
|
|
|
return <></>;
|
|
return <></>;
|
|
@@ -274,12 +280,13 @@ export type SubNavButtonsProps = CommonProps & {
|
|
|
pageId: string,
|
|
pageId: string,
|
|
|
shareLinkId?: string | null,
|
|
shareLinkId?: string | null,
|
|
|
revisionId?: string | null,
|
|
revisionId?: string | null,
|
|
|
- path?: string | null
|
|
|
|
|
|
|
+ path?: string | null,
|
|
|
|
|
+ expandContentWidth?: boolean,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export const SubNavButtons = (props: SubNavButtonsProps): JSX.Element => {
|
|
export const SubNavButtons = (props: SubNavButtonsProps): JSX.Element => {
|
|
|
const {
|
|
const {
|
|
|
- pageId, revisionId, path, shareLinkId, onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteMenuItem,
|
|
|
|
|
|
|
+ pageId, revisionId, path, shareLinkId, expandContentWidth, onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteMenuItem,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
const { data: pageInfo, error } = useSWRxPageInfo(pageId ?? null, shareLinkId);
|
|
const { data: pageInfo, error } = useSWRxPageInfo(pageId ?? null, shareLinkId);
|
|
@@ -302,6 +309,7 @@ export const SubNavButtons = (props: SubNavButtonsProps): JSX.Element => {
|
|
|
onClickDuplicateMenuItem={onClickDuplicateMenuItem}
|
|
onClickDuplicateMenuItem={onClickDuplicateMenuItem}
|
|
|
onClickRenameMenuItem={onClickRenameMenuItem}
|
|
onClickRenameMenuItem={onClickRenameMenuItem}
|
|
|
onClickDeleteMenuItem={onClickDeleteMenuItem}
|
|
onClickDeleteMenuItem={onClickDeleteMenuItem}
|
|
|
|
|
+ expandContentWidth={expandContentWidth}
|
|
|
/>
|
|
/>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|