Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][Preview] Introduce Preview Engine Class | Map Desktop Ext data #707

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Bootstrap v5 flag
  • Loading branch information
Shivika Gupta committed Sep 11, 2023
commit cb1cbf94e697220b057cdb43dc08eb80e7c060a8
9 changes: 7 additions & 2 deletions src/client/power-pages/preview/PreviewEngineContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Website } from '@maker-studio/powerportals-preview-engine/lib/Rendering
import { PortalWebView } from '../../PortalWebView';
import { load } from 'js-yaml';
import * as vscode from 'vscode';
import { ContextProperty, ContextPropertyKey } from './Utils/Constants';
import { BootstrapSiteSetting, ContextProperty, ContextPropertyKey } from './Utils/Constants';
import { findObjectIndexByProperty, getFileProperties, removeExtension } from '../commonUtility';

const fallbackURI = vscode.Uri.file('');
Expand All @@ -33,8 +33,10 @@ 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;
Expand Down Expand Up @@ -70,7 +72,7 @@ export class PreviewEngineContext {
featureConfig: new Map(),
entityAttributeMetadata: [] as IEntityAttributeMetadata[],
lcid: '' as string,
isBootstrapV5: false as boolean,
isBootstrapV5: this.isBootstrapV5,
}
} else return {}
}
Expand Down Expand Up @@ -276,6 +278,9 @@ export class PreviewEngineContext {
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,
Expand Down
4 changes: 3 additions & 1 deletion src/client/power-pages/preview/Utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ export enum ContextPropertyKey {
WEB_LINK_SET = 'adx_weblinksetid',
WEBSITE = 'adx_websiteid',
PAGE_TEMPLATE = 'adx_pagetemplateid',
}
}

export const BootstrapSiteSetting = 'Site/BootstrapV5Enabled';