mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 15:28:25 +00:00
Show invite code to send if no email service in modal
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
import { useState } from 'react';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import { plans } from 'public/data/frequentConstants';
|
import { plans } from 'public/data/frequentConstants';
|
||||||
|
|
||||||
@@ -51,6 +52,8 @@ export const OrgSettingsPage = () => {
|
|||||||
const addIncidentContact = useAddIncidentContact();
|
const addIncidentContact = useAddIncidentContact();
|
||||||
const removeIncidentContact = useDeleteIncidentContact();
|
const removeIncidentContact = useDeleteIncidentContact();
|
||||||
|
|
||||||
|
const [completeInviteLink, setcompleteInviteLink] = useState<string|undefined>("")
|
||||||
|
|
||||||
const isMoreUsersNotAllowed =
|
const isMoreUsersNotAllowed =
|
||||||
(orgUsers || []).length >= 5 &&
|
(orgUsers || []).length >= 5 &&
|
||||||
subscriptionPlan === plans.starter &&
|
subscriptionPlan === plans.starter &&
|
||||||
@@ -96,11 +99,16 @@ export const OrgSettingsPage = () => {
|
|||||||
if (!currentOrg?._id) return;
|
if (!currentOrg?._id) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await addUserToOrg.mutateAsync({ organizationId: currentOrg?._id, inviteeEmail: email });
|
const {data} = await addUserToOrg.mutateAsync({ organizationId: currentOrg?._id, inviteeEmail: email });
|
||||||
|
setcompleteInviteLink(data?.completeInviteLink)
|
||||||
|
|
||||||
|
// only show this notification when email is configured. A [completeInviteLink] will not be sent if smtp is configured
|
||||||
|
if (!data.completeInviteLink){
|
||||||
createNotification({
|
createNotification({
|
||||||
text: 'Successfully invited user to the organization.',
|
text: 'Successfully invited user to the organization.',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
createNotification({
|
createNotification({
|
||||||
@@ -247,6 +255,8 @@ export const OrgSettingsPage = () => {
|
|||||||
onRemoveMember={onRemoveUserOrgMembership}
|
onRemoveMember={onRemoveUserOrgMembership}
|
||||||
onRoleChange={onUpdateOrgUserRole}
|
onRoleChange={onUpdateOrgUserRole}
|
||||||
onGrantAccess={onGrantUserAccess}
|
onGrantAccess={onGrantUserAccess}
|
||||||
|
completeInviteLink={completeInviteLink}
|
||||||
|
setCompleteInviteLink={setcompleteInviteLink}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-6 mt-2 flex w-full flex-col items-start rounded-md bg-white/5 px-6 pt-6 pb-6">
|
<div className="mb-6 mt-2 flex w-full flex-col items-start rounded-md bg-white/5 px-6 pt-6 pb-6">
|
||||||
|
|||||||
+44
-13
@@ -1,7 +1,7 @@
|
|||||||
import { useMemo, useState } from 'react';
|
import { Dispatch, SetStateAction, useMemo, useState } from 'react';
|
||||||
import { Controller, useForm } from 'react-hook-form';
|
import { Controller, useForm } from 'react-hook-form';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { faMagnifyingGlass, faPlus, faTrash, faUsers } from '@fortawesome/free-solid-svg-icons';
|
import { faCheck, faCopy, faMagnifyingGlass, faPlus, faTrash, faUsers } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { yupResolver } from '@hookform/resolvers/yup';
|
import { yupResolver } from '@hookform/resolvers/yup';
|
||||||
import * as yup from 'yup';
|
import * as yup from 'yup';
|
||||||
@@ -43,6 +43,8 @@ type Props = {
|
|||||||
onGrantAccess: (userId: string, publicKey: string) => Promise<void>;
|
onGrantAccess: (userId: string, publicKey: string) => Promise<void>;
|
||||||
// the current user id to block remove org button
|
// the current user id to block remove org button
|
||||||
userId: string;
|
userId: string;
|
||||||
|
completeInviteLink: string | undefined,
|
||||||
|
setCompleteInviteLink: Dispatch<SetStateAction<string | undefined>>
|
||||||
};
|
};
|
||||||
|
|
||||||
const addMemberFormSchema = yup.object({
|
const addMemberFormSchema = yup.object({
|
||||||
@@ -61,7 +63,9 @@ export const OrgMembersTable = ({
|
|||||||
onGrantAccess,
|
onGrantAccess,
|
||||||
onRoleChange,
|
onRoleChange,
|
||||||
userId,
|
userId,
|
||||||
isLoading
|
isLoading,
|
||||||
|
completeInviteLink,
|
||||||
|
setCompleteInviteLink
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [searchMemberFilter, setSearchMemberFilter] = useState('');
|
const [searchMemberFilter, setSearchMemberFilter] = useState('');
|
||||||
@@ -82,7 +86,10 @@ export const OrgMembersTable = ({
|
|||||||
|
|
||||||
const onAddMember = async ({ email }: TAddMemberForm) => {
|
const onAddMember = async ({ email }: TAddMemberForm) => {
|
||||||
await onInviteMember(email);
|
await onInviteMember(email);
|
||||||
|
if (serverDetails?.emailConfigured){
|
||||||
handlePopUpClose('addMember');
|
handlePopUpClose('addMember');
|
||||||
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,6 +116,11 @@ export const OrgMembersTable = ({
|
|||||||
[members, searchMemberFilter]
|
[members, searchMemberFilter]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const copyTokenToClipboard = () => {
|
||||||
|
navigator.clipboard.writeText(completeInviteLink as string);
|
||||||
|
// setIsTokenCopied.on();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<div className="mb-4 flex">
|
<div className="mb-4 flex">
|
||||||
@@ -124,15 +136,16 @@ export const OrgMembersTable = ({
|
|||||||
<Button
|
<Button
|
||||||
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (serverDetails?.emailConfigured){
|
// if (serverDetails?.emailConfigured){
|
||||||
if (isMoreUserNotAllowed) {
|
if (isMoreUserNotAllowed) {
|
||||||
handlePopUpOpen('upgradePlan');
|
handlePopUpOpen('upgradePlan');
|
||||||
} else {
|
} else {
|
||||||
|
reset();
|
||||||
handlePopUpOpen('addMember');
|
handlePopUpOpen('addMember');
|
||||||
}
|
}
|
||||||
} else {
|
// } else {
|
||||||
handlePopUpOpen('setUpEmail');
|
// handlePopUpOpen('setUpEmail');
|
||||||
}
|
// }
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Add Member
|
Add Member
|
||||||
@@ -180,7 +193,7 @@ export const OrgMembersTable = ({
|
|||||||
<SelectItem value="member">member</SelectItem>
|
<SelectItem value="member">member</SelectItem>
|
||||||
</Select>
|
</Select>
|
||||||
)}
|
)}
|
||||||
{(status === 'invited' || status === 'verified') && (
|
{((status === 'invited' || status === 'verified') && serverDetails?.emailConfigured) && (
|
||||||
<Button className='w-40' colorSchema="secondary" onClick={() => onInviteMember(email)}>
|
<Button className='w-40' colorSchema="secondary" onClick={() => onInviteMember(email)}>
|
||||||
Resend Invite
|
Resend Invite
|
||||||
</Button>
|
</Button>
|
||||||
@@ -241,20 +254,23 @@ export const OrgMembersTable = ({
|
|||||||
isOpen={popUp?.addMember?.isOpen}
|
isOpen={popUp?.addMember?.isOpen}
|
||||||
onOpenChange={(isOpen) => {
|
onOpenChange={(isOpen) => {
|
||||||
handlePopUpToggle('addMember', isOpen);
|
handlePopUpToggle('addMember', isOpen);
|
||||||
reset();
|
setCompleteInviteLink(undefined)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title={`Invite others to ${orgName}`}
|
title={`Invite others to ${orgName}`}
|
||||||
subTitle={
|
subTitle={
|
||||||
<>
|
<div>
|
||||||
|
{!completeInviteLink && <div>
|
||||||
An invite is specific to an email address and expires after 1 day.
|
An invite is specific to an email address and expires after 1 day.
|
||||||
<br />
|
<br />
|
||||||
For security reasons, you will need to separately add members to projects.
|
For security reasons, you will need to separately add members to projects.
|
||||||
</>
|
</div>}
|
||||||
|
{completeInviteLink && "This Infisical instance does not have a email provider setup. Please share this invite link with the invitee manually"}
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<form onSubmit={handleSubmit(onAddMember)}>
|
{!completeInviteLink && <form onSubmit={handleSubmit(onAddMember)} >
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
@@ -283,7 +299,22 @@ export const OrgMembersTable = ({
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>}
|
||||||
|
{
|
||||||
|
completeInviteLink &&
|
||||||
|
<div className="mt-2 mb-3 mr-2 flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
|
||||||
|
<p className="mr-4 break-all">{completeInviteLink}</p>
|
||||||
|
<IconButton
|
||||||
|
ariaLabel="copy icon"
|
||||||
|
colorSchema="secondary"
|
||||||
|
className="group relative"
|
||||||
|
onClick={copyTokenToClipboard}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={false ? faCheck : faCopy} />
|
||||||
|
<span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">click to copy</span>
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</Modal>
|
</Modal>
|
||||||
<DeleteActionModal
|
<DeleteActionModal
|
||||||
|
|||||||
Reference in New Issue
Block a user