diff --git a/assets/src/bundles/add_forge/add-request-history-item.ejs b/assets/src/bundles/add_forge/add-request-history-item.ejs --- a/assets/src/bundles/add_forge/add-request-history-item.ejs +++ b/assets/src/bundles/add_forge/add-request-history-item.ejs @@ -12,7 +12,7 @@ aria-expanded="true" aria-controls="collapse$<%= index %>"> From <%= event.actor %> (<%= event.actor_role %>) on <%= event.date.slice(0, 16) %> <%if (event.new_status !== null) { %> - New status: <%= event.new_status %> + New status: <%= swh.add_forge.formatRequestStatusName(event.new_status) %> <% } %> @@ -22,10 +22,10 @@

<%= event.text %>

<%if (event.new_status !== null) { %>

- Status changed to: <%= event.new_status %> + Status changed to: <%= swh.add_forge.formatRequestStatusName(event.new_status) %>

<% } %> \ No newline at end of file diff --git a/assets/src/bundles/add_forge/create-request.js b/assets/src/bundles/add_forge/create-request.js --- a/assets/src/bundles/add_forge/create-request.js +++ b/assets/src/bundles/add_forge/create-request.js @@ -105,7 +105,10 @@ }, { data: 'status', - name: 'status' + name: 'status', + render: function(data, type, row, meta) { + return swh.add_forge.formatRequestStatusName(data); + } } ] }); diff --git a/assets/src/bundles/add_forge/index.js b/assets/src/bundles/add_forge/index.js --- a/assets/src/bundles/add_forge/index.js +++ b/assets/src/bundles/add_forge/index.js @@ -7,6 +7,12 @@ // bundle for add forge views +export function formatRequestStatusName(status) { + // Logic to format the request status to a human readable text + const newStatus = status.toLowerCase().replace(/_/g, ' '); + return newStatus[0].toUpperCase() + newStatus.substring(1).toLowerCase(); +} + export * from './add-forge.css'; export * from './create-request'; export * from './moderation-dashboard'; diff --git a/assets/src/bundles/add_forge/moderation-dashboard.js b/assets/src/bundles/add_forge/moderation-dashboard.js --- a/assets/src/bundles/add_forge/moderation-dashboard.js +++ b/assets/src/bundles/add_forge/moderation-dashboard.js @@ -51,7 +51,9 @@ { data: 'status', name: 'status', - render: $.fn.dataTable.render.text() + render: function(data, type, row, meta) { + return swh.add_forge.formatRequestStatusName(data); + } } ] }); diff --git a/assets/src/bundles/add_forge/request-dashboard.js b/assets/src/bundles/add_forge/request-dashboard.js --- a/assets/src/bundles/add_forge/request-dashboard.js +++ b/assets/src/bundles/add_forge/request-dashboard.js @@ -11,6 +11,12 @@ let forgeRequest; +function formatRequestStatusName(status) { + // Logic to format the request status to a human readable text + const newStatus = status.toLowerCase().replace(/_/g, ' '); + return newStatus[0].toUpperCase() + newStatus.substring(1).toLowerCase(); +} + export function onRequestDashboardLoad(requestId) { $(document).ready(() => { populateRequestDetails(requestId); @@ -46,7 +52,7 @@ const data = await response.json(); forgeRequest = data.request; - $('#requestStatus').text(forgeRequest.status); + $('#requestStatus').text(formatRequestStatusName(forgeRequest.status)); $('#requestType').text(forgeRequest.forge_type); $('#requestURL').text(forgeRequest.forge_url); $('#requestContactName').text(forgeRequest.forge_contact_name); diff --git a/cypress/integration/add-forge-now-request-create.spec.js b/cypress/integration/add-forge-now-request-create.spec.js --- a/cypress/integration/add-forge-now-request-create.spec.js +++ b/cypress/integration/add-forge-now-request-create.spec.js @@ -122,7 +122,7 @@ cy.get('#add-forge-request-browse') .should('be.visible') - .should('contain', 'PENDING'); + .should('contain', 'Pending'); }); it('should show error message on conflict', function() { diff --git a/cypress/integration/add-forge-now-request-dashboard.spec.js b/cypress/integration/add-forge-now-request-dashboard.spec.js --- a/cypress/integration/add-forge-now-request-dashboard.spec.js +++ b/cypress/integration/add-forge-now-request-dashboard.spec.js @@ -20,7 +20,7 @@ it('should load add forge request details', function() { cy.wait('@forgeAddRequest'); cy.get('#requestStatus') - .should('contain', 'PENDING'); + .should('contain', 'Pending'); cy.get('#requestType') .should('contain', 'bitbucket'); @@ -60,7 +60,7 @@ cy.get('#requestHistory') .children() - .should('contain', 'New status: PENDING'); + .should('contain', 'New status: Pending'); }); it('should load possible next status', function() {