Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: support approve (#6413)
Kilu.He3174ffed5cd7
diff --git a/frontend/appflowy_web_app/src/application/comment.type.ts b/frontend/appflowy_web_app/src/application/comment.type.tsindex b4c81e40a1..0d5bdecf53 100644--- a/frontend/appflowy_web_app/src/application/comment.type.ts+++ b/frontend/appflowy_web_app/src/application/comment.type.ts@@ -1,12 +1,8 @@-export interface CommentUser {- uuid: string;- name: string;- avatarUrl: string | null;-}+import { AFWebUser } from '@/application/types';export interface GlobalComment {commentId: string;- user: CommentUser | null;+ user: AFWebUser | null;content: string;createdAt: string;lastUpdatedAt: string;@@ -17,6 +13,6 @@ export interface GlobalComment {export interface Reaction {reactionType: string;- reactUsers: CommentUser[];+ reactUsers: AFWebUser[];commentId: string;}diff --git a/frontend/appflowy_web_app/src/application/services/js-services/http/http_api.ts b/frontend/appflowy_web_app/src/application/services/js-services/http/http_api.tsindex 31c35adc70..03c127c951 100644--- a/frontend/appflowy_web_app/src/application/services/js-services/http/http_api.ts+++ b/frontend/appflowy_web_app/src/application/services/js-services/http/http_api.ts@@ -7,7 +7,14 @@ import {ViewId,ViewLayout,Workspace,- Invitation, Types,+ Invitation,+ Types,+ AFWebUser,+ GetRequestAccessInfoResponse,+ Subscriptions,+ SubscriptionPlan,+ SubscriptionInterval,+ RequestAccessInfoStatus,} from '@/application/types';import { GlobalComment, Reaction } from '@/application/comment.type';import { initGrantService, refreshToken } from '@/application/services/js-services/http/gotrue';@@ -202,6 +209,21 @@ interface AFWorkspace {database_storage_id: string,}+function afWorkspace2Workspace (workspace: AFWorkspace): Workspace {+ return {+ id: workspace.workspace_id,+ owner: {+ uid: workspace.owner_uid,+ name: workspace.owner_name,+ },+ name: workspace.workspace_name,+ icon: workspace.icon,+ memberCount: workspace.member_count,+ databaseStorageId: workspace.database_storage_id,+ createdAt: workspace.created_at,+ };+}+export async function openWorkspace (workspaceId: string) {const url = `/api/workspace/${workspaceId}/open`;const response = await axiosInstance?.put<{@@ -242,29 +264,8 @@ export async function getUserWorkspaceInfo (): Promise<{return {user_id: user_profile.uuid,- selected_workspace: {- id: visiting_workspace.workspace_id,- name: visiting_workspace.workspace_name,- icon: visiting_workspace.icon,- memberCount: visiting_workspace.member_count,- databaseStorageId: visiting_workspace.database_storage_id,- owner: {- uid: visiting_workspace.owner_uid,- name: visiting_workspace.owner_name,- },- },- workspaces: workspaces.map(workspace => ({- id: workspace.workspace_id,- name: workspace.workspace_name,- icon: workspace.icon,- memberCount: workspace.member_count,- createdAt: workspace.created_at,- databaseStorageId: workspace.database_storage_id,- owner: {- uid: workspace.owner_uid,- name: workspace.owner_name,- },- })),+ selected_workspace: afWorkspace2Workspace(visiting_workspace),+ workspaces: workspaces.map(afWorkspace2Workspace),};}@@ -680,28 +681,14 @@ export async function getWorkspaces (): Promise<Workspace[]> {const url = `/api/workspace?${query.toString()}`;const response = await axiosInstance?.get<{code: number;- data?: {- workspace_id: string;- workspace_name: string;- member_count: number;- icon: string;- database_storage_id?: string;- }[];+ data?: AFWorkspace[];message: string;}>(url);const data = response?.data;if (data?.code === 0 && data.data) {- return data.data.map((workspace) => {- return {- id: workspace.workspace_id,- name: workspace.workspace_name,- memberCount: workspace.member_count,- icon: workspace.icon,- databaseStorageId: workspace.database_storage_id || '',- };- });+ return data.data.map(afWorkspace2Workspace);}return Promise.reject(data);@@ -1048,4 +1035,123 @@ export async function acceptInvitation (invitationId: string) {}return Promise.reject(response?.data.message);+}++export async function getRequestAccessInfo (requestId: string): Promise<GetRequestAccessInfoResponse> {+ const url = `/api/access-request/${requestId}`;+ const response = await axiosInstance?.get<{+ code: number;+ data?: {+ request_id: string;+ workspace: AFWorkspace;+ requester: AFWebUser & {+ email: string;+ };+ view: View;+ status: RequestAccessInfoStatus;+ };+ message: string;+ }>(url);++ const data = response?.data;++ if (data?.code === 0 && data.data) {+ const workspace = data.data.workspace;++ return {+ ...data.data,+ workspace: afWorkspace2Workspace(workspace),+ };+ }++ return Promise.reject(data);+}++export async function approveRequestAccess (requestId: string) {+ const url = `/api/access-request/${requestId}/approve`;+ const response = await axiosInstance?.post<{+ code: number;+ message: string;+ }>(url, {+ is_approved: true,+ });++ if (response?.data.code === 0) {+ return;+ }++ return Promise.reject(response?.data);+}++export async function sendRequestAccess (workspaceId: string, viewId: string) {+ const url = `/api/access-request`;+ const response = await axiosInstance?.post<{+ code: number;+ message: string;+ }>(url, {+ workspace_id: workspaceId,+ view_id: viewId,+ });++ if (response?.data.code === 0) {+ return;+ }++ return Promise.reject(response?.data);+}++export async function getSubscriptionLink (workspaceId: string, plan: SubscriptionPlan, interval: SubscriptionInterval) {+ const url = `/billing/api/v1/subscription-link`;+ const response = await axiosInstance?.get<{+ code: number;+ data?: string;+ message: string;+ }>(url, {+ params: {+ workspace_subscription_plan: plan,+ recurring_interval: interval,+ workspace_id: workspaceId,+ success_url: window.location.href,+ },+ });++ const data = response?.data;++ if (data?.code === 0 && data.data) {+ return data.data;+ }++ return Promise.reject(data);+}++export async function getSubscriptions () {+ const url = `/billing/api/v1/subscriptions`;+ const response = await axiosInstance?.get<{+ code: number;+ data: Subscriptions;+ message: string;+ }>(url);++ if (response?.data.code === 0) {+ return response?.data.data;+ }++ return Promise.reject(response?.data);++}++export async function getActiveSubscription (workspaceId: string) {+ const url = `/billing/api/v1/active-subscription/${workspaceId}`;++ const response = await axiosInstance?.get<{+ code: number;+ data: SubscriptionPlan[];+ message: string;+ }>(url);++ if (response?.data.code === 0) {+ return response?.data.data;+ }++ return Promise.reject(response?.data);}\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/application/services/js-services/index.ts b/frontend/appflowy_web_app/src/application/services/js-services/index.tsindex 05831dc402..3c0ea9f5ce 100644--- a/frontend/appflowy_web_app/src/application/services/js-services/index.ts+++ b/frontend/appflowy_web_app/src/application/services/js-services/index.ts@@ -27,7 +27,13 @@ import {TemplateCreatorFormValues,UploadTemplatePayload,} from '@/application/template.type';-import { DatabaseRelations, DuplicatePublishView, Types, YjsEditorKey } from '@/application/types';+import {+ DatabaseRelations,+ DuplicatePublishView,+ SubscriptionInterval, SubscriptionPlan,+ Types,+ YjsEditorKey,+} from '@/application/types';import { applyYDoc } from '@/application/ydoc/apply';import { nanoid } from 'nanoid';import * as Y from 'yjs';@@ -428,4 +434,27 @@ export class AFClientService implements AFService {return APIService.acceptInvitation(invitationId);}+ approveRequestAccess (requestId: string): Promise<void> {+ return APIService.approveRequestAccess(requestId);+ }++ getRequestAccessInfo (requestId: string) {+ return APIService.getRequestAccessInfo(requestId);+ }++ sendRequestAccess (workspaceId: string, viewId: string): Promise<void> {+ return APIService.sendRequestAccess(workspaceId, viewId);+ }++ getSubscriptionLink (workspaceId: string, plan: SubscriptionPlan, interval: SubscriptionInterval) {+ return APIService.getSubscriptionLink(workspaceId, plan, interval);+ }++ getSubscriptions () {+ return APIService.getSubscriptions();+ }++ getActiveSubscription (workspaceId: string) {+ return APIService.getActiveSubscription(workspaceId);+ }}diff --git a/frontend/appflowy_web_app/src/application/services/services.type.ts b/frontend/appflowy_web_app/src/application/services/services.type.tsindex 5dbf8a5949..8581d0398b 100644--- a/frontend/appflowy_web_app/src/application/services/services.type.ts+++ b/frontend/appflowy_web_app/src/application/services/services.type.ts@@ -6,7 +6,7 @@ import {UserWorkspaceInfo,View,Workspace,- YDoc, DatabaseRelations,+ YDoc, DatabaseRelations, GetRequestAccessInfoResponse, Subscriptions, SubscriptionPlan, SubscriptionInterval,} from '@/application/types';import { GlobalComment, Reaction } from '@/application/comment.type';import { ViewMeta } from '@/application/db/tables/view_metas';@@ -18,7 +18,9 @@ import {UploadTemplatePayload,} from '@/application/template.type';-export type AFService = PublishService;+export type AFService = PublishService & AppService & TemplateService & {+ getClientId: () => string;+};export interface AFServiceConfig {cloudConfig: AFCloudConfig;@@ -30,48 +32,41 @@ export interface AFCloudConfig {wsURL: string;}-export interface PublishService {- getClientId: () => string;+export interface AppService {+ openWorkspace: (workspaceId: string) => Promise<void>;getPageDoc: (workspaceId: string, viewId: string, errorCallback?: (error: {code: number;}) => void) => Promise<YDoc>;- getPublishViewMeta: (namespace: string, publishName: string) => Promise<ViewMeta>;- getPublishView: (namespace: string, publishName: string) => Promise<YDoc>;- getPublishRowDocument: (viewId: string) => Promise<YDoc>;- getPublishInfo: (viewId: string) => Promise<{ namespace: string; publishName: string }>;createRowDoc: (rowKey: string) => Promise<YDoc>;deleteRowDoc: (rowKey: string) => void;getAppDatabaseViewRelations: (workspaceId: string, databaseStorageId: string) => Promise<DatabaseRelations>;- openWorkspace: (workspaceId: string) => Promise<void>;-- getPublishOutline (namespace: string): Promise<View[]>;-getAppOutline: (workspaceId: string) => Promise<View[]>;getAppView: (workspaceId: string, viewId: string) => Promise<View>;getAppFavorites: (workspaceId: string) => Promise<View[]>;getAppRecent: (workspaceId: string) => Promise<View[]>;getAppTrash: (workspaceId: string) => Promise<View[]>;-- getPublishViewGlobalComments: (viewId: string) => Promise<GlobalComment[]>;- createCommentOnPublishView: (viewId: string, content: string, replyCommentId?: string) => Promise<void>;- deleteCommentOnPublishView: (viewId: string, commentId: string) => Promise<void>;- getPublishViewReactions: (viewId: string, commentId?: string) => Promise<Record<string, Reaction[]>>;- addPublishViewReaction: (viewId: string, commentId: string, reactionType: string) => Promise<void>;- removePublishViewReaction: (viewId: string, commentId: string, reactionType: string) => Promise<void>;-loginAuth: (url: string) => Promise<void>;signInMagicLink: (params: { email: string; redirectTo: string }) => Promise<void>;signInGoogle: (params: { redirectTo: string }) => Promise<void>;signInGithub: (params: { redirectTo: string }) => Promise<void>;signInDiscord: (params: { redirectTo: string }) => Promise<void>;signInApple: (params: { redirectTo: string }) => Promise<void>;-getWorkspaces: () => Promise<Workspace[]>;getWorkspaceFolder: (workspaceId: string) => Promise<FolderView>;getCurrentUser: () => Promise<User>;getUserWorkspaceInfo: () => Promise<UserWorkspaceInfo>;- duplicatePublishView: (params: DuplicatePublishView) => Promise<void>;+ uploadFileToCDN: (file: File) => Promise<string>;+ getInvitation: (invitationId: string) => Promise<Invitation>;+ acceptInvitation: (invitationId: string) => Promise<void>;+ getRequestAccessInfo: (requestId: string) => Promise<GetRequestAccessInfoResponse>;+ approveRequestAccess: (requestId: string) => Promise<void>;+ sendRequestAccess: (workspaceId: string, viewId: string) => Promise<void>;+ getSubscriptionLink: (workspaceId: string, plan: SubscriptionPlan, interval: SubscriptionInterval) => Promise<string>;+ getSubscriptions: () => Promise<Subscriptions>;+ getActiveSubscription: (workspaceId: string) => Promise<SubscriptionPlan[]>;+}+export interface TemplateService {getTemplateCategories: () => Promise<TemplateCategory[]>;addTemplateCategory: (category: TemplateCategoryFormValues) => Promise<void>;deleteTemplateCategory: (categoryId: string) => Promise<void>;@@ -88,7 +83,23 @@ export interface PublishService {updateTemplate: (id: string, template: UploadTemplatePayload) => Promise<void>;updateTemplateCategory: (categoryId: string, category: TemplateCategoryFormValues) => Promise<void>;updateTemplateCreator: (creatorId: string, creator: TemplateCreatorFormValues) => Promise<void>;- uploadFileToCDN: (file: File) => Promise<string>;- getInvitation: (invitationId: string) => Promise<Invitation>;- acceptInvitation: (invitationId: string) => Promise<void>;+}++export interface PublishService {++ getPublishViewMeta: (namespace: string, publishName: string) => Promise<ViewMeta>;+ getPublishView: (namespace: string, publishName: string) => Promise<YDoc>;+ getPublishRowDocument: (viewId: string) => Promise<YDoc>;+ getPublishInfo: (viewId: string) => Promise<{ namespace: string; publishName: string }>;++ getPublishOutline (namespace: string): Promise<View[]>;++ getPublishViewGlobalComments: (viewId: string) => Promise<GlobalComment[]>;+ createCommentOnPublishView: (viewId: string, content: string, replyCommentId?: string) => Promise<void>;+ deleteCommentOnPublishView: (viewId: string, commentId: string) => Promise<void>;+ getPublishViewReactions: (viewId: string, commentId?: string) => Promise<Record<string, Reaction[]>>;+ addPublishViewReaction: (viewId: string, commentId: string, reactionType: string) => Promise<void>;+ removePublishViewReaction: (viewId: string, commentId: string, reactionType: string) => Promise<void>;+ duplicatePublishView: (params: DuplicatePublishView) => Promise<void>;+}diff --git a/frontend/appflowy_web_app/src/application/services/tauri-services/index.ts b/frontend/appflowy_web_app/src/application/services/tauri-services/index.tsindex c6ad9a50ed..43497c4fb9 100644--- a/frontend/appflowy_web_app/src/application/services/tauri-services/index.ts+++ b/frontend/appflowy_web_app/src/application/services/tauri-services/index.ts@@ -6,7 +6,7 @@ import {UserWorkspaceInfo,Workspace,YDoc,- View, DatabaseRelations,+ View, DatabaseRelations, GetRequestAccessInfoResponse, Subscriptions, SubscriptionPlan,} from '@/application/types';import { GlobalComment, Reaction } from '@/application/comment.type';import { AFService } from '@/application/services/services.type';@@ -234,4 +234,27 @@ export class AFClientService implements AFService {return Promise.reject('Method not implemented');}+ approveRequestAccess (_requestId: string): Promise<void> {+ return Promise.reject('Method not implemented');+ }++ getRequestAccessInfo (_requestId: string): Promise<GetRequestAccessInfoResponse> {+ return Promise.reject('Method not implemented');+ }++ getSubscriptionLink (_workspaceId: string, _plan: string, _interval: string): Promise<string> {+ return Promise.reject('Method not implemented');+ }++ sendRequestAccess (_workspaceId: string, _viewId: string): Promise<void> {+ return Promise.reject('Method not implemented');+ }++ getSubscriptions (): Promise<Subscriptions> {+ return Promise.reject('Method not implemented');+ }++ getActiveSubscription (_workspaceId: string): Promise<SubscriptionPlan[]> {+ return Promise.reject('Method not implemented');+ }}diff --git a/frontend/appflowy_web_app/src/application/types.ts b/frontend/appflowy_web_app/src/application/types.tsindex 75a458bc1f..2b78a88a92 100644--- a/frontend/appflowy_web_app/src/application/types.ts+++ b/frontend/appflowy_web_app/src/application/types.ts@@ -716,6 +716,7 @@ export interface Workspace {name: string;};databaseStorageId: string;+ createdAt: string;}export interface UserWorkspaceInfo {@@ -821,4 +822,46 @@ export enum UIVariant {App = 'app',Recent = 'recent',Favorite = 'favorite',-}\ No newline at end of file+}++export interface AFWebUser {+ uuid: string;+ name: string;+ avatarUrl: string | null;+}++export enum RequestAccessInfoStatus {+ Pending = 0,+ Accepted = 1,+ Rejected = 2,+}++export interface GetRequestAccessInfoResponse {+ request_id: string;+ workspace: Workspace;+ requester: AFWebUser & {+ email: string;+ };+ view: View;+ status: RequestAccessInfoStatus;+}++export enum SubscriptionPlan {+ Free = 'free',+ Pro = 'pro',+ Team = 'team',+}++export enum SubscriptionInterval {+ Month = 'month',+ Year = 'year',+}++export interface Subscription {+ currency: string;+ plan: SubscriptionPlan;+ price_cents: number;+ recurring_interval: SubscriptionInterval;+}++export type Subscriptions = Subscription[];\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/assets/arrow.svg b/frontend/appflowy_web_app/src/assets/arrow.svgnew file mode 100644index 0000000000..7eb718a2be--- /dev/null+++ b/frontend/appflowy_web_app/src/assets/arrow.svg@@ -0,0 +1,12 @@+<svg width="100" height="40" viewBox="0 0 100 40" xmlns="http://www.w3.org/2000/svg">+ <defs>+ <linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="0%">+ <stop offset="0%" style="stop-color:currentColor;stop-opacity:1"/>+ <stop offset="100%" style="stop-color:currentColor;stop-opacity:1"/>+ </linearGradient>+ </defs>++ <path d="M75,20 L90,20 M90,20 L82,13 M90,20 L82,27" fill="none"+ stroke="url(#gradient)" stroke-width="3" stroke-linecap="round"+ stroke-linejoin="round"/>+</svg>\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/app/AppRouter.tsx b/frontend/appflowy_web_app/src/components/app/AppRouter.tsxindex 3f3ed14597..a0fd1b7187 100644--- a/frontend/appflowy_web_app/src/components/app/AppRouter.tsx+++ b/frontend/appflowy_web_app/src/components/app/AppRouter.tsx@@ -1,4 +1,5 @@import { AuthLayout } from '@/components/app/AuthLayout';+import ApproveRequestPage from '@/components/app/landing-pages/ApproveRequestPage';import RecordNotFound from '@/components/error/RecordNotFound';import AppPage from '@/pages/AppPage';import TrashPage from '@/pages/TrashPage';@@ -16,6 +17,7 @@ function AppRouter () {<Route path={':workspaceId/:viewId'} element={<AppPage />} /><Route path={'trash'} element={<TrashPage />} /></Route>+ <Route path={'approve-request'} element={<ApproveRequestPage />} /></Routes>);}diff --git a/frontend/appflowy_web_app/src/components/app/SideBar.tsx b/frontend/appflowy_web_app/src/components/app/SideBar.tsxindex b49e47b073..4723639047 100644--- a/frontend/appflowy_web_app/src/components/app/SideBar.tsx+++ b/frontend/appflowy_web_app/src/components/app/SideBar.tsx@@ -44,7 +44,7 @@ function SideBar ({width={drawerWidth}outline={outline}/>- {rendered && <Suspense><SideBarBottom /></Suspense>}+ {(rendered || !viewId) && <Suspense><SideBarBottom /></Suspense>}</div></OutlineDrawer>diff --git a/frontend/appflowy_web_app/src/components/app/app.hooks.tsx b/frontend/appflowy_web_app/src/components/app/app.hooks.tsxindex 142e29a9d9..6aad3bf254 100644--- a/frontend/appflowy_web_app/src/components/app/app.hooks.tsx+++ b/frontend/appflowy_web_app/src/components/app/app.hooks.tsx@@ -9,12 +9,13 @@ import {View,ViewLayout,} from '@/application/types';-import { filterOutViewsByLayout, findAncestors, findView, findViewByLayout } from '@/components/_shared/outline/utils';-import RequestAccess from '@/components/app/RequestAccess';-import { AFConfigContext, useCurrentUser, useService } from '@/components/main/app.hooks';+import { findAncestors, findView, findViewByLayout } from '@/components/_shared/outline/utils';+import RequestAccess from '@/components/app/landing-pages/RequestAccess';+import { AFConfigContext, useService } from '@/components/main/app.hooks';import { uniqBy } from 'lodash-es';import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';import { useNavigate, useParams } from 'react-router-dom';+import { validate as uuidValidate } from 'uuid';export interface AppContextType {toView: (viewId: string) => Promise<void>;@@ -42,12 +43,15 @@ export const AppContext = createContext<AppContextType | null>(null);export const AppProvider = ({ children }: { children: React.ReactNode }) => {const isAuthenticated = useContext(AFConfigContext)?.isAuthenticated;- const currentUser = useCurrentUser();const params = useParams();- const pathname = window.location.pathname;- const viewId = params.viewId as string;- const currentWorkspaceId = useMemo(() => params.workspaceId || currentUser?.latestWorkspaceId, [params.workspaceId, currentUser]);+ const viewId = useMemo(() => {+ const id = params.viewId;++ if (id && !uuidValidate(id)) return;+ return id;+ }, [params.viewId]);const [userWorkspaceInfo, setUserWorkspaceInfo] = useState<UserWorkspaceInfo | undefined>(undefined);+ const currentWorkspaceId = useMemo(() => params.workspaceId || userWorkspaceInfo?.selectedWorkspace.id, [params.workspaceId, userWorkspaceInfo?.selectedWorkspace.id]);const [workspaceDatabases, setWorkspaceDatabases] = useState<DatabaseRelations | undefined>(undefined);const [outline, setOutline] = useState<View[]>();const [favoriteViews, setFavoriteViews] = useState<View[]>();@@ -72,13 +76,6 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {}}, [isAuthenticated, logout]);- // If the user is logged in but the workspace is not found, log out the user- useEffect(() => {- if (currentUser && !currentWorkspaceId) {- logout();- }- }, [currentWorkspaceId, currentUser, logout]);-useEffect(() => {const rowKeys = createdRowKeys.current;@@ -125,7 +122,6 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {}, []);const toView = useCallback(async (viewId: string, keepSearch?: boolean) => {- localStorage.setItem('last_view_id', viewId);let url = `/app/${currentWorkspaceId}/${viewId}`;if (keepSearch) {@@ -135,32 +131,6 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {navigate(url);}, [currentWorkspaceId, navigate]);- useEffect(() => {- if (!currentWorkspaceId) return;- if (pathname === '/app/trash') return;-- const lastViewId = viewId || localStorage.getItem('last_view_id');- const views = filterOutViewsByLayout(outline || [], ViewLayout.AIChat);-- if (!views || views.length === 0) return;- if (lastViewId) {- const view = findView(views, lastViewId);-- if (view) {- void toView(lastViewId, true);- return;- }- }-- const firstView = findViewByLayout(views, [ViewLayout.Document, ViewLayout.Grid, ViewLayout.Board, ViewLayout.Calendar]);-- if (firstView) {- void toView(firstView.view_id);- } else {- localStorage.removeItem('last_view_id');- }- }, [viewId, currentWorkspaceId, outline, pathname, toView]);-const loadViewMeta = useCallback(async (viewId: string, callback?: (meta: View) => void) => {const view = findView(outline || [], viewId);@@ -230,7 +200,7 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {);const loadUserWorkspaceInfo = useCallback(async () => {- if (!service || !currentWorkspaceId) return;+ if (!service) return;try {const res = await service.getUserWorkspaceInfo();@@ -239,7 +209,7 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {} catch (e) {console.error(e);}- }, [currentWorkspaceId, service]);+ }, [service]);const loadDatabaseViewRelations = useCallback(async (workspaceId: string, databaseStorageId: string) => {if (!service) return;try {@@ -262,14 +232,42 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {}setOutline(res);+ try {++ await service.openWorkspace(workspaceId);+ const path = window.location.pathname.split('/')[2];++ if (path && !uuidValidate(path)) {+ return;+ }++ const lastViewId = localStorage.getItem('last_view_id');++ if (lastViewId && findView(res, lastViewId)) {+ navigate(`/app/${workspaceId}/${lastViewId}`);++ } else {+ const firstView = findViewByLayout(res, [ViewLayout.Document, ViewLayout.Board, ViewLayout.Grid, ViewLayout.Calendar]);++ if (firstView) {+ navigate(`/app/${workspaceId}/${firstView.view_id}`);+ }+ }++ } catch (e) {+ // do nothing+ }+// eslint-disable-next-line} catch (e: any) {console.error('App outline not found');if (USER_NO_ACCESS_CODE.includes(e.code)) {setRequestAccessOpened(true);+ return;}}- }, [service]);++ }, [navigate, service]);const loadFavoriteViews = useCallback(async () => {if (!service || !currentWorkspaceId) return;diff --git a/frontend/appflowy_web_app/src/components/app/header/AppHeader.tsx b/frontend/appflowy_web_app/src/components/app/header/AppHeader.tsxindex fd41c6472d..d18b9487d0 100644--- a/frontend/appflowy_web_app/src/components/app/header/AppHeader.tsx+++ b/frontend/appflowy_web_app/src/components/app/header/AppHeader.tsx@@ -93,6 +93,7 @@ export function AppHeader ({</Suspense>}</div>+</div>);}diff --git a/frontend/appflowy_web_app/src/components/app/header/RightMenu.tsx b/frontend/appflowy_web_app/src/components/app/header/RightMenu.tsxindex 0fc3133694..401b8d35a8 100644--- a/frontend/appflowy_web_app/src/components/app/header/RightMenu.tsx+++ b/frontend/appflowy_web_app/src/components/app/header/RightMenu.tsx@@ -1,6 +1,8 @@+import { NormalModal } from '@/components/_shared/modal';import MoreActions from '@/components/_shared/more-actions/MoreActions';import { openOrDownload } from '@/utils/open_schema';-import { Divider, Tooltip } from '@mui/material';+import { EditOutlined } from '@mui/icons-material';+import { Button, Divider, Tooltip } from '@mui/material';import React from 'react';import { useTranslation } from 'react-i18next';import ShareButton from 'src/components/app/share/ShareButton';@@ -8,11 +10,18 @@ import { ReactComponent as Logo } from '@/assets/logo.svg';function RightMenu () {const { t } = useTranslation();-+ const [comingSoon, setComingSoon] = React.useState(false);+return (<div className={'flex items-center gap-2'}><MoreActions /><ShareButton />+ <Button+ size={'small'} startIcon={<EditOutlined />} variant={'outlined'} color={'inherit'}+ onClick={() => setComingSoon(true)}+ >+ {t('button.editing')}+ </Button><Dividerorientation={'vertical'}className={'mx-2'}@@ -23,6 +32,17 @@ function RightMenu () {<Logo className={'h-6 w-6'} /></button></Tooltip>++ <NormalModal+ onOk={() => setComingSoon(false)} okText={t('button.gotIt')}+ title={+ <div className={'text-left font-semibold'}>{'❤️ Coming Soon'}</div>+ } open={comingSoon} onClose={() => setComingSoon(false)}+ >+ <div className={'text-text-caption'}>+ 🌟 This feature is coming soon. Stay tuned!+ </div>+ </NormalModal></div>);}diff --git a/frontend/appflowy_web_app/src/components/app/landing-pages/ApproveRequestPage.tsx b/frontend/appflowy_web_app/src/components/app/landing-pages/ApproveRequestPage.tsxnew file mode 100644index 0000000000..289b1ccd4e--- /dev/null+++ b/frontend/appflowy_web_app/src/components/app/landing-pages/ApproveRequestPage.tsx@@ -0,0 +1,310 @@+import {+ GetRequestAccessInfoResponse,+ RequestAccessInfoStatus,+ SubscriptionInterval,+ SubscriptionPlan,+} from '@/application/types';+import { ReactComponent as AppflowyLogo } from '@/assets/appflowy.svg';+import { ReactComponent as WarningIcon } from '@/assets/warning.svg';+import { NormalModal } from '@/components/_shared/modal';+import { notify } from '@/components/_shared/notify';+import { getAvatar } from '@/components/_shared/view-icon/utils';+import { AFConfigContext, useService } from '@/components/main/app.hooks';+import { downloadPage } from '@/utils/url';+import { ArrowCircleRightOutlined } from '@mui/icons-material';++import { Avatar, Button, Divider, Paper, Typography } from '@mui/material';+import React, { useCallback, useContext, useEffect, useMemo } from 'react';+import { Trans, useTranslation } from 'react-i18next';+import { useNavigate, useSearchParams } from 'react-router-dom';++const WorkspaceMemberLimitExceededCode = 1027;+const REPEAT_REQUEST_CODE = 1043;++function ApproveRequestPage () {+ const [searchParams] = useSearchParams();+ const [requestInfo, setRequestInfo] = React.useState<GetRequestAccessInfoResponse | null>(null);+ const [currentPlans, setCurrentPlans] = React.useState<SubscriptionPlan[]>([]);+ const isPro = useMemo(() => currentPlans.includes(SubscriptionPlan.Pro), [currentPlans]);+ const requestId = searchParams.get('request_id');+ const service = useService();+ const navigate = useNavigate();+ const { t } = useTranslation();+ const [upgradeModalOpen, setUpgradeModalOpen] = React.useState(false);+ const [errorModalOpen, setErrorModalOpen] = React.useState(false);+ const [alreadyProModalOpen, setAlreadyProModalOpen] = React.useState(false);+ const openLoginModal = useContext(AFConfigContext)?.openLoginModal;+ const [clicked, setClicked] = React.useState(false);++ const loadRequestInfo = useCallback(async () => {+ if (!service || !requestId) return;+ try {+ const requestInfo = await service.getRequestAccessInfo(requestId);++ setRequestInfo(requestInfo);++ if (requestInfo.status === RequestAccessInfoStatus.Accepted) {+ notify.warning(t('approveAccess.repeatApproveError'));+ setClicked(true);+ }++ const plans = await service.getActiveSubscription(requestInfo.workspace.id);++ setCurrentPlans(plans);+ } catch (e) {+ setErrorModalOpen(true);+ }+ }, [t, requestId, service]);++ const handleApprove = useCallback(async () => {+ if (!service || !requestId) return;+ try {+ await service.approveRequestAccess(requestId);+ notify.success(t('approveAccess.approveSuccess'));+ // eslint-disable-next-line+ } catch (e: any) {+ if (e.code === WorkspaceMemberLimitExceededCode) {+ setUpgradeModalOpen(true);+ }++ if (e.code === REPEAT_REQUEST_CODE) {+ notify.error(t('approveAccess.repeatApproveError'));+ return;+ }++ notify.error(t('approveAccess.approveError'));+ }+ }, [requestId, service, t]);++ const handleUpgrade = useCallback(async () => {+ if (!service || !requestInfo) return;+ const workspaceId = requestInfo.workspace.id;++ if (!workspaceId) return;++ if (isPro) {+ setAlreadyProModalOpen(true);+ return;+ }++ const plan = SubscriptionPlan.Pro;++ try {+ const link = await service.getSubscriptionLink(workspaceId, plan, SubscriptionInterval.Month);++ window.open(link, '_blank');+ } catch (e) {+ notify.error('Failed to get subscription link');+ }+ }, [requestInfo, service, isPro]);++ const workspaceAvatar = useMemo(() => {+ if (!requestInfo) return null;+ return getAvatar({+ name: requestInfo.workspace.name,+ icon: requestInfo.workspace.icon,+ });+ }, [requestInfo]);++ const requesterAvatar = useMemo(() => {+ if (!requestInfo) return null;+ return getAvatar({+ name: requestInfo.requester.name,+ icon: requestInfo.requester.avatarUrl || undefined,+ });+ }, [requestInfo]);++ useEffect(() => {+ void loadRequestInfo();+ }, [loadRequestInfo]);++ return (+ <div className={'m-0 flex h-screen w-screen items-center justify-center bg-bg-body p-0'}>+ <div className={'flex flex-col px-6 items-center gap-3 text-center max-w-[660px] mb-10'}>+ <Typography+ variant="h3" className={'mb-[27px] flex items-center gap-4 text-text-title'} gutterBottom+ >+ <>+ <AppflowyLogo className={'w-48'} />+ </>+ </Typography>++ <div className={'mb-[16px] max-md:text-[24px] text-[52px] font-semibold leading-[128%] text-text-title'}>+ {t('approveAccess.title')}+ </div>+ <div className={'flex max-md:flex-col gap-6 items-center justify-center'}>+ <Paper+ onClick={() => {+ window.open(`mailto:${requestInfo?.requester.email}`, '_blank');+ }}+ className={'border transform transition-all border-line-divider hover:scale-110 flex w-[250px] max-md:w-full hover:bg-fill-list-hover cursor-pointer overflow-hidden items-center flex-1 gap-4 p-6'}+ >+ <Avatar className={'border-2 border-text-title w-12 h-12'} {...requesterAvatar} />+ <div className={'flex flex-col flex-1 overflow-hidden items-start gap-2'}>+ <div+ className={'text-fill-default text-left w-full truncate font-semibold text-sm'}+ >@{requestInfo?.requester.name}</div>+ <div+ className={'text-text-caption text-left truncate w-full text-xs'}+ >{requestInfo?.requester.email}</div>+ </div>+ </Paper>+ <ArrowCircleRightOutlined className={'w-12 max-md:rotate-90 max-md:transform h-12 text-text-title'} />+ <Paper+ onClick={() => {+ window.open(`${window.origin}/app/${requestInfo?.workspace?.id}/${requestInfo?.view?.view_id}`, '_blank');+ }}+ className={'border border-line-divider transform transition-all hover:scale-110 flex overflow-hidden flex-1 cursor-pointer hover:bg-fill-list-hover items-center gap-4 p-6'}+ >+ <Avatar variant={'rounded'} className={'border-2 border-text-title w-12 h-12'} {...workspaceAvatar} />+ <div className={'flex flex-col flex-1 overflow-hidden items-start gap-2'}>+ <div+ className={'text-text-title text-left w-full truncate font-semibold text-sm'}+ >{requestInfo?.workspace.name}</div>+ <div className={'text-text-caption text-left w-full truncate text-xs'}>{t('approveAccess.memberCount', {+ count: requestInfo?.workspace.memberCount || 0,+ })}</div>+ </div>+ </Paper>++ </div>++ <div className={'flex items-center mt-4 w-full gap-4 justify-between'}>+ <Button+ onClick={() => {+ void handleApprove();+ setClicked(true);+ }}+ disabled={clicked || !requestInfo}+ className={'flex-1 py-2 px-4 rounded-[8px] text-[20px] font-medium max-md:text-base max-sm:text-[14px] max-md:py-2'}+ variant={'contained'} color={'primary'}+ >+ {t('approveAccess.approveButton')}+ </Button>+ <Button+ onClick={() => {+ navigate('/');+ }}+ className={'flex-1 py-2 px-4 rounded-[8px] max-sm:text-[14px] max-md:text-base text-[20px] font-medium max-md:py-2'}+ variant={'outlined'} color={'inherit'}+ >+ {t('requestAccess.backToHome')}+ </Button>+ </div>+ <Divider className={'w-full mb-3 mt-4'} />+ <div className={'max-w-[400px] flex flex-col text-text-caption'}>+ <span>+ <Trans+ i18nKey="approveAccess.ensurePlanLimit"+ components={{+ upgrade: <span+ onClick={() => setUpgradeModalOpen(true)} className={'underline text-fill-default cursor-pointer'}+ >{t('approveAccess.upgrade')}</span>,+ download: <span+ onClick={() => window.open(downloadPage, '_blank')}+ className={'underline text-fill-default cursor-pointer'}+ >{t('approveAccess.downloadApp')}</span>,+ }}+ />+ </span>+ </div>+ </div>+ <NormalModal+ keepMounted={false}+ title={+ <div className={'text-left font-semibold'}>🎉{t('upgradePlanModal.title')}</div>+ } okText={t('upgradePlanModal.actionButton')} cancelText={t('upgradePlanModal.laterButton')}+ open={upgradeModalOpen}+ onClose={() => setUpgradeModalOpen(false)}+ onOk={handleUpgrade}+ >+ <div className="mt-2 py-3">+ <p className="text-sm text-text-caption">+ 😄+ {t('upgradePlanModal.message')}+ </p>+ </div>+ <div className="mt-4 bg-gray-50 rounded-md p-4">+ <p className="text-sm font-medium text-text-caption">+ {t('upgradePlanModal.upgradeSteps')}+ </p>+ <ul className="mt-2 flex flex-col gap-1.5 list-disc list-inside text-sm text-text-caption">+ <li>{t('upgradePlanModal.step1')}</li>+ <li>{t('upgradePlanModal.step2')}</li>+ <li>{t('upgradePlanModal.step3')}</li>+ </ul>+ </div>+ <p className="mt-4 text-xs text-text-caption flex items-center gap-1">+ <WarningIcon className={'w-4 h-4 text-function-info'} />+ {t('upgradePlanModal.appNote')}{' '}+ <Trans+ i18nKey={'upgradePlanModal.refreshNote'} components={{+ refresh: <span+ className={'underline cursor-pointer text-fill-default'} onClick={() => window.location.reload()}+ >{t('upgradePlanModal.refresh')}</span>,+ }}+ />+ </p>++ </NormalModal>+ <NormalModal+ keepMounted={false}+ onOk={() => setErrorModalOpen(false)}+ title={+ <div className={'text-left font-semibold'}>{t('approveAccess.getRequestInfoError')}</div>+ } open={errorModalOpen} onClose={() => setErrorModalOpen(false)}+ >+ <div className={'flex flex-col'}>+ <span>+ <Trans+ i18nKey="requestAccess.tip"+ components={{+ link: <span+ className={'underline text-fill-default'}+ >{requestInfo?.requester.name}</span>,+ }}+ />+ </span>+ <span>+ <Trans+ i18nKey="requestAccess.mightBe"+ components={{+ login: <span+ onClick={() => openLoginModal?.()} className={'underline text-fill-default cursor-pointer'}+ >{t('signIn.logIn')}</span>,+ }}+ />+ </span>+ </div>+ </NormalModal>+ <NormalModal+ onOk={() => setAlreadyProModalOpen(false)}+ keepMounted={false}+ title={+ <div className={'text-left font-semibold gap-2 flex items-center'}>+ <WarningIcon className={'w-6 h-6 text-function-info'} />+ {t('approveAccess.alreadyProTitle')}+ </div>+ }+ open={alreadyProModalOpen}+ onClose={() => setAlreadyProModalOpen(false)}+ >+ <div className={'flex flex-col'}>+ <span>+ <Trans+ i18nKey={'approveAccess.alreadyProMessage'} components={{+ email: <span+ onClick={() => window.open(`mailto:[email protected]`, '_blank')}+ className={'underline text-fill-default cursor-pointer'}+ >[email protected]</span>,+ }}+ />+ </span>+ </div>+ </NormalModal>+ </div>++ );+}++export default ApproveRequestPage;\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/components/app/RequestAccess.tsx b/frontend/appflowy_web_app/src/components/app/landing-pages/RequestAccess.tsxsimilarity index 74%rename from frontend/appflowy_web_app/src/components/app/RequestAccess.tsxrename to frontend/appflowy_web_app/src/components/app/landing-pages/RequestAccess.tsxindex 08ab677b25..a659304a28 100644--- a/frontend/appflowy_web_app/src/components/app/RequestAccess.tsx+++ b/frontend/appflowy_web_app/src/components/app/landing-pages/RequestAccess.tsx@@ -1,11 +1,15 @@import { NormalModal } from '@/components/_shared/modal';-import { AFConfigContext, useCurrentUser } from '@/components/main/app.hooks';+import { notify } from '@/components/_shared/notify';+import { useAppViewId, useCurrentWorkspaceId } from '@/components/app/app.hooks';+import { AFConfigContext, useCurrentUser, useService } from '@/components/main/app.hooks';+import { TaskAltRounded } from '@mui/icons-material';import { Button, Divider, Typography } from '@mui/material';import React, { useContext } from 'react';import { useTranslation, Trans } from 'react-i18next';import { ReactComponent as AppflowyLogo } from '@/assets/appflowy.svg';import { useNavigate } from 'react-router-dom';-import { ReactComponent as WarningIcon } from '@/assets/warning.svg';++const REPEAT_REQUEST_CODE = 1043;function RequestAccess () {const { t } = useTranslation();@@ -15,6 +19,24 @@ function RequestAccess () {const [clicked, setClicked] = React.useState(false);const navigate = useNavigate();const [modalOpen, setModalOpen] = React.useState(false);+ const service = useService();+ const currentWorkspaceId = useCurrentWorkspaceId();+ const viewId = useAppViewId();+ const handleSendRequest = async () => {+ setModalOpen(false);+ try {+ if (!service || !currentWorkspaceId || !viewId) return;+ await service.sendRequestAccess(currentWorkspaceId, viewId);+ setModalOpen(true);+ // eslint-disable-next-line+ } catch (e: any) {+ if (e.code === REPEAT_REQUEST_CODE) {+ notify.error(t('requestAccess.repeatRequestError'));+ } else {+ notify.error(t('requestAccess.requestError'));+ }+ }+ };return (<div className={'m-0 flex h-screen w-screen items-center justify-center bg-bg-body p-0'}>@@ -35,8 +57,8 @@ function RequestAccess () {<div className={'flex items-center mt-4 w-full gap-4 justify-between'}><ButtononClick={() => {- setModalOpen(true);setClicked(true);+ void handleSendRequest();}}disabled={clicked}className={'flex-1 py-2 px-4 rounded-[8px] text-[20px] font-medium max-md:text-base max-sm:text-[14px] max-md:py-2'}@@ -81,11 +103,12 @@ function RequestAccess () {setModalOpen(false);}} title={<div className={'text-left font-semibold gap-1.5 flex items-center'}>- <WarningIcon className={'w-4 h-4'} />- Coming soon</div>+ <TaskAltRounded className={'text-function-success'} />+ {t('requestAccess.successful')}+ </div>} open={modalOpen} onClose={() => setModalOpen(false)}>- This feature is coming soon. Please contact the owner of this workspace to request access.+ {t('requestAccess.successfulMessage')}</NormalModal></div>);diff --git a/frontend/appflowy_web_app/src/components/app/share/ShareTabs.tsx b/frontend/appflowy_web_app/src/components/app/share/ShareTabs.tsxindex f7f5748e1a..3c94190dde 100644--- a/frontend/appflowy_web_app/src/components/app/share/ShareTabs.tsx+++ b/frontend/appflowy_web_app/src/components/app/share/ShareTabs.tsx@@ -2,10 +2,10 @@ import { useAppView } from '@/components/app/app.hooks';import PublishPanel from '@/components/app/share/PublishPanel';import TemplatePanel from '@/components/app/share/TemplatePanel';import { useCurrentUser } from '@/components/main/app.hooks';+import { PublishedWithChanges } from '@mui/icons-material';import React, { useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';import { ViewTabs, ViewTab, TabPanel } from 'src/components/_shared/tabs/ViewTabs';-import { ReactComponent as Check } from '@/assets/check_circle.svg';import { ReactComponent as Templates } from '@/assets/template.svg';enum TabKey {@@ -23,7 +23,7 @@ function ShareTabs () {return [{value: TabKey.PUBLISH,label: t('shareAction.publish'),- icon: view?.is_published ? <Check className={'w-4 h-4 text-function-success mb-0'} /> : undefined,+ icon: view?.is_published ? <PublishedWithChanges className={'w-4 h-4 text-function-success mb-0'} /> : undefined,Panel: PublishPanel,}, currentUser?.email?.endsWith('appflowy.io') && view?.is_published && {value: TabKey.TEMPLATE,diff --git a/frontend/appflowy_web_app/src/components/app/workspaces/Workspaces.tsx b/frontend/appflowy_web_app/src/components/app/workspaces/Workspaces.tsxindex b93318b83c..260c0d0de6 100644--- a/frontend/appflowy_web_app/src/components/app/workspaces/Workspaces.tsx+++ b/frontend/appflowy_web_app/src/components/app/workspaces/Workspaces.tsx@@ -83,7 +83,7 @@ export function Workspaces () {<div className={'flex items-center gap-1.5 text-text-title overflow-hidden'}><Avatarvariant={'rounded'}- className={`w-6 h-6 rounded-[8px] p-1 ${selectedWorkspace.icon ? 'bg-transparent' : ''}`}+ className={`w-6 h-6 border border-line-divider rounded-[8px] p-1 ${selectedWorkspace.icon ? 'bg-transparent' : ''}`}{...getAvatarProps(selectedWorkspace)}/><div className={'text-text-title flex-1 truncate font-semibold'}>{selectedWorkspace.name}</div>diff --git a/frontend/appflowy_web_app/src/components/global-comment/GlobalComment.hooks.tsx b/frontend/appflowy_web_app/src/components/global-comment/GlobalComment.hooks.tsxindex 41cdefe208..b64869940a 100644--- a/frontend/appflowy_web_app/src/components/global-comment/GlobalComment.hooks.tsx+++ b/frontend/appflowy_web_app/src/components/global-comment/GlobalComment.hooks.tsx@@ -1,5 +1,6 @@-import { CommentUser, GlobalComment, Reaction } from '@/application/comment.type';+import { GlobalComment, Reaction } from '@/application/comment.type';import { PublishContext } from '@/application/publish';+import { AFWebUser } from '@/application/types';import { AFConfigContext } from '@/components/main/app.hooks';import { stringAvatar } from '@/utils/color';import { isFlagEmoji } from '@/utils/emoji';@@ -84,7 +85,7 @@ export function useLoadReactions () {commentId,};} else {- let newReactUsers: CommentUser[] = [];+ let newReactUsers: AFWebUser[] = [];// If the user has not reacted, add the user to the reaction.if (!hasReacted) {diff --git a/frontend/appflowy_web_app/src/pages/AcceptInvitationPage.tsx b/frontend/appflowy_web_app/src/pages/AcceptInvitationPage.tsxindex 0569ea240f..395b72b050 100644--- a/frontend/appflowy_web_app/src/pages/AcceptInvitationPage.tsx+++ b/frontend/appflowy_web_app/src/pages/AcceptInvitationPage.tsx@@ -74,7 +74,12 @@ function AcceptInvitationPage () {<divclassName={'text-text-title px-6 max-md:gap-4 flex flex-col gap-12 h-screen appflowy-scroller w-screen overflow-x-hidden overflow-y-auto items-center bg-bg-base'}>- <div className={'flex w-full max-md:justify-center max-md:h-32 h-20 items-center justify-between sticky'}>+ <div+ onClick={() => {+ navigate('/app');+ }}+ className={'flex w-full cursor-pointer max-md:justify-center max-md:h-32 h-20 items-center justify-between sticky'}+ ><AppflowyLogo className={'w-32 h-12 max-md:w-52'} /></div><div className={'flex w-full max-w-[560px] flex-col items-center gap-6 text-center'}>diff --git a/frontend/appflowy_web_app/src/pages/AppPage.tsx b/frontend/appflowy_web_app/src/pages/AppPage.tsxindex 636b141113..431535b1fc 100644--- a/frontend/appflowy_web_app/src/pages/AppPage.tsx+++ b/frontend/appflowy_web_app/src/pages/AppPage.tsx@@ -128,6 +128,11 @@ function AppPage () {) : skeleton;}, [onRendered, doc, viewMeta, View, toView, loadViewMeta, createRowDoc, appendBreadcrumb, loadView, skeleton]);+ useEffect(() => {+ if (!View || !viewId || !doc) return;+ localStorage.setItem('last_view_id', viewId);+ }, [View, viewId, doc]);+if (!viewId) return null;return (<div className={'relative w-full h-full'}>diff --git a/frontend/appflowy_web_app/src/utils/open_schema.ts b/frontend/appflowy_web_app/src/utils/open_schema.tsindex 69a7ce6c4d..25879338f4 100644--- a/frontend/appflowy_web_app/src/utils/open_schema.ts+++ b/frontend/appflowy_web_app/src/utils/open_schema.ts@@ -6,8 +6,9 @@ interface AppConfig {appScheme: string;universalLink?: string;intentUrl?: string;- downloadUrl: string;+ downloadUrl?: string;timeout?: number;+}export const getOS = (): OS => {@@ -47,14 +48,19 @@ export const openAppOrDownload = (config: AppConfig): void => {const timer = setTimeout(() => {removeIframe(iframe);- redirectToUrl(downloadUrl);+ if (downloadUrl) {+ redirectToUrl(downloadUrl);+ }}, timeout);const handleVisibilityChange = (): void => {if (!document.hidden) {clearTimeout(timer);removeIframe(iframe);- redirectToUrl(downloadUrl);+ if (downloadUrl) {+ redirectToUrl(downloadUrl);+ }+document.removeEventListener('visibilitychange', handleVisibilityChange);}};@@ -89,10 +95,19 @@ export const openAppOrDownload = (config: AppConfig): void => {iframe.onload = () => {clearTimeout(timer);removeIframe(iframe);- redirectToUrl(downloadUrl);+ if (downloadUrl) {+ redirectToUrl(downloadUrl);+ }};};+export function openOnly (schema?: string) {++ return openAppOrDownload({+ appScheme: schema || openAppFlowySchema,+ });+}+export function openOrDownload (schema?: string) {const os = getOS();const downloadUrl = os === 'ios' ? iosDownloadLink : os === 'android' ? androidDownloadLink : desktopDownloadLink;diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.jsonindex 919d24482e..9825ace445 100644--- a/frontend/resources/translations/en.json+++ b/frontend/resources/translations/en.json@@ -383,7 +383,10 @@"previous": "Previous","submit": "Submit","download": "Download",- "backToHome": "Back to Home"+ "backToHome": "Back to Home",+ "viewing": "Viewing",+ "editing": "Editing",+ "gotIt": "Got it"},"label": {"welcome": "Welcome!",@@ -2623,6 +2626,44 @@"requestAccess": "Request access","backToHome": "Back to home","tip": "You're currently logged in as <link/>.",- "mightBe": "You might need to <login/> with a different account."+ "mightBe": "You might need to <login/> with a different account.",+ "successful": "Request sent successfully",+ "successfulMessage": "You will be notified once the owner approves your request.",+ "requestError": "Failed to request access",+ "repeatRequestError": "You've already requested access to this page"+ },+ "approveAccess": {+ "title": "Approve Workspace Join Request",+ "requestSummary": "<user/> requests to join <workspace/> and access <page/>",+ "upgrade": "upgrade",+ "downloadApp": "Download AppFlowy",+ "approveButton": "Approve",+ "approveSuccess": "Approved successfully",+ "approveError": "Failed to approve, ensure the workspace plan limit is not exceeded",+ "getRequestInfoError": "Failed to get request info",+ "memberCount": {+ "zero": "No members",+ "one": "1 member",+ "many": "{count} members",+ "other": "{count} members"+ },+ "alreadyProTitle": "You've reached the workspace plan limit",+ "alreadyProMessage": "Ask them to contact <email/> to unlock more members",+ "repeatApproveError": "You've already approved this request",+ "ensurePlanLimit": "Ensure the workspace plan limit is not exceeded. If the limit is exceeded, consider <upgrade/> the workspace plan or <download/>."+ },+ "upgradePlanModal": {+ "title": "Unlock Premium Features",+ "message": "You're trying to use a premium feature. Upgrade your plan to access all our powerful tools and capabilities!",+ "upgradeSteps": "How to upgrade your plan on AppFlowy:",+ "step1": "1. Go to Settings",+ "step2": "2. Click on 'Plan'",+ "step3": "3. Select 'Change Plan'",+ "appNote": "Note: ",+ "actionButton": "Upgrade Now",+ "downloadLink": "Download App",+ "laterButton": "Maybe Later",+ "refreshNote": "After successful upgrade, click <refresh/> to activate your new features.",+ "refresh": "here"}}