From fcec796130e5f395fe7543601e057d12d04dcffe Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 16 Dec 2023 11:11:57 -0500 Subject: [PATCH] Quality of life improvements on 'Invite' screen --- app/components/InputSelectRole.tsx | 2 +- app/scenes/Invite.tsx | 136 ++++++++++----------- app/scenes/Settings/Security.tsx | 2 +- shared/i18n/locales/en_US/translation.json | 3 +- 4 files changed, 67 insertions(+), 76 deletions(-) diff --git a/app/components/InputSelectRole.tsx b/app/components/InputSelectRole.tsx index 15aa55114..10d526a81 100644 --- a/app/components/InputSelectRole.tsx +++ b/app/components/InputSelectRole.tsx @@ -18,7 +18,7 @@ const InputSelectRole = ( label={t("Role")} options={[ { - label: t("Member"), + label: t("Editor"), value: "member", }, { diff --git a/app/scenes/Invite.tsx b/app/scenes/Invite.tsx index d078dae53..7ed40dc08 100644 --- a/app/scenes/Invite.tsx +++ b/app/scenes/Invite.tsx @@ -1,5 +1,5 @@ import { observer } from "mobx-react"; -import { LinkIcon, CloseIcon } from "outline-icons"; +import { CloseIcon, CopyIcon } from "outline-icons"; import * as React from "react"; import { useTranslation, Trans } from "react-i18next"; import { Link } from "react-router-dom"; @@ -14,6 +14,7 @@ import Flex from "~/components/Flex"; import Input from "~/components/Input"; import InputSelectRole from "~/components/InputSelectRole"; import NudeButton from "~/components/NudeButton"; +import { ResizingHeightContainer } from "~/components/ResizingHeightContainer"; import Text from "~/components/Text"; import Tooltip from "~/components/Tooltip"; import useCurrentTeam from "~/hooks/useCurrentTeam"; @@ -33,23 +34,12 @@ type InviteRequest = { function Invite({ onSubmit }: Props) { const [isSaving, setIsSaving] = React.useState(false); - const [linkCopied, setLinkCopied] = React.useState(false); const [invites, setInvites] = React.useState([ { email: "", name: "", role: UserRole.Member, }, - { - email: "", - name: "", - role: UserRole.Member, - }, - { - email: "", - name: "", - role: UserRole.Member, - }, ]); const { users } = useStores(); const user = useCurrentUser(); @@ -103,7 +93,7 @@ function Invite({ onSubmit }: Props) { newInvites.push({ email: "", name: "", - role: UserRole.Member, + role: invites[invites.length - 1].role, }); return newInvites; }); @@ -122,7 +112,6 @@ function Invite({ onSubmit }: Props) { ); const handleCopy = React.useCallback(() => { - setLinkCopied(true); toast.success(t("Share link copied")); }, [t]); @@ -137,6 +126,16 @@ function Invite({ onSubmit }: Props) { [] ); + const handleKeyDown = React.useCallback( + (ev: React.KeyboardEvent) => { + if (ev.key === "Enter") { + ev.preventDefault(); + handleAdd(); + } + }, + [handleAdd] + ); + return (
{team.guestSignin ? ( @@ -166,7 +165,7 @@ function Invite({ onSubmit }: Props) { )} {team.subdomain && ( - + -    + /> )} - {invites.map((invite, index) => ( - - handleChange(ev, index)} - placeholder={`example@${predictedDomain}`} - value={invite.email} - required={index === 0} - autoFocus={index === 0} - flex - /> - handleChange(ev, index)} - value={invite.name} - required={!!invite.email} - flex - /> - handleRoleChange(role, index)} - value={invite.role} - labelHidden={index !== 0} - short - /> - {index !== 0 && ( - - - handleRemove(ev, index)}> - - - - - )} - {index === 0 && invites.length > 1 && ( - - - - )} - - ))} + + {invites.map((invite, index) => ( + + handleChange(ev, index)} + placeholder={`example@${predictedDomain}`} + value={invite.email} + required={index === 0} + autoFocus + flex + /> + handleChange(ev, index)} + value={invite.name} + required={!!invite.email} + flex + /> + handleRoleChange(role, index)} + value={invite.role} + labelHidden={index !== 0} + short + /> + {index !== 0 && ( + + + handleRemove(ev, index)}> + + + + + )} + + ))} + {invites.length <= UserValidation.maxInvitesPerRequest ? ( ) : ( @@ -270,12 +265,9 @@ const CopyBlock = styled("div")` `; const Remove = styled("div")` + color: ${s("textTertiary")}; margin-top: 4px; -`; - -const Spacer = styled.div` - width: 24px; - height: 24px; + margin-right: -32px; `; export default observer(Invite); diff --git a/app/scenes/Settings/Security.tsx b/app/scenes/Settings/Security.tsx index c8f185546..7f2a2824d 100644 --- a/app/scenes/Settings/Security.tsx +++ b/app/scenes/Settings/Security.tsx @@ -227,7 +227,7 @@ function Security() { value={data.defaultUserRole} options={[ { - label: t("Member"), + label: t("Editor"), value: "member", }, { diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 81370ec6e..1545db4ee 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -222,7 +222,7 @@ "View only": "View only", "No access": "No access", "Role": "Role", - "Member": "Member", + "Editor": "Editor", "Viewer": "Viewer", "Admin": "Admin", "{{appName}} is available in your language {{optionLabel}}, would you like to change?": "{{appName}} is available in your language {{optionLabel}}, would you like to change?", @@ -637,7 +637,6 @@ "As an admin you can also <2>enable email sign-in.": "As an admin you can also <2>enable email sign-in.", "Want a link to share directly with your team?": "Want a link to share directly with your team?", "Email": "Email", - "Full name": "Full name", "Remove invite": "Remove invite", "Add another": "Add another", "Inviting": "Inviting",