feat: add membership creation date to Organization Member List table (CAL-5406) (#20595)
* feat: add membership creation date to Organization Member List table (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * feat: add migration for membership creation date (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * feat: make createdAt and updatedAt nullable (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * feat: add updatedAt column to Organization Member List table (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * fix: use type assertion to access createdAt and updatedAt fields (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * fix: display N/A for null date values (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * fix: use proper type assertions for createdAt and updatedAt fields (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * fix: add createdAt and updatedAt to UserTableUser mock in test (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * feat: add PostgreSQL trigger for membership timestamps (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * fix: use empty string instead of N/A and add translations for column headers (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * add i18n text * clean up type issue * feat: add translation keys for column headers (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * disable sort * remove duplicated i18n texts * feat: add filters for lastActiveAt, createdAt, and updatedAt (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * support date range filter * fix date range for end date * hide columns by default * revert wrong change * add missing selects * fix e2e test * fix: remove PostgreSQL trigger and let application handle timestamps (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * feat: add application-level timestamp handling for Membership model (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * add more timestamp handling * refactor: use Prisma's built-in decorators for Membership timestamps (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * refactor: remove application-level timestamp handling in favor of Prisma decorators (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * refactor: remove more application-level timestamp handling in favor of Prisma decorators (CAL-5406) Co-Authored-By: [email protected] <[email protected]> * fix e2e test --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]> Co-authored-by: Eunjae Lee <[email protected]>
This commit is contained in:
13 files changed
+152
-14
No files matched your search
@@ -83,6 +83,15 @@ 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: {
|
||||
@@ -97,6 +106,11 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
},
|
||||
},
|
||||
}),
|
||||
...(lastActiveAtFilter &&
|
||||
makeWhereClause({
|
||||
columnName: "lastActiveAt",
|
||||
filterValue: lastActiveAtFilter.value,
|
||||
})),
|
||||
},
|
||||
teamId: organizationId,
|
||||
...(searchTerm && {
|
||||
@@ -112,10 +126,27 @@ 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(
|
||||
(filter) =>
|
||||
filter.id !== "role" &&
|
||||
filter.id !== "teams" &&
|
||||
filter.id !== "lastActiveAt" &&
|
||||
filter.id !== "createdAt" &&
|
||||
filter.id !== "updatedAt"
|
||||
)
|
||||
.map((filter) => {
|
||||
if (filter.value.type === ColumnFilterType.MULTI_SELECT && isAllString(filter.value.data)) {
|
||||
const attributeOptionValues: string[] = [];
|
||||
@@ -163,6 +194,8 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
id: true,
|
||||
role: true,
|
||||
accepted: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
user: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -249,6 +282,20 @@ 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