Skip to content

Commit

Permalink
New data model load file content fix (#693) (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyaginidhi authored Sep 11, 2023
1 parent 2e062ae commit 7989c62
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Installing this extension will also make the latest Power Platform CLI (aka pac)
[Power Platform CLI Exposed](https://www.youtube.com/playlist?list=PLlrxD0HtieHhEdLHxQOU96ySSZpMCyAxf)

## Release Notes
2.0.7:
- QFE for styling files load for new data model schema

2.0.6:
- QFE for styles rendering of power pages sites

Expand Down
5 changes: 5 additions & 0 deletions src/web/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@ export enum SurveyConstants {
SURVEY_NAME = "PowerPages-NPS",
EVENT_NAME = "VscodeWeb",
AUTHORIZATION_ENDPOINT = "https://microsoft.onmicrosoft.com/cessurvey/user",
}

export enum portalSchemaVersion {
V1 = "portalschemav1",
V2 = "portalschemav2",
}
6 changes: 4 additions & 2 deletions src/web/client/dal/remoteFetchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
GetFileContent,
GetFileNameWithExtension,
getSanitizedFileName,
isPortalVersionV1,
isPortalVersionV2,
isWebfileContentLoadNeeded,
setFileContent,
} from "../utilities/commonUtil";
Expand Down Expand Up @@ -515,11 +517,11 @@ async function fetchMappingEntityContent(

const result = await response.json();
const data = result.value ?? result;
if (result[Constants.ODATA_COUNT] !== 0 && data.length >= 1) {
if (isPortalVersionV1() && result[Constants.ODATA_COUNT] > 0 && data.length > 0) {
return data[0];
}

return data ?? Constants.NO_CONTENT;
return isPortalVersionV2() ? data : Constants.NO_CONTENT;
}

export async function preprocessData(
Expand Down
11 changes: 10 additions & 1 deletion src/web/client/utilities/commonUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
DATA,
MULTI_FILE_FEATURE_SETTING_NAME,
NO_CONTENT,
VERSION_CONTROL_FOR_WEB_EXTENSION_SETTING_NAME
VERSION_CONTROL_FOR_WEB_EXTENSION_SETTING_NAME,
portalSchemaVersion
} from "../common/constants";
import { IAttributePath } from "../common/interfaces";
import { schemaEntityName } from "../schema/constants";
Expand Down Expand Up @@ -168,4 +169,12 @@ export function isWebfileContentLoadNeeded(fileName: string, fsPath: string): bo
return fileExtension !== undefined ?
validImageExtensions.includes(fileExtension.toLowerCase()) ||
doesFileExist(fsPath) : false;
}

export function isPortalVersionV1(): boolean {
return WebExtensionContext.currentSchemaVersion.toLowerCase() === portalSchemaVersion.V1;
}

export function isPortalVersionV2(): boolean {
return WebExtensionContext.currentSchemaVersion.toLowerCase() === portalSchemaVersion.V2;
}

0 comments on commit 7989c62

Please sign in to comment.