Skip to content

Commit

Permalink
Merge branch 'main' into users/amitjoshi/thinkingMsgAccessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
amitjoshi committed Jan 2, 2025
2 parents 8a0acab + b9db334 commit 5901762
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
30 changes: 20 additions & 10 deletions src/common/copilot/assets/scripts/copilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
copyButton.classList.add("action-button");
copyButton.classList.add("copy-button");
copyButton.title = copilotStrings.COPY_TO_CLIPBOARD_MESSAGE;
copyButton.setAttribute("aria-label", copilotStrings.COPY_TO_CLIPBOARD_MESSAGE);
copyButton.addEventListener("click", () => {
copyCodeToClipboard(code);
});
Expand All @@ -144,12 +145,12 @@
insertButton.classList.add("action-button");
insertButton.classList.add("insert-button");
insertButton.title = copilotStrings.INSERT_CODE_MESSAGE;
insertButton.setAttribute("aria-label", copilotStrings.INSERT_CODE_MESSAGE);
insertButton.addEventListener("click", () => {
insertCode(code);
});
actionWrapper.appendChild(insertButton);


return actionWrapper;
}

Expand All @@ -160,7 +161,6 @@
return truncatedInitials.join("").toUpperCase();
}


function handleUserMessage(message) {
const messageWrapper = document.createElement("div");
messageWrapper.classList.add("message-wrapper");
Expand Down Expand Up @@ -259,21 +259,21 @@
const listPrompt = copilotStrings.LIST_PROMPT;

suggestedPrompt.innerHTML = `<p class="suggested-title">${copilotStrings.SUGGESTIONS_MESSAGE}</p>
<a href='#' class="suggested-prompt">
<a href='#' class="suggested-prompt" tabindex="0" aria-label="${formPrompt}">
<span class="icon-container">
${starIconSvg}
</span>
${formPrompt}
</a>
<br>
<a href='#' class="suggested-prompt">
<a href='#' class="suggested-prompt" tabindex="0" aria-label="${webApiPrompt}">
<span class="icon-container">
${starIconSvg}
</span>
${webApiPrompt}
</a>
<br>
<a href='#' class="suggested-prompt">
<a href='#' class="suggested-prompt" tabindex="0" aria-label="${listPrompt}">
<span class="icon-container">
${starIconSvg}
</span>
Expand All @@ -287,7 +287,7 @@
const walkthrough = document.createElement("div");
walkthrough.classList.add("walkthrough-div");
walkthrough.innerHTML = `<p class="walkthrough-title">${copilotStrings.GETTING_STARTED_MESSAGE}</p>
<a href="#" class="walkthrough-content">
<a href="#" class="walkthrough-content" tabindex="0" aria-label="${copilotStrings.LEARN_MORE_MESSAGE}">
${bookIconSvg}
<span id="walk-text">${copilotStrings.LEARN_MORE_MESSAGE}</span>
</a>`;
Expand Down Expand Up @@ -344,6 +344,7 @@
messageIndex++;

const apiResponseElement = parseCodeBlocks(apiResponse);
apiResponseElement.setAttribute("aria-live", "assertive"); // Add aria-live attribute to response
messageElement.appendChild(apiResponseElement);

messageWrapper.dataset.id = message.id;
Expand Down Expand Up @@ -378,7 +379,7 @@
notLoggedIn.classList.add("not-loggedIn");
notLoggedIn.innerHTML = `<p id="greeting"></p>
<p>${copilotStrings.LOGIN_MESSAGE}</p>
<button id="loginButton" >${copilotStrings.LOGIN_BUTTON}</button>`;
<button id="loginButton" aria-label="${copilotStrings.LOGIN_BUTTON}">${copilotStrings.LOGIN_BUTTON}</button>`;

messageElement.appendChild(notLoggedIn);

Expand Down Expand Up @@ -406,21 +407,31 @@
vscode.postMessage({ type: "openGitHubCopilotLink" });
});


const suggestedPromptDiv = createSuggestedPromptDiv();
messageElement.appendChild(suggestedPromptDiv);

const suggestedPrompts = document.querySelectorAll(".suggested-prompt");
suggestedPrompts.forEach((suggestedPrompt) => {
suggestedPrompt.addEventListener("click", handleSuggestionsClick);
suggestedPrompt.addEventListener("keydown", (event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
handleSuggestionsClick.call(suggestedPrompt);
}
});
});

const walkthroughDiv = createWalkthroughDiv();
messageElement.appendChild(walkthroughDiv);

