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

[PowerPages][vscode.dev] Showing Content Snippets Not Having Language Record #1086

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 7 additions & 2 deletions src/web/client/dal/remoteFetchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,16 @@ async function createContentFiles(
schemaEntityKey.LANGUAGE_FIELD
);

let languageCode = WebExtensionContext.websiteLanguageCode;

if (languageCodeAttribute && result[languageCodeAttribute] === null) {
throw new Error(ERROR_CONSTANTS.LANGUAGE_CODE_ID_VALUE_NULL);
if (entityName !== schemaEntityName.CONTENTSNIPPETS) {
throw new Error(ERROR_CONSTANTS.LANGUAGE_CODE_ID_VALUE_NULL);
} else {
languageCode = Constants.DEFAULT_LANGUAGE_CODE; // Handles the case where language code is null for content snippets
}
}

let languageCode = WebExtensionContext.websiteLanguageCode;
if (defaultFileInfo?.fileName === undefined &&
languageCodeAttribute &&
result[languageCodeAttribute]) {
Expand Down
4 changes: 2 additions & 2 deletions src/web/client/schema/portalSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const portal_schema_V1 = {
_fetchQueryParameters:
"?$filter=adx_contentsnippetid eq {entityId}&$select=adx_name,adx_value,_adx_contentsnippetlanguageid_value",
_multiFileFetchQueryParameters:
"?$filter=_adx_websiteid_value eq {websiteId} and _adx_contentsnippetlanguageid_value ne null &$select=adx_name,adx_value,adx_contentsnippetid,_adx_contentsnippetlanguageid_value&$count=true",
"?$filter=_adx_websiteid_value eq {websiteId} &$select=adx_name,adx_value,adx_contentsnippetid,_adx_contentsnippetlanguageid_value&$count=true",
_attributes: "adx_value",
_attributesExtension: new Map([["adx_value", "html"]]),
},
Expand Down Expand Up @@ -334,7 +334,7 @@ export const portal_schema_V2 = {
_fetchQueryParameters:
"?$filter=powerpagecomponentid eq {entityId}&$select=name,content",
_multiFileFetchQueryParameters:
"?$filter=_powerpagesiteid_value eq {websiteId} and powerpagecomponenttype eq 7 and _powerpagesitelanguageid_value ne null &$select=name,content,_powerpagesitelanguageid_value&$count=true",
"?$filter=_powerpagesiteid_value eq {websiteId} and powerpagecomponenttype eq 7 &$select=name,content,_powerpagesitelanguageid_value&$count=true",
_attributes: "content.value",
_attributesExtension: new Map([["content.value", "html"]]),
},
Expand Down
10 changes: 7 additions & 3 deletions src/web/client/utilities/commonUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { doesFileExist, getFileAttributePath, getFileEntityName, updateEntityCol
import { isWebFileV2 } from "./schemaHelperUtil";
import { ServiceEndpointCategory } from "../../../common/services/Constants";
import { PPAPIService } from "../../../common/services/PPAPIService";
import * as Constants from "../common/constants";

// decodes file content to UTF-8
export function convertContentToUint8Array(content: string, isBase64Encoded: boolean): Uint8Array {
Expand All @@ -42,15 +43,18 @@ export function GetFileNameWithExtension(
languageCode: string,
extension: string
) {
fileName = isLanguageCodeNeededInFileName(entity) ? `${fileName}.${languageCode}` : fileName;
if (entity === schemaEntityName.CONTENTSNIPPETS) {
fileName = languageCode && languageCode != Constants.DEFAULT_LANGUAGE_CODE ? `${fileName}.${languageCode}` : fileName; // Handle the case where language is not provided for content snippets
} else {
fileName = isLanguageCodeNeededInFileName(entity) ? `${fileName}.${languageCode}` : fileName;
}
fileName = isExtensionNeededInFileName(entity) ? `${fileName}.${extension}` : fileName;

return getSanitizedFileName(fileName);
}

export function isLanguageCodeNeededInFileName(entity: string) {
return entity === schemaEntityName.WEBPAGES ||
entity === schemaEntityName.CONTENTSNIPPETS;
return entity === schemaEntityName.WEBPAGES ||entity === schemaEntityName.CONTENTSNIPPETS;
}

export function isExtensionNeededInFileName(entity: string) {
Expand Down
Loading