Skip to content

Commit 818ab0b

Browse files
authored
Merge pull request #486 from shuhaib-aot/Feature/user-name-change
Changes : user role from token and user name from user details
2 parents 6c14a51 + 5a5609a commit 818ab0b

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

forms-flow-nav/src/constants/constants.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,21 @@ export const OPERATIONS = {
187187
export const PageSizes = [5, 10, 25, 50, 100, "all"];
188188

189189
// draft config
190-
const DRAFT_POLLING_RATE_FROM_ENV =
191-
(window._env_ && window._env_.REACT_APP_DRAFT_POLLING_RATE)
190+
const DRAFT_POLLING_RATE_FROM_ENV = window._env_?.REACT_APP_DRAFT_POLLING_RATE;
192191

193192
export const DRAFT_POLLING_RATE = DRAFT_POLLING_RATE_FROM_ENV
194193
? Number(DRAFT_POLLING_RATE_FROM_ENV)
195194
: null;
196-
const DRAFT_ENABLED_VARIABLE =
197-
(window._env_ && window._env_.REACT_APP_DRAFT_ENABLED) ||
198-
false;
195+
const DRAFT_ENABLED_VARIABLE = window._env_?.REACT_APP_DRAFT_ENABLED ||false;
199196
export const DRAFT_ENABLED =
200197
DRAFT_ENABLED_VARIABLE === "true" || DRAFT_ENABLED_VARIABLE === true
201198
? true
202199
: false;
203200

204201
// This is to check if the application is running in enterprise mode or not
205-
export const IS_ENTERPRISE =
206-
(window._env_ && window._env_.REACT_APP_IS_ENTERPRISE) || false;
202+
export const IS_ENTERPRISE = window._env_?.REACT_APP_IS_ENTERPRISE || false;
203+
204+
205+
export const USER_NAME_DISPLAY_CLAIM =
206+
window._env_?.REACT_APP_USER_NAME_DISPLAY_CLAIM ||
207+
process.env.REACT_APP_USER_NAME_DISPLAY_CLAIM;

forms-flow-nav/src/sidenav/Sidebar.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "./Sidebar.scss";
22
import Accordion from "react-bootstrap/Accordion";
3-
import React, { useEffect, useState } from "react";
3+
import React, { useEffect, useMemo, useState } from "react";
44
import { useHistory ,useLocation } from "react-router-dom";
55
import { useTranslation } from "react-i18next";
66
import {
@@ -12,7 +12,8 @@ import {
1212
ENABLE_APPLICATIONS_MODULE,
1313
ENABLE_TASKS_MODULE,
1414
ENABLE_INTEGRATION_PREMIUM,
15-
IS_ENTERPRISE
15+
IS_ENTERPRISE,
16+
USER_NAME_DISPLAY_CLAIM
1617
} from "../constants/constants";
1718
import { StorageService, StyleServices} from "@formsflow/service";
1819
import i18n from "../resourceBundles/i18n";
@@ -122,7 +123,16 @@ const Sidebar = React.memo(({ props, sidenavHeight="100%" }) => {
122123
return initials.substring(0, 2).toUpperCase(); // Get the first two initials
123124
};
124125

125-
const userName = userDetail?.name || userDetail?.preferred_username || "";
126+
127+
// fetch the username form the user details
128+
const userName = useMemo(()=>{
129+
const value = userDetail[USER_NAME_DISPLAY_CLAIM] || userDetail?.name || userDetail?.preferred_username || "";
130+
if(Array.isArray(value)){
131+
return value.length > 0 ? value[0] : "";
132+
}
133+
return value;
134+
},[userDetail]);
135+
126136
const initials = getInitials(userName);
127137

128138
React.useEffect(() => {

0 commit comments

Comments
 (0)