const walkthroughContent = document.getElementById("walk-text");
walkthroughContent.addEventListener("click", handleWalkthroughClick);

walkthroughContent.addEventListener("keydown", (event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
handleWalkthroughClick.call(walkthroughContent);
}
});
}
};
}
Expand All @@ -446,7 +457,6 @@
<p>${copilotStrings.DOCUMENTATION_LINK}<a></p>`;

messageElement.appendChild(notAvailabel);

}

// Handle messages sent from the extension to the webview
Expand Down
9 changes: 7 additions & 2 deletions src/web/client/dal/remoteFetchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,16 @@ async function createContentFiles(
schemaEntityKey.LANGUAGE_FIELD
);

let languageCode = WebExtensionContext.websiteLanguageCode;

if (languageCodeAttribute && result[languageCodeAttribute] === null) {
throw new Error(ERROR_CONSTANTS.LANGUAGE_CODE_ID_VALUE_NULL);
if (entityName !== schemaEntityName.CONTENTSNIPPETS) {
throw new Error(ERROR_CONSTANTS.LANGUAGE_CODE_ID_VALUE_NULL);
} else {
languageCode = Constants.DEFAULT_LANGUAGE_CODE; // Handles the case where language code is null for content snippets
}
}

let languageCode = WebExtensionContext.websiteLanguageCode;
if (defaultFileInfo?.fileName === undefined &&
languageCodeAttribute &&
result[languageCodeAttribute]) {
Expand Down
4 changes: 2 additions & 2 deletions src/web/client/schema/portalSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const portal_schema_V1 = {
_fetchQueryParameters:
"?$filter=adx_contentsnippetid eq {entityId}&$select=adx_name,adx_value,_adx_contentsnippetlanguageid_value",
_multiFileFetchQueryParameters:
"?$filter=_adx_websiteid_value eq {websiteId} and _adx_contentsnippetlanguageid_value ne null &$select=adx_name,adx_value,adx_contentsnippetid,_adx_contentsnippetlanguageid_value&$count=true",
"?$filter=_adx_websiteid_value eq {websiteId} &$select=adx_name,adx_value,adx_contentsnippetid,_adx_contentsnippetlanguageid_value&$count=true",
_attributes: "adx_value",
_attributesExtension: new Map([["adx_value", "html"]]),
},
Expand Down Expand Up @@ -334,7 +334,7 @@ export const portal_schema_V2 = {
_fetchQueryParameters:
"?$filter=powerpagecomponentid eq {entityId}&$select=name,content",
_multiFileFetchQueryParameters:
"?$filter=_powerpagesiteid_value eq {websiteId} and powerpagecomponenttype eq 7 and _powerpagesitelanguageid_value ne null &$select=name,content,_powerpagesitelanguageid_value&$count=true",
"?$filter=_powerpagesiteid_value eq {websiteId} and powerpagecomponenttype eq 7 &$select=name,content,_powerpagesitelanguageid_value&$count=true",
_attributes: "content.value",
_attributesExtension: new Map([["content.value", "html"]]),
},
Expand Down
10 changes: 7 additions & 3 deletions src/web/client/utilities/commonUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { doesFileExist, getFileAttributePath, getFileEntityName, updateEntityCol
import { isWebFileV2 } from "./schemaHelperUtil";
import { ServiceEndpointCategory } from "../../../common/services/Constants";
import { PPAPIService } from "../../../common/services/PPAPIService";
import * as Constants from "../common/constants";

// decodes file content to UTF-8
export function convertContentToUint8Array(content: string, isBase64Encoded: boolean): Uint8Array {
Expand All @@ -42,15 +43,18 @@ export function GetFileNameWithExtension(
languageCode: string,
extension: string
) {
fileName = isLanguageCodeNeededInFileName(entity) ? `${fileName}.${languageCode}` : fileName;
if (entity === schemaEntityName.CONTENTSNIPPETS) {
fileName = languageCode && languageCode != Constants.DEFAULT_LANGUAGE_CODE ? `${fileName}.${languageCode}` : fileName; // Handle the case where language is not provided for content snippets
} else {
fileName = isLanguageCodeNeededInFileName(entity) ? `${fileName}.${languageCode}` : fileName;
}
fileName = isExtensionNeededInFileName(entity) ? `${fileName}.${extension}` : fileName;

return getSanitizedFileName(fileName);
}

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

export function isExtensionNeededInFileName(entity: string) {
Expand Down

0 comments on commit 5901762

Please sign in to comment.