diff --git a/app/client/src/api/Api.tsx b/app/client/src/api/Api.tsx index bc6f54e6aa..a599879511 100644 --- a/app/client/src/api/Api.tsx +++ b/app/client/src/api/Api.tsx @@ -67,10 +67,7 @@ axiosInstance.interceptors.response.use( } } const errorData = error.response.data.responseMeta; - if ( - errorData.status === 404 && - errorData.error.code === 4028 - ) { + if (errorData.status === 404 && errorData.error.code === 4028) { history.push(PAGE_NOT_FOUND_URL); return Promise.reject({ code: 404, diff --git a/app/client/src/api/ApplicationApi.tsx b/app/client/src/api/ApplicationApi.tsx index 2023d0fdc2..ec2477a677 100644 --- a/app/client/src/api/ApplicationApi.tsx +++ b/app/client/src/api/ApplicationApi.tsx @@ -6,6 +6,11 @@ export interface PublishApplicationRequest { applicationId: string; } +export interface ChangeAppViewAccessRequest { + applicationId: string; + publicAccess: boolean; +} + export interface PublishApplicationResponse extends ApiResponse { data: {}; } @@ -79,6 +84,8 @@ class ApplicationApi extends Api { static baseURL = "v1/applications/"; static publishURLPath = (applicationId: string) => `publish/${applicationId}`; static createApplicationPath = (orgId: string) => `?orgId=${orgId}`; + static changeAppViewAccessPath = (applicationId: string) => + `${applicationId}/changeAccess`; static setDefaultPagePath = (request: SetDefaultPageRequest) => `${ApplicationApi.baseURL}${request.applicationId}/page/${request.pageId}/makeDefault`; static publishApplication( @@ -120,6 +127,17 @@ class ApplicationApi extends Api { ): AxiosPromise { return Api.put(ApplicationApi.setDefaultPagePath(request)); } + + static changeAppViewAccess( + request: ChangeAppViewAccessRequest, + ): AxiosPromise { + return Api.put( + ApplicationApi.baseURL + + ApplicationApi.changeAppViewAccessPath(request.applicationId), + { publicAccess: request.publicAccess }, + ); + } + static deleteApplication( request: DeleteApplicationRequest, ): AxiosPromise { diff --git a/app/client/src/constants/ReduxActionConstants.tsx b/app/client/src/constants/ReduxActionConstants.tsx index 24c506d1a5..d5e2dbc831 100644 --- a/app/client/src/constants/ReduxActionConstants.tsx +++ b/app/client/src/constants/ReduxActionConstants.tsx @@ -82,6 +82,9 @@ export const ReduxActionTypes: { [key: string]: string } = { STORE_AS_DATASOURCE_COMPLETE: "STORE_AS_DATASOURCE_COMPLETE", PUBLISH_APPLICATION_INIT: "PUBLISH_APPLICATION_INIT", PUBLISH_APPLICATION_SUCCESS: "PUBLISH_APPLICATION_SUCCESS", + CHANGE_APPVIEW_ACCESS_INIT: "CHANGE_APPVIEW_ACCESS_INIT", + CHANGE_APPVIEW_ACCESS_SUCCESS: "CHANGE_APPVIEW_ACCESS_SUCCESS", + CHANGE_APPVIEW_ACCESS_ERROR: "CHANGE_APPVIEW_ACCESS_ERROR", CREATE_PAGE_INIT: "CREATE_PAGE_INIT", CREATE_PAGE_SUCCESS: "CREATE_PAGE_SUCCESS", FETCH_PAGE_LIST_INIT: "FETCH_PAGE_LIST_INIT", @@ -382,6 +385,7 @@ export type ApplicationPayload = { organizationId: string; pageCount: number; defaultPageId?: string; + isPublic?: boolean; userPermissions?: string[]; }; diff --git a/app/client/src/pages/Editor/EditorHeader.tsx b/app/client/src/pages/Editor/EditorHeader.tsx index 63b1ae67ff..8473bee5ab 100644 --- a/app/client/src/pages/Editor/EditorHeader.tsx +++ b/app/client/src/pages/Editor/EditorHeader.tsx @@ -1,6 +1,14 @@ -import React from "react"; +import React, { useEffect } from "react"; +import { connect } from "react-redux"; +import { AppState } from "reducers"; import styled from "styled-components"; import { Breadcrumbs, IBreadcrumbProps } from "@blueprintjs/core"; +import { ReduxActionTypes } from "constants/ReduxActionConstants"; +import { + getCurrentOrg, + getCurrentOrgId, +} from "selectors/organizationSelectors"; +import { Org } from "constants/orgConstants"; import { BASE_URL, APPLICATIONS_URL, @@ -22,6 +30,8 @@ import { import AnalyticsUtil from "utils/AnalyticsUtil"; import { Skin } from "constants/DefaultTheme"; import { HelpModal } from "components/designSystems/appsmith/help/HelpModal"; +import { FormDialogComponent } from "components/editorComponents/form/FormDialogComponent"; +import ShareApplicationForm from "pages/Editor/ShareApplicationForm"; const LoadingContainer = styled.div` display: flex; @@ -48,13 +58,16 @@ const StretchedBreadCrumb = styled(Breadcrumbs)` } `; -const InviteButton = styled.div` +const ShareButton = styled.div` display: flex; flex-grow: 1; justify-content: flex-end; `; type EditorHeaderProps = { + currentOrg: Org; + currentOrgId: string; + fetchCurrentOrg: (orgId: string) => void; isSaving?: boolean; pageSaveError?: boolean; pageName?: string; @@ -77,6 +90,12 @@ export const EditorHeader = (props: EditorHeaderProps) => { page => page.pageId === props.currentPageId, )?.pageName; + const { fetchCurrentOrg, currentOrgId } = props; + + useEffect(() => { + fetchCurrentOrg(currentOrgId); + }, [fetchCurrentOrg, currentOrgId]); + const pageSelectorData: CustomizedDropdownProps = { sections: [ { @@ -146,9 +165,22 @@ export const EditorHeader = (props: EditorHeaderProps) => { - - {/*