From 223aea2b12c75b2a5c1a97747441feca6c301455 Mon Sep 17 00:00:00 2001 From: Millicent Achieng Date: Mon, 20 Sep 2021 06:08:26 +0300 Subject: [PATCH] Update messages to mention workaround is used because redirected download URL is not CORS compliant --- src/app/services/graph-constants.ts | 2 + .../views/app-sections/ResponseMessages.tsx | 40 +++++++++++++------ .../headers/ResponseHeaders.tsx | 2 +- .../query-response/response/Response.tsx | 3 +- src/messages/GE.json | 10 +++-- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/app/services/graph-constants.ts b/src/app/services/graph-constants.ts index 97eabf5c6..850c1eec1 100644 --- a/src/app/services/graph-constants.ts +++ b/src/app/services/graph-constants.ts @@ -22,3 +22,5 @@ export enum PERMS_SCOPE { export const ADAPTIVE_CARD_URL = 'https://templates.adaptivecards.io/graph.microsoft.com'; export const GRAPH_TOOOLKIT_EXAMPLE_URL = 'https://mgt.dev/?path=/story'; +export const ONE_DRIVE_CONTENT_DOWNLOAD_DOCUMENTATION_LINK = + 'https://docs.microsoft.com/en-us/onedrive/developer/rest-api/concepts/working-with-cors#downloading-onedrive-files-in-javascript-apps'; diff --git a/src/app/views/app-sections/ResponseMessages.tsx b/src/app/views/app-sections/ResponseMessages.tsx index 698bb88f8..e2107452a 100644 --- a/src/app/views/app-sections/ResponseMessages.tsx +++ b/src/app/views/app-sections/ResponseMessages.tsx @@ -6,6 +6,7 @@ import { IGraphResponse } from '../../../types/query-response'; import { IQuery } from '../../../types/query-runner'; import { runQuery } from '../../services/actions/query-action-creators'; import { setSampleQuery } from '../../services/actions/query-input-action-creators'; +import { ONE_DRIVE_CONTENT_DOWNLOAD_DOCUMENTATION_LINK } from '../../services/graph-constants'; interface ODataLink { link: string; @@ -40,6 +41,7 @@ export function responseMessages(graphResponse: IGraphResponse, sampleQuery: IQu dispatch(runQuery(query)); } + // Display link to step to next result if (odataLink) { return ( @@ -51,19 +53,33 @@ export function responseMessages(graphResponse: IGraphResponse, sampleQuery: IQu ); } + // Display link to downlod file response if (body?.contentDownloadUrl) { - const workaroundQueries = { - oneDrive: `await client.api('/drive/items/{item-id}').get().select('content.downloadUrl')` - }; return ( - -   - - -   - {body?.isWorkaround == true &&
{workaroundQueries.oneDrive}
} - {body?.isOriginalFormat == false &&
}  -
- ); +
+ + + + +   + + {body?.isWorkaround == true && + + + {body?.isOriginalFormat == false && + +   + + + } +   + + + . + + + } +
+ ); } } diff --git a/src/app/views/query-response/headers/ResponseHeaders.tsx b/src/app/views/query-response/headers/ResponseHeaders.tsx index 7549773e3..5843dbbb5 100644 --- a/src/app/views/query-response/headers/ResponseHeaders.tsx +++ b/src/app/views/query-response/headers/ResponseHeaders.tsx @@ -17,7 +17,7 @@ const ResponseHeaders = () => { const height = convertVhToPx(getResponseHeight(response.height, responseAreaExpanded), 100); - const responseIsDownloadUrl = body['contentDownloadUrl']; + const responseIsDownloadUrl = body?.contentDownloadUrl; if (!headers && responseIsDownloadUrl) { return ( diff --git a/src/app/views/query-response/response/Response.tsx b/src/app/views/query-response/response/Response.tsx index 481ca7a83..a06a40359 100644 --- a/src/app/views/query-response/response/Response.tsx +++ b/src/app/views/query-response/response/Response.tsx @@ -20,7 +20,8 @@ const Response = () => { return (
{responseMessages(graphResponse, sampleQuery, dispatch)} - {headers &&