feat: Send emails to potentially affected Organization Members on disabling delegation credential (#21276)
* mvp * Improve UI * wip * self-review * self-review --------- Co-authored-by: Omar López <[email protected]>
This commit is contained in:
1 parent
d84d80eea6
commit
4fcf4081d0
15 files changed
+292
-9
No files matched your search
@@ -113,7 +113,7 @@ Step 6: Enable Delegation Credential(To Be taken By Cal.com organization Owner/A
|
||||
|
||||
Cron jobs ensure that for each and every member of the organization that has Delegation Credential enabled, corresponding SelectedCalendar records are there. These crons currently run every 5 minutes and process a batch in one run to avoid overloading the DB and third party CalendarAPIs, look at vercel.json for the up-to-date schedule.
|
||||
|
||||
- `credentials` cron job creates Delegation User Credential records for all the members of the organization who don't have Delegation User Credentials yet. It also ensures that on disabling Delegation Credential, the Delegation User Credentials are deleted which automatically deletes the SelectedCalendars through DB cascade.
|
||||
- `credentials` cron job creates Delegation User Credential records for all the members of the organization who don't have Delegation User Credentials yet. It also ensures that on disabling Delegation Credential, the Delegation User Credentials are deleted which automatically deletes the SelectedCalendar and CalendarCache records through DB cascade.
|
||||
- `selected-calendars` cron job creates SelectedCalendar records for all the Delegation User Credentials of the organization who don't have Selected Calendars yet.
|
||||
|
||||
### Important Points
|
||||
@@ -134,7 +134,8 @@ Cron jobs ensure that for each and every member of the organization that has Del
|
||||
|
||||
### Impact of disabling Delegation Credential
|
||||
|
||||
Disabling effectively stops generating in-memory delegation user credentials. So, any members who haven't manually connected their Calendar and thus their calendar connections were working only because of Delegation Credential, would have their calendar connections broken.
|
||||
- It immediately stops generating in-memory delegation user credentials. So, any members who haven't manually connected their Calendar and thus their calendar connections were working only because of Delegation Credential, would have their calendar connections broken.
|
||||
- Credentials cron job would delete the Delegation User Credentials which will then cascade to delete the SelectedCalendar and CalendarCache records.
|
||||
|
||||
### Impact of enabling Delegation Credential
|
||||
- Existing calendar-cache records are re-used as we identify the relevant record by userId and key of CalendarCache record.
|
||||
|
||||
@@ -458,6 +458,41 @@ function DelegationCredentialList() {
|
||||
);
|
||||
}
|
||||
|
||||
function MembersThatWillBeAffectedOnDisablingDelegationCredential({
|
||||
delegationCredentialId,
|
||||
}: {
|
||||
delegationCredentialId: string;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const { data: affectedMembers, isLoading: isLoadingAffectedMembers } =
|
||||
trpc.viewer.delegationCredential.getAffectedMembersForDisable.useQuery({ id: delegationCredentialId });
|
||||
|
||||
return (
|
||||
<div className="mt-4">
|
||||
<strong>{t("members_affected_by_disabling_delegation_credential")}</strong>
|
||||
{isLoadingAffectedMembers ? (
|
||||
<div>{t("loading")}</div>
|
||||
) : affectedMembers?.length ? (
|
||||
<>
|
||||
<ul className="list-disc space-y-1 p-1 pl-5 sm:w-80">
|
||||
{affectedMembers.slice(0, 5).map((m) => (
|
||||
<li className="text-muted text-sm" key={m.email}>
|
||||
{m.name ? `${m.name} (${m.email})` : m.email}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{affectedMembers.length > 5 && (
|
||||
<p className="mt-2 text-sm text-gray-500">
|
||||
{t("and_count_more", { count: affectedMembers.length - 5 })}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<div className="mt-2">{t("no_members_affected_by_disabling_delegation_credential")}</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const ToggleDelegationDialog = ({
|
||||
delegation,
|
||||
onConfirm,
|
||||
@@ -468,27 +503,34 @@ const ToggleDelegationDialog = ({
|
||||
onClose: () => void;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
|
||||
if (!delegation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isDisablingDelegation = delegation.enabled;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
name="toggle-delegation"
|
||||
open={!!delegation}
|
||||
onOpenChange={(open) => (!open ? onClose() : undefined)}>
|
||||
<ConfirmationDialogContent
|
||||
title={t(delegation.enabled ? "disable_delegation_credential" : "enable_delegation_credential")}
|
||||
confirmBtnText={t(delegation.enabled ? "disable" : "enable")}
|
||||
title={t(isDisablingDelegation ? "disable_delegation_credential" : "enable_delegation_credential")}
|
||||
confirmBtnText={t(isDisablingDelegation ? "disable" : "enable")}
|
||||
cancelBtnText={t("cancel")}
|
||||
variety={delegation.enabled ? "danger" : "success"}
|
||||
variety={isDisablingDelegation ? "danger" : "success"}
|
||||
onConfirm={onConfirm}>
|
||||
<p className="mt-5">
|
||||
{t(
|
||||
delegation.enabled
|
||||
isDisablingDelegation
|
||||
? "disable_delegation_credential_description"
|
||||
: "enable_delegation_credential_description"
|
||||
)}
|
||||
</p>
|
||||
{isDisablingDelegation && (
|
||||
<MembersThatWillBeAffectedOnDisablingDelegationCredential delegationCredentialId={delegation.id} />
|
||||
)}
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user