Skip to content

Commit

Permalink
refactor: Add ADX_LANGUAGECODE and ADX_WEBSITE_LANGUAGE constants
Browse files Browse the repository at this point in the history
  • Loading branch information
ritikramuka committed May 21, 2024
1 parent 9717e15 commit 6ea0bfa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/common/copilot/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const THUMBS_UP = 'thumbsUp';
export const THUMBS_DOWN = 'thumbsDown';
export const ADX_ENTITYFORM = "adx_entityform";
export const ADX_ENTITYLIST = "adx_entitylist";
export const ADX_LANGUAGECODE = "adx_languagecode";
export const ADX_WEBSITE_LANGUAGE = "adx_website_language";
export const ATTRIBUTE_DESCRIPTION = 'description';
export const ATTRIBUTE_DATAFIELD_NAME = 'datafieldname';
export const ATTRIBUTE_CLASSID = 'classid';
Expand Down
7 changes: 3 additions & 4 deletions src/common/copilot/dataverseMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import { sendTelemetryEvent } from "./telemetry/copilotTelemetry";
import { CopilotDataverseMetadataFailureEvent, CopilotDataverseMetadataSuccessEvent, CopilotGetEntityFailureEvent, CopilotGetLanguageCodeFailureEvent, CopilotGetLanguageCodeSuccessEvent, CopilotYamlParsingFailureEvent } from "./telemetry/telemetryConstants";
import { getEntityMetadata, getDefaultLanguageCodeWeb } from "../../web/client/utilities/fileAndEntityUtil";
import { DOMParser } from "@xmldom/xmldom";
import { ATTRIBUTE_CLASSID, ATTRIBUTE_DATAFIELD_NAME, ATTRIBUTE_DESCRIPTION, ControlClassIdMap, SYSTEFORMS_API_PATH } from "./constants";
import { ADX_LANGUAGECODE, ADX_WEBSITE_LANGUAGE, ATTRIBUTE_CLASSID, ATTRIBUTE_DATAFIELD_NAME, ATTRIBUTE_DESCRIPTION, ControlClassIdMap, SYSTEFORMS_API_PATH } from "./constants";
import { findWebsiteYAML, getUserAgent } from "../utilities/Utils";
import { EntityMetadataKeyAdx } from "../../web/client/schema/constants";


declare const IS_DESKTOP: string | undefined;
Expand Down Expand Up @@ -260,7 +259,7 @@ async function fetchLanguageCodeId(): Promise<string> {
const yamlContent = await readWebsiteYAML(activeFilePath);
if (yamlContent) {
const parsedYAML = yaml.parse(yamlContent);
const languageCodeId = parsedYAML[EntityMetadataKeyAdx.LANGUAGE_ID];
const languageCodeId = parsedYAML[ADX_WEBSITE_LANGUAGE];
return languageCodeId;
} else {
return "";
Expand Down Expand Up @@ -311,7 +310,7 @@ async function fetchLanguageCodeFromAPI(
orgUrl: orgUrl,
});

return matchingLanguage?.[EntityMetadataKeyAdx.LANGUAGE_NAME_CODE] ?? vscode.env.language;
return matchingLanguage?.[ADX_LANGUAGECODE] ?? vscode.env.language;
} catch (error) {
sendTelemetryEvent(telemetry, {
eventName: CopilotGetLanguageCodeFailureEvent,
Expand Down
2 changes: 0 additions & 2 deletions src/web/client/schema/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,4 @@ export enum EntityMetadataKeyCore {
export enum EntityMetadataKeyAdx {
ENTITY_LOGICAL_NAME = "adx_entityname",
FORM_LOGICAL_NAME = "adx_formname",
LANGUAGE_NAME_CODE = "adx_languagecode",
LANGUAGE_ID = "adx_website_language"
}

0 comments on commit 6ea0bfa

Please sign in to comment.