mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-09-17 12:37:02 +00:00
fix: share link issues (#6465)
This commit is contained in:
parent
6b585ef9a7
commit
9c05788834
@ -0,0 +1,46 @@
|
|||||||
|
import NormalModal from '@/components/_shared/modal/NormalModal';
|
||||||
|
import { AFConfigContext, useCurrentUser } from '@/components/main/app.hooks';
|
||||||
|
import React, { useContext } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { ReactComponent as ErrorIcon } from '@/assets/error.svg';
|
||||||
|
|
||||||
|
function ChangeAccount ({
|
||||||
|
setModalOpened,
|
||||||
|
modalOpened,
|
||||||
|
}: {
|
||||||
|
setModalOpened: (opened: boolean) => void;
|
||||||
|
modalOpened: boolean;
|
||||||
|
|
||||||
|
}) {
|
||||||
|
const currentUser = useCurrentUser();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const openLoginModal = useContext(AFConfigContext)?.openLoginModal;
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<NormalModal
|
||||||
|
onCancel={() => {
|
||||||
|
setModalOpened(false);
|
||||||
|
navigate('/');
|
||||||
|
}}
|
||||||
|
closable={false}
|
||||||
|
cancelText={t('invitation.errorModal.close')}
|
||||||
|
onOk={openLoginModal}
|
||||||
|
okText={t('invitation.errorModal.changeAccount')}
|
||||||
|
title={<div className={'text-left font-bold flex gap-2 items-center'}>
|
||||||
|
<ErrorIcon className={'w-5 h-5 text-function-error'} />
|
||||||
|
{t('invitation.errorModal.title')}
|
||||||
|
</div>}
|
||||||
|
open={modalOpened}
|
||||||
|
>
|
||||||
|
<div className={'text-text-title flex flex-col text-sm gap-1 whitespace-pre-wrap break-words'}>
|
||||||
|
{t('invitation.errorModal.description', {
|
||||||
|
email: currentUser?.email,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</NormalModal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ChangeAccount;
|
@ -13,7 +13,7 @@ export function ViewIcon ({ layout, size }: { layout: ViewLayout; size: number |
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (size === 'medium') {
|
if (size === 'medium') {
|
||||||
return 'h-5 w-5';
|
return 'h-4.5 w-4.5';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size === 'large') {
|
if (size === 'large') {
|
||||||
|
@ -235,12 +235,17 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
await service.openWorkspace(workspaceId);
|
await service.openWorkspace(workspaceId);
|
||||||
const path = window.location.pathname.split('/')[2];
|
const wId = window.location.pathname.split('/')[2];
|
||||||
|
const pageId = window.location.pathname.split('/')[3];
|
||||||
|
|
||||||
if (path && !uuidValidate(path)) {
|
// skip /app/trash and /app/*other-pages
|
||||||
|
if (wId && !uuidValidate(wId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skip /app/:workspaceId/:pageId
|
||||||
|
if (pageId && uuidValidate(pageId) && wId && uuidValidate(wId) && wId === workspaceId) return;
|
||||||
|
|
||||||
const lastViewId = localStorage.getItem('last_view_id');
|
const lastViewId = localStorage.getItem('last_view_id');
|
||||||
|
|
||||||
if (lastViewId && findView(res, lastViewId)) {
|
if (lastViewId && findView(res, lastViewId)) {
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
import { ReactComponent as AppflowyLogo } from '@/assets/appflowy.svg';
|
import { ReactComponent as AppflowyLogo } from '@/assets/appflowy.svg';
|
||||||
import { ReactComponent as WarningIcon } from '@/assets/warning.svg';
|
import { ReactComponent as WarningIcon } from '@/assets/warning.svg';
|
||||||
import { NormalModal } from '@/components/_shared/modal';
|
import { NormalModal } from '@/components/_shared/modal';
|
||||||
|
import ChangeAccount from '@/components/_shared/modal/ChangeAccount';
|
||||||
import { notify } from '@/components/_shared/notify';
|
import { notify } from '@/components/_shared/notify';
|
||||||
import { getAvatar } from '@/components/_shared/view-icon/utils';
|
import { getAvatar } from '@/components/_shared/view-icon/utils';
|
||||||
import { AFConfigContext, useService } from '@/components/main/app.hooks';
|
import { AFConfigContext, useService } from '@/components/main/app.hooks';
|
||||||
@ -23,6 +24,8 @@ const REPEAT_REQUEST_CODE = 1043;
|
|||||||
|
|
||||||
function ApproveRequestPage () {
|
function ApproveRequestPage () {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
|
const isAuthenticated = useContext(AFConfigContext)?.isAuthenticated;
|
||||||
|
|
||||||
const [requestInfo, setRequestInfo] = React.useState<GetRequestAccessInfoResponse | null>(null);
|
const [requestInfo, setRequestInfo] = React.useState<GetRequestAccessInfoResponse | null>(null);
|
||||||
const [currentPlans, setCurrentPlans] = React.useState<SubscriptionPlan[]>([]);
|
const [currentPlans, setCurrentPlans] = React.useState<SubscriptionPlan[]>([]);
|
||||||
const isPro = useMemo(() => currentPlans.includes(SubscriptionPlan.Pro), [currentPlans]);
|
const isPro = useMemo(() => currentPlans.includes(SubscriptionPlan.Pro), [currentPlans]);
|
||||||
@ -33,9 +36,13 @@ function ApproveRequestPage () {
|
|||||||
const [upgradeModalOpen, setUpgradeModalOpen] = React.useState(false);
|
const [upgradeModalOpen, setUpgradeModalOpen] = React.useState(false);
|
||||||
const [errorModalOpen, setErrorModalOpen] = React.useState(false);
|
const [errorModalOpen, setErrorModalOpen] = React.useState(false);
|
||||||
const [alreadyProModalOpen, setAlreadyProModalOpen] = React.useState(false);
|
const [alreadyProModalOpen, setAlreadyProModalOpen] = React.useState(false);
|
||||||
const openLoginModal = useContext(AFConfigContext)?.openLoginModal;
|
|
||||||
const [clicked, setClicked] = React.useState(false);
|
const [clicked, setClicked] = React.useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isAuthenticated) {
|
||||||
|
navigate('/login?redirectTo=' + encodeURIComponent(window.location.href));
|
||||||
|
}
|
||||||
|
}, [isAuthenticated, navigate]);
|
||||||
const loadRequestInfo = useCallback(async () => {
|
const loadRequestInfo = useCallback(async () => {
|
||||||
if (!service || !requestId) return;
|
if (!service || !requestId) return;
|
||||||
try {
|
try {
|
||||||
@ -248,36 +255,7 @@ function ApproveRequestPage () {
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
</NormalModal>
|
</NormalModal>
|
||||||
<NormalModal
|
<ChangeAccount setModalOpened={setErrorModalOpen} modalOpened={errorModalOpen} />
|
||||||
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
|
<NormalModal
|
||||||
onOk={() => setAlreadyProModalOpen(false)}
|
onOk={() => setAlreadyProModalOpen(false)}
|
||||||
keepMounted={false}
|
keepMounted={false}
|
||||||
|
@ -97,6 +97,9 @@ function RequestAccess () {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<NormalModal
|
<NormalModal
|
||||||
|
cancelButtonProps={{
|
||||||
|
className: 'hidden',
|
||||||
|
}}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
setModalOpen(false);
|
setModalOpen(false);
|
||||||
}} onOk={() => {
|
}} onOk={() => {
|
||||||
@ -106,7 +109,8 @@ function RequestAccess () {
|
|||||||
<TaskAltRounded className={'text-function-success'} />
|
<TaskAltRounded className={'text-function-success'} />
|
||||||
{t('requestAccess.successful')}
|
{t('requestAccess.successful')}
|
||||||
</div>
|
</div>
|
||||||
} open={modalOpen} onClose={() => setModalOpen(false)}
|
} open={modalOpen}
|
||||||
|
onClose={() => setModalOpen(false)}
|
||||||
>
|
>
|
||||||
{t('requestAccess.successfulMessage')}
|
{t('requestAccess.successfulMessage')}
|
||||||
</NormalModal>
|
</NormalModal>
|
||||||
|
@ -37,7 +37,7 @@ function ToggleIcon ({ block, className }: { block: ToggleListNode; className: s
|
|||||||
onMouseDown={(e) => {
|
onMouseDown={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}}
|
}}
|
||||||
className={`${className} ${readOnly ? '' : 'cursor-pointer'} pr-1 text-xl hover:text-fill-default`}
|
className={`${className} ${readOnly ? '' : 'cursor-pointer hover:text-fill-default'} pr-1 text-xl`}
|
||||||
>
|
>
|
||||||
{collapsed ? <ExpandSvg className={'-rotate-90 transform'} /> : <ExpandSvg />}
|
{collapsed ? <ExpandSvg className={'-rotate-90 transform'} /> : <ExpandSvg />}
|
||||||
</span>
|
</span>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { Invitation } from '@/application/types';
|
import { Invitation } from '@/application/types';
|
||||||
import { ReactComponent as AppflowyLogo } from '@/assets/appflowy.svg';
|
import { ReactComponent as AppflowyLogo } from '@/assets/appflowy.svg';
|
||||||
import { ReactComponent as ErrorIcon } from '@/assets/error.svg';
|
import ChangeAccount from '@/components/_shared/modal/ChangeAccount';
|
||||||
import { NormalModal } from '@/components/_shared/modal';
|
|
||||||
import { notify } from '@/components/_shared/notify';
|
import { notify } from '@/components/_shared/notify';
|
||||||
import { getAvatar } from '@/components/_shared/view-icon/utils';
|
import { getAvatar } from '@/components/_shared/view-icon/utils';
|
||||||
import { AFConfigContext, useCurrentUser, useService } from '@/components/main/app.hooks';
|
import { AFConfigContext, useCurrentUser, useService } from '@/components/main/app.hooks';
|
||||||
@ -17,7 +16,6 @@ function AcceptInvitationPage () {
|
|||||||
const isAuthenticated = useContext(AFConfigContext)?.isAuthenticated;
|
const isAuthenticated = useContext(AFConfigContext)?.isAuthenticated;
|
||||||
const currentUser = useCurrentUser();
|
const currentUser = useCurrentUser();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const openLoginModal = useContext(AFConfigContext)?.openLoginModal;
|
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const invitationId = searchParams.get('invited_id');
|
const invitationId = searchParams.get('invited_id');
|
||||||
const service = useService();
|
const service = useService();
|
||||||
@ -156,27 +154,7 @@ function AcceptInvitationPage () {
|
|||||||
{t('invitation.joinWorkspace')}
|
{t('invitation.joinWorkspace')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<NormalModal
|
<ChangeAccount setModalOpened={setModalOpened} modalOpened={modalOpened} />
|
||||||
onCancel={() => {
|
|
||||||
setModalOpened(false);
|
|
||||||
navigate('/');
|
|
||||||
}}
|
|
||||||
closable={false}
|
|
||||||
cancelText={t('invitation.errorModal.close')}
|
|
||||||
onOk={openLoginModal}
|
|
||||||
okText={t('invitation.errorModal.changeAccount')}
|
|
||||||
title={<div className={'text-left font-bold flex gap-2 items-center'}>
|
|
||||||
<ErrorIcon className={'w-5 h-5 text-function-error'} />
|
|
||||||
{t('invitation.errorModal.title')}
|
|
||||||
</div>}
|
|
||||||
open={modalOpened}
|
|
||||||
>
|
|
||||||
<div className={'text-text-title flex flex-col text-sm gap-1 whitespace-pre-wrap break-words'}>
|
|
||||||
{t('invitation.errorModal.description', {
|
|
||||||
email: currentUser?.email,
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</NormalModal>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user