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

Support Web template and content snippet #283

Merged
merged 3 commits into from
Sep 9, 2022
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
35 changes: 15 additions & 20 deletions src/web/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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 {
Expand Down
12 changes: 7 additions & 5 deletions src/web/client/common/portalSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1311,9 +1311,11 @@ export const portal_schema_data = {
"_disableplugins": "true",
"_foldername": "content-snippets",
"_propextension": "contentsnippet",
"_exporttype": "SubFolders",
"_exporttype": "SingleFolder",
tyaginidhi marked this conversation as resolved.
Show resolved Hide resolved
"_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": {
Expand Down Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/web/client/common/remoteFetchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down