Skip to content

Commit

Permalink
Fix: Make invitation URL copyable (#4108)
Browse files Browse the repository at this point in the history
  • Loading branch information
svenaas committed Feb 28, 2024
1 parent 68e7a36 commit c762b6d
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions frontend/components/organization/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ function successNotification(message) {
});
}

function showInviteAlert(email, link) {
// eslint-disable-next-line no-alert
return window.alert(`${email} does not have cloud.gov account yet, please send them the following link to get started:\n\n${link}`);
}

function showRemoveConfirm(member, org) {
// eslint-disable-next-line no-alert
return window.confirm(`Are you sure you want to remove ${member.User.UAAIdentity.email} from ${org.name}?`);
Expand All @@ -39,6 +34,11 @@ function reducer(state, { type, payload }) {
isLoading: false,
...payload,
};
case 'invitationSent':
return {
...state,
mostRecentlyAddedUser: payload,
};
case 'addMember':
return {
...state,
Expand All @@ -64,6 +64,7 @@ const initialState = {
members: [],
org: null,
roles: [],
mostRecentlyAddedUser: null,
};

function Edit({ actions }) {
Expand All @@ -84,7 +85,7 @@ function Edit({ actions }) {
}, ['1']);

const {
isLoading, members, org, roles,
isLoading, members, org, roles, mostRecentlyAddedUser,
} = state;

if (isLoading) {
Expand All @@ -108,6 +109,23 @@ function Edit({ actions }) {

const getSandboxMsg = days => <span>{sandboxMsg(days)}</span>;

function getInvitationSentMsg() {
return (
<span>
The new member must create a Pages account to accept the invitation to this organization.
They may check their inbox at
{' '}
{mostRecentlyAddedUser.email}
{' '}
for an invitation by email or visit
{' '}
<a href="{mostRecentlyAddedUser.link}">{mostRecentlyAddedUser.link}</a>
{' '}
to get started.
</span>
);
}

return (
<div>
<div className="page-header usa-grid-full">
Expand All @@ -125,6 +143,15 @@ function Edit({ actions }) {
alertRole={false}
/>
)}
{ mostRecentlyAddedUser
&& (
<AlertBanner
status="info"
header="Sent invitation to create a Pages account"
message={getInvitationSentMsg()}
alertRole={false}
/>
)}
<h3>Members</h3>
<AddUserForm
className="well"
Expand All @@ -136,13 +163,12 @@ function Edit({ actions }) {
({ member, invite: { email, link } }, reduxDispatch) => {
dispatch({ type: 'addMember', payload: member });
if (link) {
showInviteAlert(email, link);
dispatch({ type: 'invitationSent', payload: { email, link } });
}
reduxDispatch(successNotification('Successfully added user.'));
}
}
/>

<table className="usa-table-borderless log-table log-table__site-builds org-member-table table-full-width">
<thead>
<tr>
Expand Down

0 comments on commit c762b6d

Please sign in to comment.