-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): impl team workspace (#8920)
AF-1738 AF-1735 AF-1731 AF-1721 AF-1717 AF-1736 AF-1727 AF-1719 AF-1877 UI for team workspaces : - add upgrade to team & successful upgrade page ( `/upgrade-to-team` & `/upgrade-success/team`) - update team plans on pricing page ( settings —> pricing plans ) - update reaching the usage/member limit modal - update invite member modal - update member CRUD options
- Loading branch information
Showing
77 changed files
with
3,788 additions
and
1,044 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+218 KB
...ontend/component/src/components/affine-other-page-layout/assets/dot-bg.dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+257 KB
...ntend/component/src/components/affine-other-page-layout/assets/dot-bg.light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+366 KB
...nd/component/src/components/affine-other-page-layout/assets/other-page.dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+374 KB
...d/component/src/components/affine-other-page-layout/assets/other-page.light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/frontend/component/src/components/member-components/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './accept-invite-page'; | ||
export * from './invite-modal'; | ||
export * from './invite-team-modal'; | ||
export * from './member-limit-modal'; | ||
export * from './pagination'; |
49 changes: 49 additions & 0 deletions
49
...es/frontend/component/src/components/member-components/invite-team-modal/email-invite.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useI18n } from '@affine/i18n'; | ||
import { cssVar } from '@toeverything/theme'; | ||
|
||
import Input from '../../../ui/input'; | ||
import * as styles from './styles.css'; | ||
|
||
export const EmailInvite = ({ | ||
inviteEmail, | ||
setInviteEmail, | ||
handleConfirm, | ||
importCSV, | ||
isMutating, | ||
isValidEmail, | ||
}: { | ||
inviteEmail: string; | ||
setInviteEmail: (value: string) => void; | ||
handleConfirm: () => void; | ||
isMutating: boolean; | ||
isValidEmail: boolean; | ||
importCSV: React.ReactNode; | ||
}) => { | ||
const t = useI18n(); | ||
return ( | ||
<> | ||
<div className={styles.modalSubTitle}> | ||
{t['com.affine.payment.member.team.invite.email-invite']()} | ||
</div> | ||
<div> | ||
<Input | ||
inputStyle={{ fontSize: cssVar('fontXs') }} | ||
disabled={isMutating} | ||
placeholder={t[ | ||
'com.affine.payment.member.team.invite.email-placeholder' | ||
]()} | ||
value={inviteEmail} | ||
onChange={setInviteEmail} | ||
onEnter={handleConfirm} | ||
size="large" | ||
/> | ||
{!isValidEmail ? ( | ||
<div className={styles.errorHint}> | ||
{t['com.affine.auth.sign.email.error']()} | ||
</div> | ||
) : null} | ||
</div> | ||
<div>{importCSV}</div> | ||
</> | ||
); | ||
}; |
117 changes: 117 additions & 0 deletions
117
packages/frontend/component/src/components/member-components/invite-team-modal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { emailRegex } from '@affine/component/auth-components'; | ||
import type { WorkspaceInviteLinkExpireTime } from '@affine/graphql'; | ||
import { useI18n } from '@affine/i18n'; | ||
import { useCallback, useEffect, useState } from 'react'; | ||
|
||
import { ConfirmModal } from '../../../ui/modal'; | ||
import { notify } from '../../../ui/notification'; | ||
import { type InviteMethodType, ModalContent } from './modal-content'; | ||
import * as styles from './styles.css'; | ||
|
||
export interface InviteTeamMemberModalProps { | ||
open: boolean; | ||
setOpen: (value: boolean) => void; | ||
onConfirm: (params: { emails: string[] }) => void; | ||
isMutating: boolean; | ||
copyTextToClipboard: (text: string) => Promise<boolean>; | ||
onGenerateInviteLink: ( | ||
expireTime: WorkspaceInviteLinkExpireTime | ||
) => Promise<string>; | ||
onRevokeInviteLink: () => Promise<boolean>; | ||
importCSV: React.ReactNode; | ||
} | ||
|
||
const parseEmailString = (emailString: string): string[] => { | ||
return emailString | ||
.split(',') | ||
.map(email => email.trim()) | ||
.filter(email => email.length > 0); | ||
}; | ||
|
||
export const InviteTeamMemberModal = ({ | ||
open, | ||
setOpen, | ||
onConfirm, | ||
isMutating, | ||
copyTextToClipboard, | ||
onGenerateInviteLink, | ||
onRevokeInviteLink, | ||
importCSV, | ||
}: InviteTeamMemberModalProps) => { | ||
const t = useI18n(); | ||
const [inviteEmails, setInviteEmails] = useState(''); | ||
const [isValidEmail, setIsValidEmail] = useState(true); | ||
const [inviteMethod, setInviteMethod] = useState<InviteMethodType>('email'); | ||
|
||
const handleConfirm = useCallback(() => { | ||
if (inviteMethod === 'link') { | ||
setOpen(false); | ||
return; | ||
} | ||
const inviteEmailsArray = parseEmailString(inviteEmails); | ||
const invalidEmail = inviteEmailsArray.find( | ||
email => !emailRegex.test(email) | ||
); | ||
if (invalidEmail) { | ||
setIsValidEmail(false); | ||
return; | ||
} | ||
setIsValidEmail(true); | ||
|
||
onConfirm({ | ||
emails: inviteEmailsArray, | ||
}); | ||
notify.success({ | ||
title: t['com.affine.payment.member.team.invite.notify.title'](), | ||
message: t['com.affine.payment.member.team.invite.notify.message'](), | ||
}); | ||
}, [inviteEmails, inviteMethod, onConfirm, setOpen, t]); | ||
|
||
useEffect(() => { | ||
if (!open) { | ||
setInviteEmails(''); | ||
setIsValidEmail(true); | ||
} | ||
}, [open]); | ||
|
||
return ( | ||
<ConfirmModal | ||
width={480} | ||
open={open} | ||
onOpenChange={setOpen} | ||
title={t['com.affine.payment.member.team.invite.title']()} | ||
cancelText={t['com.affine.inviteModal.button.cancel']()} | ||
contentOptions={{ | ||
['data-testid' as string]: 'invite-modal', | ||
style: { | ||
padding: '20px 24px', | ||
}, | ||
}} | ||
confirmText={ | ||
inviteMethod === 'email' | ||
? t['com.affine.payment.member.team.invite.send-invites']() | ||
: t['com.affine.payment.member.team.invite.done']() | ||
} | ||
confirmButtonOptions={{ | ||
loading: isMutating, | ||
variant: 'primary', | ||
}} | ||
onConfirm={handleConfirm} | ||
childrenContentClassName={styles.contentStyle} | ||
> | ||
<ModalContent | ||
inviteEmail={inviteEmails} | ||
setInviteEmail={setInviteEmails} | ||
handleConfirm={handleConfirm} | ||
isMutating={isMutating} | ||
isValidEmail={isValidEmail} | ||
inviteMethod={inviteMethod} | ||
importCSV={importCSV} | ||
onInviteMethodChange={setInviteMethod} | ||
copyTextToClipboard={copyTextToClipboard} | ||
onGenerateInviteLink={onGenerateInviteLink} | ||
onRevokeInviteLink={onRevokeInviteLink} | ||
/> | ||
</ConfirmModal> | ||
); | ||
}; |
Oops, something went wrong.