* initial commit * props hoc * changes * removed ignores and withWidgetProps * added extra props to canvasStructure * widget props changes * list widget changes * reintroduced widget props hook and other refactors * remove warnings * added deepequal for childWidgets selector * fix global hotkeys and tabs widget jest test * fix main container test fix * fixed view mode width * fix form widget values * minor fix * fix skeleton * form widget validity fix * jest test fix * fixed tests: GlobalHotkeys, Tabs, CanvasSelectectionArena and fixed main container rendering * minor fix * minor comments * reverted commented code * simplified structure, selective redux state updates and other inconsistencies * fix junit test cases * stop form widget from force rendering children * fix test case * random commit to re run tests * update isFormValid prop only if it exists * detangling circular dependency * fixing cypress tests * cleaned up code * clean up man cnavas props and fix jest cases * fix rendering order of child widgets for canvas * fix dropdown reset spec * adding comments * cleaning up unwanted code * fix multiselect widget on deploy * adressing review comments * addressing minor review comment changes * destructuring modal widget child and fix test case * fix communityIssues cypress spec * rewrite isVisible logic to match previous behaviour * merging widget props with component props before checking isVisible * adressing review comments for modal widget's isVisible Co-authored-by: rahulramesha <rahul@appsmith.com>
107 lines
3.1 KiB
TypeScript
107 lines
3.1 KiB
TypeScript
import React, { useMemo } from "react";
|
|
import { Link, RouteComponentProps, withRouter } from "react-router-dom";
|
|
import { useSelector } from "react-redux";
|
|
import { getIsFetchingPage } from "selectors/appViewSelectors";
|
|
import styled from "styled-components";
|
|
import { AppViewerRouteParams } from "constants/routes";
|
|
import { theme } from "constants/DefaultTheme";
|
|
import { Icon, NonIdealState, Spinner } from "@blueprintjs/core";
|
|
import Centered from "components/designSystems/appsmith/CenteredWrapper";
|
|
import AppPage from "./AppPage";
|
|
import { getCanvasWidth, getCurrentPageName } from "selectors/editorSelectors";
|
|
import RequestConfirmationModal from "pages/Editor/RequestConfirmationModal";
|
|
import { getCurrentApplication } from "selectors/applicationSelectors";
|
|
import {
|
|
isPermitted,
|
|
PERMISSION_TYPE,
|
|
} from "../Applications/permissionHelpers";
|
|
import { builderURL } from "RouteBuilder";
|
|
import { getCanvasWidgetsStructure } from "selectors/entitiesSelector";
|
|
import { isEqual } from "lodash";
|
|
|
|
const Section = styled.section`
|
|
height: 100%;
|
|
width: 100%;
|
|
margin: 0 auto;
|
|
position: relative;
|
|
overflow-x: auto;
|
|
overflow-y: auto;
|
|
`;
|
|
|
|
type AppViewerPageContainerProps = RouteComponentProps<AppViewerRouteParams>;
|
|
|
|
function AppViewerPageContainer(props: AppViewerPageContainerProps) {
|
|
const currentPageName = useSelector(getCurrentPageName);
|
|
const widgetsStructure = useSelector(getCanvasWidgetsStructure, isEqual);
|
|
const canvasWidth = useSelector(getCanvasWidth);
|
|
const isFetchingPage = useSelector(getIsFetchingPage);
|
|
const currentApplication = useSelector(getCurrentApplication);
|
|
const { match } = props;
|
|
|
|
// get appsmith editr link
|
|
const appsmithEditorLink = useMemo(() => {
|
|
if (
|
|
currentApplication?.userPermissions &&
|
|
isPermitted(
|
|
currentApplication?.userPermissions,
|
|
PERMISSION_TYPE.MANAGE_APPLICATION,
|
|
)
|
|
) {
|
|
return (
|
|
<p>
|
|
Please add widgets to this page in the
|
|
<Link
|
|
to={builderURL({
|
|
pageId: props.match.params.pageId as string,
|
|
})}
|
|
>
|
|
Appsmith Editor
|
|
</Link>
|
|
</p>
|
|
);
|
|
}
|
|
}, [currentApplication?.userPermissions]);
|
|
|
|
const pageNotFound = (
|
|
<Centered>
|
|
<NonIdealState
|
|
description={appsmithEditorLink}
|
|
icon={
|
|
<Icon
|
|
color={theme.colors.primaryOld}
|
|
icon="page-layout"
|
|
iconSize={theme.fontSizes[9]}
|
|
/>
|
|
}
|
|
title="This page seems to be blank"
|
|
/>
|
|
</Centered>
|
|
);
|
|
|
|
const pageLoading = (
|
|
<Centered>
|
|
<Spinner />
|
|
</Centered>
|
|
);
|
|
|
|
if (isFetchingPage) return pageLoading;
|
|
|
|
if (!(widgetsStructure.children && widgetsStructure.children.length > 0))
|
|
return pageNotFound;
|
|
|
|
return (
|
|
<Section>
|
|
<AppPage
|
|
appName={currentApplication?.name}
|
|
canvasWidth={canvasWidth}
|
|
pageId={match.params.pageId}
|
|
pageName={currentPageName}
|
|
widgetsStructure={widgetsStructure}
|
|
/>
|
|
<RequestConfirmationModal />
|
|
</Section>
|
|
);
|
|
}
|
|
|
|
export default withRouter(AppViewerPageContainer);
|