Skip to content

Commit c2898b9

Browse files
authored
Revert "feat: fluent v9 upgrades feature branch (#3428)" (#3757)
This reverts commit 31f8fab.
1 parent 31f8fab commit c2898b9

File tree

169 files changed

+7509
-6987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+7509
-6987
lines changed

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"package.json": "package-lock.json, .npmrc"
2424
},
2525
"cSpell.words": [
26-
"fluentui",
27-
"noreferrer"
26+
"fluentui"
2827
],
2928
}

package-lock.json

Lines changed: 805 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
"@azure/msal-browser": "4.5.1",
99
"@babel/core": "7.26.10",
1010
"@babel/runtime": "7.26.10",
11-
"@fluentui-contrib/react-resize-handle": "0.6.1",
11+
"@fluentui/react": "8.122.9",
1212
"@fluentui/react-components": "9.60.0",
1313
"@fluentui/react-icons": "2.0.274",
14+
"@fluentui/react-icons-mdl2": "1.3.83",
1415
"@microsoft/applicationinsights-react-js": "17.3.4",
1516
"@microsoft/applicationinsights-web": "3.3.6",
1617
"@microsoft/microsoft-graph-client": "3.0.7",
17-
"@microsoft/microsoft-graph-types": "2.40.0",
1818
"@monaco-editor/react": "4.7.0",
1919
"@ms-ofb/officebrowserfeedbacknpm": "file:packages/officebrowserfeedbacknpm-1.6.6.tgz",
2020
"@reduxjs/toolkit": "2.6.0",
@@ -48,6 +48,7 @@
4848
"postcss-flexbugs-fixes": "5.0.2",
4949
"postcss-loader": "8.1.1",
5050
"postcss-preset-env": "10.1.1",
51+
"re-resizable": "6.11.2",
5152
"react": "18.3.0",
5253
"react-app-polyfill": "3.0.0",
5354
"react-dom": "18.3.0",
@@ -68,8 +69,7 @@
6869
"start": "node scripts/start.js",
6970
"build": "node scripts/build.js && node versioned-build.js",
7071
"test": "node scripts/test.js --no-watch --testPathIgnorePatterns=src/tests/ui src/tests/accessibility /scripts/ --max-old-space-size=8192",
71-
"lint": "eslint . \"**/*.{js,ts,tsx}\" --quiet",
72-
"lint-fix": "eslint . \"**/*.{js,ts,tsx}\" --quiet --fix",
72+
"lint": "eslint . \"**/*.{js,ts,tsx}\"",
7373
"prebuild:prod": "standard-version",
7474
"build:prod": "npm run build",
7575
"bump": "standard-version --skip.tag --skip.changelog",

src/app/services/actions/autocomplete-action-creators.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { ApplicationState, store } from '../../../../src/store/index';
66
import { fetchAutoCompleteOptions } from '../../../app/services/slices/autocomplete.slice';
77
import { suggestions } from '../../../modules/suggestions/suggestions';
88
import { Mode } from '../../../types/enums';
9-
import { SnippetError } from '../../../types/snippets';
109
import { AUTOCOMPLETE_FETCH_ERROR, AUTOCOMPLETE_FETCH_PENDING, AUTOCOMPLETE_FETCH_SUCCESS } from '../redux-constants';
1110
import { mockThunkMiddleware } from './mockThunkMiddleware';
1211

@@ -62,13 +61,13 @@ const mockState: ApplicationState = {
6261
isLoadingData: false,
6362
response: {
6463
body: undefined,
65-
headers: {}
64+
headers: undefined
6665
}
6766
},
6867
snippets: {
6968
pending: false,
70-
data: {},
71-
error: {} as SnippetError
69+
data: [],
70+
error: null
7271
},
7372
responseAreaExpanded: false,
7473
dimensions: {

src/app/services/actions/permissions-action-creator.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
import { authenticationWrapper } from '../../../modules/authentication';
1212
import { ApplicationState, store } from '../../../store/index';
1313
import { Mode } from '../../../types/enums';
14-
import { SnippetError } from '../../../types/snippets';
1514
import { getPermissionsScopeType } from '../../utils/getPermissionsScopeType';
1615
import { translateMessage } from '../../utils/translate-messages';
1716
import { ACCOUNT_TYPE } from '../graph-constants';
@@ -83,13 +82,13 @@ const mockState: ApplicationState = {
8382
isLoadingData: false,
8483
response: {
8584
body: undefined,
86-
headers: {}
85+
headers: undefined
8786
}
8887
},
8988
snippets: {
9089
pending: false,
91-
data: {},
92-
error: {} as SnippetError
90+
data: [],
91+
error: null
9392
},
9493
responseAreaExpanded: false,
9594
dimensions: {
@@ -302,7 +301,7 @@ describe('Permissions action creators', () => {
302301
statusText: translateMessage('Revoking'),
303302
status: translateMessage('Please wait while we revoke this permission'),
304303
ok: false,
305-
messageBarType: 'info'
304+
messageType: 0
306305
}
307306
}
308307
]
@@ -358,7 +357,7 @@ describe('Permissions action creators', () => {
358357
statusText: translateMessage('Revoking '),
359358
status: translateMessage('Please wait while we revoke this permission'),
360359
ok: false,
361-
messageBarType: 'info'
360+
messageType: 0
362361
}
363362
}
364363
]
@@ -417,7 +416,7 @@ describe('Permissions action creators', () => {
417416
statusText: translateMessage('Revoking'),
418417
status: translateMessage('Please wait while we revoke this permission'),
419418
ok: false,
420-
messageBarType: 'info'
419+
messageType: 0
421420
}
422421
}
423422
]

