From f094518935366ca954846655042a6b5ef138fb2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nidhi=20Tyagi=20=F0=9F=8C=9F=F0=9F=90=87=F0=9F=8C=B4?= =?UTF-8?q?=E2=9D=84=EF=B8=8F?= Date: Thu, 8 Sep 2022 08:21:09 +0530 Subject: [PATCH 1/2] Enable webtemplate and content snippet load in extension --- src/web/client/common/constants.ts | 35 +++++++++----------- src/web/client/common/portalSchema.ts | 12 ++++--- src/web/client/common/remoteFetchProvider.ts | 2 +- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/web/client/common/constants.ts b/src/web/client/common/constants.ts index fa276992..4f89f2f9 100644 --- a/src/web/client/common/constants.ts +++ b/src/web/client/common/constants.ts @@ -24,6 +24,7 @@ export const DATA_SOURCE = 'dataSource'; export const ADX_WEB_TEMPLATES = 'adx_webtemplates'; export const EMPTY_FILE_NAME = 'defaultfilename'; export const FILE_NAME_FIELD = '_primarynamefield'; +export const FILE_FOLDER_NAME = '_foldername'; export const CHARSET = 'utf-8'; export const PROVIDER_ID = "microsoft"; export const SCOPE_OPTION = "//.default"; @@ -45,7 +46,8 @@ export enum httpMethod { export enum vscodeUrlPathEntityName { WEBFILES = "webfiles", WEBPAGES = "webpages", - WEBTEMPLATES = "webtemplates" + WEBTEMPLATES = "webtemplates", + CONTENTSNIPPET = "contentsnippet" } /* Corresponding name of the entityType maintained in portalSchema file @@ -55,7 +57,8 @@ export enum vscodeUrlPathEntityName { export enum schemaEntityName { WEBFILES = "adx_webfile", WEBPAGES = "adx_webpage", - WEBTEMPLATES = "adx_webtemplate" + WEBTEMPLATES = "adx_webtemplate", + CONTENTSNIPPET = "adx_contentsnippet" } /* Corresponding name of the entityType in Dataverse entities. @@ -66,7 +69,8 @@ export enum schemaEntityName { export enum dataverseUrlPathEntityName { WEBFILES = "annotations", WEBPAGES = "adx_webpages", - WEBTEMPLATES = "adx_webtemplates" + WEBTEMPLATES = "adx_webtemplates", + CONTENTSNIPPET = "adx_contentsnippets" } /*This decides the folder hierarchy a file being displayed in File explorer will follow. @@ -83,35 +87,26 @@ export enum entityAttributesWithBase64Encoding { } export const columnExtension = new Map([ - ["customcss.css", "adx_customcss"], - ["customjs.js", "adx_customjavascript"], - ["webpage.copy.html", "adx_copy"], ["adx_customcss", "customcss.css"], ["adx_customjavascript", "customjs.js"], ["adx_copy", "webpage.copy.html"], ["documentbody", "css"] ]); -export const entityFolder = new Map([ - ["webpages", "web-pages"], - ["webtemplates", "web-templates"], - ["annotations", "web-files"], - ["contentpages", "content-pages"], - ["adx_webpages", "web-pages"] -]); - export const pathParamToSchema = new Map([ - [vscodeUrlPathEntityName.WEBPAGES, "adx_webpages"], - [vscodeUrlPathEntityName.WEBFILES, "annotations"], - [vscodeUrlPathEntityName.WEBTEMPLATES, "adx_webtemplates"], - ["adx_webpages", "adx_webpage"], - ["adx_webtemplates", "adx_webtemplate"], + [vscodeUrlPathEntityName.WEBPAGES, dataverseUrlPathEntityName.WEBPAGES], + [vscodeUrlPathEntityName.WEBFILES, dataverseUrlPathEntityName.WEBFILES], + [vscodeUrlPathEntityName.WEBTEMPLATES, dataverseUrlPathEntityName.WEBTEMPLATES], + [vscodeUrlPathEntityName.CONTENTSNIPPET, dataverseUrlPathEntityName.CONTENTSNIPPET], + [dataverseUrlPathEntityName.CONTENTSNIPPET, schemaEntityName.CONTENTSNIPPET], + [dataverseUrlPathEntityName.WEBPAGES, schemaEntityName.WEBPAGES], + [dataverseUrlPathEntityName.WEBTEMPLATES, schemaEntityName.WEBTEMPLATES], ["adx_websites", "adx_website"], ["adx_portallanguages", "adx_portallanguage"], ["adx_websitelanguages", "adx_websitelanguage"], ["adx_webfiles", "adx_webfile"], ["adx_copy", "adx_copy"], - ["annotations", "adx_webfile"], + [dataverseUrlPathEntityName.WEBFILES, schemaEntityName.WEBFILES], ]); export enum queryParameters { diff --git a/src/web/client/common/portalSchema.ts b/src/web/client/common/portalSchema.ts index 2a09c89e..2b328d6c 100644 --- a/src/web/client/common/portalSchema.ts +++ b/src/web/client/common/portalSchema.ts @@ -1311,9 +1311,11 @@ export const portal_schema_data = { "_disableplugins": "true", "_foldername": "content-snippets", "_propextension": "contentsnippet", - "_exporttype": "SubFolders", + "_exporttype": "SingleFolder", "_languagefield": "adx_contentsnippetlanguageid", - "_languagegroupby": "adx_name" + "_languagegroupby": "adx_name", + "_fetchQueryParameters": "?$filter=adx_contentsnippetid%20eq%20{entityId}&$select=adx_name,adx_value", + "_attributes": "adx_value" }, { "fields": { @@ -1387,9 +1389,9 @@ export const portal_schema_data = { "_disableplugins": "true", "_foldername": "web-templates", "_propextension": "webtemplate", - "_exporttype": "SubFolders", - "_fetchQueryParameters": "?$select=adx_name,adx_webtemplateid", - "_attributes": "adx_copy,adx_source" + "_exporttype": "SingleFolder", + "_fetchQueryParameters": "?$filter=adx_webtemplateid%20eq%20{entityId}&$select=adx_name,adx_source", + "_attributes": "adx_source" }, { "fields": { diff --git a/src/web/client/common/remoteFetchProvider.ts b/src/web/client/common/remoteFetchProvider.ts index 0f786e69..6cb35a5a 100644 --- a/src/web/client/common/remoteFetchProvider.ts +++ b/src/web/client/common/remoteFetchProvider.ts @@ -100,7 +100,7 @@ function createContentFiles( const attributes = entityEntry?.get('_attributes'); const exportType = entityEntry?.get('_exporttype'); const portalFolderName = queryParamsMap.get(Constants.WEBSITE_NAME) as string; - const subUri = Constants.entityFolder.get(entity) as string; + const subUri = entitiesSchemaMap.get(Constants.pathParamToSchema.get(entity) as string)?.get(Constants.FILE_FOLDER_NAME); let languageCode: string = Constants.DEFAULT_LANGUAGE_CODE; if (languageIdCodeMap?.size && lcid) { From a3aba2736ec84874fb765780b095f3d7be01b66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nidhi=20Tyagi=20=F0=9F=8C=9F=F0=9F=90=87=F0=9F=8C=B4?= =?UTF-8?q?=E2=9D=84=EF=B8=8F?= Date: Thu, 8 Sep 2022 08:21:46 +0530 Subject: [PATCH 2/2] remove lower casing of filenames --- src/web/client/common/remoteFetchProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/client/common/remoteFetchProvider.ts b/src/web/client/common/remoteFetchProvider.ts index 6cb35a5a..7c6df758 100644 --- a/src/web/client/common/remoteFetchProvider.ts +++ b/src/web/client/common/remoteFetchProvider.ts @@ -120,7 +120,7 @@ function createContentFiles( const fetchedFileName = entitiesSchemaMap.get(Constants.pathParamToSchema.get(entity) as string)?.get(Constants.FILE_NAME_FIELD); if (fetchedFileName) { - fileName = result[fetchedFileName].toLowerCase(); + fileName = result[fetchedFileName]; } if (fileName === Constants.EMPTY_FILE_NAME) {