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

Web Extension: Remove dependency on website preview URL #1091

Merged
merged 8 commits into from
Jan 22, 2025
Prev Previous commit
Next Next commit
Rename method
priyanshu92 committed Jan 22, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 49e848f49c28c1d3a829d3346ed99cba318fb137
8 changes: 4 additions & 4 deletions src/web/client/utilities/commonUtil.ts
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ export function GetFileNameWithExtension(
}

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

export function isExtensionNeededInFileName(entity: string) {
@@ -310,15 +310,15 @@ export function getRangeForMultilineMatch(text: string, pattern: string, index:
return range;
}

export async function validateWebsitePreviewURL(): Promise<{ websiteUrl: string, isValid: boolean }> {
export async function getValidWebsitePreviewUrl(): Promise<{ websiteUrl: string, isValid: boolean }> {
const envId = getEnvironmentIdFromUrl();
const serviceEndpointStamp = WebExtensionContext.serviceEndpointCategory;
const websitePreviewId = WebExtensionContext.urlParametersMap?.get(queryParameters.PORTAL_ID);

if (serviceEndpointStamp === ServiceEndpointCategory.NONE || !envId || !websitePreviewId) {
WebExtensionContext.telemetry.sendErrorTelemetry(
webExtensionTelemetryEventNames.WEB_EXTENSION_WEBSITE_PREVIEW_URL_VALIDATION_INSUFFICIENT_PARAMETERS,
validateWebsitePreviewURL.name,
getValidWebsitePreviewUrl.name,
`serviceEndpointStamp:${serviceEndpointStamp}, envId:${envId}, websitePreviewId:${websitePreviewId}`
);
return { websiteUrl: '', isValid: false };
@@ -329,7 +329,7 @@ export async function validateWebsitePreviewURL(): Promise<{ websiteUrl: string,
if (siteDetails == null) {
WebExtensionContext.telemetry.sendErrorTelemetry(
webExtensionTelemetryEventNames.WEB_EXTENSION_WEBSITE_PREVIEW_URL_VALIDATION_SITE_DETAILS_FETCH_FAILED,
validateWebsitePreviewURL.name,
getValidWebsitePreviewUrl.name,
);
return { websiteUrl: '', isValid: false };
}
4 changes: 2 additions & 2 deletions src/web/client/webViews/powerPagesNavigationProvider.ts
Original file line number Diff line number Diff line change
@@ -7,14 +7,14 @@ import * as vscode from 'vscode';
import * as path from 'path';
import WebExtensionContext from "../WebExtensionContext";
import { httpMethod } from '../common/constants';
import { getBackToStudioURL, validateWebsitePreviewURL } from '../utilities/commonUtil';
import { getBackToStudioURL, getValidWebsitePreviewUrl } from '../utilities/commonUtil';
import { webExtensionTelemetryEventNames } from '../../../common/OneDSLoggerTelemetry/web/client/webExtensionTelemetryEvents';

export class PowerPagesNavigationProvider implements vscode.TreeDataProvider<PowerPagesNode> {

private _onDidChangeTreeData: vscode.EventEmitter<PowerPagesNode | undefined | void> = new vscode.EventEmitter<PowerPagesNode | undefined | void>();
readonly onDidChangeTreeData: vscode.Event<PowerPagesNode | undefined | void> = this._onDidChangeTreeData.event;
private isWebsitePreviewURLValid: Promise<{ websiteUrl: string, isValid: boolean }> = validateWebsitePreviewURL();
private isWebsitePreviewURLValid: Promise<{ websiteUrl: string, isValid: boolean }> = getValidWebsitePreviewUrl();

refresh(): void {
this._onDidChangeTreeData.fire();