Skip to content

Commit

Permalink
WIP: Render bugrefs in JavaScript as well
Browse files Browse the repository at this point in the history
Does not work so easily because JavaScript's regex support does not
accept the advanced Perl regex we use in the backend.

See os-autoinst/os-autoinst-distri-opensuse#17986 (review)
for further context.
  • Loading branch information
Martchus committed Oct 17, 2023
1 parent f46075b commit 13c8b3e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
14 changes: 10 additions & 4 deletions assets/javascripts/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ function moduleResultCSS(result) {
return 'resultunknown';
}

function renderModuleRow(module, snippets) {
function bugrefToHref(text, bugrefRegex) {
debugger;
return text; // TODO
}

function renderModuleRow(module, snippets, bugrefRegex) {
const E = createElement;
const rowid = 'module_' + module.name.replace(/[^a-z0-9_-]+/gi, '-');
const flags = [];
Expand Down Expand Up @@ -187,7 +192,7 @@ function renderModuleRow(module, snippets) {
const textresult = E('pre', [textData]);
var html = stepActions.outerHTML;
html += textresult.outerHTML;
const txt = escape(html);
const txt = escape(bugrefToHref(html, bugrefRegex));
const link = E('a', box, {
class: 'no_hover' + (title === 'wait_serial' ? ' serial-result-preview' : ''),
'data-text': txt,
Expand Down Expand Up @@ -218,7 +223,7 @@ function renderModuleRow(module, snippets) {
return E('tr', [component, result, links], {id: rowid});
}

function renderModuleTable(container, response) {
function renderModuleTable(container, response, bugrefRegex) {
container.innerHTML = response.snippets.header;

if (response.modules === undefined || response.modules === null) {
Expand All @@ -242,6 +247,7 @@ function renderModuleTable(container, response) {
);
}

tbody.appendChild(renderModuleRow(module, response.snippets));
const bugrefRegex = typeof response.bugref_regex === 'string' ? new RegExp(response.bugref_regex) : undefined;
tbody.appendChild(renderModuleRow(module, response.snippets, bugrefRegex));
}
}
3 changes: 2 additions & 1 deletion assets/javascripts/running.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function updateTestStatus(newStatus) {

// show embedded logfile (autoinst-log.txt) if there are no test modules are available and skip further processing
const modules = data.modules;
const bugrefRegex = typeof data.bugref_regex === 'string' ? new RegExp() : undefined;
if (!Array.isArray(modules)) {
if (typeof snippets.header === 'string') {
detailsTab.panelElement.innerHTML = snippets.header;
Expand Down Expand Up @@ -159,7 +160,7 @@ function updateTestStatus(newStatus) {
document.body.appendChild(previewContainer);
}
// actually update the row
resultRow.replaceWith(renderModuleRow(module, snippets));
resultRow.replaceWith(renderModuleRow(module, snippets, bugrefRegex));
});

testStatus.running = newStatus.running;
Expand Down
4 changes: 2 additions & 2 deletions lib/OpenQA/WebAPI/Controller/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use OpenQA::Utils;
use OpenQA::Jobs::Constants;
use OpenQA::Schema::Result::Jobs;
use OpenQA::Schema::Result::JobDependencies;
use OpenQA::Utils qw(determine_web_ui_web_socket_url get_ws_status_only_url);
use OpenQA::Utils qw(determine_web_ui_web_socket_url get_ws_status_only_url BUGREF_REGEX);
use Mojo::ByteStream;
use Mojo::Util 'xml_escape';
use Mojo::File 'path';
Expand Down Expand Up @@ -351,7 +351,7 @@ sub details ($self) {
md5thumb_url => $self->url_for('thumb_image', md5_dirname => '$DIRNAME$', md5_basename => '$BASENAME$'),
thumbnail_url => $self->url_for('test_thumbnail', testid => $job->id, filename => '$FILENAME$')};

return $self->render(json => {snippets => $snips, modules => \@ret});
return $self->render(json => {snippets => $snips, modules => \@ret, bugref_regex => '' . BUGREF_REGEX});
}

sub external ($self) {
Expand Down

0 comments on commit 13c8b3e

Please sign in to comment.