From fe636d5a78256da4c504336f6f1c1d97f4ec4850 Mon Sep 17 00:00:00 2001 From: David JENNI <3200210+davidjenni@users.noreply.github.com> Date: Mon, 14 Nov 2022 13:17:46 -0800 Subject: [PATCH] [rel/stable] cherry pick 3025834 - Revert access token change - no silent prompts (#350) Cherry-pick of PR #346 Co-authored-by: davidjen@DAVIDJENDEV --- .github/workflows/PullRequest.yml | 6 +++--- src/web/client/common/fileSystemProvider.ts | 15 ++++----------- src/web/client/common/localStore.ts | 5 ++++- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/.github/workflows/PullRequest.yml b/.github/workflows/PullRequest.yml index be2ebcef..7df16b90 100644 --- a/.github/workflows/PullRequest.yml +++ b/.github/workflows/PullRequest.yml @@ -30,10 +30,10 @@ jobs: - name: Setup Node.js environment uses: actions/setup-node@v2 with: - node-version: 14.x + node-version: 16.x - - name: Install dependencies - run: npm i -g npm + # - name: Install dependencies + # run: npm i -g npm - name: Build and unit test run: | diff --git a/src/web/client/common/fileSystemProvider.ts b/src/web/client/common/fileSystemProvider.ts index b615a9e0..e2148584 100644 --- a/src/web/client/common/fileSystemProvider.ts +++ b/src/web/client/common/fileSystemProvider.ts @@ -14,7 +14,6 @@ import { SaveEntityDetails } from './portalSchemaInterface'; import { fetchDataFromDataverseAndUpdateVFS } from './remoteFetchProvider'; import { saveData } from './remoteSaveProvider'; import * as nls from 'vscode-nls'; -import { dataverseAuthentication } from './authenticationProvider'; const localize: nls.LocalizeFunc = nls.loadMessageBundle(); export class File implements vscode.FileStat { @@ -262,14 +261,12 @@ export class PortalsFS implements vscode.FileSystemProvider { private async _loadFromDataverseToVFS() { const powerPlatformContext = await PowerPlatformExtensionContextManager.authenticateAndUpdateDataverseProperties(); await createFileSystem(this, powerPlatformContext.queryParamsMap.get(WEBSITE_NAME) as string); - const accessToken: string = await dataverseAuthentication(powerPlatformContext.queryParamsMap.get(ORG_URL) as string); - - if (!accessToken) { + if (!powerPlatformContext.dataverseAccessToken) { throw vscode.FileSystemError.NoPermissions(); } await fetchDataFromDataverseAndUpdateVFS( - accessToken, + powerPlatformContext.dataverseAccessToken, powerPlatformContext.entity, powerPlatformContext.entityId, powerPlatformContext.queryParamsMap, @@ -285,11 +282,6 @@ export class PortalsFS implements vscode.FileSystemProvider { const dataMap: Map = powerPlatformContext.saveDataMap; const dataverseOrgUrl = powerPlatformContext.queryParamsMap.get(ORG_URL) as string; - const accessToken: string = await dataverseAuthentication(dataverseOrgUrl); - - if (!accessToken) { - throw vscode.FileSystemError.NoPermissions(); - } if (dataMap.get(uri.fsPath)?.getUseBase64Encoding as boolean) { stringDecodedValue = toBase64(stringDecodedValue); @@ -304,7 +296,8 @@ export class PortalsFS implements vscode.FileSystemProvider { httpMethod.PATCH, true); - await saveData(accessToken, + await saveData( + powerPlatformContext.dataverseAccessToken, patchRequestUrl, entityName, uri, diff --git a/src/web/client/common/localStore.ts b/src/web/client/common/localStore.ts index bec60beb..072f36da 100644 --- a/src/web/client/common/localStore.ts +++ b/src/web/client/common/localStore.ts @@ -18,6 +18,7 @@ export interface IPowerPlatformExtensionContext { websiteLanguageIdToPortalLanguageMap: Map; websiteIdToLanguage: Map; entitiesFolderNameMap: Map // FolderName for entity, schemaEntityName + dataverseAccessToken: string; entityId: string; entity: string; rootDirectory: vscode.Uri; @@ -40,6 +41,7 @@ class PowerPlatformExtensionContextManager { entitiesFolderNameMap: this.entitiesFolderNameMap, entity: '', entityId: '', + dataverseAccessToken: '', rootDirectory: vscode.Uri.parse(''), saveDataMap: new Map(), defaultFileUri: vscode.Uri.parse(``) @@ -70,7 +72,8 @@ class PowerPlatformExtensionContextManager { ... this.PowerPlatformExtensionContext, websiteIdToLanguage: await this.websiteIdToLanguageMap(accessToken, dataverseOrgUrl), websiteLanguageIdToPortalLanguageMap: await this.websiteLanguageIdToPortalLanguage(accessToken, dataverseOrgUrl), - languageIdCodeMap: await this.languageIdToCode(accessToken, dataverseOrgUrl) + languageIdCodeMap: await this.languageIdToCode(accessToken, dataverseOrgUrl), + dataverseAccessToken: accessToken, }; }