src/app/services/actions/permissions-action-creator.util.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { User } from '@microsoft/microsoft-graph-types';
21
import { componentNames, eventTypes, telemetry } from '../../../telemetry';
32
import { IOAuthGrantPayload, IPermissionGrant } from '../../../types/permissions';
43
import { IUser } from '../../../types/profile';
5-
import { CustomBody, ResponseValue } from '../../../types/query-response';
64
import { IQuery } from '../../../types/query-runner';
75
import { RevokeScopesError } from '../../utils/error-utils/RevokeScopesError';
86
import { exponentialFetchRetry } from '../../utils/fetch-retry-handler';
97
import { GRAPH_URL } from '../graph-constants';
10-
import { parseResponse, makeGraphRequest as queryMakeGraphRequest } from './query-action-creator-util';
8+
import { makeGraphRequest, parseResponse } from './query-action-creator-util';
119

1210
interface IPreliminaryChecksObject {
1311
defaultUserScopes: string[];
@@ -109,9 +107,7 @@ export class RevokePermissionsUtil {
109107
const tenantAdminQuery = { ...genericQuery };
110108
tenantAdminQuery.sampleUrl = `${GRAPH_URL}/v1.0/me/memberOf`;
111109
const response = await RevokePermissionsUtil.makeExponentialFetch([], tenantAdminQuery);
112-
const value = (response as CustomBody).value
113-
const isAdmin = value ? value.some((v: Partial<User>)=>v?.displayName === 'Global Administrator') : false
114-
return isAdmin
110+
return response ? response.value.some((value: any) => value.displayName === 'Global Administrator') : false
115111
}
116112

117113
public async getUserPermissionChecks(preliminaryObject: PartialCheckObject): Promise<{
@@ -195,7 +191,7 @@ export class RevokePermissionsUtil {
195191
genericQuery.sampleUrl = `${GRAPH_URL}/v1.0/oauth2PermissionGrants?$filter=clientId eq '${servicePrincipalAppId}'`;
196192
genericQuery.sampleHeaders = [{ name: 'ConsistencyLevel', value: 'eventual' }];
197193
const oAuthGrant = await RevokePermissionsUtil.makeExponentialFetch(scopes, genericQuery);
198-
return oAuthGrant as IOAuthGrantPayload;
194+
return oAuthGrant;
199195
}
200196

201197
public permissionToRevokeInGrant(permissionsGrant: IPermissionGrant, allPrincipalGrant: IPermissionGrant,
@@ -211,8 +207,7 @@ export class RevokePermissionsUtil {
211207
const currentAppId = process.env.REACT_APP_CLIENT_ID;
212208
genericQuery.sampleUrl = `${GRAPH_URL}/v1.0/servicePrincipals?$filter=appId eq '${currentAppId}'`;
213209
const response = await this.makeGraphRequest(scopes, genericQuery);
214-
const value = (response as CustomBody)?.value
215-
return value ? value[0]?.id ?? '' : ''
210+
return response ? response.value[0].id : '';
216211
}
217212

218213
private async revokePermission(permissionGrantId: string, newScopes: string): Promise<boolean> {
@@ -224,24 +219,32 @@ export class RevokePermissionsUtil {
224219
patchQuery.sampleUrl = `${GRAPH_URL}/v1.0/oauth2PermissionGrants/${permissionGrantId}`;
225220
genericQuery.sampleHeaders = [{ name: 'ConsistencyLevel', value: 'eventual' }];
226221
patchQuery.selectedVerb = 'PATCH';
227-
228-
const response = await RevokePermissionsUtil.makeGraphRequest([], patchQuery);
229-
const error = (response as CustomBody).error;
230-
if (error) {
231-
return false;
222+
// eslint-disable-next-line no-useless-catch
223+
try {
224+
const response = await RevokePermissionsUtil.makeGraphRequest([], patchQuery);
225+
const { error } = response;
226+
if (error) {
227+
return false;
228+
}
229+
return true;
230+
}
231+
catch (error: any) {
232+
throw error;
232233
}
233-
return true;
234234
}
235235

236-
private static async makeExponentialFetch(
237-
scopes: string[], query: IQuery, condition?: (args?: unknown) => Promise<boolean>) {
238-
const response = await exponentialFetchRetry(() => queryMakeGraphRequest(scopes)(query), 8, 100, condition);
239-
return parseResponse(response as Response);
236+
private static async makeExponentialFetch(scopes: string[], query: IQuery, condition?:
237+
(args?: any) => Promise<boolean>) {
238+
const respHeaders: any = {};
239+
const response = await exponentialFetchRetry(() => makeGraphRequest(scopes)(query),
240+
8, 100, condition);
241+
return parseResponse(response, respHeaders);
240242
}
241243

242244
private static async makeGraphRequest(scopes: string[], query: IQuery) {
243-
const response = await queryMakeGraphRequest(scopes)(query);
244-
return parseResponse(response as Response);
245+
const respHeaders: any = {};
246+
const response = await makeGraphRequest(scopes)(query);
247+
return parseResponse(response, respHeaders);
245248
}
246249

247250
private trackRevokeConsentEvent = (status: string, permissionObject: any) => {

src/app/services/actions/profile-actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ export async function getProfileImage(): Promise<string> {
103103

104104
export async function getProfileResponse(): Promise<IProfileResponse> {
105105
const scopes = DEFAULT_USER_SCOPES.split(' ');
106+
const respHeaders: Record<string, string> = {};
106107

107108
const response = await makeGraphRequest(scopes)(query);
108-
const userInfo = await parseResponse(response as Response);
109+
const userInfo = await parseResponse(response, respHeaders);
109110
return {
110111
userInfo,
111112
response

src/app/services/actions/query-action-creator-util.ts

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ import {
1010

1111
import { authenticationWrapper } from '../../../modules/authentication';
1212
import { ApplicationState } from '../../../store';
13-
import { ResponseBody } from '../../../types/query-response';
13+
import { ContentType } from '../../../types/enums';
1414
import { IQuery } from '../../../types/query-runner';
1515
import { IRequestOptions } from '../../../types/request';
1616
import { IStatus } from '../../../types/status';
1717
import { ClientError } from '../../utils/error-utils/ClientError';
18-
import { getHeaders } from '../../utils/http-methods.utils';
1918
import { encodeHashCharacters } from '../../utils/query-url-sanitization';
2019
import { translateMessage } from '../../utils/translate-messages';
2120
import { authProvider, GraphClient } from '../graph-client';
@@ -37,7 +36,7 @@ export async function anonymousRequest(
3736
export function createAnonymousRequest(query: IQuery, proxyUrl: string, queryRunnerStatus: IStatus) {
3837
const escapedUrl = encodeURIComponent(query.sampleUrl);
3938
const graphUrl = `${proxyUrl}?url=${escapedUrl}`;
40-
const sampleHeaders: Record<string, string> = {};
39+
const sampleHeaders: any = {};
4140

4241
if (query.sampleHeaders && query.sampleHeaders.length > 0) {
4342
query.sampleHeaders.forEach((header) => {
@@ -107,30 +106,30 @@ function createAuthenticatedRequest(
107106

108107
export function makeGraphRequest(scopes: string[]) {
109108
return async (query: IQuery) => {
110-
let response: ResponseBody;
109+
let response;
111110

112111
const graphRequest: GraphRequest = createAuthenticatedRequest(scopes, query);
113112

114113
switch (query.selectedVerb) {
115114
case 'GET':
116-
response = await graphRequest.get() as ResponseBody;
115+
response = await graphRequest.get();
117116
break;
118117
case 'POST':
119-
response = await graphRequest.post(query.sampleBody) as ResponseBody;
118+
response = await graphRequest.post(query.sampleBody);
120119
break;
121120
case 'PUT':
122-
response = await graphRequest.put(query.sampleBody) as ResponseBody;
121+
response = await graphRequest.put(query.sampleBody);
123122
break;
124123
case 'PATCH':
125-
response = await graphRequest.patch(query.sampleBody) as ResponseBody;
124+
response = await graphRequest.patch(query.sampleBody);
126125
break;
127126
case 'DELETE':
128-
response = await graphRequest.delete() as ResponseBody;
127+
response = await graphRequest.delete();
129128
break;
130129
default:
131130
return;
132131
}
133-
return Promise.resolve(response) as ResponseBody;
132+
return Promise.resolve(response);
134133
};
135134
}
136135

@@ -147,26 +146,32 @@ export function isBetaURLResponse(json: any) {
147146
return !!json?.account?.[0]?.source?.type?.[0];
148147
}
149148

150-
export function getContentType(headers: Record<string, string>): string {
151-
const contentTypeHeader = Object.keys(headers).find(header => header.toLowerCase() === 'content-type');
152-
let contentType = contentTypeHeader ? headers[contentTypeHeader] : '';
153-
/* Example: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
154-
* Take the first option after splitting since it is the only value useful in the description of the content
155-
*/
156-
if (contentType) {
157-
const splitContentTypes = contentType.split(';');
158-
contentType = (splitContentTypes.length > 0) ? splitContentTypes[0].toLowerCase() : contentType;
149+
export function getContentType(headers: any) {
150+
let contentType = null;
151+
152+
if (headers) {
153+
let contentTypes = headers['content-type'];
154+
if (headers instanceof Headers) {
155+
contentTypes = headers.get('content-type');
156+
}
157+
if (contentTypes) {
158+
/* Example: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
159+
* Take the first option after splitting since it is the only value useful in the description of the content
160+
*/
161+
const splitContentTypes = contentTypes.split(';');
162+
if (splitContentTypes.length > 0) {
163+
contentType = splitContentTypes[0].toLowerCase();
164+
}
165+
}
159166
}
160-
return contentType.toLowerCase();
167+
return contentType;
161168
}
162169

163-
export function isFileResponse(headers: Record<string, string>) {
164-
const contentDisposition: string | null = (headers instanceof Headers) ?
165-
headers.get('content-disposition') : headers['content-disposition'];
166-
170+
export function isFileResponse(headers: any) {
171+
const contentDisposition = headers['content-disposition'];
167172
if (contentDisposition) {
168173
const directives = contentDisposition.split(';');
169-
if (directives.includes('attachment')) {
174+
if (directives.contains('attachment')) {
170175
return true;
171176
}
172177
}
@@ -186,40 +191,48 @@ export function isFileResponse(headers: Record<string, string>) {
186191
return false;
187192
}
188193

189-
export async function generateResponseDownloadUrl(response: Response) {
190-
const headers = getHeaders(response)
194+
export async function generateResponseDownloadUrl(
195+
response: Response,
196+
respHeaders: any
197+
) {
191198
try {
192-
const fileContents = await parseResponse(response);
193-
const contentType = getContentType(headers);
199+
const fileContents = await parseResponse(response, respHeaders);
200+
const contentType = getContentType(respHeaders);
194201
if (fileContents) {
195202
const buffer = await response.arrayBuffer();
196203
const blob = new Blob([buffer], { type: contentType });
197204
return URL.createObjectURL(blob);
198205
}
199-
} catch {
206+
} catch (error) {
200207
return null;
201208
}
202209
}
203210

204211
async function tryParseJson(textValue: string) {
205212
try {
206213
return JSON.parse(textValue);
207-
} catch {
214+
} catch (error) {
208215
return textValue;
209216
}
210217
}
211218

212-
export const parseResponse = (response: ResponseBody): Promise<ResponseBody> => {
213-
if (response instanceof Response && response.headers) {
214-
const headers = getHeaders(response)
215-
const contentType = getContentType(headers);
219+
export function parseResponse(
220+
response: Response,
221+
respHeaders: { [key: string]: string } = {}
222+
): Promise<any> {
223+
if (response && response.headers) {
224+
response.headers.forEach((val: string, key: string) => {
225+
respHeaders[key] = val;
226+
});
227+
228+
const contentType = getContentType(response.headers);
216229
switch (contentType) {
217-
case 'application/json':
230+
case ContentType.Json:
218231
return response.text().then(tryParseJson);
219-
case 'application/xml':
220-
case 'text/html':
221-
case 'text/csv':
222-
case 'text/plain':
232+
case ContentType.XML:
233+
case ContentType.HTML:
234+
case ContentType.TextCsv:
235+
case ContentType.TextPlain:
223236
return response.text();
224237

225238
default:

0 commit comments

Comments
 (0)