Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate response section to fluent UI v9 #3473

Draft
wants to merge 23 commits into
base: feat/fluent-v9-upgrade
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2aa1628
feat: add new components for Monaco and response display in v9
musale Nov 28, 2024
2ec1728
feat: implement Monaco v9 editor and enhance response display functio…
musale Nov 29, 2024
8e40ecb
feat: implement ResponseV9 component and update pivot items to use it
musale Nov 29, 2024
c5a8cea
feat: add OneNote and PDF content types, update response headers hand…
musale Nov 29, 2024
4934e83
feat: add @microsoft/microsoft-graph-types dependency, update respons…
musale Nov 29, 2024
f2d4bbe
feat: update graph response handling to initialize headers and remove…
musale Dec 2, 2024
1fdc231
Merge branch 'feat/fluent-v9-upgrade' into feat/response-v9
musale Dec 9, 2024
dd7ffa6
Use a Record to allow serialization of headers
musale Dec 9, 2024
06c6133
refactor: update response handling to use ResponseBody type and impro…
musale Dec 9, 2024
ee93483
feat: add CopyButtonV9 and ResponseHeadersV9 components, update compo…
musale Dec 9, 2024
093d8ea
feat: introduce SnippetV9 and CopyButtonV9 components, update related…
musale Dec 10, 2024
ada6582
feat: enhance MonacoV9 and SnippetsV9 components with extra informati…
musale Dec 10, 2024
719a95e
feat: add GraphToolkitV9 component and integrate it into pivot items
musale Dec 10, 2024
48651dc
refactor: remove unused styledGraphToolkit definition from GraphToolk…
musale Dec 10, 2024
3e24781
refactor: update adaptive cards lookup and improve error handling in …
musale Dec 10, 2024
f8e4032
refactor: clean up imports and reorganize state selection in Adaptive…
musale Dec 10, 2024
a1609c5
WIP: back from leave
musale Jan 2, 2025
ca176fa
Merge branch 'feat/fluent-v9-upgrade' into feat/response-v9
musale Jan 7, 2025
4fa32da
refactor: Update imports and clean up code formatting in QueryRespons…
musale Jan 7, 2025
64a4424
refactor: Simplify QueryResponse component by returning GetPivotItems…
musale Jan 7, 2025
163aa75
refactor: Restore GetPivotItems usage and reintroduce QueryResponse l…
musale Jan 7, 2025
6665ff1
refactor: Introduce QueryResponseV9 component and update App to use it
musale Jan 7, 2025
5daf913
Merge branch 'feat/fluent-v9-upgrade' into feat/response-v9
musale Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"package.json": "package-lock.json, .npmrc"
},
"cSpell.words": [
"fluentui"
"fluentui",
"norefferer"
],
}
19 changes: 19 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"fmt"
"net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World!")
}

func main() {
http.HandleFunc("/", handler)
fmt.Println("Starting server on :8080")
fmt.Println("also good to go")
if err := http.ListenAndServe(":8080", nil); err != nil {
fmt.Println("Error starting server:", err)
}
}
25 changes: 25 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
"@azure/msal-browser": "3.26.1",
"@babel/core": "7.26.0",
"@babel/runtime": "7.26.0",
"@fluentui-contrib/react-resize-handle": "0.6.1",
"@fluentui/react-components": "9.56.8",
"@fluentui/react-icons": "2.0.270",
"@fluentui/react": "8.122.4",
"@fluentui/react-icons-mdl2": "1.3.80",
"@microsoft/applicationinsights-react-js": "17.3.4",
"@microsoft/applicationinsights-web": "3.3.4",
"@microsoft/microsoft-graph-client": "3.0.7",
"@microsoft/microsoft-graph-types": "2.40.0",
"@monaco-editor/react": "4.6.0",
"@ms-ofb/officebrowserfeedbacknpm": "file:packages/officebrowserfeedbacknpm-1.6.6.tgz",
"@reduxjs/toolkit": "2.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ApplicationState, store } from '../../../../src/store/index';
import { fetchAutoCompleteOptions } from '../../../app/services/slices/autocomplete.slice';
import { suggestions } from '../../../modules/suggestions/suggestions';
import { Mode } from '../../../types/enums';
import { SnippetError } from '../../../types/snippets';
import { AUTOCOMPLETE_FETCH_ERROR, AUTOCOMPLETE_FETCH_PENDING, AUTOCOMPLETE_FETCH_SUCCESS } from '../redux-constants';
import { mockThunkMiddleware } from './mockThunkMiddleware';

