revert: "feat: add membership creation date to Organization Member List table (CAL-5406) (#20595)" (#20978)
This reverts commit d21f7ccbc8.
This commit is contained in:
1 parent
eacd05bf3b
commit
5aaca2b7aa
13 files changed
+14
-152
No files matched your search
@@ -660,7 +660,9 @@ test.describe("Out of office", () => {
|
||||
await page.locator('[data-testid="add-filter-button"]').click();
|
||||
await page.locator('[data-testid="add-filter-item-dateRange"]').click();
|
||||
await expect(
|
||||
page.locator('[data-testid="filter-popover-trigger-dateRange"]', { hasText: "Last 7 Days" }).first()
|
||||
page
|
||||
.locator('[data-testid="filter-popover-trigger-dateRange"] span', { hasText: "Last 7 Days" })
|
||||
.nth(0)
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
|
||||
@@ -3093,9 +3093,6 @@
|
||||
"enable_delegation_credential_description": "Grant Cal.com automatic access to the calendars of all organization members by enabling delegation credential.",
|
||||
"disable_delegation_credential": "Disable Delegation Credential",
|
||||
"disable_delegation_credential_description": "Once delegation credential is disabled, organization members who haven’t connected their calendars will need to do so manually.",
|
||||
"last_active": "Last Active",
|
||||
"member_since": "Member Since",
|
||||
"last_updated": "Last Updated",
|
||||
"salesforce_on_cancel_write_to_event": "On cancelled booking, write to event record instead of deleting event",
|
||||
"salesforce_on_every_cancellation": "On every cancellation",
|
||||
"report_issue": "Report issue",
|
||||
|
||||
@@ -68,8 +68,6 @@ describe("generate Csv for Org Users Table", () => {
|
||||
teams: [],
|
||||
attributes: [],
|
||||
lastActiveAt: "",
|
||||
createdAt: null,
|
||||
updatedAt: null,
|
||||
};
|
||||
|
||||
it("should throw if no headers", () => {
|
||||
|
||||
@@ -30,7 +30,6 @@ export function ActiveFilters<TData>({ table }: ActiveFiltersProps<TData>) {
|
||||
key={column.id}
|
||||
column={column}
|
||||
options={column.dateRangeOptions}
|
||||
showColumnName
|
||||
showClearButton
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useState, useEffect, useCallback } from "react";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { Button, buttonClasses } from "@calcom/ui/components/button";
|
||||
import {
|
||||
Command,
|
||||
@@ -36,21 +35,14 @@ import { useFilterPopoverOpen } from "./useFilterPopoverOpen";
|
||||
type DateRangeFilterProps = {
|
||||
column: Extract<FilterableColumn, { type: ColumnFilterType.DATE_RANGE }>;
|
||||
options?: DateRangeFilterOptions;
|
||||
showColumnName?: boolean;
|
||||
showClearButton?: boolean;
|
||||
};
|
||||
|
||||
export const DateRangeFilter = ({
|
||||
column,
|
||||
options,
|
||||
showColumnName = false,
|
||||
showClearButton = false,
|
||||
}: DateRangeFilterProps) => {
|
||||
export const DateRangeFilter = ({ column, options, showClearButton = false }: DateRangeFilterProps) => {
|
||||
const { open, onOpenChange } = useFilterPopoverOpen(column.id);
|
||||
const filterValue = useFilterValue(column.id, ZDateRangeFilterValue);
|
||||
const { updateFilter, removeFilter } = useDataTable();
|
||||
const range = options?.range ?? "past";
|
||||
const endOfDay = options?.endOfDay ?? false;
|
||||
const forceCustom = range === "custom";
|
||||
const forcePast = range === "past";
|
||||
|
||||
@@ -81,13 +73,13 @@ export const DateRangeFilter = ({
|
||||
type: ColumnFilterType.DATE_RANGE,
|
||||
data: {
|
||||
startDate: startDate.toDate().toISOString(),
|
||||
endDate: (endOfDay ? endDate.endOf("day") : endDate).toDate().toISOString(),
|
||||
endDate: endDate.toDate().toISOString(),
|
||||
preset: preset.value,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
[column.id, endOfDay]
|
||||
[column.id]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -145,10 +137,6 @@ export const DateRangeFilter = ({
|
||||
customButtonLabel = `${format(startDate.toDate(), "LLL dd, y")} - ?`;
|
||||
}
|
||||
|
||||
const selectedValue = isCustomPreset
|
||||
? customButtonLabel
|
||||
: t(selectedPreset.labelKey, selectedPreset.i18nOptions);
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={onOpenChange}>
|
||||
<PopoverTrigger asChild>
|
||||
@@ -158,15 +146,8 @@ export const DateRangeFilter = ({
|
||||
StartIcon="calendar-range"
|
||||
EndIcon="chevron-down"
|
||||
data-testid={`filter-popover-trigger-${column.id}`}>
|
||||
{showColumnName && (
|
||||
<>
|
||||
<span>{column.title}</span>
|
||||
<Badge variant="gray" className="ml-2">
|
||||
{selectedValue}
|
||||
</Badge>
|
||||
</>
|
||||
)}
|
||||
{!showColumnName && <span>{selectedValue}</span>}
|
||||
{!isCustomPreset && <span>{t(selectedPreset.labelKey, selectedPreset.i18nOptions)}</span>}
|
||||
{isCustomPreset && <span>{customButtonLabel}</span>}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="flex w-fit p-0" align="end">
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
isMultiSelectFilterValue,
|
||||
isTextFilterValue,
|
||||
isNumberFilterValue,
|
||||
isDateRangeFilterValue,
|
||||
} from "./utils";
|
||||
|
||||
type MakeWhereClauseProps = {
|
||||
@@ -155,19 +154,6 @@ export function makeWhereClause(props: MakeWhereClauseProps) {
|
||||
default:
|
||||
throw new Error(`Invalid operator for number filter: ${operator}`);
|
||||
}
|
||||
} else if (isDateRangeFilterValue(filterValue)) {
|
||||
const { startDate, endDate } = filterValue.data;
|
||||
if (!startDate || !endDate) {
|
||||
throw new Error(`Invalid date range filter: ${JSON.stringify({ columnName, startDate, endDate })}`);
|
||||
}
|
||||
|
||||
return {
|
||||
[columnName]: {
|
||||
...jsonPathObj,
|
||||
gte: startDate,
|
||||
lte: endDate,
|
||||
},
|
||||
};
|
||||
}
|
||||
throw new Error(`Invalid filter type: ${JSON.stringify({ columnName, filterValue })}`);
|
||||
}
|
||||
@@ -113,8 +113,7 @@ export const ZFilterValue = z.union([
|
||||
]);
|
||||
|
||||
export type DateRangeFilterOptions = {
|
||||
range?: "past" | "custom";
|
||||
endOfDay?: boolean;
|
||||
range: "past" | "custom";
|
||||
};
|
||||
|
||||
export type TextFilterOptions = {
|
||||
|
||||
@@ -131,7 +131,7 @@ function UserListTableContent({ oAuthClientId }: PlatformManagedUsersTableProps)
|
||||
enableHiding: false,
|
||||
size: 200,
|
||||
header: () => {
|
||||
return t("managed_users");
|
||||
return `Managed Users`;
|
||||
},
|
||||
cell: ({ row }) => {
|
||||
if (isPending) {
|
||||
@@ -166,7 +166,7 @@ function UserListTableContent({ oAuthClientId }: PlatformManagedUsersTableProps)
|
||||
{
|
||||
id: "role",
|
||||
accessorFn: (data) => data.role,
|
||||
header: t("role"),
|
||||
header: "Role",
|
||||
size: 100,
|
||||
cell: ({ row, table }) => {
|
||||
if (isPending) {
|
||||
@@ -188,7 +188,7 @@ function UserListTableContent({ oAuthClientId }: PlatformManagedUsersTableProps)
|
||||
{
|
||||
id: "teams",
|
||||
accessorFn: (data) => data.teams.map((team) => team.name),
|
||||
header: t("teams"),
|
||||
header: "Teams",
|
||||
size: 140,
|
||||
cell: ({ row, table }) => {
|
||||
if (isPending) {
|
||||
|
||||
@@ -74,8 +74,6 @@ const initalColumnVisibility = {
|
||||
member: true,
|
||||
role: true,
|
||||
teams: true,
|
||||
createdAt: false,
|
||||
updatedAt: false,
|
||||
actions: true,
|
||||
};
|
||||
|
||||
@@ -368,52 +366,9 @@ function UserListTableContent() {
|
||||
...generateAttributeColumns(),
|
||||
{
|
||||
id: "lastActiveAt",
|
||||
accessorKey: "lastActiveAt",
|
||||
header: t("last_active"),
|
||||
enableSorting: false,
|
||||
enableColumnFilter: true,
|
||||
meta: {
|
||||
filter: {
|
||||
type: ColumnFilterType.DATE_RANGE,
|
||||
dateRangeOptions: {
|
||||
endOfDay: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
header: "Last Active",
|
||||
cell: ({ row }) => <div>{row.original.lastActiveAt}</div>,
|
||||
},
|
||||
{
|
||||
id: "createdAt",
|
||||
accessorKey: "createdAt",
|
||||
header: t("member_since"),
|
||||
enableSorting: false,
|
||||
enableColumnFilter: true,
|
||||
meta: {
|
||||
filter: {
|
||||
type: ColumnFilterType.DATE_RANGE,
|
||||
dateRangeOptions: {
|
||||
endOfDay: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
cell: ({ row }) => <div>{row.original.createdAt || ""}</div>,
|
||||
},
|
||||
{
|
||||
id: "updatedAt",
|
||||
accessorKey: "updatedAt",
|
||||
header: t("last_updated"),
|
||||
enableSorting: false,
|
||||
enableColumnFilter: true,
|
||||
meta: {
|
||||
filter: {
|
||||
type: ColumnFilterType.DATE_RANGE,
|
||||
dateRangeOptions: {
|
||||
endOfDay: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
cell: ({ row }) => <div>{row.original.updatedAt || ""}</div>,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
enableHiding: false,
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
ALTER TABLE "Membership" ADD COLUMN "createdAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "updatedAt" TIMESTAMP(3);
|
||||
@@ -546,8 +546,6 @@ model Membership {
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
disableImpersonation Boolean @default(false)
|
||||
AttributeToUser AttributeToUser[]
|
||||
createdAt DateTime? @default(now())
|
||||
updatedAt DateTime? @updatedAt
|
||||
|
||||
@@unique([userId, teamId])
|
||||
@@index([teamId])
|
||||
|
||||
@@ -188,8 +188,6 @@ async function main() {
|
||||
userId: member.user.id,
|
||||
role: member.role,
|
||||
accepted: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
})),
|
||||
});
|
||||
}
|
||||
@@ -426,8 +424,6 @@ async function createPerformanceData() {
|
||||
userId: memberId.id,
|
||||
role: "MEMBER",
|
||||
accepted: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
})),
|
||||
});
|
||||
|
||||
|
||||
@@ -83,15 +83,6 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
const teamFilter = filters.find((filter) => filter.id === "teams") as
|
||||
| TypedColumnFilter<ColumnFilterType.MULTI_SELECT>
|
||||
| undefined;
|
||||
const lastActiveAtFilter = filters.find((filter) => filter.id === "lastActiveAt") as
|
||||
| TypedColumnFilter<ColumnFilterType.DATE_RANGE>
|
||||
| undefined;
|
||||
const createdAtFilter = filters.find((filter) => filter.id === "createdAt") as
|
||||
| TypedColumnFilter<ColumnFilterType.DATE_RANGE>
|
||||
| undefined;
|
||||
const updatedAtFilter = filters.find((filter) => filter.id === "updatedAt") as
|
||||
| TypedColumnFilter<ColumnFilterType.DATE_RANGE>
|
||||
| undefined;
|
||||
|
||||
const whereClause: Prisma.MembershipWhereInput = {
|
||||
user: {
|
||||
@@ -106,11 +97,6 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
},
|
||||
},
|
||||
}),
|
||||
...(lastActiveAtFilter &&
|
||||
makeWhereClause({
|
||||
columnName: "lastActiveAt",
|
||||
filterValue: lastActiveAtFilter.value,
|
||||
})),
|
||||
},
|
||||
teamId: organizationId,
|
||||
...(searchTerm && {
|
||||
@@ -126,27 +112,10 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
columnName: "role",
|
||||
filterValue: roleFilter.value,
|
||||
})),
|
||||
...(createdAtFilter &&
|
||||
makeWhereClause({
|
||||
columnName: "createdAt",
|
||||
filterValue: createdAtFilter.value,
|
||||
})),
|
||||
...(updatedAtFilter &&
|
||||
makeWhereClause({
|
||||
columnName: "updatedAt",
|
||||
filterValue: updatedAtFilter.value,
|
||||
})),
|
||||
};
|
||||
|
||||
const attributeFilters: Prisma.MembershipWhereInput["AttributeToUser"][] = filters
|
||||
.filter(
|
||||
(filter) =>
|
||||
filter.id !== "role" &&
|
||||
filter.id !== "teams" &&
|
||||
filter.id !== "lastActiveAt" &&
|
||||
filter.id !== "createdAt" &&
|
||||
filter.id !== "updatedAt"
|
||||
)
|
||||
.filter((filter) => filter.id !== "role" && filter.id !== "teams")
|
||||
.map((filter) => {
|
||||
if (filter.value.type === ColumnFilterType.MULTI_SELECT && isAllString(filter.value.data)) {
|
||||
const attributeOptionValues: string[] = [];
|
||||
@@ -194,8 +163,6 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
id: true,
|
||||
role: true,
|
||||
accepted: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
user: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -282,20 +249,6 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
.format(membership.user.lastActiveAt)
|
||||
.toLowerCase()
|
||||
: null,
|
||||
createdAt: membership.createdAt
|
||||
? new Intl.DateTimeFormat(ctx.user.locale, {
|
||||
timeZone: ctx.user.timeZone,
|
||||
})
|
||||
.format(membership.createdAt)
|
||||
.toLowerCase()
|
||||
: null,
|
||||
updatedAt: membership.updatedAt
|
||||
? new Intl.DateTimeFormat(ctx.user.locale, {
|
||||
timeZone: ctx.user.timeZone,
|
||||
})
|
||||
.format(membership.updatedAt)
|
||||
.toLowerCase()
|
||||
: null,
|
||||
avatarUrl: user.avatarUrl,
|
||||
teams: user.teams
|
||||
.filter((team) => team.team.id !== organizationId) // In this context we dont want to return the org team
|
||||
|
||||
Reference in new issue
Block a user