feat: Enhance private link expiration with usage and date limits (#22304)
* init * fix type * fix a re-render infinite loop because of missing readOnly (╯°□°)╯︵ ┻━┻) * further fixes * improvement * fix expiry datetime check * remove unnecessary prismaMock def * revert * fix test * add test ids * remove unit tests in favor of e2e * e2e test update * fix e2e * fix e2e * remove unnecessary change * abstract into injectable object * further improvements * fix label not selecting radio * fix type * code improvement * DI implementation * fix type * fix quick copy * code improvement and a few fixes * further improvements and NITS * further into DI * select * improve link list sorting * prep for easier conflict resolution * add back translations * using useCopy instead * improvement * add index to update salt and have different hash generation * fix private link description * fix increment regression in expiry logic * fixes * address feedback * use extractHostTimezone in event type listing * remove unused function * remove translationBundler * -_- * address feedback * further changes * address more feedback * NIT * address improvement suggestions * use extractHostTimezone * remove console log * pre update * code improvement * further fixes * cleanup * -_-
This commit is contained in:
1 parent
b9c49b4567
commit
66b52bb19f
30 files changed
+1564
-220
No files matched your search
@@ -19,6 +19,7 @@ export default function Type({
|
||||
hashedLink,
|
||||
durationConfig,
|
||||
eventData,
|
||||
useApiV2,
|
||||
}: PageProps) {
|
||||
return (
|
||||
<BookingPageErrorBoundary>
|
||||
@@ -34,6 +35,7 @@ export default function Type({
|
||||
duration={duration}
|
||||
hashedLink={hashedLink}
|
||||
durationConfig={durationConfig}
|
||||
useApiV2={useApiV2}
|
||||
/>
|
||||
</main>
|
||||
</BookingPageErrorBoundary>
|
||||
|
||||
@@ -16,6 +16,8 @@ import CreateEventTypeDialog from "@calcom/features/eventtypes/components/Create
|
||||
import { DuplicateDialog } from "@calcom/features/eventtypes/components/DuplicateDialog";
|
||||
import { InfiniteSkeletonLoader } from "@calcom/features/eventtypes/components/SkeletonLoader";
|
||||
import { APP_NAME, WEBSITE_URL } from "@calcom/lib/constants";
|
||||
import { extractHostTimezone } from "@calcom/lib/hashedLinksUtils";
|
||||
import { filterActiveLinks } from "@calcom/lib/hashedLinksUtils";
|
||||
import { useCopy } from "@calcom/lib/hooks/useCopy";
|
||||
import { useDebounce } from "@calcom/lib/hooks/useDebounce";
|
||||
import { useInViewObserver } from "@calcom/lib/hooks/useInViewObserver";
|
||||
@@ -467,6 +469,14 @@ export const InfiniteEventTypeList = ({
|
||||
return deleteDialogTypeSchedulingType === SchedulingType.MANAGED ? "_managed" : "";
|
||||
};
|
||||
|
||||
const userTimezone = extractHostTimezone({
|
||||
userId: firstItem.userId,
|
||||
teamId: firstItem?.teamId,
|
||||
hosts: firstItem?.hosts,
|
||||
owner: firstItem?.owner,
|
||||
team: firstItem?.team,
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="bg-default border-subtle flex flex-col overflow-hidden rounded-md border">
|
||||
<ul ref={parent} className="divide-subtle !static w-full divide-y" data-testid="event-types">
|
||||
@@ -474,11 +484,17 @@ export const InfiniteEventTypeList = ({
|
||||
return page?.eventTypes?.map((type, index) => {
|
||||
const embedLink = `${group.profile.slug}/${type.slug}`;
|
||||
const calLink = `${bookerUrl}/${embedLink}`;
|
||||
|
||||
const activeHashedLinks = type.hashedLink ? filterActiveLinks(type.hashedLink, userTimezone) : [];
|
||||
|
||||
// Ensure index is within bounds for active links
|
||||
const currentIndex = privateLinkCopyIndices[type.slug] ?? 0;
|
||||
const safeIndex = activeHashedLinks.length > 0 ? currentIndex % activeHashedLinks.length : 0;
|
||||
|
||||
const isPrivateURLEnabled =
|
||||
type.hashedLink && type.hashedLink.length > 0
|
||||
? type.hashedLink[privateLinkCopyIndices[type.slug] ?? 0]?.link
|
||||
: "";
|
||||
activeHashedLinks.length > 0 ? activeHashedLinks[safeIndex]?.link : "";
|
||||
const placeholderHashedLink = `${bookerUrl}/d/${isPrivateURLEnabled}/${type.slug}`;
|
||||
|
||||
const isManagedEventType = type.schedulingType === SchedulingType.MANAGED;
|
||||
const isChildrenManagedEventType =
|
||||
type.metadata?.managedEventConfig !== undefined &&
|
||||
@@ -580,8 +596,8 @@ export const InfiniteEventTypeList = ({
|
||||
copyToClipboard(placeholderHashedLink);
|
||||
setPrivateLinkCopyIndices((prev) => {
|
||||
const prevIndex = prev[type.slug] ?? 0;
|
||||
prev[type.slug] = (prevIndex + 1) % type.hashedLink.length;
|
||||
return prev;
|
||||
const nextIndex = (prevIndex + 1) % activeHashedLinks.length;
|
||||
return { ...prev, [type.slug]: nextIndex };
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user