Expand Down Expand Up @@ -61,13 +62,13 @@ const mockState: ApplicationState = {
isLoadingData: false,
response: {
body: undefined,
headers: undefined
headers: {}
}
},
snippets: {
pending: false,
data: [],
error: null
data: {},
error: {} as SnippetError
},
responseAreaExpanded: false,
dimensions: {
Expand Down
7 changes: 4 additions & 3 deletions src/app/services/actions/permissions-action-creator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { authenticationWrapper } from '../../../modules/authentication';
import { ApplicationState, store } from '../../../store/index';
import { Mode } from '../../../types/enums';
import { SnippetError } from '../../../types/snippets';
import { getPermissionsScopeType } from '../../utils/getPermissionsScopeType';
import { translateMessage } from '../../utils/translate-messages';
import { ACCOUNT_TYPE } from '../graph-constants';
Expand Down Expand Up @@ -82,13 +83,13 @@ const mockState: ApplicationState = {
isLoadingData: false,
response: {
body: undefined,
headers: undefined
headers: {}
}
},
snippets: {
pending: false,
data: [],
error: null
data: {},
error: {} as SnippetError
},
responseAreaExpanded: false,
dimensions: {
Expand Down
45 changes: 21 additions & 24 deletions src/app/services/actions/permissions-action-creator.util.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { User } from '@microsoft/microsoft-graph-types';
import { componentNames, eventTypes, telemetry } from '../../../telemetry';
import { IOAuthGrantPayload, IPermissionGrant } from '../../../types/permissions';
import { IUser } from '../../../types/profile';
import { CustomBody, ResponseValue } from '../../../types/query-response';
import { IQuery } from '../../../types/query-runner';
import { RevokeScopesError } from '../../utils/error-utils/RevokeScopesError';
import { exponentialFetchRetry } from '../../utils/fetch-retry-handler';
import { GRAPH_URL } from '../graph-constants';
import { makeGraphRequest, parseResponse } from './query-action-creator-util';
import { parseResponse, makeGraphRequest as queryMakeGraphRequest } from './query-action-creator-util';

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

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

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

private async revokePermission(permissionGrantId: string, newScopes: string): Promise<boolean> {
Expand All @@ -219,32 +224,24 @@ export class RevokePermissionsUtil {
patchQuery.sampleUrl = `${GRAPH_URL}/v1.0/oauth2PermissionGrants/${permissionGrantId}`;
genericQuery.sampleHeaders = [{ name: 'ConsistencyLevel', value: 'eventual' }];
patchQuery.selectedVerb = 'PATCH';
// eslint-disable-next-line no-useless-catch
try {
const response = await RevokePermissionsUtil.makeGraphRequest([], patchQuery);
const { error } = response;
if (error) {
return false;
}
return true;
}
catch (error: any) {
throw error;

const response = await RevokePermissionsUtil.makeGraphRequest([], patchQuery);
const error = (response as CustomBody).error;
if (error) {
return false;
}
return true;
}

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

private static async makeGraphRequest(scopes: string[], query: IQuery) {
const respHeaders: any = {};
const response = await makeGraphRequest(scopes)(query);
return parseResponse(response, respHeaders);
const response = await queryMakeGraphRequest(scopes)(query);
return parseResponse(response as Response);
}

private trackRevokeConsentEvent = (status: string, permissionObject: any) => {
Expand Down
3 changes: 1 addition & 2 deletions src/app/services/actions/profile-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ export async function getProfileImage(): Promise<string> {

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

const response = await makeGraphRequest(scopes)(query);
const userInfo = await parseResponse(response, respHeaders);
const userInfo = await parseResponse(response as Response);
return {
userInfo,
response
Expand Down
Loading
Loading