Skip to content

Commit 1353b50

Browse files
authored
set aria label for the plain text log link (#826)
1 parent d30d5e8 commit 1353b50

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

src/main/frontend/common/i18n/i18n-provider.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ export const I18NProvider: FunctionComponent<I18NProviderProps> = ({
4545
<I18NContext.Provider value={messages}>{children}</I18NContext.Provider>
4646
);
4747
};
48+
49+
export function useMessages() {
50+
return useContext(I18NContext);
51+
}

src/main/frontend/common/i18n/messages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export enum LocalizedMessageKey {
8181
start = "node.start",
8282
end = "node.end",
8383
changesSummary = "changes.summary",
84+
consoleNewTab = "console.newTab",
8485
}
8586

8687
const DEFAULT_MESSAGES: ResourceBundle = {
@@ -96,6 +97,7 @@ const DEFAULT_MESSAGES: ResourceBundle = {
9697
[LocalizedMessageKey.start]: "Start",
9798
[LocalizedMessageKey.end]: "End",
9899
[LocalizedMessageKey.changesSummary]: "{0} {0,choice,1#change|1<changes}",
100+
[LocalizedMessageKey.consoleNewTab]: "View step as plain text",
99101
};
100102

101103
export function defaultMessages(locale: string): Messages {

src/main/frontend/pipeline-console-view/pipeline-console/main/ConsoleLogCard.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99

1010
import StatusIcon from "../../../common/components/status-icon.tsx";
1111
import Tooltip from "../../../common/components/tooltip.tsx";
12+
import { LocalizedMessageKey, useMessages } from "../../../common/i18n";
1213
import { classNames } from "../../../common/utils/classnames.ts";
1314
import { Total } from "../../../common/utils/timings.tsx";
1415
import {
@@ -72,6 +73,8 @@ export default function ConsoleLogCard(props: ConsoleLogCardProps) {
7273
return `${(size / gib).toFixed(2)}GiB`;
7374
};
7475

76+
const messages = useMessages();
77+
7578
return (
7679
<div className={"pgv-step-detail-group"} key={`step-card-${props.step.id}`}>
7780
<div
@@ -124,12 +127,13 @@ export default function ConsoleLogCard(props: ConsoleLogCardProps) {
124127
</div>
125128
</a>
126129

127-
<Tooltip content={"View step as plain text"}>
130+
<Tooltip content={messages.format(LocalizedMessageKey.consoleNewTab)}>
128131
<a
129132
href={`log?nodeId=${props.step.id}`}
130133
className={"jenkins-button jenkins-button--tertiary"}
131134
target="_blank"
132135
rel="noreferrer"
136+
aria-label={messages.format(LocalizedMessageKey.consoleNewTab)}
133137
>
134138
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
135139
<path

src/main/resources/io/jenkins/plugins/pipelinegraphview/Messages.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ FlowNodeWrapper.noStage=System Generated
3333

3434
run.alreadyCancelled=Run was already cancelled
3535
run.isFinished=Run is already finished
36+
37+
console.newTab=View step as plain text

src/test/java/io/jenkins/plugins/pipelinegraphview/playwright/PipelineConsole.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public void stepContainsText(String stepName, String textToFind) {
7070
Locator stepLogs = stepContainer.getByRole(AriaRole.LOG);
7171
assertThat(stepLogs).containsText(textToFind);
7272

73-
try (Page plainText = page.waitForPopup(stepContainer.locator("a[href*='log?nodeId=']")::click)) {
74-
plainText.waitForLoadState();
73+
Locator plainTextLogsLink = stepContainer.getByRole(
74+
AriaRole.LINK, new Locator.GetByRoleOptions().setName("View step as plain text"));
75+
try (Page plainText = page.context().waitForPage(plainTextLogsLink::click)) {
7576
assertThat(plainText.locator("body")).containsText(textToFind);
7677
}
7778
}

0 commit comments

Comments
 (0)