Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import cookie from 'cookie';
import {
AccountHomeIcon,
DashboardIcon,
FacilityBasedPreviewIcon,
HardshipIcon,
HelpSupportIcon,
ManageUsersIcon,
MyApplicationsIcon,
MyTestDataIcon,
PaymentIcon,
PhysicianCompareIcon,
StarIcon,
TargetIcon,
IndividualReporting,
ManageDocumentsIcon,
AuthorContentIcon,
RegistrationIcon,
} from '../../lib/SvgComponents';
import { isReviewerRole, isContentMgmtRole } from './Content/SelectRole/utils';
const submissionsUrl = '/user/submissions';
const dashboardUrl = '/user/dashboard';
const manageUrl = '/user/manage-access';
const feedbackUrl = `${submissionsUrl}/feedback`;
const physicianCompareUrl = `${submissionsUrl}/doctors-clinicians-preview`;
const reportsPortalUrl = `${submissionsUrl}/reports`;
const facilityBasedPreviewBaseUrl = `${submissionsUrl}/facility-based-preview`;
const viewingToolUrl = '/user/helpdesk-viewing-tool';
const contentMgrDashboardUrl = '/user/content-management';
const registrationUrl = '/user/registration/';
const performanceFeedbackUrl = (performanceYear) => {
if (performanceYear) {
return `${feedbackUrl}/${performanceYear}`;
} else {
return feedbackUrl;
}
};
const facilityBasedPreviewUrl = (performanceYear) => {
return `${facilityBasedPreviewBaseUrl}/${performanceYear}`;
};
const handleNavigation = (e, linkCallbackFunction, label) => {
if (linkCallbackFunction) {
const { pathname, hash, search } = e.currentTarget;
e.preventDefault();
e.stopPropagation();
linkCallbackFunction(`${pathname}${hash}${search}`);
}
window?.utag?.link({
ga_event_category: 'side navbar',
ga_event_action: 'click',
ga_event_label: label,
page_title: `${window.document.title}`,
page_url: `${window.location.pathname}`,
event: 'trackEvent',
});
};
/**
* Load icon by url
* @param {string} url
* @returns svg icon
*/
const getIcon = (url, linkLabel) => {
const icons = {
[dashboardUrl]: DashboardIcon,
[feedbackUrl]: StarIcon,
[manageUrl]: ManageUsersIcon,
[physicianCompareUrl]: PhysicianCompareIcon,
[reportsPortalUrl]: HardshipIcon,
[submissionsUrl]: AccountHomeIcon,
[facilityBasedPreviewBaseUrl]: FacilityBasedPreviewIcon,
[registrationUrl]: RegistrationIcon,
'/developers': HelpSupportIcon,
'/resources/help-and-support': HelpSupportIcon,
'/user/apm-incentive-payments': PaymentIcon,
'/user/applications': MyApplicationsIcon,
'/user/exception/#/landing': HardshipIcon,
'/user/targeted-review/#/landing': TargetIcon,
'/user/test-data': MyTestDataIcon,
'/user/self-nomination/#/landing': IndividualReporting,
'/user/reviewers': AccountHomeIcon,
'/reviewer/exception': HardshipIcon,
'/reviewer/targeted-review': TargetIcon,
'/self-nomination': IndividualReporting,
'/case-management': FacilityBasedPreviewIcon,
[contentMgrDashboardUrl]: AccountHomeIcon,
'Manage Documents': ManageDocumentsIcon,
'Author Content': AuthorContentIcon,
};
if (linkLabel) return icons[linkLabel];
return icons[url];
};
const singleRoleContentMap = {
'QPP Content Management - Author': 'contentManager',
'QPP Content Management - Approver': 'contentManager',
'QPP Content Management - Admin': 'contentManager',
'QPP Front-end - Author': 'contentManager',
'QPP Self-Nomination': 'internalReviewers',
'QPP Targeted Review & Exceptions': 'internalReviewers',
'QPP Case Management - PIMMS Reviewer': 'internalReviewers',
'QPP Case Management - ACO PAC Reviewer': 'internalReviewers',
'QPP Case Management - CMS Reviewer': 'internalReviewers',
};
const multiRoleContentMap = {
Reviewer: 'internalReviewers',
'Content Manager': 'contentManager',
};
const replaceDefaultContentMgrLinks = (defaultContent) => {
const host = window.location.host;
const updatedDefaultContent = {
...defaultContent,
contentManager: [
defaultContent.contentManager.find(
(obj) => obj.label === 'Dashboard Home',
),
{
url: `${host}.qpp.cms.gov/cm/`,
label: 'Manage Documents',
},
{
url: `${host}.qpp.cms.gov/content-management/`,
label: 'Author Content',
},
],
};
return updatedDefaultContent;
};
/**
* Load the side nav content for the given role
* @param {string} roleName role of given user from internalReviewerNames
* @param {object} navContent object of side nav links by role (levelOneContent & defaultContent)
* @returns {array} returns an array of objects (side nav menu links) from levelOneContent
* || defaultContent
*/
const loadSideNavContent = (roleName, navContent, isMultiRoleUser = false) => {
const { levelOneContent, defaultContent } = navContent;
const updatedDefaultContent = replaceDefaultContentMgrLinks(defaultContent);
const roleContentMap = isMultiRoleUser
? multiRoleContentMap
: singleRoleContentMap;
const contentByRole = roleContentMap[roleName];
if (levelOneContent) {
return levelOneContent[contentByRole] || levelOneContent.default;
}
return updatedDefaultContent[contentByRole] || updatedDefaultContent.default;
};
/**
* Check if user is currently impersonating
* @param {string} docCookie document cookie
* @returns {boolean}
*/
const isImpersonating = (docCookie) => {
const parsedCookies = cookie.parse(docCookie);
return (
parsedCookies.qpp_can_impersonate && parsedCookies.qpp_impersonated_user
);
};
/**
* Check if user has multiple roles, used to display Select Role dropdown
* @param {string} docCookie document cookie
* @returns {boolean}
*/
const isMultiRoleUser = (docCookie) => {
const activeRoles = new Set();
const {
qpp_cms_internal_authorized,
qpp_has_authorizations,
qpp_is_dev_pre,
} = cookie.parse(docCookie);
let internalAuthz = [];
if (qpp_cms_internal_authorized) {
internalAuthz = JSON.parse(qpp_cms_internal_authorized);
}
// Filter out test internalCms authz
const filteredInternalAuthz = internalAuthz.filter((internalAuth) => {
return (
internalAuth !== 'Test internalCms Resource' &&
internalAuth !== 'Test internalCms Resource 2'
);
});
filteredInternalAuthz.forEach((element) => {
if (isReviewerRole(element)) {
return activeRoles.add('reviewer');
}
if (isContentMgmtRole(element)) {
return activeRoles.add('content manager');
}
return activeRoles.add(element);
});
if (qpp_has_authorizations === 'true') {
activeRoles.add('qpp user');
}
if (qpp_is_dev_pre === 'true') {
activeRoles.clear(); // reset roles since there is no dropdown in devpre
activeRoles.add('devpre user');
}
return activeRoles.size > 1;
};
/**
* Transform cookie values to permissions object
* @param {object} cookies parsed document.cookie values
* @returns {object}
*/
const transformCookieValues = (cookies) => {
const {
qpp_can_impersonate,
qpp_has_authorizations,
user_has_apm_payments,
qpp_cms_internal_authorized,
qpp_ehr_authorized,
qpp_has_non_registry_authorizations,
} = cookies;
return {
canImpersonate: qpp_can_impersonate === 'true',
hasAuthorizations: qpp_has_authorizations === 'true',
hasApmPayments: user_has_apm_payments === 'true',
internalReviewerNames: qpp_cms_internal_authorized
? JSON.parse(qpp_cms_internal_authorized)
: [],
ehrAuthorized: qpp_ehr_authorized === 'true',
hasNonRegistryAuthorizations:
qpp_has_non_registry_authorizations === 'true',
};
};
const permissionsByRole = {
'QPP User': {
canImpersonate: false,
hasAuthorizations: true,
hasApmPayments: true,
},
Reviewer: {
hasAuthorizations: false,
hasApmPaymentss: false,
},
'Helpdesk Viewer': {
hasAuthorizations: false,
hasApmPayments: false,
hasNonRegistryAuthorizations: false,
internalReviewerNames: ['QPP Helpdesk'],
},
// Helpdesk role && impersonating (use impersonated user authz values)
Impersonation: {
internalReviewerNames: ['QPP Helpdesk'],
},
'Content Manager': {
hasAuthorizations: false,
hasApmPaymentss: false,
hasNonRegistryAuthorizations: false,
},
};
/**
* Return permissions by role
* @param {string} selectedRole selected user role
* @param {object} permissionValues default permission values from transformed parsed cookie
* @returns {object}
*/
const loadUserPermissionsByRole = (selectedRole, permissionValues) => {
return {
...permissionValues,
...permissionsByRole[selectedRole],
};
};
/**
* Helper fn to return user permissions/properties from cookies set on login
* @param {string} docCookie cookie values set on login
* @param {string} selectedRole string of selected role if user has multiple roles
* @returns {object}
*/
const loadUserPermissions = (docCookie, selectedRole) => {
const parsedCookies = cookie.parse(docCookie);
const permissionValues = transformCookieValues(parsedCookies);
const impersonating = isImpersonating(docCookie);
const role = impersonating ? 'Impersonation' : selectedRole;
if (role) {
return loadUserPermissionsByRole(role, permissionValues);
}
return permissionValues;
};
/**
* Return map of link conditionals based on user cookies for side nav
* @param {object} userPermissions user permissions/properties derived from cookies set on login
* @returns {object}
*/
const getUrlConditionMap = (userPermissions) => {
return {
[dashboardUrl]: userPermissions.hasAuthorizations,
[feedbackUrl]: userPermissions.hasAuthorizations,
'/user/apm-incentive-payments': userPermissions.hasApmPayments,
[physicianCompareUrl]: userPermissions.hasNonRegistryAuthorizations,
[registrationUrl]: userPermissions.hasAuthorizations,
[reportsPortalUrl]: userPermissions.hasAuthorizations,
[facilityBasedPreviewBaseUrl]: userPermissions.hasAuthorizations,
'/user/helpdesk-viewing-tool': userPermissions.canImpersonate,
'/reviewer/exception': userPermissions.internalReviewerNames?.includes(
'QPP Targeted Review & Exceptions',
),
'/reviewer/targeted-review':
userPermissions.internalReviewerNames?.includes(
'QPP Targeted Review & Exceptions',
),
'/self-nomination': userPermissions.internalReviewerNames?.includes(
'QPP Self-Nomination',
),
'/case-management': userPermissions.internalReviewerNames?.some((val) =>
[
'QPP Case Management - PIMMS Reviewer',
'QPP Case Management - ACO PAC Reviewer',
'QPP Case Management - CMS Reviewer',
].includes(val),
),
// dev pre
'/user/applications': userPermissions.ehrAuthorized,
'/user/test-data': userPermissions.ehrAuthorized,
};
};
const isImpersonationLink = (docCookie, linkLabel) => {
if (!isImpersonating(docCookie)) return;
const helpdeskLinks = ['Account Home', 'Manage Access', 'Help and Support'];
return !helpdeskLinks.includes(linkLabel);
};
/**
* Set SideNav expanded state as qpp_side_nav_expanded in localStorage
*/
const sideNavExpandedStorage = {
isNullOrUndefined: function () {
const sideNavExpandedValue = localStorage.getItem('qpp_side_nav_expanded');
return sideNavExpandedValue === null || sideNavExpandedValue === undefined;
},
init: function () {
if (this.isNullOrUndefined()) {
localStorage.setItem('qpp_side_nav_expanded', true);
}
},
toggle: function () {
const isSideNavExpanded = JSON.parse(
localStorage.getItem('qpp_side_nav_expanded'),
);
if (!isSideNavExpanded) {
localStorage.setItem('qpp_side_nav_expanded', true);
} else {
localStorage.setItem('qpp_side_nav_expanded', false);
}
},
get: function () {
return JSON.parse(localStorage.getItem('qpp_side_nav_expanded'));
},
remove: function () {
localStorage.removeItem('qpp_side_nav_expanded');
},
setDefault: function () {
let defaultValue = true;
if (!this.isNullOrUndefined()) {
defaultValue = this.get();
}
return defaultValue;
},
};
module.exports = {
submissionsUrl,
dashboardUrl,
feedbackUrl,
manageUrl,
physicianCompareUrl,
registrationUrl,
performanceFeedbackUrl,
facilityBasedPreviewUrl,
handleNavigation,
reportsPortalUrl,
facilityBasedPreviewBaseUrl,
viewingToolUrl,
loadUserPermissions,
getUrlConditionMap,
isMultiRoleUser,
getIcon,
isImpersonating,
isImpersonationLink,
loadSideNavContent,
sideNavExpandedStorage,
};
|