Merge branch 'fix/back-to-editor' into 'feature/acl'
Back to editor in app view mode should not be visible to users with only read application permissions See merge request theappsmith/internal-tools-client!719
This commit is contained in:
commit
2d28e82f54
|
|
@ -12,6 +12,7 @@ import {
|
||||||
import {
|
import {
|
||||||
ReduxActionTypes,
|
ReduxActionTypes,
|
||||||
PageListPayload,
|
PageListPayload,
|
||||||
|
ApplicationPayload,
|
||||||
} from "constants/ReduxActionConstants";
|
} from "constants/ReduxActionConstants";
|
||||||
import {
|
import {
|
||||||
getPageList,
|
getPageList,
|
||||||
|
|
@ -35,6 +36,9 @@ import {
|
||||||
} from "actions/metaActions";
|
} from "actions/metaActions";
|
||||||
import AppRoute from "pages/common/AppRoute";
|
import AppRoute from "pages/common/AppRoute";
|
||||||
import { editorInitializer } from "utils/EditorUtils";
|
import { editorInitializer } from "utils/EditorUtils";
|
||||||
|
import { getCurrentOrg } from "selectors/organizationSelectors";
|
||||||
|
import { PERMISSION_TYPE } from "pages/Applications/permissionHelpers";
|
||||||
|
import { Organization } from "constants/orgConstants";
|
||||||
|
|
||||||
const AppViewWrapper = styled.div`
|
const AppViewWrapper = styled.div`
|
||||||
margin-top: ${props => props.theme.headerHeight};
|
margin-top: ${props => props.theme.headerHeight};
|
||||||
|
|
@ -51,6 +55,7 @@ const AppViewerBody = styled.section`
|
||||||
export type AppViewerProps = {
|
export type AppViewerProps = {
|
||||||
currentDSLPageId?: string;
|
currentDSLPageId?: string;
|
||||||
currentLayoutId?: string;
|
currentLayoutId?: string;
|
||||||
|
currentApplication: ApplicationPayload | undefined;
|
||||||
pages?: PageListPayload;
|
pages?: PageListPayload;
|
||||||
initializeAppViewer: Function;
|
initializeAppViewer: Function;
|
||||||
isInitialized: boolean;
|
isInitialized: boolean;
|
||||||
|
|
@ -86,8 +91,10 @@ class AppViewer extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const { isInitialized } = this.props;
|
const { isInitialized, currentApplication } = this.props;
|
||||||
|
const userPermissions = currentApplication?.userPermissions ?? [];
|
||||||
if (!isInitialized) return null;
|
if (!isInitialized) return null;
|
||||||
|
|
||||||
const items: SideNavItemProps[] | undefined =
|
const items: SideNavItemProps[] | undefined =
|
||||||
this.props.pages &&
|
this.props.pages &&
|
||||||
this.props.pages.map(page => ({
|
this.props.pages.map(page => ({
|
||||||
|
|
@ -101,6 +108,7 @@ class AppViewer extends Component<
|
||||||
loading: false,
|
loading: false,
|
||||||
}));
|
}));
|
||||||
if (!this.state.registered) return null;
|
if (!this.state.registered) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EditorContext.Provider
|
<EditorContext.Provider
|
||||||
value={{
|
value={{
|
||||||
|
|
@ -110,7 +118,11 @@ class AppViewer extends Component<
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AppViewWrapper>
|
<AppViewWrapper>
|
||||||
<AppViewerHeader url={this.props.editorURL} />
|
<AppViewerHeader
|
||||||
|
url={this.props.editorURL}
|
||||||
|
permissions={userPermissions || []}
|
||||||
|
permissionRequired={PERMISSION_TYPE.MANAGE_APPLICATION}
|
||||||
|
/>
|
||||||
<AppViewerBody>
|
<AppViewerBody>
|
||||||
<AppViewerSideNavWrapper>
|
<AppViewerSideNavWrapper>
|
||||||
<SideNav items={items} active={this.props.currentDSLPageId} />
|
<SideNav items={items} active={this.props.currentDSLPageId} />
|
||||||
|
|
@ -136,6 +148,7 @@ const mapStateToProps = (state: AppState) => ({
|
||||||
pages: getPageList(state),
|
pages: getPageList(state),
|
||||||
isInitialized: getIsInitialized(state),
|
isInitialized: getIsInitialized(state),
|
||||||
editorURL: getEditorURL(state),
|
editorURL: getEditorURL(state),
|
||||||
|
currentApplication: state.ui.applications.currentApplication,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch: any) => ({
|
const mapDispatchToProps = (dispatch: any) => ({
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import styled from "styled-components";
|
||||||
import StyledHeader from "components/designSystems/appsmith/StyledHeader";
|
import StyledHeader from "components/designSystems/appsmith/StyledHeader";
|
||||||
import Button from "components/editorComponents/Button";
|
import Button from "components/editorComponents/Button";
|
||||||
import { BACK_TO_EDITOR } from "constants/messages";
|
import { BACK_TO_EDITOR } from "constants/messages";
|
||||||
|
import { isPermitted } from "pages/Applications/permissionHelpers";
|
||||||
const HeaderWrapper = styled(StyledHeader)`
|
const HeaderWrapper = styled(StyledHeader)`
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|
@ -13,12 +14,19 @@ const HeaderWrapper = styled(StyledHeader)`
|
||||||
`;
|
`;
|
||||||
type AppViewerHeaderProps = {
|
type AppViewerHeaderProps = {
|
||||||
url?: string;
|
url?: string;
|
||||||
|
permissionRequired: string;
|
||||||
|
permissions: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AppViewerHeader = (props: AppViewerHeaderProps) => {
|
export const AppViewerHeader = (props: AppViewerHeaderProps) => {
|
||||||
|
const hasPermission = isPermitted(
|
||||||
|
props.permissions,
|
||||||
|
props.permissionRequired,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HeaderWrapper>
|
<HeaderWrapper>
|
||||||
{props.url && (
|
{props.url && hasPermission && (
|
||||||
<Button
|
<Button
|
||||||
className="t--back-to-editor"
|
className="t--back-to-editor"
|
||||||
href={props.url}
|
href={props.url}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { fetchPage, fetchPageList } from "actions/pageActions";
|
||||||
import { fetchDatasources } from "actions/datasourceActions";
|
import { fetchDatasources } from "actions/datasourceActions";
|
||||||
import { fetchPlugins } from "actions/pluginActions";
|
import { fetchPlugins } from "actions/pluginActions";
|
||||||
import { fetchActions } from "actions/actionActions";
|
import { fetchActions } from "actions/actionActions";
|
||||||
|
import { fetchApplication } from "actions/applicationActions";
|
||||||
import AnalyticsUtil from "utils/AnalyticsUtil";
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
||||||
import { getCurrentApplication } from "selectors/applicationSelectors";
|
import { getCurrentApplication } from "selectors/applicationSelectors";
|
||||||
|
|
||||||
|
|
@ -64,6 +65,7 @@ export function* initializeAppViewerSaga(
|
||||||
yield all([
|
yield all([
|
||||||
put(fetchActions(applicationId)),
|
put(fetchActions(applicationId)),
|
||||||
put(fetchPageList(applicationId)),
|
put(fetchPageList(applicationId)),
|
||||||
|
put(fetchApplication(applicationId)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
yield all([
|
yield all([
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user