Skip to content

Commit

Permalink
Merge pull request #2727 from RedHatInsights/master
Browse files Browse the repository at this point in the history
[stable] Update build
  • Loading branch information
Hyperkid123 authored Dec 11, 2023
2 parents 7ed6355 + 321b7a2 commit d71d15d
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 13 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@redhat-cloud-services/eslint-config-redhat-cloud-services": "^1.2.6",
"@redhat-cloud-services/frontend-components-config-utilities": "^3.0.2",
"@redhat-cloud-services/types": "^0.0.22",
"@redhat-cloud-services/types": "1.0.4",
"@simonsmith/cypress-image-snapshot": "^8.1.2",
"@swc/core": "^1.3.76",
"@swc/jest": "^0.2.29",
Expand Down
1 change: 1 addition & 0 deletions src/analytics/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ChromeUser } from '@redhat-cloud-services/types';
function buildUser(token: any): DeepRequired<ChromeUser> {
return {
entitlements: {},
scope: [],
identity: {
account_number: token.account_number || '540155',
type: 'User',
Expand Down
3 changes: 3 additions & 0 deletions src/auth/ChromeAuthContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ export type ChromeAuthContextValue<LoginResponse = void> = {
login: (requiredScopes?: string[]) => Promise<LoginResponse>;
tokenExpires: number;
getToken: () => Promise<string>;
getRefreshToken: () => Promise<string>;
postbackUrl?: string;
getOfflineToken: () => Promise<AxiosResponse<OfflineTokenResponse>>;
doOffline: () => Promise<void>;
};

const blankUser: ChromeUser = {
scope: [],
entitlements: {},
identity: {
org_id: '',
Expand All @@ -34,6 +36,7 @@ const ChromeAuthContext = createContext<ChromeAuthContextValue>({
logout: () => undefined,
login: () => Promise.resolve(),
getToken: () => Promise.resolve(''),
getRefreshToken: () => Promise.resolve(''),
getOfflineToken: () =>
Promise.resolve({
data: {},
Expand Down
13 changes: 9 additions & 4 deletions src/auth/OIDCConnector/OIDCSecured.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { login, logout } from './utils';
import createGetUserPermissions from '../createGetUserPermissions';
import initializeAccessRequestCookies from '../initializeAccessRequestCookies';
import { getOfflineToken, prepareOfflineRedirect } from '../offline';
import { OFFLINE_REDIRECT_STORAGE_KEY } from '../../utils/consts';

type Entitlement = { is_entitled: boolean; is_trial: boolean };
const serviceAPI = entitlementsApi();
Expand All @@ -28,6 +29,7 @@ const log = logger('OIDCSecured.tsx');
/* eslint-disable @typescript-eslint/no-explicit-any */
function mapOIDCUserToChromeUser(user: User | Record<string, any>, entitlements: { [entitlement: string]: Entitlement }): ChromeUser {
return {
scope: [],
entitlements,
identity: {
org_id: user.profile?.org_id as any,
Expand Down Expand Up @@ -92,12 +94,15 @@ export function OIDCSecured({
authChannel.postMessage({ type: 'login' });
},
getToken: () => Promise.resolve(authRef.current.user?.access_token ?? ''),
getOfflineToken: () =>
getOfflineToken(
getRefreshToken: () => Promise.resolve(authRef.current.user?.refresh_token ?? ''),
getOfflineToken: () => {
const redirectUri = new URL(localStorage.getItem(OFFLINE_REDIRECT_STORAGE_KEY) || `${window.location.origin}${window.location.pathname}`);
return getOfflineToken(
authRef.current.settings.metadata?.token_endpoint ?? '',
authRef.current.settings.client_id,
encodeURIComponent((authRef.current.settings.metadata?.token_endpoint ?? '').split('#')[0])
),
encodeURIComponent(redirectUri.toString().split('#')[0])
);
},
doOffline: () => login(authRef.current, ['offline_access'], prepareOfflineRedirect()),
getUser: () => Promise.resolve(mapOIDCUserToChromeUser(authRef.current.user ?? {}, {})),
token: authRef.current.user?.access_token ?? '',
Expand Down
5 changes: 5 additions & 0 deletions src/chrome/create-chrome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jest.mock('@scalprum/core', () => {
jest.mock('../auth/fetchPermissions');

const mockUser: ChromeUser = {
scope: [],
entitlements: {},
identity: {
org_id: '1234',
Expand Down Expand Up @@ -61,6 +62,9 @@ describe('create chrome', () => {
getToken() {
return Promise.resolve('string');
},
getRefreshToken() {
return Promise.resolve('string');
},
getUser() {
return Promise.resolve(mockUser);
},
Expand Down Expand Up @@ -103,6 +107,7 @@ describe('create chrome', () => {
return;
},
version: 2,
activateQuickstart: jest.fn(),
},
setPageMetadata: jest.fn(),
useGlobalFilter: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions src/chrome/create-chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const createChromeContext = ({
const api: ChromeAPI = {
...actions,
auth: {
getRefreshToken: chromeAuth.getRefreshToken,
getToken: chromeAuth.getToken,
getUser: chromeAuth.getUser,
logout: chromeAuth.logout,
Expand Down
4 changes: 4 additions & 0 deletions src/components/FavoriteServices/LandingNavFavorites.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
}
}

.chr-c-card-landing-fav {
height: 110px;
}

2 changes: 1 addition & 1 deletion src/components/FavoriteServices/LandingNavFavorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const LandingNavFavorites = () => {
return favoritedServices.slice((page - 1) * perPage, page * perPage).map((favorite, index) => (
<GalleryItem key={index}>
<Link to={favorite.pathname} className="chr-c-favorite-service__tile">
<Card isClickable>
<Card className="chr-c-card-landing-fav" isClickable>
<CardHeader selectableActions={{ selectableActionId: 'id', selectableActionAriaLabelledby: 'clickable-card' }} className="pf-v5-u-pb-0">
<CardTitle className="pf-v5-u-text-align-center pf-v5-u-active-color-100 pf-v5-u-font-size-sm">{favorite.name}</CardTitle>
</CardHeader>
Expand Down
1 change: 1 addition & 0 deletions src/components/RootApp/ScalprumRoot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ describe('ScalprumRoot', () => {
toggle: jest.fn(),
// eslint-disable-next-line react/display-name
Catalog: () => <div></div>,
activateQuickstart: jest.fn(),
},
};

Expand Down
1 change: 1 addition & 0 deletions src/utils/VisibilitySingleton.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jest.mock('@scalprum/core', () => {
});

const userMock: ChromeUser = {
scope: [],
identity: {
// eslint-disable-next-line camelcase
account_number: '0',
Expand Down

0 comments on commit d71d15d

Please sign in to comment.