fix: Remove/Disable Duplicate button in Read Only mode of an event-type (#15511)

* fix: Remove/Disable Duplicate button in Read Only mode of an event-type

* fix: use readonly variable

* fix: hiding for smaller devices

* update test cases

---------

Co-authored-by: Keith Williams <[email protected]>
Co-authored-by: unknown <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-07-03 15:23:22 +05:30
1 parent 4f76d4468e
commit 8cd9285cc6
2 files changed
+42 -41

No files matched your search

@@ -164,7 +164,7 @@ const Item = ({
</small> </small>
) : null} ) : null}
{readOnly && ( {readOnly && (
<Badge variant="gray" className="ml-2"> <Badge variant="gray" className="ml-2" data-testid="readonly-badge">
{t("readonly")} {t("readonly")}
</Badge> </Badge>
)} )}
@@ -195,7 +195,7 @@ const Item = ({
</small> </small>
) : null} ) : null}
{readOnly && ( {readOnly && (
<Badge variant="gray" className="ml-2"> <Badge variant="gray" className="ml-2" data-testid="readonly-badge">
{t("readonly")} {t("readonly")}
</Badge> </Badge>
)} )}
@@ -513,7 +513,8 @@ export const EventTypeList = ({
</DropdownItem> </DropdownItem>
</DropdownMenuItem> </DropdownMenuItem>
)} )}
{!isManagedEventType && !isChildrenManagedEventType && ( {/* readonly is only set when we are on a team - if we are on a user event type null will be the value. */}
{!readOnly && !isManagedEventType && !isChildrenManagedEventType && (
<> <>
<DropdownMenuItem className="outline-none"> <DropdownMenuItem className="outline-none">
<DropdownItem <DropdownItem
@@ -541,25 +542,24 @@ export const EventTypeList = ({
</DropdownMenuItem> </DropdownMenuItem>
)} )}
{/* readonly is only set when we are on a team - if we are on a user event type null will be the value. */} {/* readonly is only set when we are on a team - if we are on a user event type null will be the value. */}
{(group.metadata?.readOnly === false || group.metadata.readOnly === null) && {!readOnly && !isChildrenManagedEventType && (
!isChildrenManagedEventType && ( <>
<> <DropdownMenuSeparator />
<DropdownMenuSeparator /> <DropdownMenuItem>
<DropdownMenuItem> <DropdownItem
<DropdownItem color="destructive"
color="destructive" onClick={() => {
onClick={() => { setDeleteDialogOpen(true);
setDeleteDialogOpen(true); setDeleteDialogTypeId(type.id);
setDeleteDialogTypeId(type.id); setDeleteDialogSchedulingType(type.schedulingType);
setDeleteDialogSchedulingType(type.schedulingType); }}
}} StartIcon="trash"
StartIcon="trash" className="w-full rounded-none">
className="w-full rounded-none"> {t("delete")}
{t("delete")} </DropdownItem>
</DropdownItem> </DropdownMenuItem>
</DropdownMenuItem> </>
</> )}
)}
</DropdownMenuContent> </DropdownMenuContent>
</Dropdown> </Dropdown>
</ButtonGroup> </ButtonGroup>
@@ -629,7 +629,7 @@ export const EventTypeList = ({
</DropdownItem> </DropdownItem>
</DropdownMenuItem> </DropdownMenuItem>
)} )}
{!isManagedEventType && !isChildrenManagedEventType && ( {!readOnly && !isManagedEventType && !isChildrenManagedEventType && (
<DropdownMenuItem className="outline-none"> <DropdownMenuItem className="outline-none">
<DropdownItem <DropdownItem
onClick={() => openDuplicateModal(type, group)} onClick={() => openDuplicateModal(type, group)}
@@ -640,24 +640,23 @@ export const EventTypeList = ({
</DropdownMenuItem> </DropdownMenuItem>
)} )}
{/* readonly is only set when we are on a team - if we are on a user event type null will be the value. */} {/* readonly is only set when we are on a team - if we are on a user event type null will be the value. */}
{(group.metadata?.readOnly === false || group.metadata.readOnly === null) && {!readOnly && !isChildrenManagedEventType && (
!isChildrenManagedEventType && ( <>
<> <DropdownMenuItem className="outline-none">
<DropdownMenuItem className="outline-none"> <DropdownItem
<DropdownItem color="destructive"
color="destructive" onClick={() => {
onClick={() => { setDeleteDialogOpen(true);
setDeleteDialogOpen(true); setDeleteDialogTypeId(type.id);
setDeleteDialogTypeId(type.id); setDeleteDialogSchedulingType(type.schedulingType);
setDeleteDialogSchedulingType(type.schedulingType); }}
}} StartIcon="trash"
StartIcon="trash" className="w-full rounded-none">
className="w-full rounded-none"> {t("delete")}
{t("delete")} </DropdownItem>
</DropdownItem> </DropdownMenuItem>
</DropdownMenuItem> </>
</> )}
)}
<DropdownMenuSeparator /> <DropdownMenuSeparator />
{!isManagedEventType && ( {!isManagedEventType && (
<div className="hover:bg-subtle flex h-9 cursor-pointer flex-row items-center justify-between px-4 py-2"> <div className="hover:bg-subtle flex h-9 cursor-pointer flex-row items-center justify-between px-4 py-2">
+2
View File
@@ -91,6 +91,8 @@ testBothFutureAndLegacyRoutes.describe("Event Types tests", () => {
const firstFullSlug = await page.locator(`[data-testid=event-type-slug-${eventTypeId}]`).innerText(); const firstFullSlug = await page.locator(`[data-testid=event-type-slug-${eventTypeId}]`).innerText();
const firstSlug = firstFullSlug.split("/")[2]; const firstSlug = firstFullSlug.split("/")[2];
await expect(page.locator("[data-testid=readonly-badge]")).toBeHidden();
await page.click(`[data-testid=event-type-options-${eventTypeId}]`); await page.click(`[data-testid=event-type-options-${eventTypeId}]`);
await page.click(`[data-testid=event-type-duplicate-${eventTypeId}]`); await page.click(`[data-testid=event-type-duplicate-${eventTypeId}]`);
// Wait for the dialog to appear so we can get the URL // Wait for the dialog to appear so we can get the URL