Skip to content

Commit 7659997

Browse files
[WEB-5594] feat: enhance authentication method handling in member columns and introduce new login labels (#8260)
1 parent 316856a commit 7659997

File tree

10 files changed

+43
-10
lines changed

10 files changed

+43
-10
lines changed

apps/web/ce/components/workspace/settings/useMemberColumns.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from "react";
22
import { useParams } from "next/navigation";
3-
import { EUserPermissions, EUserPermissionsLevel } from "@plane/constants";
3+
import { EUserPermissions, EUserPermissionsLevel, LOGIN_MEDIUM_LABELS } from "@plane/constants";
44
import { useTranslation } from "@plane/i18n";
55
import { renderFormattedDate } from "@plane/utils";
66
import { MemberHeaderColumn } from "@/components/project/member-header-column";
@@ -29,6 +29,7 @@ export const useMemberColumns = () => {
2929
const isAdmin = allowPermissions([EUserPermissions.ADMIN], EUserPermissionsLevel.WORKSPACE);
3030

3131
const isSuspended = (rowData: RowData) => rowData.is_active === false;
32+
3233
// handlers
3334
const handleDisplayFilterUpdate = (filterUpdates: Partial<IMemberFilters>) => {
3435
updateFilters(filterUpdates);
@@ -49,7 +50,7 @@ export const useMemberColumns = () => {
4950
tdRender: (rowData: RowData) => (
5051
<NameColumn
5152
rowData={rowData}
52-
workspaceSlug={workspaceSlug as string}
53+
workspaceSlug={workspaceSlug}
5354
isAdmin={isAdmin}
5455
currentUser={currentUser}
5556
setRemoveMemberModal={setRemoveMemberModal}
@@ -101,16 +102,18 @@ export const useMemberColumns = () => {
101102
handleDisplayFilterUpdate={handleDisplayFilterUpdate}
102103
/>
103104
),
104-
tdRender: (rowData: RowData) => <AccountTypeColumn rowData={rowData} workspaceSlug={workspaceSlug as string} />,
105+
tdRender: (rowData: RowData) => <AccountTypeColumn rowData={rowData} workspaceSlug={workspaceSlug} />,
105106
},
106107

107108
{
108109
key: "Authentication",
109110
content: t("workspace_settings.settings.members.details.authentication"),
110-
tdRender: (rowData: RowData) =>
111-
isSuspended(rowData) ? null : (
112-
<div className="capitalize">{rowData.member.last_login_medium?.replace("-", " ")}</div>
113-
),
111+
tdRender: (rowData: RowData) => {
112+
if (isSuspended(rowData)) return null;
113+
const loginMedium = rowData.member.last_login_medium;
114+
if (!loginMedium) return null;
115+
return <div>{LOGIN_MEDIUM_LABELS[loginMedium]}</div>;
116+
},
114117
},
115118

116119
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { TCoreLoginMediums } from "@plane/types";
2+
3+
export const CORE_LOGIN_MEDIUM_LABELS: Record<TCoreLoginMediums, string> = {
4+
email: "Email",
5+
"magic-code": "Magic code",
6+
github: "GitHub",
7+
gitlab: "GitLab",
8+
google: "Google",
9+
gitea: "Gitea",
10+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { TExtendedLoginMediums } from "@plane/types";
2+
3+
export const EXTENDED_LOGIN_MEDIUM_LABELS: Record<TExtendedLoginMediums, string> = {};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import type { TLoginMediums } from "@plane/types";
2+
import { CORE_LOGIN_MEDIUM_LABELS } from "./core";
3+
import { EXTENDED_LOGIN_MEDIUM_LABELS } from "./extended";
4+
15
export enum E_PASSWORD_STRENGTH {
26
EMPTY = "empty",
37
LENGTH_NOT_VALID = "length_not_valid",
@@ -156,3 +160,8 @@ export enum EAuthErrorCodes {
156160
// Rate limit
157161
RATE_LIMIT_EXCEEDED = "5900",
158162
}
163+
164+
export const LOGIN_MEDIUM_LABELS: Record<TLoginMediums, string> = {
165+
...CORE_LOGIN_MEDIUM_LABELS,
166+
...EXTENDED_LOGIN_MEDIUM_LABELS,
167+
} as const;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type TExtendedLoginMediums = never;

packages/types/src/instance/auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ export type TGetBaseAuthenticationModeProps = {
4343
updateConfig: (key: TInstanceAuthenticationMethodKeys, value: string) => void;
4444
resolvedTheme: string | undefined;
4545
};
46+
47+
export type TCoreLoginMediums = "email" | "magic-code" | "github" | "gitlab" | "google" | "gitea";

packages/types/src/instance/base.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import type {
55
TInstanceImageConfigurationKeys,
66
TInstanceAuthenticationKeys,
77
TInstanceWorkspaceConfigurationKeys,
8+
TCoreLoginMediums,
89
} from "./";
10+
import type { TExtendedLoginMediums } from "./auth-ee";
911

1012
export interface IInstanceInfo {
1113
instance: IInstance;
@@ -98,3 +100,5 @@ export interface IInstanceConfiguration {
98100
export type IFormattedInstanceConfiguration = {
99101
[key in TInstanceConfigurationKeys]: string;
100102
};
103+
104+
export type TLoginMediums = TCoreLoginMediums | TExtendedLoginMediums;

packages/types/src/instance/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from "./ai";
22
export * from "./auth";
3+
export * from "./auth-ee";
34
export * from "./base";
45
export * from "./email";
56
export * from "./image";

packages/types/src/users.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { TUserPermissions } from "./enums";
22
import type { IIssueActivity, TIssuePriorities, TStateGroups } from ".";
3+
import type { TLoginMediums } from "./instance";
34

45
/**
56
* @description The start of the week for the user
@@ -15,8 +16,6 @@ export enum EStartOfTheWeek {
1516
SATURDAY = 6,
1617
}
1718

18-
export type TLoginMediums = "email" | "magic-code" | "github" | "gitlab" | "google";
19-
2019
export interface IUserLite {
2120
avatar_url: string;
2221
display_name: string;

packages/types/src/workspace.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ICycle } from "./cycle";
33
import type { TUserPermissions } from "./enums";
44
import type { TProjectMembership } from "./project";
55
import type { IUser, IUserLite } from "./users";
6+
import type { TLoginMediums } from "./instance";
67
import type { IWorkspaceViewProps } from "./view-props";
78

89
export enum EUserWorkspaceRoles {
@@ -82,7 +83,7 @@ export interface IWorkspaceMember {
8283
last_name?: string;
8384
joining_date?: string;
8485
display_name?: string;
85-
last_login_medium?: string;
86+
last_login_medium?: TLoginMediums;
8687
is_active?: boolean;
8788
}
8889

0 commit comments

Comments
 (0)