Skip to content
Snippets Groups Projects
Commit 6f0cc70f authored by Jayesh's avatar Jayesh :cat2:
Browse files

Show forge request status in a human readable form

JS mapping to get the right request status name
Changes in three views and cypress tests
parent 9399ba56
No related branches found
No related tags found
No related merge requests found
......@@ -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) { %>
<span style="padding-left: 10px;">New status:</span> <%= event.new_status %>
<span style="padding-left: 10px;">New status:</span> <%= swh.add_forge.formatRequestStatusName(event.new_status) %>
<% } %>
</button>
</h2>
......@@ -22,7 +22,7 @@
<p><%= event.text %></p>
<%if (event.new_status !== null) { %>
<p>
<span>Status changed to:</span> <strong><%= event.new_status %></strong>
<span>Status changed to:</span> <strong><%= swh.add_forge.formatRequestStatusName(event.new_status) %></strong>
</p>
<% } %>
</div>
......
......@@ -105,7 +105,10 @@ export function populateRequestBrowseList() {
},
{
data: 'status',
name: 'status'
name: 'status',
render: function(data, type, row, meta) {
return swh.add_forge.formatRequestStatusName(data);
}
}
]
});
......
......@@ -11,3 +11,20 @@ export * from './add-forge.css';
export * from './create-request';
export * from './moderation-dashboard';
export * from './request-dashboard';
export function formatRequestStatusName(status) {
// Mapping to format the request status to a human readable text
const statusLabel = {
'PENDING': 'Pending',
'WAITING_FOR_FEEDBACK': 'Waiting for feedback',
'FEEDBACK_TO_HANDLE': 'Feedback to handle',
'ACCEPTED': 'Accepted',
'SCHEDULED': 'Scheduled',
'FIRST_LISTING_DONE': 'First listing done',
'FIRST_ORIGIN_LOADED': 'First origin loaded',
'REJECTED': 'Rejected',
'SUSPENDED': 'Suspended',
'DENIED': 'Denied'
};
return status in statusLabel ? statusLabel[status] : status;
}
......@@ -51,7 +51,9 @@ export async function populateModerationList() {
{
data: 'status',
name: 'status',
render: $.fn.dataTable.render.text()
render: function(data, type, row, meta) {
return swh.add_forge.formatRequestStatusName(data);
}
}
]
});
......
......@@ -46,7 +46,7 @@ async function populateRequestDetails(requestId) {
const data = await response.json();
forgeRequest = data.request;
$('#requestStatus').text(forgeRequest.status);
$('#requestStatus').text(swh.add_forge.formatRequestStatusName(forgeRequest.status));
$('#requestType').text(forgeRequest.forge_type);
$('#requestURL').text(forgeRequest.forge_url);
$('#requestContactName').text(forgeRequest.forge_contact_name);
......@@ -98,25 +98,12 @@ export function populateDecisionSelectOption(currentStatus) {
'DENIED': []
};
const statusLabel = {
'PENDING': 'pending',
'WAITING_FOR_FEEDBACK': 'waiting for feedback',
'FEEDBACK_TO_HANDLE': 'feedback to handle',
'ACCEPTED': 'accepted',
'SCHEDULED': 'scheduled',
'FIRST_LISTING_DONE': 'first listing done',
'FIRST_ORIGIN_LOADED': 'first origin loaded',
'REJECTED': 'rejected',
'SUSPENDED': 'suspended',
'DENIED': 'denied'
};
// Determine the possible next status out of the current one
const nextStatuses = nextStatusesFor[currentStatus];
function addStatusOption(status, index) {
// Push the next possible status options
const label = statusLabel[status];
const label = swh.add_forge.formatRequestStatusName(status);
$('#decisionOptions').append(
`<option value="${status}">${label}</option>`
);
......
......@@ -122,7 +122,7 @@ describe('Test add-forge-request creation', function() {
cy.get('#add-forge-request-browse')
.should('be.visible')
.should('contain', 'PENDING');
.should('contain', 'Pending');
});
it('should show error message on conflict', function() {
......
......@@ -20,7 +20,7 @@ describe('Test add forge now request dashboard load', function() {
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 @@ describe('Test add forge now request dashboard load', function() {
cy.get('#requestHistory')
.children()
.should('contain', 'New status: PENDING');
.should('contain', 'New status: Pending');
});
it('should load possible next status', function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment