feat: update the messages on the page to use the filename instead of the id. (#12568)

This commit is contained in:
Ridhwana 2021-02-04 15:50:02 +02:00 committed by GitHub
parent a6c12ad986
commit d67a259d91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View file

@ -21,7 +21,7 @@ describe('DataUpdateScriptController', () => {
<tbody>
<tr class="alert-danger" id="data_update_script_1_row">
<td id="data_update_script_1">1</td>
<td class="data_update_script__filename" id="data_update_script_1_file_name">
<td class="data_update_script__filename" data-filename="Some filename" id="data_update_script_1_filename">
Some filename
<button id="data_update_script_1_button" data-action="click->data-update-script#forceRun" data-value="1" type="button">
Re-run
@ -67,7 +67,7 @@ describe('DataUpdateScriptController', () => {
await flushPromises();
const banner = document.getElementById('data-update-script__error');
expect(banner.innerHTML).toMatch(/Data Script 1 - Something went wrong/);
expect(banner.innerHTML).toMatch(/Some filename - Something went wrong./);
});
it('updates the status column with new values and formatting', async () => {

View file

@ -33,10 +33,13 @@ export default class DataUpdateScriptController extends Controller {
if (response.ok) {
this.pollForScriptResponse(id, statusColumn, runAtColumn);
} else {
const fileNameElement = document.getElementById(
`data_update_script_${id}_filename`,
);
this.setErrorBanner(
runAtColumn,
statusColumn,
`Data Script ${id} - Something went wrong`,
`${fileNameElement.dataset.filename} - Something went wrong.`,
'alert-danger',
);
}
@ -87,10 +90,14 @@ export default class DataUpdateScriptController extends Controller {
);
if (counter > 20) {
clearInterval(pollForStatus);
const fileNameElement = document.getElementById(
`data_update_script_${id}_filename`,
);
this.setErrorBanner(
runAtColumn,
statusColumn,
`Data Script with ${id} may take some time. Please refresh the page to check for the status.`,
`${fileNameElement.dataset.filename} may take some time to run. Please refresh the page to check for the status.`,
'alert-info',
);
}

View file

@ -14,9 +14,9 @@
</thead>
<tbody class="crayons-card">
<% @data_update_scripts.each do |script| %>
<tr class="<%= 'alert-danger' if script.status == 'failed' %>" id="data_update_script_<%= script.id %>_row">
<tr class="<%= "alert-danger" if script.status == "failed" %>" id="data_update_script_<%= script.id %>_row">
<td id="data_update_script_<%= script.id %>" class="whitespace-nowrap"><%= script.id %></td>
<td class="data_update_script__filename">
<td data-filename="<%= script.file_name %>" id="data_update_script_<%= script.id %>_filename" class="data_update_script__filename">
<%= script.file_name %>
<% if script.status == "failed" %>
<button class="ml-2" id="data_update_script_<%= script.id %>_button"