From f370c72d0bae646fcbbe3400b167c08781ab863f Mon Sep 17 00:00:00 2001 From: Bidisha Das Date: Mon, 24 Jun 2024 17:21:10 +0530 Subject: [PATCH] changes for portal metadata view --- .../portalMetadataView/TreeView/DataMapper.ts | 1420 +++++++++++++++++ .../TreeView/PortalDrops/PortalDrops.ts | 11 + .../TreeView/TreeViewProvider.ts | 76 + .../TreeView/Types/Entity/AbstractEntity.ts | 6 + .../TreeView/Types/Entity/ContentSnippet.ts | 18 + .../Types/Entity/EntityAttributeMetadata.ts | 7 + .../TreeView/Types/Entity/EntityForm.ts | 117 ++ .../Types/Entity/EntityFormMetadata.ts | 57 + .../TreeView/Types/Entity/EntityList.ts | 84 + .../TreeView/Types/Entity/EntityView.ts | 219 +++ .../TreeView/Types/Entity/IItem.ts | 13 + .../TreeView/Types/Entity/PageTemplate.ts | 19 + .../TreeView/Types/Entity/SiteMarker.ts | 10 + .../TreeView/Types/Entity/SiteSettings.ts | 10 + .../TreeView/Types/Entity/WebForm.ts | 36 + .../TreeView/Types/Entity/WebFormMetadata.ts | 75 + .../TreeView/Types/Entity/WebFormStep.ts | 146 ++ .../TreeView/Types/Entity/WebPage.ts | 76 + .../TreeView/Types/Entity/WebTemplate.ts | 13 + .../TreeView/Types/Entity/Weblink.ts | 35 + .../TreeView/Types/Entity/WeblinkSet.ts | 15 + .../TreeView/Types/Entity/Website.ts | 19 + .../TreeView/Types/View/WebPage.ts | 22 + .../TreeView/Utils/Constant.ts | 37 + .../TreeView/Utils/IDataResolver.ts | 123 ++ .../services/DefaultPortalComponentService.ts | 13 + .../services/IPortalComponentService.ts | 16 + .../services/PortalComponentServiceFactory.ts | 24 + .../services/WebPageService.ts | 13 + .../services/WebsiteService.ts | 13 + 30 files changed, 2743 insertions(+) create mode 100644 src/common/portalMetadataView/TreeView/DataMapper.ts create mode 100644 src/common/portalMetadataView/TreeView/PortalDrops/PortalDrops.ts create mode 100644 src/common/portalMetadataView/TreeView/TreeViewProvider.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/AbstractEntity.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/ContentSnippet.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/EntityAttributeMetadata.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/EntityForm.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/EntityFormMetadata.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/EntityList.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/EntityView.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/IItem.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/PageTemplate.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/SiteMarker.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/SiteSettings.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/WebForm.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/WebFormMetadata.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/WebFormStep.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/WebPage.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/WebTemplate.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/Weblink.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/WeblinkSet.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/Entity/Website.ts create mode 100644 src/common/portalMetadataView/TreeView/Types/View/WebPage.ts create mode 100644 src/common/portalMetadataView/TreeView/Utils/Constant.ts create mode 100644 src/common/portalMetadataView/TreeView/Utils/IDataResolver.ts create mode 100644 src/common/portalMetadataView/services/DefaultPortalComponentService.ts create mode 100644 src/common/portalMetadataView/services/IPortalComponentService.ts create mode 100644 src/common/portalMetadataView/services/PortalComponentServiceFactory.ts create mode 100644 src/common/portalMetadataView/services/WebPageService.ts create mode 100644 src/common/portalMetadataView/services/WebsiteService.ts diff --git a/src/common/portalMetadataView/TreeView/DataMapper.ts b/src/common/portalMetadataView/TreeView/DataMapper.ts new file mode 100644 index 00000000..eb9a4690 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/DataMapper.ts @@ -0,0 +1,1420 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + */ + +import * as path from "path"; +import * as vscode from 'vscode'; +import { IPreviewEngineContext } from '../TreeView/Utils/IDataResolver'; +import { Webpage } from '../TreeView/Types/Entity/WebPage'; +import { Website } from '../TreeView/Types/Entity/Website'; +import { WebTemplate } from '../TreeView/Types/Entity/WebTemplate'; +import { PageTemplate } from '../TreeView/Types/Entity/PageTemplate'; +import { PortalWebView } from '../../../client/PortalWebView'; +import { ContextProperty } from '../TreeView/Utils/Constant'; +import { createTree } from './TreeViewProvider'; +import { IItem } from '../TreeView/Types/Entity/IItem'; +import { PortalComponentServiceFactory } from "../services/PortalComponentServiceFactory"; + +const yaml = require("js-yaml"); +const load = yaml.load; +const fallbackURI = vscode.Uri.file(''); + +export const treeView = async () => { + const previewHelper = new PreviewHelper(); + try { + await previewHelper.createContext(); + const getPath=await previewHelper.getPath(); + const IPortalMetadataContext = await previewHelper.getPreviewHelper(); + console.log(IPortalMetadataContext); + const web=await previewHelper.web(); + const { allwebTemplate, allwebPage, allpageTemplate } = convertAllMetadataToItems(IPortalMetadataContext, getPath); + const websiteIItem = await createWebsiteItem(previewHelper); + const { webtemplateIItem, webPageIItem, pageTemplateItem } = createIndividualItems(allwebTemplate, allwebPage, allpageTemplate); + (websiteIItem.children as IItem[]).push(webtemplateIItem, webPageIItem, pageTemplateItem); + console.log(websiteIItem); + createTree(websiteIItem); + + } catch (error) { + console.error('Error:', error); + } +}; + +function convertAllMetadataToItems(IPortalMetadataContext: any, getPath: any) { + const allwebTemplate = convertWebTemplatesToIItems(IPortalMetadataContext, getPath); + const allwebPage = convertWebpagesToItems(IPortalMetadataContext, getPath); + const allpageTemplate = convertPageTemplateToItems(IPortalMetadataContext); + return { allwebTemplate, allwebPage, allpageTemplate }; +} + +async function createWebsiteItem(previewHelper: PreviewHelper) { + const web = await previewHelper.web(); + return { + label: web.adx_name ?? 'Unnamed Website', + title: web.adx_name ?? 'Unnamed Website', + id: web.adx_websiteid, + isFile: false, + content: "", + path: vscode.Uri.parse(`/${web.adx_name}`), + component: "12", + children: [], + error: "" + }; +} + +function createIndividualItems(allwebTemplate: IItem[], allwebPage: IItem[], allpageTemplate: IItem[]) { + const webtemplateIItem = { + label: 'Web Template', + title: 'Web Template', + id: '', + isFile: false, + content: "", + path: vscode.Uri.parse(`/WebTemplate`), + component: "", + children: allwebTemplate, + error: "" + }; + + const webPageIItem = { + label: 'Web Page', + title: 'Web Page', + id: '', + isFile: false, + content: "", + path: vscode.Uri.parse(`/WebPage`), + component: "", + children: allwebPage, + error: "" + }; + + const pageTemplateItem = { + label: 'Page Template', + title: 'Page Template', + id: '', + isFile: false, + content: "", + path: vscode.Uri.parse(`/PageTemplate`), + component: "", + children: allpageTemplate, + error: "" + }; + + return { webtemplateIItem, webPageIItem, pageTemplateItem }; +} + + + + + + +function createItem(label: string, title: string, id: string, isFile: boolean, path: vscode.Uri, component: string, children: IItem[] = [], content: string = '', error: string = ''): IItem { + return { + label, + title, + id, + isFile, + content, + path, + component, + children, + error, + }; +} + +function createCopyItems(webpage: Webpage, getPath: any, y: string, x: string, langSuffix: string = '',content: string = ''): IItem[] { + const basePath = `${getPath.path}/web-pages/${y}${content}/${x}${langSuffix}`; + const copyItem = createItem(`${webpage.adx_name} Copy`, `${webpage.adx_name} Copy`, `${webpage.adx_webpageid}_copy`, true, vscode.Uri.file(`${basePath}.webpage.copy.html`), "01"); + const dependenciesItem = createItem(`Dependencies`, `Dependencies`, '', false, vscode.Uri.file(`/dependencies`), "01"); + const cssItem = createItem(`${webpage.adx_name}.css`, `${webpage.adx_name}.css`, `${webpage.adx_webpageid}_css`, true, vscode.Uri.file(`${basePath}.webpage.custom_css.css`), "01"); + const jsItem = createItem(`${webpage.adx_name}.js`, `${webpage.adx_name}.js`, `${webpage.adx_webpageid}_js`, true, vscode.Uri.file(`${basePath}.webpage.custom_javascript.js`), "01"); + const summaryItem = createItem(`${webpage.adx_name} Summary`, `${webpage.adx_name} Summary`, `${webpage.adx_webpageid}_summary`, true, vscode.Uri.file(`${basePath}.webpage.summary.html`), "01"); + const pageCopy = createItem(`Page Copy`, `Page Copy`, `Page_copy`, false, vscode.Uri.file(`/pagecopy`), "01", [copyItem, dependenciesItem]); + const pageSummary = createItem(`Page Summary`, `Page Summary`, `Page_Summary`, false, vscode.Uri.file(`/pageSummary`), "01", [summaryItem]); + + return [pageCopy, cssItem, jsItem, pageSummary]; +} + +function convertWebpagesToItems(metadataContext: IPreviewEngineContext, getPath: any): IItem[] { + return PortalComponentServiceFactory.getPortalComponent("WebPage")?.create(metadataContext, getPath) || []; + // const items: IItem[] = []; + // const webpages: Webpage[] | undefined = metadataContext.webpages; + + // if (!webpages) { + // return items; + // } + + // const contentPage: Webpage[] = []; + + // for (const webpage of webpages) { + // if (!webpage.adx_webpagelanguageid) { + // const str = webpage.adx_name; + // let x = str.replace(/\s+/g, '-'); + // let y = x.toLowerCase(); + // const [pageCopy, cssItem, jsItem, pageSummary] = createCopyItems(webpage, getPath, y, x); + // const webpageItem = createItem(webpage.adx_name, webpage.adx_name, webpage.adx_webpageid, false, vscode.Uri.parse(`/${webpage.adx_name}`), "03", [pageCopy, cssItem, jsItem, pageSummary]); + // items.push(webpageItem); + // } else { + // contentPage.push(webpage); + // } + // } + + // items.forEach(item => { + // webpages.forEach(webpage => { + // if (item.id === webpage.adx_parentpageid) { + // const subItem = items.find(it => webpage.adx_webpageid === it.id); + // if (subItem) { + // let subpageItem = item.children.find(child => child.label === "Subpage"); + // if (!subpageItem) { + // subpageItem = createItem('Subpage', 'Subpage', '', false, vscode.Uri.parse(`/Subpage`), "", [subItem]); + // item.children.push(subpageItem); + // } else { + // subpageItem.children.push(subItem); + // } + // } + // } + // }); + // }); + + // for (const contentpg of contentPage) { + // const str = contentpg.adx_name; + // let x = str.replace(/\s+/g, '-'); + // let y = x.toLowerCase(); + // const [pageCopy, cssItem, jsItem, pageSummary] = createCopyItems(contentpg, getPath, y, x, '.en-US','/content-pages'); + // const contentPageItem = createItem(`${contentpg.adx_name} Content Page`, `${contentpg.adx_name} Content Page`, `${contentpg.adx_webpageid}_content`, false, vscode.Uri.file(`${contentpg.adx_name}/Content`), "", [pageCopy, cssItem, jsItem, pageSummary]); + + // items.forEach(item => { + // if (item.title === contentpg.adx_name) { + // item.children.push(contentPageItem); + // } + // }); + // } + + // console.log(items); + // return items.filter(item => item.label === "Home"); +} + +function convertWebTemplatesToIItems(metadataContext: IPreviewEngineContext,getPath: any): IItem[] { + return PortalComponentServiceFactory.getPortalComponent("")?.create(metadataContext, getPath) || []; + // const items: IItem[] = []; + // const webTemplates: WebTemplate[] | undefined = metadataContext.webTemplates; + + // if (!webTemplates) { + // return items; + // } + + // for (const template of webTemplates) { + // const str=template.adx_name; + // let x=str.replace(/\s+/g, '-'); + // let y=x.toLowerCase(); + // const children: IItem[] = [ + // { + // label: "SourceDependencies", + // title: "SourceDependencies", + // id: `${template.adx_webtemplateid}_sourceDependencies`, + // isFile: false, + // content: "", + // path: vscode.Uri.parse(`/${template.adx_name}/sourceDependencies`), + // component: "", + // children: [], + // error: "" + // }, + // { + // label: `${template.adx_name}.html`, + // title: `${template.adx_name}.html`, + // id: `${template.adx_webtemplateid}_html`, + // isFile: true, + // content: template.adx_source, + // // path: vscode.Uri.parse(`/${template.adx_name}/${template.adx_name}.html`), + // path: vscode.Uri.file(`${getPath.path}/web-templates/${y}/${x}.webtemplate.source.html`), + // component: "01", + // children: [], + // error: "" + // } + // ]; + + // const item: IItem = { + // label: template.adx_name, + // title: template.adx_name, + // id: template.adx_webtemplateid, + // isFile: false, + // content: '', + // path: vscode.Uri.parse(`/${template.adx_name}`), + // component: "8", + // children: children, + // error: "" + // }; + + // items.push(item); + // } + // return items; +} + +function convertPageTemplateToItems(metadataContext: IPreviewEngineContext): IItem[] { + const items: IItem[] = []; + const pageTemplates: PageTemplate[] | undefined = metadataContext.pageTemplates; + + if (!pageTemplates) { + return items; + } + + for (const template of pageTemplates) { + const item: IItem = { + label: template.adx_name, + title: template.adx_name, + id: template.adx_pagetemplateid, + isFile: true, + content: template.adx_description || '', + path: undefined, + component: "8", + children: [], + error: "" + }; + + items.push(item); + } + return items; +} + + + + + +export class PreviewHelper { + private pathroot: vscode.Uri | null; + private previewHelper: IPreviewEngineContext; + private websiteData: Website; + + constructor() { + this.previewHelper = {}; + // this.pathroot = PortalWebView.getPortalRootFolder(); + this.pathroot= vscode.Uri.file('/c:/Users/t-mansisingh/Desktop/clone2/mansi-site-1---site-ajx90'); + this.websiteData = {} as Website; + } + + public createContext = async () => { + this.websiteData = await this.getWebsite(); + this.previewHelper = await this.createEngineContext(); + } + public getPath=async()=>{ + return this.pathroot; + } + + // should have proper naming convention + public web=async()=>{ + return this.websiteData; + } + + public getPreviewHelper = () => { + return this.previewHelper; + } + + private getWebsite = async (): Promise => { + const website = await vscode.workspace.fs.readFile(this.pathroot?.with({ path: this.pathroot.path + '/website.yml' }) || fallbackURI); + const websiteYaml = load(new TextDecoder().decode(website)); + return websiteYaml as Website; + } + + private createEngineContext = async (): Promise => { + if (this.pathroot) { + return { + webpages: await this.getWebpages(), + pageTemplates: await this.getPageTemplates(), + webTemplates: await this.getWebTemplates(), + } + } else return {} + } + + private getWebpages = async (): Promise => { + const webpagesDir = await vscode.workspace.fs.readDirectory(this.pathroot?.with({ path: this.pathroot.path + '/web-pages' }) || fallbackURI); + const webpageArray: Webpage[] = []; + + for (const webpage of webpagesDir) { + webpageArray.push(await this.webPageHelper(this.pathroot?.with({ path: this.pathroot.path + '/web-pages/' + webpage[0] + '/' + webpage[0] }) || fallbackURI)); + + const contentPageDir = await vscode.workspace.fs.readDirectory(this.pathroot?.with({ path: this.pathroot.path + '/web-pages/' + webpage[0] + '/content-pages' }) || fallbackURI); + for (const page of contentPageDir) { + if (page[0].endsWith(ContextProperty.WEBPAGE_YAML)) { + const pageName = page[0].slice(0, -12); + webpageArray.push(await this.webPageHelper(this.pathroot?.with({ path: this.pathroot.path + '/web-pages/' + webpage[0] + '/content-pages/' + pageName }) || fallbackURI)); + } + } + } + return webpageArray; + } + + private webPageHelper = async (pageUri: vscode.Uri): Promise => { + const webpageYaml = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.yml' })); + const webpageJS = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.custom_javascript.js' })); + const webpageCSS = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.custom_css.css' })); + const webpageCopy = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.copy.html' })); + const webpageSummary = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.summary.html' })); + const webpageRecord = load(new TextDecoder().decode(webpageYaml)) as Webpage; + webpageRecord.adx_customcss = new TextDecoder().decode(webpageCSS); + webpageRecord.adx_customjavascript = new TextDecoder().decode(webpageJS); + webpageRecord.adx_copy = new TextDecoder().decode(webpageCopy); + webpageRecord.adx_summary = new TextDecoder().decode(webpageSummary); + webpageRecord.adx_websiteid = this.websiteData.adx_websiteid; + return webpageRecord; + } + + private getPageTemplates = async (): Promise => { + const pageTemplatesDirectory = await vscode.workspace.fs.readDirectory(this.pathroot?.with({ path: this.pathroot.path + '/page-templates' }) || fallbackURI); + const pageTemplatesArray: PageTemplate[] = []; + + for (const pageTemplate of pageTemplatesDirectory) { + pageTemplatesArray.push(await this.pageTemplateHelper(this.pathroot?.with({ path: this.pathroot.path + '/page-templates/' + pageTemplate[0] }) || fallbackURI)); + } + return pageTemplatesArray; + } + + private pageTemplateHelper = async (fileUri: vscode.Uri): Promise => { + const pageTemplateYaml = await vscode.workspace.fs.readFile(fileUri); + const pageTemplateRecord = load(new TextDecoder().decode(pageTemplateYaml)) as PageTemplate; + return pageTemplateRecord; + }; + + + private webTemplateHelper = async (fileUri: vscode.Uri): Promise => { + const webTemplateYaml = await vscode.workspace.fs.readFile(fileUri?.with({ path: fileUri.path + '.webtemplate.yml' })); + const webTemplateSource = await vscode.workspace.fs.readFile(fileUri?.with({ path: fileUri.path + '.webtemplate.source.html' })); + const webTemplateSourceHTML = new TextDecoder().decode(webTemplateSource); + const webTemplateRecord = load(new TextDecoder().decode(webTemplateYaml)) as WebTemplate; + webTemplateRecord.adx_source = webTemplateSourceHTML; + webTemplateRecord.adx_websiteid = this.websiteData.adx_websiteid; + return webTemplateRecord; + }; + + private getWebTemplates = async (): Promise => { + const webTemplatesDirectory = await vscode.workspace.fs.readDirectory(this.pathroot?.with({ path: this.pathroot.path + '/web-templates' }) || fallbackURI); + + const webTemplatesArray: WebTemplate[] = []; + for (const webTemplate of webTemplatesDirectory) { + webTemplatesArray.push(await this.webTemplateHelper(this.pathroot?.with({ path: this.pathroot.path + '/web-templates/' + webTemplate[0] + `/${webTemplate[0]}` }) || fallbackURI)); + } + return webTemplatesArray; + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// export class PreviewEngineContext { + +// private previewEngineContext: IPreviewEngineContext; +// private websiteRecord: Website; +// private rootPath: vscode.Uri | null; +// private isBootstrapV5: boolean; + +// constructor() { +// this.isBootstrapV5 = false; +// this.previewEngineContext = {}; +// this.rootPath = PortalWebView.getPortalRootFolder(); +// this.websiteRecord = {} as Website; +// console.log(this.rootPath); +// } + +// public createContext = async () => { +// this.websiteRecord = await this.getWebsite(); +// this.previewEngineContext = await this.createEngineContext(); +// } + +// public getPreviewEngineContext = () => { +// return this.previewEngineContext; +// } + +// private createEngineContext = async (): Promise => { + +// if (this.rootPath) { +// return { +// webpages: await this.getWebpages(), +// contentSnippets: await this.getContentSnippets(), +// webTemplates: await this.getWebTemplates(), +// siteMarkers: await this.getSiteMarker(), +// siteSettings: await this.getSiteSetting(), +// entityLists: await this.getEntityLists(), +// entityForms: await this.getEntityForms(), +// webForms: await this.getWebForms(), +// weblinks: await this.getWeblinks(), +// weblinkSets: await this.getWeblinkSets(), +// website: this.websiteRecord, +// pageTemplates: await this.getPageTemplates(), +// dataResolverExtras: {}, +// resx: {}, +// featureConfig: new Map(), +// entityAttributeMetadata: [] as IEntityAttributeMetadata[], +// lcid: '' as string, +// isBootstrapV5: this.isBootstrapV5, +// } +// } else return {} +// } + +// private getWebsite = async (): Promise => { +// const website = await vscode.workspace.fs.readFile(this.rootPath?.with({ path: this.rootPath.path + '/website.yml' }) || fallbackURI); +// const websiteYaml = load(new TextDecoder().decode(website)); +// console.log(websiteYaml); +// return websiteYaml as Website; +// } + +// private webPageHelper = async (pageUri: vscode.Uri): Promise => { +// const webpageYaml = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.yml' })); +// const webpageJS = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.custom_javascript.js' })); +// const webpageCSS = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.custom_css.css' })); +// const webpageCopy = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.copy.html' })); +// const webpageSummary = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.summary.html' })); +// const webpageRecord = load(new TextDecoder().decode(webpageYaml)) as Webpage; +// webpageRecord.adx_customcss = new TextDecoder().decode(webpageCSS); +// webpageRecord.adx_customjavascript = new TextDecoder().decode(webpageJS); +// webpageRecord.adx_copy = new TextDecoder().decode(webpageCopy); +// webpageRecord.adx_summary = new TextDecoder().decode(webpageSummary); +// webpageRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return webpageRecord; +// } + + +// private getWebpages = async (): Promise => { +// const webpagesDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/web-pages' }) || fallbackURI); + +// const webpageArray: Webpage[] = []; +// for (const webpage of webpagesDirectory) { +// webpageArray.push(await this.webPageHelper(this.rootPath?.with({ path: this.rootPath.path + '/web-pages/' + webpage[0] + '/' + webpage[0] }) || fallbackURI)); + +// const contentPageDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/web-pages/' + webpage[0] + '/content-pages' }) || fallbackURI); +// for (const page of contentPageDirectory) { +// if (page[0].endsWith(ContextProperty.WEBPAGE_YAML)) { +// const pageName = page[0].slice(0, -12); +// webpageArray.push(await this.webPageHelper(this.rootPath?.with({ path: this.rootPath.path + '/web-pages/' + webpage[0] + '/content-pages/' + pageName }) || fallbackURI)); +// } +// } +// } +// console.log(webpageArray); +// return webpageArray; +// } + +// private getWeblinks = async (): Promise => { +// const weblinksDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets' }) || fallbackURI); + +// const weblinksArray: Weblink[] = []; +// for (const link of weblinksDirectory) { +// const linkSubDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets/' + link[0] }) || fallbackURI); +// for (const sublink of linkSubDirectory) { +// if (sublink[0].endsWith(ContextProperty.WEB_LINK)) { +// const weblinkYaml = await vscode.workspace.fs.readFile(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets/' + link[0] + `/${sublink[0]}` }) || fallbackURI); +// const weblinkRecord = load(new TextDecoder().decode(weblinkYaml)) as Weblink[] +// weblinksArray.push(...weblinkRecord); +// } +// } +// } +// return weblinksArray; +// } + +// private webLinkSetHelper = async (fileUri: vscode.Uri): Promise => { +// const weblinkSetYaml = await vscode.workspace.fs.readFile(fileUri); +// const weblinkSetRecord = load(new TextDecoder().decode(weblinkSetYaml)) as WeblinkSet; +// weblinkSetRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return weblinkSetRecord; +// }; + +// private getWeblinkSets = async (): Promise => { +// const weblinkSetsDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets' }) || fallbackURI); + +// const weblinkSetsArray: WeblinkSet[] = []; +// for (const weblinkSet of weblinkSetsDirectory) { +// const linkSubDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets/' + weblinkSet[0] }) || fallbackURI); +// for (const sublink of linkSubDirectory) { +// if (sublink[0].endsWith(ContextProperty.WEB_LINK_SET)) { +// weblinkSetsArray.push(await this.webLinkSetHelper(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets/' + weblinkSet[0] + `/${sublink[0]}` }) || fallbackURI)); // adx_title not in pac data but is manadatory, studio sends as undefined. +// } +// } +// } +// return weblinkSetsArray; +// } + + +// private contentSnippetHelper = async (fileUri: vscode.Uri): Promise => { +// const snippetYaml = await vscode.workspace.fs.readFile(fileUri?.with({ path: fileUri.path + '.contentsnippet.yml' })); +// const snippetValue = await vscode.workspace.fs.readFile(fileUri?.with({ path: fileUri.path + '.contentsnippet.value.html' })); +// const snippetRecord = load(new TextDecoder().decode(snippetYaml)) as ContentSnippet +// snippetRecord.adx_value = new TextDecoder().decode(snippetValue); +// snippetRecord.adx_websiteid = '92d6c1b4-d84b-ee11-be6e-0022482d5cfb'; +// snippetRecord.stateCode = 0; //check with PAC SME on how to get this field +// return snippetRecord; +// }; + + +// private getContentSnippets = async (): Promise => { +// const contentSnippetsDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/content-snippets' }) || fallbackURI); + +// const contentSnippetsArray: ContentSnippet[] = []; +// for (const contentSnippet of contentSnippetsDirectory) { +// const snippetSubDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/content-snippets/' + contentSnippet[0] }) || fallbackURI); +// for (const snippet of snippetSubDirectory) { +// if (snippet[0].endsWith(ContextProperty.CONTENT_SNIPPET_YAML)) { +// contentSnippetsArray.push(await this.contentSnippetHelper(this.rootPath?.with({ path: this.rootPath.path + '/content-snippets/' + contentSnippet[0] + `/${snippet[0].slice(0, -19)}` }) || fallbackURI)); +// } +// } +// } +// return contentSnippetsArray; +// } + +// private pageTemplateHelper = async (fileUri: vscode.Uri): Promise => { +// const pageTemplateYaml = await vscode.workspace.fs.readFile(fileUri); +// const pageTemplateRecord = load(new TextDecoder().decode(pageTemplateYaml)) as PageTemplate; +// return pageTemplateRecord; +// }; + + +// private getPageTemplates = async (): Promise => { +// const pageTemplatesDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/page-templates' }) || fallbackURI); + +// const pageTemplatesArray: PageTemplate[] = []; +// for (const pageTemplate of pageTemplatesDirectory) { +// pageTemplatesArray.push(await this.pageTemplateHelper(this.rootPath?.with({ path: this.rootPath.path + '/page-templates/' + pageTemplate[0] }) || fallbackURI)); +// } +// return pageTemplatesArray; +// } + +// private webTemplateHelper = async (fileUri: vscode.Uri): Promise => { +// const webTemplateYaml = await vscode.workspace.fs.readFile(fileUri?.with({ path: fileUri.path + '.webtemplate.yml' })); +// const webTemplateSource = await vscode.workspace.fs.readFile(fileUri?.with({ path: fileUri.path + '.webtemplate.source.html' })); +// const webTemplateSourceHTML = new TextDecoder().decode(webTemplateSource); +// const webTemplateRecord = load(new TextDecoder().decode(webTemplateYaml)) as WebTemplate; +// webTemplateRecord.adx_source = webTemplateSourceHTML; +// webTemplateRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return webTemplateRecord; +// }; + +// private getWebTemplates = async (): Promise => { +// const webTemplatesDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/web-templates' }) || fallbackURI); + +// const webTemplatesArray: WebTemplate[] = []; +// for (const webTemplate of webTemplatesDirectory) { +// webTemplatesArray.push(await this.webTemplateHelper(this.rootPath?.with({ path: this.rootPath.path + '/web-templates/' + webTemplate[0] + `/${webTemplate[0]}` }) || fallbackURI)); +// } +// return webTemplatesArray; +// } + +// private entityFormHelper = async (fileUri: vscode.Uri): Promise => { +// const entityFormYaml = await vscode.workspace.fs.readFile(fileUri); +// const entityFormRecord = load(new TextDecoder().decode(entityFormYaml)) as EntityForm; +// entityFormRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return entityFormRecord; +// }; + +// private getEntityForms = async (): Promise => { +// const entityFormsDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/basic-forms' }) || fallbackURI); + +// const entityFormsArray: EntityForm[] = []; +// for (const entityForm of entityFormsDirectory) { +// entityFormsArray.push(await this.entityFormHelper(this.rootPath?.with({ path: this.rootPath.path + '/basic-forms/' + entityForm[0] + `/${entityForm[0]}.basicform.yml` }) || fallbackURI)); +// } +// return entityFormsArray; +// } + +// private entityListHelper = async (fileUri: vscode.Uri): Promise => { +// const entityListYaml = await vscode.workspace.fs.readFile(fileUri); +// const entityListRecord = load(new TextDecoder().decode(entityListYaml)) as EntityList; +// entityListRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return entityListRecord; +// }; + +// private getEntityLists = async (): Promise => { +// const entityListsDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/lists' }) || fallbackURI); + +// const entityListsArray: EntityList[] = []; +// for (const entityList of entityListsDirectory) { +// if (entityList[0].endsWith(ContextProperty.ENTITY_LIST)) { +// entityListsArray.push(await this.entityListHelper(this.rootPath?.with({ path: this.rootPath.path + '/lists/' + entityList[0] }) || fallbackURI)); +// } +// } +// return entityListsArray; +// } + +// private webFormHelper = async (fileUri: vscode.Uri): Promise => { +// const webFormYaml = await vscode.workspace.fs.readFile(fileUri); +// const webFormRecord = load(new TextDecoder().decode(webFormYaml)) as WebForm; +// webFormRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return webFormRecord; +// }; + + +// private getWebForms = async (): Promise => { +// const webFormsDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/advanced-forms' }) || fallbackURI); + +// const webFormsArray: WebForm[] = []; +// for (const webForm of webFormsDirectory) { +// webFormsArray.push(await this.webFormHelper(this.rootPath?.with({ path: this.rootPath.path + '/advanced-forms/' + webForm[0] + `/${webForm[0]}.advancedform.yml` }) || fallbackURI)); +// } +// return webFormsArray; +// } + +// private getSiteSetting = async (): Promise => { +// const siteSetting = await vscode.workspace.fs.readFile(this.rootPath?.with({ path: this.rootPath.path + '/sitesetting.yml' }) || fallbackURI); +// const siteSettingYaml = load(new TextDecoder().decode(siteSetting)) as SiteSetting[]; +// const siteSettingRecords = siteSettingYaml.map((siteSettingRecord) => { +// if (siteSettingRecord.adx_name === BootstrapSiteSetting) { +// this.isBootstrapV5 = siteSettingRecord.adx_value ? String(siteSettingRecord.adx_value).toLowerCase() === 'true' : false; +// } +// return { +// adx_websiteid: this.websiteRecord.adx_websiteid, +// adx_name: siteSettingRecord.adx_name, +// adx_value: siteSettingRecord.adx_value, +// adx_sitesettingid: siteSettingRecord.adx_sitesettingid, +// } +// }); +// return siteSettingRecords; +// } + +// private getSiteMarker = async (): Promise => { +// const siteMarker = await vscode.workspace.fs.readFile(this.rootPath?.with({ path: this.rootPath.path + '/sitemarker.yml' }) || fallbackURI); +// const siteMarkerYaml = load(new TextDecoder().decode(siteMarker)) as SiteMarker[]; +// const siteMarkerRecords = siteMarkerYaml.map((siteMarkerRecord) => { +// return { +// adx_name: siteMarkerRecord.adx_name as string, +// adx_pageid: siteMarkerRecord.adx_pageid as string, +// adx_sitemarkerid: siteMarkerRecord.adx_sitemarkerid, +// adx_websiteid: this.websiteRecord.adx_websiteid, + +// } + +// }); +// return siteMarkerRecords; +// } + +// public updateContext = async () => { +// const fileUri = vscode.window.activeTextEditor?.document.uri || fallbackURI; +// const fileName = getFileProperties(fileUri.path).fileCompleteName; +// if (!fileName) { +// // TODO: Handle this scenario +// return; +// } +// // Check entity type +// const entityType: ContextProperty = this.getEntityType(fileName); + +// switch (entityType) { +// case ContextProperty.SITE_MARKER: +// this.previewEngineContext.siteMarkers = await this.getSiteMarker(); +// break; +// case ContextProperty.SITE_SETTING: +// this.previewEngineContext.siteSettings = await this.getSiteSetting(); +// break; +// case ContextProperty.WEBSITE: +// { +// const websiteObj = await this.getWebsite(); +// if (websiteObj?.adx_websiteid === this.websiteRecord?.adx_websiteid) { +// this.websiteRecord = websiteObj; +// } +// else { +// this.websiteRecord = websiteObj; +// this.previewEngineContext = await this.createEngineContext(); +// } +// break; +// } +// case ContextProperty.WEB_LINK: +// this.previewEngineContext.weblinks = await this.getWeblinks(); +// break; +// case ContextProperty.WEB_LINK_SET: { +// const obj = await this.webLinkSetHelper(fileUri); +// const value = obj[ContextPropertyKey.WEB_LINK_SET as unknown as keyof WeblinkSet]; +// const index = findObjectIndexByProperty(this.previewEngineContext.weblinkSets, ContextPropertyKey.WEB_LINK_SET, value); +// if (index != -1 && this.previewEngineContext.weblinkSets) { +// this.previewEngineContext.weblinkSets[index] = obj; +// } else { +// this.previewEngineContext.weblinkSets = await this.getWeblinkSets(); +// } +// break; +// } +// case ContextProperty.ENTITY_FORM: +// { +// const obj = await this.entityFormHelper(fileUri); +// const value = obj[ContextPropertyKey.ENTITY_FORM as unknown as keyof EntityForm]; +// const index = findObjectIndexByProperty(this.previewEngineContext.entityForms, ContextPropertyKey.ENTITY_FORM, value); +// if (index != -1 && this.previewEngineContext.entityForms) { +// this.previewEngineContext.entityForms[index] = obj; +// } else { +// this.previewEngineContext.entityForms = await this.getEntityForms(); +// } +// break; +// } +// case ContextProperty.ENTITY_LIST: +// { +// const obj = await this.entityListHelper(fileUri); +// const value = obj[ContextPropertyKey.ENTITY_LIST as unknown as keyof EntityList]; +// const index = findObjectIndexByProperty(this.previewEngineContext.entityLists, ContextPropertyKey.ENTITY_LIST, value); +// if (index != -1 && this.previewEngineContext.entityLists) { +// this.previewEngineContext.entityLists[index] = obj; +// } else { +// this.previewEngineContext.entityLists = await this.getEntityLists(); +// } +// break; +// } +// case ContextProperty.WEB_FORM: +// { +// const obj = await this.webFormHelper(fileUri); +// const value = obj[ContextPropertyKey.WEB_FORM as unknown as keyof WebForm]; +// const index = findObjectIndexByProperty(this.previewEngineContext.webForms, ContextPropertyKey.WEB_FORM, value); +// if (index != -1 && this.previewEngineContext.webForms) { +// this.previewEngineContext.webForms[index] = obj; +// } else { +// this.previewEngineContext.webForms = await this.getWebForms(); +// } +// break; +// } +// case ContextProperty.PAGE_TEMPLATE: +// { +// const obj = await this.pageTemplateHelper(fileUri); +// const value = obj[ContextPropertyKey.PAGE_TEMPLATE as unknown as keyof PageTemplate]; +// const index = findObjectIndexByProperty(this.previewEngineContext.pageTemplates, ContextPropertyKey.PAGE_TEMPLATE, value); +// if (index != -1 && this.previewEngineContext.pageTemplates) { +// this.previewEngineContext.pageTemplates[index] = obj; +// } else { +// this.previewEngineContext.pageTemplates = await this.getPageTemplates(); +// } +// break; +// } +// case ContextProperty.WEBPAGE_YAML: +// case ContextProperty.WEBPAGE_COPY: +// case ContextProperty.WEBPAGE_CSS: +// case ContextProperty.WEBPAGE_JS: +// case ContextProperty.WEBPAGE_SUMMARY: +// { +// const obj = await this.webPageHelper(fileUri?.with({ path: removeExtension(fileUri.path, entityType) })); +// const value = obj[ContextPropertyKey.WEBPAGE as unknown as keyof Webpage]; +// const index = findObjectIndexByProperty(this.previewEngineContext.webpages, ContextPropertyKey.WEBPAGE, value); +// if (index != -1 && this.previewEngineContext.webpages) { +// this.previewEngineContext.webpages[index] = obj; +// } else { +// this.previewEngineContext.webpages = await this.getWebpages(); +// } +// break; +// } +// case ContextProperty.WEB_TEMPLATE_YAML: +// case ContextProperty.WEB_TEMPLATE_SOURCE: +// { +// const obj = await this.webTemplateHelper(fileUri?.with({ path: removeExtension(fileUri.path, entityType) })); +// const value = obj[ContextPropertyKey.WEB_TEMPLATE as unknown as keyof WebTemplate]; +// const index = findObjectIndexByProperty(this.previewEngineContext.webTemplates, ContextPropertyKey.WEB_TEMPLATE, value); +// if (index != -1 && this.previewEngineContext.webTemplates) { +// this.previewEngineContext.webTemplates[index] = obj; +// } else { +// this.previewEngineContext.webTemplates = await this.getWebTemplates(); +// } +// break; +// } +// case ContextProperty.CONTENT_SNIPPET_YAML: +// case ContextProperty.CONTENT_SNIPPET_VALUE: +// { +// const obj = await this.contentSnippetHelper(fileUri?.with({ path: removeExtension(fileUri.path, entityType) })); +// const value = obj[ContextPropertyKey.CONTENT_SNIPPET as unknown as keyof ContentSnippet]; +// const index = findObjectIndexByProperty(this.previewEngineContext.contentSnippets, ContextPropertyKey.CONTENT_SNIPPET, value); +// if (index != -1 && this.previewEngineContext.contentSnippets) { +// this.previewEngineContext.contentSnippets[index] = obj; +// } else { +// this.previewEngineContext.contentSnippets = await this.getContentSnippets(); +// } +// break; +// } +// default: +// break; +// } +// } + +// private getEntityType = (filename: string): ContextProperty => { + +// if (filename.endsWith(ContextProperty.WEBSITE)) { +// return ContextProperty.WEBSITE; +// } else if (filename.endsWith(ContextProperty.SITE_SETTING)) { +// return ContextProperty.SITE_SETTING; +// } else if (filename.endsWith(ContextProperty.SITE_MARKER)) { +// return ContextProperty.SITE_MARKER; +// } else if (filename.endsWith(ContextProperty.ENTITY_FORM)) { +// return ContextProperty.ENTITY_FORM; +// } else if (filename.endsWith(ContextProperty.ENTITY_LIST)) { +// return ContextProperty.ENTITY_LIST; +// } else if (filename.endsWith(ContextProperty.WEB_FORM)) { +// return ContextProperty.WEB_FORM; +// } else if (filename.endsWith(ContextProperty.WEB_LINK)) { +// return ContextProperty.WEB_LINK; +// } else if (filename.endsWith(ContextProperty.WEB_LINK_SET)) { +// return ContextProperty.WEB_LINK_SET; +// } else if (filename.endsWith(ContextProperty.PAGE_TEMPLATE)) { +// return ContextProperty.PAGE_TEMPLATE; +// } else if (filename.endsWith(ContextProperty.WEB_TEMPLATE_YAML)) { +// return ContextProperty.WEB_TEMPLATE_YAML; +// } else if (filename.endsWith(ContextProperty.WEB_TEMPLATE_SOURCE)) { +// return ContextProperty.WEB_TEMPLATE_SOURCE; +// } else if (filename.endsWith(ContextProperty.WEBPAGE_YAML)) { +// return ContextProperty.WEBPAGE_YAML; +// } else if (filename.endsWith(ContextProperty.WEBPAGE_COPY)) { +// return ContextProperty.WEBPAGE_COPY; +// } else if (filename.endsWith(ContextProperty.WEBPAGE_CSS)) { +// return ContextProperty.WEBPAGE_CSS; +// } else if (filename.endsWith(ContextProperty.WEBPAGE_JS)) { +// return ContextProperty.WEBPAGE_JS; +// } else if (filename.endsWith(ContextProperty.WEBPAGE_SUMMARY)) { +// return ContextProperty.WEBPAGE_SUMMARY; +// } else if (filename.endsWith(ContextProperty.CONTENT_SNIPPET_YAML)) { +// return ContextProperty.CONTENT_SNIPPET_YAML; +// } else if (filename.endsWith(ContextProperty.CONTENT_SNIPPET_VALUE)) { +// return ContextProperty.CONTENT_SNIPPET_VALUE; +// } else { +// return ContextProperty.UNKNOWN_PROPERTY; +// } +// } +// } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// export const treeView = () => { +// const web = new PreviewEngineContext(); +// web.createContext(); +// console.log(web.getPreviewEngineContext()); +// } + +// export class PreviewEngineContext { +// private previewEngineContext: IPreviewEngineContext; +// private websiteRecord: Website; +// private rootPath: vscode.Uri | null; +// private isBootstrapV5: boolean; + +// constructor() { +// this.isBootstrapV5 = false; +// this.previewEngineContext = {}; +// this.rootPath = PortalWebView.getPortalRootFolder(); +// this.websiteRecord = {} as Website; +// } + +// public createContext = async () => { +// this.websiteRecord = await this.getWebsite(); +// this.previewEngineContext = await this.createEngineContext(); +// } + +// public getPreviewEngineContext = () => { +// return this.previewEngineContext; +// } + +// private createEngineContext = async (): Promise => { + +// if (this.rootPath) { +// return { +// webpages: await this.getWebpages(), +// contentSnippets: await this.getContentSnippets(), +// webTemplates: await this.getWebTemplates(), +// siteMarkers: await this.getSiteMarker(), +// siteSettings: await this.getSiteSetting(), +// entityLists: await this.getEntityLists(), +// entityForms: await this.getEntityForms(), +// webForms: await this.getWebForms(), +// weblinks: await this.getWeblinks(), +// weblinkSets: await this.getWeblinkSets(), +// website: this.websiteRecord, +// pageTemplates: await this.getPageTemplates(), +// dataResolverExtras: {}, +// resx: {}, +// featureConfig: new Map(), +// entityAttributeMetadata: [] as IEntityAttributeMetadata[], +// lcid: '' as string, +// isBootstrapV5: this.isBootstrapV5, +// } +// } else return {} +// } + +// private getWebsite = async (): Promise => { +// const website = await vscode.workspace.fs.readFile(this.rootPath?.with({ path: this.rootPath.path + '/website.yml' }) || fallbackURI); +// const websiteYaml = load(new TextDecoder().decode(website)); +// return websiteYaml as Website; +// } + +// private webPageHelper = async (pageUri: vscode.Uri): Promise => { +// const webpageYaml = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.yml' })); +// const webpageJS = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.custom_javascript.js' })); +// const webpageCSS = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.custom_css.css' })); +// const webpageCopy = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.copy.html' })); +// const webpageSummary = await vscode.workspace.fs.readFile(pageUri?.with({ path: pageUri.path + '.webpage.summary.html' })); +// const webpageRecord = load(new TextDecoder().decode(webpageYaml)) as Webpage; +// webpageRecord.adx_customcss = new TextDecoder().decode(webpageCSS); +// webpageRecord.adx_customjavascript = new TextDecoder().decode(webpageJS); +// webpageRecord.adx_copy = new TextDecoder().decode(webpageCopy); +// webpageRecord.adx_summary = new TextDecoder().decode(webpageSummary); +// webpageRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return webpageRecord; +// } + + +// private getWebpages = async (): Promise => { +// const webpagesDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/web-pages' }) || fallbackURI); + +// const webpageArray: Webpage[] = []; +// for (const webpage of webpagesDirectory) { +// webpageArray.push(await this.webPageHelper(this.rootPath?.with({ path: this.rootPath.path + '/web-pages/' + webpage[0] + '/' + webpage[0] }) || fallbackURI)); + +// const contentPageDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/web-pages/' + webpage[0] + '/content-pages' }) || fallbackURI); +// for (const page of contentPageDirectory) { +// if (page[0].endsWith(ContextProperty.WEBPAGE_YAML)) { +// const pageName = page[0].slice(0, -12); +// webpageArray.push(await this.webPageHelper(this.rootPath?.with({ path: this.rootPath.path + '/web-pages/' + webpage[0] + '/content-pages/' + pageName }) || fallbackURI)); +// } +// } +// } +// return webpageArray; +// } + +// private getWeblinks = async (): Promise => { +// const weblinksDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets' }) || fallbackURI); + +// const weblinksArray: Weblink[] = []; +// for (const link of weblinksDirectory) { +// const linkSubDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets/' + link[0] }) || fallbackURI); +// for (const sublink of linkSubDirectory) { +// if (sublink[0].endsWith(ContextProperty.WEB_LINK)) { +// const weblinkYaml = await vscode.workspace.fs.readFile(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets/' + link[0] + `/${sublink[0]}` }) || fallbackURI); +// const weblinkRecord = load(new TextDecoder().decode(weblinkYaml)) as Weblink[] +// weblinksArray.push(...weblinkRecord); +// } +// } +// } +// return weblinksArray; +// } + +// private webLinkSetHelper = async (fileUri: vscode.Uri): Promise => { +// const weblinkSetYaml = await vscode.workspace.fs.readFile(fileUri); +// const weblinkSetRecord = load(new TextDecoder().decode(weblinkSetYaml)) as WeblinkSet; +// weblinkSetRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return weblinkSetRecord; +// }; + +// private getWeblinkSets = async (): Promise => { +// const weblinkSetsDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets' }) || fallbackURI); + +// const weblinkSetsArray: WeblinkSet[] = []; +// for (const weblinkSet of weblinkSetsDirectory) { +// const linkSubDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets/' + weblinkSet[0] }) || fallbackURI); +// for (const sublink of linkSubDirectory) { +// if (sublink[0].endsWith(ContextProperty.WEB_LINK_SET)) { +// weblinkSetsArray.push(await this.webLinkSetHelper(this.rootPath?.with({ path: this.rootPath.path + '/weblink-sets/' + weblinkSet[0] + `/${sublink[0]}` }) || fallbackURI)); // adx_title not in pac data but is manadatory, studio sends as undefined. +// } +// } +// } +// return weblinkSetsArray; +// } + + +// private contentSnippetHelper = async (fileUri: vscode.Uri): Promise => { +// const snippetYaml = await vscode.workspace.fs.readFile(fileUri?.with({ path: fileUri.path + '.contentsnippet.yml' })); +// const snippetValue = await vscode.workspace.fs.readFile(fileUri?.with({ path: fileUri.path + '.contentsnippet.value.html' })); +// const snippetRecord = load(new TextDecoder().decode(snippetYaml)) as ContentSnippet +// snippetRecord.adx_value = new TextDecoder().decode(snippetValue); +// snippetRecord.adx_websiteid = '92d6c1b4-d84b-ee11-be6e-0022482d5cfb'; +// snippetRecord.stateCode = 0; //check with PAC SME on how to get this field +// return snippetRecord; +// }; + + +// private getContentSnippets = async (): Promise => { +// const contentSnippetsDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/content-snippets' }) || fallbackURI); + +// const contentSnippetsArray: ContentSnippet[] = []; +// for (const contentSnippet of contentSnippetsDirectory) { +// const snippetSubDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/content-snippets/' + contentSnippet[0] }) || fallbackURI); +// for (const snippet of snippetSubDirectory) { +// if (snippet[0].endsWith(ContextProperty.CONTENT_SNIPPET_YAML)) { +// contentSnippetsArray.push(await this.contentSnippetHelper(this.rootPath?.with({ path: this.rootPath.path + '/content-snippets/' + contentSnippet[0] + `/${snippet[0].slice(0, -19)}` }) || fallbackURI)); +// } +// } +// } +// return contentSnippetsArray; +// } + +// private pageTemplateHelper = async (fileUri: vscode.Uri): Promise => { +// const pageTemplateYaml = await vscode.workspace.fs.readFile(fileUri); +// const pageTemplateRecord = load(new TextDecoder().decode(pageTemplateYaml)) as PageTemplate; +// return pageTemplateRecord; +// }; + + +// private getPageTemplates = async (): Promise => { +// const pageTemplatesDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/page-templates' }) || fallbackURI); + +// const pageTemplatesArray: PageTemplate[] = []; +// for (const pageTemplate of pageTemplatesDirectory) { +// pageTemplatesArray.push(await this.pageTemplateHelper(this.rootPath?.with({ path: this.rootPath.path + '/page-templates/' + pageTemplate[0] }) || fallbackURI)); +// } +// return pageTemplatesArray; +// } + +// private webTemplateHelper = async (fileUri: vscode.Uri): Promise => { +// const webTemplateYaml = await vscode.workspace.fs.readFile(fileUri?.with({ path: fileUri.path + '.webtemplate.yml' })); +// const webTemplateSource = await vscode.workspace.fs.readFile(fileUri?.with({ path: fileUri.path + '.webtemplate.source.html' })); +// const webTemplateSourceHTML = new TextDecoder().decode(webTemplateSource); +// const webTemplateRecord = load(new TextDecoder().decode(webTemplateYaml)) as WebTemplate; +// webTemplateRecord.adx_source = webTemplateSourceHTML; +// webTemplateRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return webTemplateRecord; +// }; + +// private getWebTemplates = async (): Promise => { +// const webTemplatesDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/web-templates' }) || fallbackURI); + +// const webTemplatesArray: WebTemplate[] = []; +// for (const webTemplate of webTemplatesDirectory) { +// webTemplatesArray.push(await this.webTemplateHelper(this.rootPath?.with({ path: this.rootPath.path + '/web-templates/' + webTemplate[0] + `/${webTemplate[0]}` }) || fallbackURI)); +// } +// return webTemplatesArray; +// } + +// private entityFormHelper = async (fileUri: vscode.Uri): Promise => { +// const entityFormYaml = await vscode.workspace.fs.readFile(fileUri); +// const entityFormRecord = load(new TextDecoder().decode(entityFormYaml)) as EntityForm; +// entityFormRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return entityFormRecord; +// }; + +// private getEntityForms = async (): Promise => { +// const entityFormsDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/basic-forms' }) || fallbackURI); + +// const entityFormsArray: EntityForm[] = []; +// for (const entityForm of entityFormsDirectory) { +// entityFormsArray.push(await this.entityFormHelper(this.rootPath?.with({ path: this.rootPath.path + '/basic-forms/' + entityForm[0] + `/${entityForm[0]}.basicform.yml` }) || fallbackURI)); +// } +// return entityFormsArray; +// } + +// private entityListHelper = async (fileUri: vscode.Uri): Promise => { +// const entityListYaml = await vscode.workspace.fs.readFile(fileUri); +// const entityListRecord = load(new TextDecoder().decode(entityListYaml)) as EntityList; +// entityListRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return entityListRecord; +// }; + +// private getEntityLists = async (): Promise => { +// const entityListsDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/lists' }) || fallbackURI); + +// const entityListsArray: EntityList[] = []; +// for (const entityList of entityListsDirectory) { +// if (entityList[0].endsWith(ContextProperty.ENTITY_LIST)) { +// entityListsArray.push(await this.entityListHelper(this.rootPath?.with({ path: this.rootPath.path + '/lists/' + entityList[0] }) || fallbackURI)); +// } +// } +// return entityListsArray; +// } + +// private webFormHelper = async (fileUri: vscode.Uri): Promise => { +// const webFormYaml = await vscode.workspace.fs.readFile(fileUri); +// const webFormRecord = load(new TextDecoder().decode(webFormYaml)) as WebForm; +// webFormRecord.adx_websiteid = this.websiteRecord.adx_websiteid; +// return webFormRecord; +// }; + + +// private getWebForms = async (): Promise => { +// const webFormsDirectory = await vscode.workspace.fs.readDirectory(this.rootPath?.with({ path: this.rootPath.path + '/advanced-forms' }) || fallbackURI); + +// const webFormsArray: WebForm[] = []; +// for (const webForm of webFormsDirectory) { +// webFormsArray.push(await this.webFormHelper(this.rootPath?.with({ path: this.rootPath.path + '/advanced-forms/' + webForm[0] + `/${webForm[0]}.advancedform.yml` }) || fallbackURI)); +// } +// return webFormsArray; +// } + +// private getSiteSetting = async (): Promise => { +// const siteSetting = await vscode.workspace.fs.readFile(this.rootPath?.with({ path: this.rootPath.path + '/sitesetting.yml' }) || fallbackURI); +// const siteSettingYaml = load(new TextDecoder().decode(siteSetting)) as SiteSetting[]; +// const siteSettingRecords = siteSettingYaml.map((siteSettingRecord) => { +// if (siteSettingRecord.adx_name === BootstrapSiteSetting) { +// this.isBootstrapV5 = siteSettingRecord.adx_value ? String(siteSettingRecord.adx_value).toLowerCase() === 'true' : false; +// } +// return { +// adx_websiteid: this.websiteRecord.adx_websiteid, +// adx_name: siteSettingRecord.adx_name, +// adx_value: siteSettingRecord.adx_value, +// adx_sitesettingid: siteSettingRecord.adx_sitesettingid, +// } +// }); +// return siteSettingRecords; +// } + +// private getSiteMarker = async (): Promise => { +// const siteMarker = await vscode.workspace.fs.readFile(this.rootPath?.with({ path: this.rootPath.path + '/sitemarker.yml' }) || fallbackURI); +// const siteMarkerYaml = load(new TextDecoder().decode(siteMarker)) as SiteMarker[]; +// const siteMarkerRecords = siteMarkerYaml.map((siteMarkerRecord) => { +// return { +// adx_name: siteMarkerRecord.adx_name as string, +// adx_pageid: siteMarkerRecord.adx_pageid as string, +// adx_sitemarkerid: siteMarkerRecord.adx_sitemarkerid, +// adx_websiteid: this.websiteRecord.adx_websiteid, + +// } + +// }); +// return siteMarkerRecords; +// } + +// public updateContext = async () => { +// const fileUri = vscode.window.activeTextEditor?.document.uri || fallbackURI; +// const fileName = getFileProperties(fileUri.path).fileCompleteName; +// if (!fileName) { +// // TODO: Handle this scenario +// return; +// } +// // Check entity type +// const entityType: ContextProperty = this.getEntityType(fileName); + +// switch (entityType) { +// case ContextProperty.SITE_MARKER: +// this.previewEngineContext.siteMarkers = await this.getSiteMarker(); +// break; +// case ContextProperty.SITE_SETTING: +// this.previewEngineContext.siteSettings = await this.getSiteSetting(); +// break; +// case ContextProperty.WEBSITE: +// { +// const websiteObj = await this.getWebsite(); +// if (websiteObj?.adx_websiteid === this.websiteRecord?.adx_websiteid) { +// this.websiteRecord = websiteObj; +// } +// else { +// this.websiteRecord = websiteObj; +// this.previewEngineContext = await this.createEngineContext(); +// } +// break; +// } +// case ContextProperty.WEB_LINK: +// this.previewEngineContext.weblinks = await this.getWeblinks(); +// break; +// case ContextProperty.WEB_LINK_SET: { +// const obj = await this.webLinkSetHelper(fileUri); +// const value = obj[ContextPropertyKey.WEB_LINK_SET as unknown as keyof WeblinkSet]; +// const index = findObjectIndexByProperty(this.previewEngineContext.weblinkSets, ContextPropertyKey.WEB_LINK_SET, value); +// if (index != -1 && this.previewEngineContext.weblinkSets) { +// this.previewEngineContext.weblinkSets[index] = obj; +// } else { +// this.previewEngineContext.weblinkSets = await this.getWeblinkSets(); +// } +// break; +// } +// case ContextProperty.ENTITY_FORM: +// { +// const obj = await this.entityFormHelper(fileUri); +// const value = obj[ContextPropertyKey.ENTITY_FORM as unknown as keyof EntityForm]; +// const index = findObjectIndexByProperty(this.previewEngineContext.entityForms, ContextPropertyKey.ENTITY_FORM, value); +// if (index != -1 && this.previewEngineContext.entityForms) { +// this.previewEngineContext.entityForms[index] = obj; +// } else { +// this.previewEngineContext.entityForms = await this.getEntityForms(); +// } +// break; +// } +// case ContextProperty.ENTITY_LIST: +// { +// const obj = await this.entityListHelper(fileUri); +// const value = obj[ContextPropertyKey.ENTITY_LIST as unknown as keyof EntityList]; +// const index = findObjectIndexByProperty(this.previewEngineContext.entityLists, ContextPropertyKey.ENTITY_LIST, value); +// if (index != -1 && this.previewEngineContext.entityLists) { +// this.previewEngineContext.entityLists[index] = obj; +// } else { +// this.previewEngineContext.entityLists = await this.getEntityLists(); +// } +// break; +// } +// case ContextProperty.WEB_FORM: +// { +// const obj = await this.webFormHelper(fileUri); +// const value = obj[ContextPropertyKey.WEB_FORM as unknown as keyof WebForm]; +// const index = findObjectIndexByProperty(this.previewEngineContext.webForms, ContextPropertyKey.WEB_FORM, value); +// if (index != -1 && this.previewEngineContext.webForms) { +// this.previewEngineContext.webForms[index] = obj; +// } else { +// this.previewEngineContext.webForms = await this.getWebForms(); +// } +// break; +// } +// case ContextProperty.PAGE_TEMPLATE: +// { +// const obj = await this.pageTemplateHelper(fileUri); +// const value = obj[ContextPropertyKey.PAGE_TEMPLATE as unknown as keyof PageTemplate]; +// const index = findObjectIndexByProperty(this.previewEngineContext.pageTemplates, ContextPropertyKey.PAGE_TEMPLATE, value); +// if (index != -1 && this.previewEngineContext.pageTemplates) { +// this.previewEngineContext.pageTemplates[index] = obj; +// } else { +// this.previewEngineContext.pageTemplates = await this.getPageTemplates(); +// } +// break; +// } +// case ContextProperty.WEBPAGE_YAML: +// case ContextProperty.WEBPAGE_COPY: +// case ContextProperty.WEBPAGE_CSS: +// case ContextProperty.WEBPAGE_JS: +// case ContextProperty.WEBPAGE_SUMMARY: +// { +// const obj = await this.webPageHelper(fileUri?.with({ path: removeExtension(fileUri.path, entityType) })); +// const value = obj[ContextPropertyKey.WEBPAGE as unknown as keyof Webpage]; +// const index = findObjectIndexByProperty(this.previewEngineContext.webpages, ContextPropertyKey.WEBPAGE, value); +// if (index != -1 && this.previewEngineContext.webpages) { +// this.previewEngineContext.webpages[index] = obj; +// } else { +// this.previewEngineContext.webpages = await this.getWebpages(); +// } +// break; +// } +// case ContextProperty.WEB_TEMPLATE_YAML: +// case ContextProperty.WEB_TEMPLATE_SOURCE: +// { +// const obj = await this.webTemplateHelper(fileUri?.with({ path: removeExtension(fileUri.path, entityType) })); +// const value = obj[ContextPropertyKey.WEB_TEMPLATE as unknown as keyof WebTemplate]; +// const index = findObjectIndexByProperty(this.previewEngineContext.webTemplates, ContextPropertyKey.WEB_TEMPLATE, value); +// if (index != -1 && this.previewEngineContext.webTemplates) { +// this.previewEngineContext.webTemplates[index] = obj; +// } else { +// this.previewEngineContext.webTemplates = await this.getWebTemplates(); +// } +// break; +// } +// case ContextProperty.CONTENT_SNIPPET_YAML: +// case ContextProperty.CONTENT_SNIPPET_VALUE: +// { +// const obj = await this.contentSnippetHelper(fileUri?.with({ path: removeExtension(fileUri.path, entityType) })); +// const value = obj[ContextPropertyKey.CONTENT_SNIPPET as unknown as keyof ContentSnippet]; +// const index = findObjectIndexByProperty(this.previewEngineContext.contentSnippets, ContextPropertyKey.CONTENT_SNIPPET, value); +// if (index != -1 && this.previewEngineContext.contentSnippets) { +// this.previewEngineContext.contentSnippets[index] = obj; +// } else { +// this.previewEngineContext.contentSnippets = await this.getContentSnippets(); +// } +// break; +// } +// default: +// break; +// } +// } + +// private getEntityType = (filename: string): ContextProperty => { + +// if (filename.endsWith(ContextProperty.WEBSITE)) { +// return ContextProperty.WEBSITE; +// } else if (filename.endsWith(ContextProperty.SITE_SETTING)) { +// return ContextProperty.SITE_SETTING; +// } else if (filename.endsWith(ContextProperty.SITE_MARKER)) { +// return ContextProperty.SITE_MARKER; +// } else if (filename.endsWith(ContextProperty.ENTITY_FORM)) { +// return ContextProperty.ENTITY_FORM; +// } else if (filename.endsWith(ContextProperty.ENTITY_LIST)) { +// return ContextProperty.ENTITY_LIST; +// } else if (filename.endsWith(ContextProperty.WEB_FORM)) { +// return ContextProperty.WEB_FORM; +// } else if (filename.endsWith(ContextProperty.WEB_LINK)) { +// return ContextProperty.WEB_LINK; +// } else if (filename.endsWith(ContextProperty.WEB_LINK_SET)) { +// return ContextProperty.WEB_LINK_SET; +// } else if (filename.endsWith(ContextProperty.PAGE_TEMPLATE)) { +// return ContextProperty.PAGE_TEMPLATE; +// } else if (filename.endsWith(ContextProperty.WEB_TEMPLATE_YAML)) { +// return ContextProperty.WEB_TEMPLATE_YAML; +// } else if (filename.endsWith(ContextProperty.WEB_TEMPLATE_SOURCE)) { +// return ContextProperty.WEB_TEMPLATE_SOURCE; +// } else if (filename.endsWith(ContextProperty.WEBPAGE_YAML)) { +// return ContextProperty.WEBPAGE_YAML; +// } else if (filename.endsWith(ContextProperty.WEBPAGE_COPY)) { +// return ContextProperty.WEBPAGE_COPY; +// } else if (filename.endsWith(ContextProperty.WEBPAGE_CSS)) { +// return ContextProperty.WEBPAGE_CSS; +// } else if (filename.endsWith(ContextProperty.WEBPAGE_JS)) { +// return ContextProperty.WEBPAGE_JS; +// } else if (filename.endsWith(ContextProperty.WEBPAGE_SUMMARY)) { +// return ContextProperty.WEBPAGE_SUMMARY; +// } else if (filename.endsWith(ContextProperty.CONTENT_SNIPPET_YAML)) { +// return ContextProperty.CONTENT_SNIPPET_YAML; +// } else if (filename.endsWith(ContextProperty.CONTENT_SNIPPET_VALUE)) { +// return ContextProperty.CONTENT_SNIPPET_VALUE; +// } else { +// return ContextProperty.UNKNOWN_PROPERTY; +// } +// } +// } \ No newline at end of file diff --git a/src/common/portalMetadataView/TreeView/PortalDrops/PortalDrops.ts b/src/common/portalMetadataView/TreeView/PortalDrops/PortalDrops.ts new file mode 100644 index 00000000..cb62037d --- /dev/null +++ b/src/common/portalMetadataView/TreeView/PortalDrops/PortalDrops.ts @@ -0,0 +1,11 @@ +import { Drop } from 'liquidjs'; +import { IDataResolver } from '../Utils/IDataResolver'; + +export class PortalDrop extends Drop { + protected dataResolver: IDataResolver; + + constructor(dataResolver: IDataResolver) { + super(); + this.dataResolver = dataResolver; + } +} diff --git a/src/common/portalMetadataView/TreeView/TreeViewProvider.ts b/src/common/portalMetadataView/TreeView/TreeViewProvider.ts new file mode 100644 index 00000000..0e54b2c8 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/TreeViewProvider.ts @@ -0,0 +1,76 @@ +import * as vscode from 'vscode'; + +import {IItem} from './TreeView/Types/Entity/IItem'; + +class MyTreeItem extends vscode.TreeItem { + constructor(public readonly item: IItem, public readonly collapsibleState: vscode.TreeItemCollapsibleState) { + super(item.label, collapsibleState); + this.tooltip = `${this.item.title}`; + this.description = this.item.content; + this.iconPath = this.getIconPath(item.isFile); + } + + contextValue = this.item.isFile ? 'file' : 'folder'; + + command = this.item.isFile ? { + title: 'Open HTML File', + command: 'extension.openFile', + arguments: [this.item] + } : undefined; + + private getIconPath(isFile: boolean): vscode.ThemeIcon { + if (this.item.isFile) { + return new vscode.ThemeIcon('file'); + } else { + return new vscode.ThemeIcon('folder'); + } + } +} + + +class MyTreeDataProvider implements vscode.TreeDataProvider { + private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter(); + readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; + + constructor(private readonly data: IItem[]) {} + + getTreeItem(element: MyTreeItem): vscode.TreeItem { + return element; + } + + getChildren(element?: MyTreeItem): Thenable { + if (element) { + return Promise.resolve(this.getItemChildren(element.item)); + } else { + return Promise.resolve(this.data.map(item => new MyTreeItem(item, vscode.TreeItemCollapsibleState.Collapsed))); + } + } + + private getItemChildren(item: IItem): MyTreeItem[] { + return item.children.map(child => new MyTreeItem(child, child.children.length > 0 ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None)); + } +} + +export function createTree(websiteIItem: IItem){ + const treeDataProvider = new MyTreeDataProvider([websiteIItem]); + vscode.window.registerTreeDataProvider('exampleView', treeDataProvider); + + vscode.commands.registerCommand('extension.openWebpage', (webpageName: string) => { + vscode.window.showInformationMessage(`Opening Webpage: ${webpageName}`); + }); + + vscode.commands.registerCommand('extension.openFile', async (item: IItem) => { + try { + if (item.path) { + const document = await vscode.workspace.openTextDocument(item.path); + await vscode.window.showTextDocument(document); + } else{ + const document = await vscode.workspace.openTextDocument({ content: item.content, language: 'plaintext' }); + await vscode.window.showTextDocument(document); + } + } catch (error) { + console.error('Error opening HTML file:', error); + vscode.window.showErrorMessage('Error opening HTML file'); + } + }); + } diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/AbstractEntity.ts b/src/common/portalMetadataView/TreeView/Types/Entity/AbstractEntity.ts new file mode 100644 index 00000000..9fe59973 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/AbstractEntity.ts @@ -0,0 +1,6 @@ +export interface AbstractEntity { + ownerId?: string; + stateCode?: number; + statusCode?: number; + } + \ No newline at end of file diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/ContentSnippet.ts b/src/common/portalMetadataView/TreeView/Types/Entity/ContentSnippet.ts new file mode 100644 index 00000000..e36749db --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/ContentSnippet.ts @@ -0,0 +1,18 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface ContentSnippet extends AbstractEntity { + adx_display_name?: string; + adx_value: string; + adx_createdbyipaddress?: string; + adx_createdbyusername?: string; + adx_name: string; + adx_modifiedbyipaddress?: string; + adx_modifiedbyusername?: string; + adx_websiteid: string; + adx_websiteidname?: string; + adx_contentsnippetlanguageidname?: string; + adx_type?: number; + adx_contentsnippetlanguageid?: string; + adx_typename?: string; + adx_contentsnippetid: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/EntityAttributeMetadata.ts b/src/common/portalMetadataView/TreeView/Types/Entity/EntityAttributeMetadata.ts new file mode 100644 index 00000000..b4dda8c8 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/EntityAttributeMetadata.ts @@ -0,0 +1,7 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface IEntityAttributeMetadata extends AbstractEntity { + attributeType: string; + localizedDisplayName: string; + logicalName: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/EntityForm.ts b/src/common/portalMetadataView/TreeView/Types/Entity/EntityForm.ts new file mode 100644 index 00000000..e787514d --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/EntityForm.ts @@ -0,0 +1,117 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface EntityForm extends AbstractEntity { + adx_appendquerystring?: boolean; + adx_appendquerystringname?: string; + adx_associatecurrentportaluser?: boolean; + adx_associatecurrentportalusername?: string; + adx_attachfile?: boolean; + adx_attachfileaccept?: string; + adx_attachfileacceptextensions?: string; + adx_attachfileallowmultiple?: boolean; + adx_attachfilelabel?: string; + adx_attachfilemaxsize?: number; + adx_attachfilename?: string; + adx_attachfilerequired?: boolean; + adx_attachfilerequirederrormessage?: string; + adx_attachfilerequiredname?: string; + adx_attachfilerestrictaccept?: boolean; + adx_attachfilesaveoption?: number; + adx_attachfilesizeerrormessage?: string; + adx_attachfilestoragelocation?: number; + adx_attachfiletypeerrormessage?: string; + adx_autogeneratesteps?: boolean; + adx_autogeneratestepsname?: string; + adx_captcharequired?: boolean; + adx_captcharequiredname?: string; + adx_entityformid: string; + adx_entityname: string; + adx_entitypermissionsenabled?: boolean; + adx_entitysourcetype?: number; + adx_forceallfieldsrequired?: boolean; + adx_formname: string; + adx_geolocation_addresslinefieldname?: string; + adx_geolocation_cityfieldname?: string; + adx_geolocation_countryfieldname?: string; + adx_geolocation_countyfieldname?: string; + adx_geolocation_displaymap?: boolean; + adx_geolocation_enabled?: boolean; + adx_geolocation_formattedaddressfieldname?: string; + adx_geolocation_latitudefieldname?: string; + adx_geolocation_longitudefieldname?: string; + adx_geolocation_maptype?: number; + adx_geolocation_neighborhoodfieldname?: string; + adx_geolocation_postalcodefieldname?: string; + adx_geolocation_statefieldname?: string; + adx_hideformonsuccess?: boolean; + adx_instructions?: string; + adx_mode?: number; + adx_modename?: string; + adx_name: string; + adx_nextbuttoncssclass?: string; + adx_nextbuttontext?: string; + adx_onsuccess?: number; + adx_populatereferenceentitylookupfield?: boolean; + adx_populatereferenceentitylookupfieldname?: string; + adx_portaluserlookupattributeisactivityparty?: boolean; + adx_portaluserlookupattributeisactivitypartyname?: string; + adx_previousbuttoncssclass?: string; + adx_previousbuttontext?: string; + adx_primarykeyname?: string; + adx_provisionedlanguages?: number; + adx_recommendedfieldsrequired?: boolean; + adx_recommendedfieldsrequiredname?: string; + adx_recordidquerystringparametername?: string; + adx_recordnotfoundmessage?: string; + adx_recordsourceallowcreateonnull?: boolean; + adx_recordsourceentitylogicalname?: string; + adx_recordsourcerelationshipname?: string; + adx_redirecturl?: string; + adx_redirecturlappendentityidquerystring?: boolean; + adx_redirecturlappendentityidquerystringname?: string; + adx_redirecturlcustomquerystring?: string; + adx_redirecturlquerystringattribute?: string; + adx_redirecturlquerystringattributeparamname?: string; + adx_redirecturlquerystringname?: string; + adx_redirectwebpage?: string; + adx_redirectwebpagename?: string; + adx_referenceentitylogicalname?: string; + adx_referenceentityprimarykeylogicalname?: string; + adx_referenceentityreadonlyformname?: string; + adx_referenceentityrelationshipname?: string; + adx_referenceentityshowreadonlyform?: boolean; + adx_referenceentityshowreadonlyformname?: string; + adx_referenceentitysourcetype?: number; + adx_referenceentitysourcetypename?: string; + adx_referencequeryattributelogicalname?: string; + adx_referencequerystringisprimarykey?: boolean; + adx_referencequerystringisprimarykeyname?: string; + adx_referencequerystringname?: string; + adx_referencerecordsourcerelationshipname?: string; + adx_referencetargetlookupattributelogicalname?: string; + adx_registerstartupscript?: string; + adx_renderwebresourcesinline?: boolean; + adx_setentityreference?: boolean; + adx_setentityreferencename?: string; + adx_settings?: string; + adx_showcaptchaforauthenticatedusers?: boolean; + adx_showcaptchaforauthenticatedusersname?: string; + adx_showownerfields?: boolean; + adx_showownerfieldsname?: string; + adx_showunsupportedfields?: boolean; + adx_showunsupportedfieldsname?: string; + adx_submitbuttonbusytext?: string; + adx_submitbuttoncssclass?: string; + adx_submitbuttontext?: string; + adx_successmessage: string; + adx_tabname?: string; + adx_targetentityportaluserlookupattribute?: string; + adx_tooltipenabled?: boolean; + adx_validationgroup?: string; + adx_validationsummarycssclass?: string; + adx_validationsummaryheadertext?: string; + adx_validationsummarylinksenabled?: boolean; + adx_validationsummarylinktext?: string; + adx_websiteid: string; + adx_websiteidname?: string; +} \ No newline at end of file diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/EntityFormMetadata.ts b/src/common/portalMetadataView/TreeView/Types/Entity/EntityFormMetadata.ts new file mode 100644 index 00000000..21d93467 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/EntityFormMetadata.ts @@ -0,0 +1,57 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface EntityFormMetadata extends AbstractEntity { + adx_adddescription?: boolean; + adx_adddescriptionname?: string; + adx_attributelogicalname?: string; + adx_constantsummaximumtotal?: number; + adx_constantsumminimumtotal?: number; + adx_constantsumvalidationerrormessage?: string; + adx_controlstyle?: number; + adx_cssclass?: string; + adx_description?: string; + adx_descriptionposition?: number; + adx_entityform: string; + adx_entityformforcreate?: string; + adx_entityformforcreatename?: string; + adx_entityformmetadataid: string; + adx_entityformname?: string; + adx_fieldisrequired?: boolean; + adx_geolocationvalidatorerrormessage?: string; + adx_groupname?: string; + adx_ignoredefaultvalue?: boolean; + adx_label?: string; + adx_maxmultiplechoiceselectedcount?: number; + adx_minmultiplechoiceselectedcount?: number; + adx_multiplechoicevalidationerrormessage?: string; + adx_name?: string; + adx_notes_settings?: string; + adx_onsavefromattribute?: string; + adx_onsavetype?: number; + adx_onsavetypename?: string; + adx_onsavevalue?: string; + adx_prepopulatefromattribute?: string; + adx_prepopulatetype?: number; + adx_prepopulatetypename?: string; + adx_prepopulatevalue?: string; + adx_provisionedlanguages?: number; + adx_randomizeoptionsetvalues?: boolean; + adx_randomizeoptionsetvaluesname?: string; + adx_rangevalidationerrormessage?: string; + adx_rankordernotiesvalidationerrormessage?: string; + adx_requiredfieldvalidationerrormessage?: string; + adx_sectionname?: string; + adx_setvalueonsave?: boolean; + adx_setvalueonsavename?: string; + adx_subgrid_name?: string; + adx_subgrid_settings?: string; + adx_tabname?: string; + adx_timeline_settings?: string; + adx_type: number; + adx_typename?: string; + adx_useattributedescriptionproperty?: boolean; + adx_useattributedescriptionpropertyname?: string; + adx_validationerrormessage?: string; + adx_validationregularexpression?: string; + adx_validationregularexpressionerrormessage?: string; +} \ No newline at end of file diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/EntityList.ts b/src/common/portalMetadataView/TreeView/Types/Entity/EntityList.ts new file mode 100644 index 00000000..c8893ad0 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/EntityList.ts @@ -0,0 +1,84 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface EntityList extends AbstractEntity { + adx_provisionedlanguages?: number; + adx_calendar_stylename?: string; + adx_calendar_initialviewname?: string; + adx_calendar_initialdate?: Date; + adx_map_longitude?: string; + adx_filter_applybuttonlabel?: string; + adx_map_infoboxdescriptionfieldname?: string; + adx_map_distanceunitsname?: string; + adx_map_infoboxtitlefieldname?: string; + adx_odata_enabled?: boolean; + adx_calendar_alldayfieldname?: string; + adx_calendar_enddatefieldname?: string; + adx_entitypermissionsenabledname?: string; + adx_map_type?: number; + adx_pagesize: number; + adx_filteraccount?: string; + adx_entitylistid: string; + adx_websiteidname?: string; + adx_idquerystringparametername?: string; + adx_filterwebsite?: string; + adx_map_distanceunits?: number; + adx_map_credentials?: string; + adx_map_latitudefieldname?: string; + adx_calendar_organizerfieldname?: string; + adx_map_pushpinwidth?: number; + adx_calendar_enabledname?: string; + adx_odata_entitysetname?: string; + adx_odata_entitytypename?: string; + adx_map_pushpinurl?: string; + adx_filter_enabled?: boolean; + adx_filter_definition?: string; + adx_views: string; + adx_webpagefordetailsviewname?: string; + adx_filter_enabledname?: string; + adx_websiteid: string; + adx_map_pushpinheight?: number; + adx_filter_orientation?: number; + adx_registerstartupscript?: string; + adx_createbuttonlabel?: string; + adx_map_resturl?: string; + adx_entitypermissionsenabled?: boolean; + adx_map_typename?: string; + adx_calendar_timezone?: number; + adx_map_infoboxoffsetx?: number; + adx_map_zoom?: number; + adx_key?: string; + adx_view?: string; + adx_calendar_timezonemodename?: string; + adx_filterportaluser?: string; + adx_calendar_descriptionfieldname?: string; + adx_map_distancevalues?: string; + adx_detailsbuttonlabel?: string; + adx_searchenabledname?: string; + adx_calendar_locationfieldname?: string; + adx_searchplaceholdertext?: string; + adx_webpageforcreatename?: string; + adx_primarykeyname?: string; + adx_settings?: string; + adx_calendar_initialview?: number; + adx_searchenabled?: boolean; + adx_calendar_enabled?: boolean; + adx_name: string; + adx_calendar_startdatefieldname?: string; + adx_calendar_style?: number; + adx_entityname: string; + adx_map_enabledname?: string; + adx_map_enabled?: boolean; + adx_map_latitude?: string; + adx_webpageforcreate?: string; + adx_webpagefordetailsview?: string; + adx_filter_orientationname?: string; + adx_emptylisttext?: string; + adx_calendar_timezonemode?: number; + adx_odata_enabledname?: string; + adx_searchtooltiptext?: string; + adx_calendar_summaryfieldname?: string; + adx_odata_view?: string; + adx_map_infoboxoffsety?: number; + adx_map_longitudefieldname?: string; + adx_iscodecomponent?: boolean; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/EntityView.ts b/src/common/portalMetadataView/TreeView/Types/Entity/EntityView.ts new file mode 100644 index 00000000..fd54bb3c --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/EntityView.ts @@ -0,0 +1,219 @@ +// /*! +// * Copyright (C) Microsoft Corporation. All rights reserved. +// */ + +// /** +// * Enum to represent different view query types. Derived from /src/Core/ObjectModel/Services/UserQuery/UserQueryService.cs +// */ +// export enum QueryType { +// MainApplicationView = 0, // aka 'public' +// AdvancedSearch = 1, +// SubGrid = 2, +// QuickFindSearch = 4, +// Reporting = 8, +// OfflineFilters = 16, +// MASearch = 32, +// LookupView = 64, +// SMAppointmentBookView = 128, +// OutlookFilters = 256, +// AddressBookFilters = 512, +// SavedQueryTypeOther = 2048, +// InteractiveWorkflowView = 4096, +// OfflineTemplate = 8192, +// OutlookTemplate = 131072, +// CustomDefinedView = 16384, +// } + +// export interface RelatedEntityInfo { +// to: string; +// from: string; +// name: string; +// } + +// export class EntityView { +// public static readonly attributePathSeparator: string = '.'; + +// public id: string; + +// public description: string | null = null; + +// public primaryEntityTypeName: string | null = null; + +// public fetchXml: Document | null = null; + +// public layoutXml: Document | null = null; + +// // eslint-disable-next-line @typescript-eslint/no-explicit-any +// public columnTitles: any[] = []; // TODO: This is metadata. + +// public queryType: QueryType | null = null; + +// public isDefault: boolean | null = null; + +// public isReadonly: boolean | null = null; + +// public constructor(public name: string | null = null, fetchXml: string, layoutXml: string) { +// const parser: DOMParser = new DOMParser(); + +// if (fetchXml) { +// this.fetchXml = parser.parseFromString(fetchXml, 'text/xml'); +// } + +// if (layoutXml) { +// this.layoutXml = parser.parseFromString(layoutXml, 'text/xml'); +// } +// } + +// public getNameOfPrimaryEntityTypeFromFetchXml(): string { +// const fetchXml: Document = this.fetchXml; + +// if (fetchXml === null) { +// throw new Error('fetchXml'); +// } + +// const entityElementCollection: NodeListOf = fetchXml.querySelectorAll('entity'); + +// if (entityElementCollection.length === 0) { +// throw new Error("Required element 'entity' not present"); +// } + +// if (entityElementCollection.length > 1) { +// throw new Error("Multiple elements 'entity' present"); +// } + +// const entityElement: Element = entityElementCollection.item(0); + +// const nameAttribute: string | null = entityElement.getAttribute('name'); + +// if (nameAttribute === null) { +// throw new Error("Attribute 'name' of element 'entity' not present"); +// } + +// return nameAttribute; +// } + +// public getRelatedEntities(): Map { +// const fetchXml: Document = this.fetchXml; + +// if (fetchXml === null) { +// throw new Error('fetchXml'); +// } + +// const linkEntityElementCollection: Element[] = Array.from(fetchXml.querySelectorAll('link-entity')); + +// const namesOfRelatedEntityTypes: Map = new Map(); + +// if (linkEntityElementCollection.length === 0) { +// return namesOfRelatedEntityTypes; +// } + +// linkEntityElementCollection.forEach((linkEntityElement) => { +// // do not include intersect entities in the group of entities to be fetched +// if (linkEntityElement.getAttribute('intersect') === 'true') { +// return; +// } + +// const nameAttribute: string | null = linkEntityElement.getAttribute('name'); // Type of the related entity. + +// if (nameAttribute === null) { +// throw new Error("Attribute 'name' of element 'link-entity' not present"); +// } + +// const to = linkEntityElement.getAttribute('to'); +// const from = linkEntityElement.getAttribute('from'); + +// const attributePathComponents: string[] = []; +// let entityElement = linkEntityElement; + +// while (entityElement && entityElement.tagName.toLowerCase() !== 'entity') { +// attributePathComponents.push(entityElement.getAttribute('alias')!); // Name of the field with the serves as a navigation property. +// entityElement = entityElement.parentElement!; +// } + +// if (entityElement) { +// namesOfRelatedEntityTypes.set( +// attributePathComponents.reverse().join(EntityView.attributePathSeparator), +// { +// to, +// from, +// name: nameAttribute, +// } +// ); +// } +// }); + +// return namesOfRelatedEntityTypes; +// } + +// public getAttributeElement(attributePath: string, createIfNotPresent?: boolean): Element | null { +// const { fetchXml } = this; + +// let entityElement: Element | null = fetchXml.querySelector(`entity`); + +// if (entityElement === null) { +// throw new Error('Entity element not found in fetchxml'); +// } + +// const attributePathComponents: string[] = attributePath.split(EntityView.attributePathSeparator); + +// // Process navigation properties. +// for (let i: number = 0; i < attributePathComponents.length - 1; i++) { +// const pathComponent: string = attributePathComponents[i]; + +// let linkEntityElement: Element | null = entityElement.querySelector( +// `link-entity[alias=${pathComponent}]` +// ); + +// if (linkEntityElement === null && createIfNotPresent === true) { +// linkEntityElement = fetchXml.createElement('link-entity'); +// linkEntityElement.setAttribute('alias', pathComponent); +// entityElement.appendChild(linkEntityElement); +// } + +// if (linkEntityElement === null) { +// throw new Error('attributePath'); +// } + +// entityElement = linkEntityElement; +// } + +// // Process property. +// const attributeNamePathComponent: string = attributePathComponents[attributePathComponents.length - 1]; + +// let attributeElement: Element | null = entityElement.querySelector( +// `attribute[name=${attributeNamePathComponent}]` +// ); + +// if (attributeElement === null && createIfNotPresent === true) { +// attributeElement = fetchXml.createElement('attribute'); +// attributeElement.setAttribute('name', attributeNamePathComponent); +// entityElement.appendChild(attributeElement); +// } + +// if (attributeElement === null) { +// return null; +// } + +// return attributeElement; +// } + +// public clone(): EntityView { +// const xmlSerializer: XMLSerializer = new XMLSerializer(); + +// const serializedFetchXml: string = this.fetchXml ? xmlSerializer.serializeToString(this.fetchXml) : null; + +// const serializedLayoutXml: string = this.layoutXml +// ? xmlSerializer.serializeToString(this.layoutXml) +// : null; + +// const clonedView: EntityView = new EntityView(this.name, serializedFetchXml, serializedLayoutXml); + +// clonedView.id = this.id; +// clonedView.description = this.description; +// clonedView.columnTitles = this.columnTitles.slice(0); +// clonedView.primaryEntityTypeName = this.primaryEntityTypeName; +// clonedView.queryType = this.queryType; + +// return clonedView; +// } +// } \ No newline at end of file diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/IItem.ts b/src/common/portalMetadataView/TreeView/Types/Entity/IItem.ts new file mode 100644 index 00000000..a6557a53 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/IItem.ts @@ -0,0 +1,13 @@ +import * as vscode from 'vscode'; + +export interface IItem { + label: string; + title: string; + id: string; + isFile: boolean; + content: string; + path?: vscode.Uri; + component: string; + children: IItem[]; + error: string; + } \ No newline at end of file diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/PageTemplate.ts b/src/common/portalMetadataView/TreeView/Types/Entity/PageTemplate.ts new file mode 100644 index 00000000..096c6d30 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/PageTemplate.ts @@ -0,0 +1,19 @@ +export interface PageTemplate { + adx_description?: string; + adx_webtemplateid?: string; + adx_isdefaultname?: string; + adx_name: string; + adx_typename?: string; + adx_usewebsiteheaderandfootername?: string; + adx_entityname?: string; + adx_usewebsiteheaderandfooter?: boolean; + adx_websiteid?: string; + adx_isdefault?: boolean; + adx_websiteidname?: string; + adx_webtemplateidname?: string; + adx_type?: number; + adx_pagetemplateid: string; + adx_botconsumerid?: string; + adx_rewriteurl?: string; + adx_botconsumeridname?: string; + } \ No newline at end of file diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/SiteMarker.ts b/src/common/portalMetadataView/TreeView/Types/Entity/SiteMarker.ts new file mode 100644 index 00000000..e09690e8 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/SiteMarker.ts @@ -0,0 +1,10 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface SiteMarker extends AbstractEntity { + adx_websiteid: string; + adx_name: string; + adx_pageidname?: string; + adx_websiteidname?: string; + adx_pageid: string; + adx_sitemarkerid: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/SiteSettings.ts b/src/common/portalMetadataView/TreeView/Types/Entity/SiteSettings.ts new file mode 100644 index 00000000..9a4f5353 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/SiteSettings.ts @@ -0,0 +1,10 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface SiteSetting extends AbstractEntity { + adx_websiteid: string; + adx_description?: string; + adx_value?: string; + adx_name: string; + adx_websiteidname?: string; + adx_sitesettingid: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/WebForm.ts b/src/common/portalMetadataView/TreeView/Types/Entity/WebForm.ts new file mode 100644 index 00000000..798b1b5b --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/WebForm.ts @@ -0,0 +1,36 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface WebForm extends AbstractEntity { + adx_progressindicatorpositionname?: string; + adx_savechangeswarningmessage?: string; + adx_progressindicatorposition?: number; + adx_name: string; + adx_editexpiredstatuscode?: number; + adx_startstep?: string; + adx_editexpiredstatecode?: number; + adx_editnotpermittedmessage?: string; + adx_websiteid: string; + adx_editexistingrecordpermittedname?: string; + adx_progressindicatortypename?: string; + adx_progressindicatorprependstepnum?: boolean; + adx_progressindicatorignorelaststep?: boolean; + adx_progressindicatorenabled?: boolean; + adx_multiplerecordsperuserpermitted?: boolean; + adx_authenticationrequired?: boolean; + adx_provisionedlanguages?: number; + adx_authenticationrequiredname?: string; + adx_startnewsessiononloadname?: string; + adx_startstepname?: string; + adx_startnewsessiononload?: boolean; + adx_progressindicatorprependstepnumname?: string; + adx_editexpiredmessage?: string; + adx_savechangeswarningonclose?: boolean; + adx_webformid: string; + adx_progressindicatorignorelaststepname?: string; + adx_editexistingrecordpermitted?: boolean; + adx_savechangeswarningonclosename?: string; + adx_progressindicatortype?: number; + adx_progressindicatorenabledname?: string; + adx_multiplerecordsperuserpermittedname?: string; + adx_websiteidname?: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/WebFormMetadata.ts b/src/common/portalMetadataView/TreeView/Types/Entity/WebFormMetadata.ts new file mode 100644 index 00000000..41938fb7 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/WebFormMetadata.ts @@ -0,0 +1,75 @@ + +import { AbstractEntity } from './AbstractEntity'; + +export interface WebFormMetadata extends AbstractEntity { + adx_adddescription?: boolean; + adx_adddescriptionname?: string; + adx_attributelogicalname: string; + adx_constantsummaximumtotal?: number; + adx_constantsumminimumtotal?: number; + adx_constantsumvalidationerrormessage?: string; + adx_controlstyle?: number; + adx_cssclass?: string; + adx_description?: string; + adx_descriptionposition?: number; + adx_entityformforcreate?: string; + adx_entityformforcreateinwebformmetadata?: string; + adx_entityformforcreatename?: string; + adx_fieldisrequired?: boolean; + adx_geolocationvalidatorerrormessage?: string; + adx_groupname?: string; + adx_ignoredefaultvalue?: boolean; + adx_label?: string; + adx_maxmultiplechoiceselectedcount?: number; + adx_minmultiplechoiceselectedcount?: number; + adx_multiplechoicevalidationerrormessage?: string; + adx_notes_settings?: string; + adx_onsavefromattribute?: string; + adx_onsavetype?: number; + adx_onsavetypename?: string; + adx_onsavevalue?: string; + adx_prepopulatefromattribute?: string; + adx_prepopulatetype?: number; + adx_prepopulatetypename?: string; + adx_prepopulatevalue?: string; + adx_provisionedlanguages?: number; + adx_purchasecreateinvoiceonpayment?: boolean; + adx_purchasefulfillorderonpayment?: boolean; + adx_purchaselineitemdescriptionattribute?: string; + adx_purchaselineiteminstructionsattribute?: string; + adx_purchaselineitemorderattribute?: string; + adx_purchaselineitemproductattribute?: string; + adx_purchaselineitemquantityattribute?: string; + adx_purchaselineitemrelationship?: string; + adx_purchaselineitemrequiredattribute?: string; + adx_purchaselineitemuomattribute?: string; + adx_purchaseoptionalproductsrelationship?: string; + adx_purchasequotename?: string; + adx_purchaserequiredproductsrelationship?: string; + adx_purchaserequiresshipping?: boolean; + adx_purchasetargetentityinvoicerelationship?: string; + adx_purchasetargetentityorderrelationship?: string; + adx_purchasetargetentityrelationship?: string; + adx_randomizeoptionsetvalues?: boolean; + adx_randomizeoptionsetvaluesname?: string; + adx_rangevalidationerrormessage?: string; + adx_rankordernotiesvalidationerrormessage?: string; + adx_requiredfieldvalidationerrormessage?: string; + adx_sectionname?: string; + adx_setvalueonsave?: boolean; + adx_setvalueonsavename?: string; + adx_subgrid_name?: string; + adx_subgrid_settings?: string; + adx_tabname?: string; + adx_timeline_settings?: string; + adx_type: number; + adx_typename?: string; + adx_useattributedescriptionproperty?: boolean; + adx_useattributedescriptionpropertyname?: string; + adx_validationerrormessage?: string; + adx_validationregularexpression?: string; + adx_validationregularexpressionerrormessage?: string; + adx_webformstep: string; + adx_entityformmetadataid?: string; + adx_webformstepid?: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/WebFormStep.ts b/src/common/portalMetadataView/TreeView/Types/Entity/WebFormStep.ts new file mode 100644 index 00000000..fae6f0b2 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/WebFormStep.ts @@ -0,0 +1,146 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface WebFormStep extends AbstractEntity { + adx_accept?: string; + adx_allowmultiplefiles?: boolean; + adx_appendquerystring?: boolean; + adx_appendquerystringname?: string; + adx_associatecurrentportaluser?: boolean; + adx_associatecurrentportalusername?: string; + adx_attachfile?: boolean; + adx_attachfilelabel?: string; + adx_attachfilemaxsize?: number; + adx_attachfilename?: string; + adx_attachfilerequired?: boolean; + adx_attachfilerequirederrormessage?: string; + adx_attachfilerequiredname?: string; + adx_attachfilerestrictaccept?: boolean; + adx_attachfilesizeerrormessage?: string; + adx_attachfilestoragelocation?: number; + adx_attachfiletypeerrormessage?: string; + adx_autogeneratesteps?: boolean; + adx_autogeneratestepsname?: string; + adx_autonumberattributelogicalname?: string; + adx_autonumberdefinitionname?: string; + adx_captcharequired?: boolean; + adx_captcharequiredname?: string; + adx_condition?: string; + adx_conditiondefaultnextstep?: string; + adx_conditiondefaultnextstepname?: string; + adx_createautonumber?: boolean; + adx_editexistingrecordpermitted?: boolean; + adx_editexpiredmessage?: string; + adx_editexpiredstatecode?: number; + adx_editexpiredstatusreason?: number; + adx_editnotpermittedmessage?: string; + adx_entitypermissionsenabled?: boolean; + adx_entitysourcestep?: string; + adx_entitysourcestepname?: string; + adx_entitysourcetype?: number; + adx_forceallfieldsrequired?: boolean; + adx_formname?: string; + adx_geolocation_addresslinefieldname?: string; + adx_geolocation_cityfieldname?: string; + adx_geolocation_countryfieldname?: string; + adx_geolocation_countyfieldname?: string; + adx_geolocation_displaymap?: boolean; + adx_geolocation_enabled?: boolean; + adx_geolocation_formattedaddressfieldname?: string; + adx_geolocation_latitudefieldname?: string; + adx_geolocation_longitudefieldname?: string; + adx_geolocation_maptype?: number; + adx_geolocation_neighborhoodfieldname?: string; + adx_geolocation_postalcodefieldname?: string; + adx_geolocation_statefieldname?: string; + adx_hideformonsuccess?: boolean; + adx_instructions?: string; + adx_loadeventkeyname?: string; + adx_loguser?: boolean; + adx_mode?: number; + adx_modename?: string; + adx_movepreviouspermitted?: boolean; + adx_multiplerecordsperuserpermitted?: boolean; + adx_name: string; + adx_nextbuttoncssclass?: string; + adx_nextbuttontext?: string; + adx_nextstep: string; + adx_nextstepname?: string; + adx_populatereferenceentitylookupfield?: boolean; + adx_populatereferenceentitylookupfieldname?: string; + adx_portaluserlookupattributeisactivityparty?: boolean; + adx_portaluserlookupattributeisactivitypartyname?: string; + adx_postbackurl?: string; + adx_previousbuttoncssclass?: string; + adx_previousbuttontext?: string; + adx_previousstep: string; + adx_previousstepname?: string; + adx_primarykeyattributelogicalname?: string; + adx_primarykeyquerystringparametername?: string; + adx_provisionedlanguages?: number; + adx_recommendedfieldsrequired?: boolean; + adx_recommendedfieldsrequiredname?: string; + adx_recordnotfoundmessage?: string; + adx_recordsourcerelationshipname?: string; + adx_redirecturl?: string; + adx_redirecturlappendentityidquerystring?: boolean; + adx_redirecturlappendentityidquerystringname?: string; + adx_redirecturlcustomquerystring?: string; + adx_redirecturlquerystringattribute?: string; + adx_redirecturlquerystringattributeparamname?: string; + adx_redirecturlquerystringname?: string; + adx_redirectwebpage?: string; + adx_referenceentitylogicalname?: string; + adx_referenceentityprimarykeylogicalname?: string; + adx_referenceentityreadonlyformname?: string; + adx_referenceentityrelationshipname?: string; + adx_referenceentityshowreadonlyform?: boolean; + adx_referenceentityshowreadonlyformname?: string; + adx_referenceentitysourcetype?: number; + adx_referenceentitysourcetypename?: string; + adx_referenceentitystep?: string; + adx_referenceentitystepname?: string; + adx_referencequeryattributelogicalname?: string; + adx_referencequerystringisprimarykey?: boolean; + adx_referencequerystringisprimarykeyname?: string; + adx_referencequerystringname?: string; + adx_referencerecordsourcerelationshipname?: string; + adx_referencesourceentitylogicalname?: string; + adx_referencetargetlookupattributelogicalname?: string; + adx_registerstartupscript?: string; + adx_renderwebresourcesinline?: boolean; + adx_savedeventkeyname?: string; + adx_savingeventkeyname?: string; + adx_setentityreference?: boolean; + adx_setentityreferencename?: string; + adx_settings?: string; + adx_showcaptchaforauthenticatedusers?: boolean; + adx_showcaptchaforauthenticatedusersname?: string; + adx_showownerfields?: boolean; + adx_showownerfieldsname?: string; + adx_showunsupportedfields?: boolean; + adx_showunsupportedfieldsname?: string; + adx_submitbuttonbusytext?: string; + adx_submitbuttoncssclass?: string; + adx_submitbuttontext?: string; + adx_submiteventkeyname?: string; + adx_successmessage: string; + adx_tabname?: string; + adx_targetentitylogicalname: string; + adx_targetentityportaluserlookupattribute?: string; + adx_targetentityprimarykeylogicalname?: string; + adx_title: string; + adx_tooltipenabled?: boolean; + adx_type: number; + adx_usercontrolpath?: string; + adx_usercontroltitle?: string; + adx_userhostaddressattributelogicalname?: string; + adx_useridentitynameattributelogicalname?: string; + adx_validationgroup?: string; + adx_validationsummarycssclass?: string; + adx_validationsummaryheadertext?: string; + adx_validationsummarylinksenabled?: boolean; + adx_validationsummarylinktext?: string; + adx_webform: string; + adx_webformname?: string; + adx_webformstepid: string; +} \ No newline at end of file diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/WebPage.ts b/src/common/portalMetadataView/TreeView/Types/Entity/WebPage.ts new file mode 100644 index 00000000..431ef6da --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/WebPage.ts @@ -0,0 +1,76 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface Webpage extends AbstractEntity { + adx_customcss?: string; + adx_authoridname?: string; + adx_entityform?: string; + adx_alloworigin?: string; + adx_modifiedbyipaddress?: string; + adx_entityformname?: string; + adx_meta_description?: string; + adx_botconsumeridname?: string; + adx_hiddenfromsitemapname?: string; + adx_modifiedbyusername?: string; + adx_webpagelanguageid?: string; + adx_title?: string; + adx_createdbyipaddress?: string; + adx_websiteidname?: string; + adx_editorialcomments?: string; + adx_categoryname?: string; + adx_authoridyominame?: string; + adx_parentpageidname?: string; + adx_navigationname?: string; + adx_authorid?: string; + adx_isrootname?: string; + adx_hiddenfromsitemap?: boolean; + adx_excludefromsearchname?: string; + adx_image?: string; + adx_imageurl?: string; + adx_publishingstateidname?: string; + adx_webform?: string; + adx_partialurl: string; + adx_displaydate?: Date; + adx_websiteid: string; + adx_customjavascript?: string; + adx_isofflinecachedname?: string; + adx_imagename?: string; + adx_enabletracking?: boolean; + adx_subjectid?: string; + adx_rootwebpageidname?: string; + adx_webformname?: string; + adx_displayorder?: number; + adx_isroot: boolean; + adx_category?: number; + adx_webpagelanguageidname?: string; + adx_summary?: string; + adx_subjectidname?: string; + adx_parentpageid?: string; + adx_expirationdate?: Date; + adx_entitylist?: string; + adx_releasedate?: Date; + adx_enabletrackingname?: string; + adx_createdbyusername?: string; + adx_sharedpageconfigurationname?: string; + adx_pagetemplateidname?: string; + adx_name: string; + adx_excludefromsearch?: boolean; + adx_navigation?: string; + adx_pagetemplateid: string; + adx_feedbackpolicy?: number; + adx_botconsumerid?: string; + adx_enableratingname?: string; + adx_masterwebpageid?: string; + adx_entitylistname?: string; + adx_feedbackpolicyname?: string; + adx_copy?: string; + adx_masterwebpageidname?: string; + adx_enablerating?: boolean; + adx_rootwebpageid?: string; + adx_webpageid: string; + adx_sharedpageconfiguration?: boolean; + adx_publishingstateid?: string; + adx_isofflinecached?: boolean; + _adx_webform_value?: string; + _adx_entitylist_value?: string; + _adx_entityform_value?: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/WebTemplate.ts b/src/common/portalMetadataView/TreeView/Types/Entity/WebTemplate.ts new file mode 100644 index 00000000..40508371 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/WebTemplate.ts @@ -0,0 +1,13 @@ +/*! + * Copyright (C) Microsoft Corporation. All rights reserved. + */ +import { AbstractEntity } from './AbstractEntity'; + +export interface WebTemplate extends AbstractEntity { + adx_mimetype?: string; + adx_websiteid: string; + adx_source: string; + adx_websiteidname?: string; + adx_webtemplateid: string; + adx_name: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/Weblink.ts b/src/common/portalMetadataView/TreeView/Types/Entity/Weblink.ts new file mode 100644 index 00000000..2ef1feeb --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/Weblink.ts @@ -0,0 +1,35 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface Weblink extends AbstractEntity { + adx_disablepagevalidation?: boolean; + adx_imageurl?: string; + adx_imagewidth?: number; + adx_displaypagechildlinks?: boolean; + adx_modifiedbyusername?: string; + adx_weblinksetidname?: string; + adx_displayorder: number; + adx_openinnewwindowname?: string; + adx_name: string; + adx_displayimageonly?: boolean; + adx_weblinksetid: string; + adx_imagealttext?: string; + adx_createdbyusername?: string; + adx_parentweblinkid?: string; + adx_modifiedbyipaddress?: string; + adx_robotsfollowlink: boolean; + adx_description?: string; + adx_publishingstateid?: string; + adx_disablepagevalidationname?: string; + adx_createdbyipaddress?: string; + adx_pageidname?: string; + adx_weblinkid: string; + adx_displaypagechildlinksname?: string; + adx_parentweblinkidname?: string; + adx_openinnewwindow: boolean; + adx_externalurl?: string; + adx_displayimageonlyname?: string; + adx_robotsfollowlinkname?: string; + adx_imageheight?: number; + adx_pageid?: string; + adx_publishingstateidname?: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/WeblinkSet.ts b/src/common/portalMetadataView/TreeView/Types/Entity/WeblinkSet.ts new file mode 100644 index 00000000..df9d2271 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/WeblinkSet.ts @@ -0,0 +1,15 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface WeblinkSet extends AbstractEntity { + adx_publishingstateidname?: string; + adx_name: string; + adx_weblinksetid: string; + adx_copy?: string; + adx_websitelanguageidname?: string; + adx_websiteidname?: string; + adx_websitelanguageid: string; + adx_websiteid: string; + adx_display_name?: string; + adx_publishingstateid?: string; + adx_title: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/Entity/Website.ts b/src/common/portalMetadataView/TreeView/Types/Entity/Website.ts new file mode 100644 index 00000000..5102d4f7 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/Entity/Website.ts @@ -0,0 +1,19 @@ +import { AbstractEntity } from './AbstractEntity'; + +export interface Website extends AbstractEntity { + adx_defaultlanguagename?: string; + adx_name?: string; + adx_defaultbotconsumerid?: string; + adx_defaultlanguage: string; + adx_partialurl?: string; + adx_headerwebtemplateid?: string; + adx_parentwebsiteidname?: string; + adx_headerwebtemplateidname?: string; + adx_websiteid: string; + adx_defaultbotconsumeridname?: string; + adx_website_language: number; + adx_primarydomainname?: string; + adx_footerwebtemplateid?: string; + adx_footerwebtemplateidname?: string; + adx_parentwebsiteid?: string; +} diff --git a/src/common/portalMetadataView/TreeView/Types/View/WebPage.ts b/src/common/portalMetadataView/TreeView/Types/View/WebPage.ts new file mode 100644 index 00000000..14017124 --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Types/View/WebPage.ts @@ -0,0 +1,22 @@ +/*! + * Copyright (C) Microsoft Corporation. All rights reserved. + */ + +import { WebTemplate } from '../Entity/WebTemplate'; + +export interface WebpageView { + baseURL: string; + runtimeCdnRootPath: string; + cssWebFiles: string[]; + runtimeJsAssets: string[]; + runtimeCssAssets: string[]; + fontStyles: string[]; +} + +export interface WebPageContent { + webTemplateContent: string; + header: WebTemplate; + footer: WebTemplate; + customJs?: string; + customCss?: string; +} diff --git a/src/common/portalMetadataView/TreeView/Utils/Constant.ts b/src/common/portalMetadataView/TreeView/Utils/Constant.ts new file mode 100644 index 00000000..409c5e1a --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Utils/Constant.ts @@ -0,0 +1,37 @@ +export enum ContextProperty { + WEBPAGE_YAML = '.webpage.yml', + WEBPAGE_COPY = '.webpage.copy.html', + WEBPAGE_CSS = '.webpage.custom_css.css', + WEBPAGE_JS = '.webpage.custom_javascript.js', + WEBPAGE_SUMMARY = '.webpage.summary.html', + CONTENT_SNIPPET_YAML = '.contentsnippet.yml', + CONTENT_SNIPPET_VALUE = '.contentsnippet.value.html', + WEB_TEMPLATE_YAML = '.webtemplate.yml', + WEB_TEMPLATE_SOURCE = '.webtemplate.source.html', + SITE_MARKER = 'sitemarker.yml', + SITE_SETTING = 'sitesetting.yml', + ENTITY_LIST = '.list.yml', + ENTITY_FORM = '.basicform.yml', + WEB_FORM = '.advancedform.yml', + WEB_LINK = '.weblink.yml', + WEB_LINK_SET = '.weblinkset.yml', + WEBSITE = 'website.yml', + PAGE_TEMPLATE = '.pagetemplate.yml', + UNKNOWN_PROPERTY = '' +} +export enum ContextPropertyKey { + WEBPAGE = 'adx_webpageid', + CONTENT_SNIPPET = 'adx_contentsnippetid', + WEB_TEMPLATE = 'adx_webtemplateid', + SITE_MARKER = 'adx_sitemarkerid', + SITE_SETTING = 'adx_sitesettingid', + ENTITY_LIST = 'adx_entitylistid', + ENTITY_FORM = 'adx_entityformid', + WEB_FORM = 'adx_webformid', + WEB_LINK = 'adx_weblinkid', + WEB_LINK_SET = 'adx_weblinksetid', + WEBSITE = 'adx_websiteid', + PAGE_TEMPLATE = 'adx_pagetemplateid', +} + +export const BootstrapSiteSetting = 'Site/BootstrapV5Enabled'; \ No newline at end of file diff --git a/src/common/portalMetadataView/TreeView/Utils/IDataResolver.ts b/src/common/portalMetadataView/TreeView/Utils/IDataResolver.ts new file mode 100644 index 00000000..be0d801b --- /dev/null +++ b/src/common/portalMetadataView/TreeView/Utils/IDataResolver.ts @@ -0,0 +1,123 @@ + +import { ContentSnippet } from '../Types/Entity/ContentSnippet'; +import { EntityForm } from '../Types/Entity/EntityForm'; +import { EntityList } from '../Types/Entity/EntityList'; +import { PageTemplate } from '../Types//Entity/PageTemplate'; +import { SiteMarker } from '../Types/Entity/SiteMarker'; +import { SiteSetting } from '../Types/Entity/SiteSettings'; +import { WebForm } from '../Types/Entity/WebForm'; +import { Weblink } from '../Types/Entity/Weblink'; +import { WeblinkSet } from '../Types/Entity/WeblinkSet'; +import { PortalDrop } from '../PortalDrops/PortalDrops'; +import { WebpageView } from '../Types/View/WebPage'; +import { Webpage } from '../Types/Entity/WebPage'; +import { Website } from '../Types/Entity/Website'; +import { WebTemplate } from '../Types/Entity/WebTemplate'; +import { IEntityAttributeMetadata } from '../Types/Entity/EntityAttributeMetadata'; + +export type PortalEntity = + | Webpage + | ContentSnippet + | WebTemplate + | SiteSetting + | SiteMarker + | Website + | WeblinkSet + | Weblink; + +export interface IPreviewEngineContext { + webpages?: Webpage[]; + contentSnippets?: ContentSnippet[]; + webTemplates?: WebTemplate[]; + siteMarkers?: SiteMarker[]; + siteSettings?: SiteSetting[]; + entityLists?: EntityList[]; + entityForms?: EntityForm[]; + webForms?: WebForm[]; + weblinks?: Weblink[]; + weblinkSets?: WeblinkSet[]; + website?: Website; + pageTemplates?: PageTemplate[]; + dataResolverExtras?: { [key: string]: {} }; + resx?: { [key: string]: string }; + featureConfig?: Map; + entityAttributeMetadata?: IEntityAttributeMetadata[]; + lcid?: string; + isBootstrapV5?: boolean; +} + + +export enum RenderingMode { + VIEW = 'viewer', + EDIT = 'editor', +} + +export enum DebugMode { + OFF = 'OFF', + INFO = 'INFO', + ERROR = 'ERROR', + TRACE = 'TRACE', +} + +interface IEngineConfig { + strictFilters: boolean; + strictVariables: boolean; + isDynamicComponentCheck?: boolean; + addDynamicEntity?: (entityName: string, id: string, attributeName?: string) => void; + addFetchXMLExpression?: (varName: string, fetchXML: string) => void; + addPcfControl?: (controlName: string) => void; + addDynamicDrops?: (dropName: string) => void; +} + +export interface IPreviewEngineConfig { + renderingMode?: RenderingMode; + debugMode?: DebugMode; + engineConfig?: IEngineConfig; + websiteLanguageId?: string; + breadcrumb?: IBreadcrumbParams; +} + +export interface IBreadcrumbParams { + separator: string; + home_as: string; + tag: string; + textClass: string; +} + +export interface IDataResolver { + context?: IPreviewEngineContext; + config?: IPreviewEngineConfig; +} + +export interface IPortalDrops { + [key: string]: PortalDrop; +} + +export interface IPortalPreviewEngine { + renderWebpageById: ( + webpageId: string, + htmlMeta?: WebpageView, + beforeTagRender?: (tagName: string, entityName: string, entityId: string) => void, + dynamicContext?: {} + ) => string; + evaluateExpression: ( + expression: string, + webpageId?: string, + beforeTagRender?: (tagName: string, entityName: string, entityId: string) => void, + dynamicContext?: {} + ) => string; + renderWebpageByURL: ( + pageUrl: string, + htmlMeta?: WebpageView, + beforeTagRender?: (tagName: string, entityName: string, entityId: string) => void, + dynamicContext?: {} + ) => string; + updateContext: (context?: IPreviewEngineContext) => void; + updateConfig: (config?: IPreviewEngineConfig) => void; + getConfig: () => IPreviewEngineConfig; + renderPartialWebpageById: ( + webpageId?: string, + htmlMeta?: WebpageView, + beforeTagRender?: (tagName: string, entityName: string, entityId: string) => void + ) => { header: string; mainContent: string; footer: string }; +} diff --git a/src/common/portalMetadataView/services/DefaultPortalComponentService.ts b/src/common/portalMetadataView/services/DefaultPortalComponentService.ts new file mode 100644 index 00000000..824432ef --- /dev/null +++ b/src/common/portalMetadataView/services/DefaultPortalComponentService.ts @@ -0,0 +1,13 @@ +/*! + * Copyright (C) Microsoft Corporation. All rights reserved. + */ + +import { IItem } from "../TreeView/Types/Entity/IItem"; +import {IPortalComponentService} from "./IPortalComponentService"; + +export class DefaultPortalComponentService implements IPortalComponentService { + create(metadataContext: any, getPath?:any) : IItem[] { + // have the logic for creating IItem for remaining components like Webtemplate, contentsnippet, entity list, entity form. They all look similar + return []; + } +} \ No newline at end of file diff --git a/src/common/portalMetadataView/services/IPortalComponentService.ts b/src/common/portalMetadataView/services/IPortalComponentService.ts new file mode 100644 index 00000000..b079e79c --- /dev/null +++ b/src/common/portalMetadataView/services/IPortalComponentService.ts @@ -0,0 +1,16 @@ +/*! + * Copyright (C) Microsoft Corporation. All rights reserved. + */ +import { IItem } from "../TreeView/Types/Entity/IItem"; + +export interface IPortalComponentService { + /** + * Save source value of the component and refresh component if save successful. + * @param id: Id of component + * @param value: source code value + * @param element Outer HTML element for portal component + * @param subComponent one of many dependent on its parent component service for saving + */ + create(metadataContext: any, getPath?: any): IItem[] ; + +} \ No newline at end of file diff --git a/src/common/portalMetadataView/services/PortalComponentServiceFactory.ts b/src/common/portalMetadataView/services/PortalComponentServiceFactory.ts new file mode 100644 index 00000000..2ddd410a --- /dev/null +++ b/src/common/portalMetadataView/services/PortalComponentServiceFactory.ts @@ -0,0 +1,24 @@ +/*! + * Copyright (C) Microsoft Corporation. All rights reserved. + */ + +import {IPortalComponentService} from "./IPortalComponentService"; +import {WebsiteService} from "./WebsiteService"; +import {WebPageService} from "./WebPageService"; +import {DefaultPortalComponentService} from "./DefaultPortalComponentService"; + +export class PortalComponentServiceFactory { + static getPortalComponent(componentType: string): IPortalComponentService | null { + switch (componentType) { + case "Website": { + return new WebsiteService(); + } + case "WebPage": { + return new WebPageService(); + } + default: { + return new DefaultPortalComponentService(); + } + } + } +} \ No newline at end of file diff --git a/src/common/portalMetadataView/services/WebPageService.ts b/src/common/portalMetadataView/services/WebPageService.ts new file mode 100644 index 00000000..f15c8397 --- /dev/null +++ b/src/common/portalMetadataView/services/WebPageService.ts @@ -0,0 +1,13 @@ +/*! + * Copyright (C) Microsoft Corporation. All rights reserved. + */ + +import {IPortalComponentService} from "./IPortalComponentService"; +import { IItem } from "../TreeView/Types/Entity/IItem"; + +export class WebPageService implements IPortalComponentService { + create(metadataContext: any, getPath?: any) : IItem[] { + // have the logic for creating IItem for remaining components + return []; + } +} \ No newline at end of file diff --git a/src/common/portalMetadataView/services/WebsiteService.ts b/src/common/portalMetadataView/services/WebsiteService.ts new file mode 100644 index 00000000..79f02d71 --- /dev/null +++ b/src/common/portalMetadataView/services/WebsiteService.ts @@ -0,0 +1,13 @@ +/*! + * Copyright (C) Microsoft Corporation. All rights reserved. + */ + +import {IPortalComponentService} from "./IPortalComponentService"; +import { IItem } from "../TreeView/Types/Entity/IItem"; + +export class WebsiteService implements IPortalComponentService { + create(metadataContext: any, getPath?:any) : IItem[] { + // have the logic for creating IItem for remaining components + return []; + } +} \ No newline at end of file