8000 Fix dashboard URLs direct accessing issue and Modified URL patterns by lasanthaDLPDS · Pull Request #732 · wso2/testgrid · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix dashboard URLs direct accessing issue and Modified URL patterns #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 4, 2018

Conversation

lasanthaDLPDS
Copy link
Contributor
@lasanthaDLPDS lasanthaDLPDS commented May 3, 2018

Purpose

The purpose of this PR is to fix TESTGRID dashboard URLs direct accessing issue. This resolves #425, resolves #731, resolves #730

Goals

In order to fix TESTGRID dashboard URLs direct accessing issue, check the existing of properties at the page loading time. If those are not available invoke d backend API and get required data to render pages. Further added bootstrap styling for pages and fixed issues which are related to displaying info on infra combination page and fixed formatting issues as well.

Approach

1t
2t
3t

User stories

N/A

Release note

N/A

Documentation
N/A

Training
N/A

Certification
N/A

Marketing
N/A

Automation tests

  • Unit tests
    N/A
  • Integration tests
    N/A

Security checks

Samples
N/A

Related PRs
N/A

Migrations (if applicable)
N/A

Test environment
JDK - 1.8
OS - Ubuntu
DB - MySQL
Browser - Chrome

Learning
N/A

In order to fix direct accessing issue, it is required to have these APIs. Since we are changing the URL patterns, changed web context root path parameter as well.
Modified URLs of the TESTGRID dashboard pages and fixed the direct accessing issue of those pages. Further added bootstrap styling for pages and fixed issues which are related to displaying info on infra combination page. Further fixed formatting issues as well.
@lasanthaDLPDS lasanthaDLPDS changed the title Masterclone test Fix dashboard URLs direct accessing issue and Modified URL patterns May 3, 2018
status.setId(product.getId());
status.setName(StringUtil.concatStrings(product.getName()));
status.setProductId(product.getId());
status.setProductName(StringUtil.concatStrings(product.getName()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to use StringUtil.concatStrings here.

@@ -138,6 +138,44 @@ public Response getAllProductStatuses() {
return Response.status(Response.Status.OK).entity(list).build();
}

/**
* This method returns the product that are currently in TestGrid.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not properly imply the purpose of the API. Shall we change it?

if (productInstance.isPresent()) {
product = productInstance.get();
productStatus.setProductId(product.getId());
productStatus.setProductName(StringUtil.concatStrings(product.getName()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to use StringUtil.concatStrings here.

<img
src={require('../success.png')}
style={{
verticalAlign: "middle",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we specify classes for these elements and write the styles in a separate css file? That way we will not need to duplicate the styles. We can do it as a separate effort btw.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 yes, we have to move this type of repeating styling into a separate CSS file. This fix resolves formatting issues and +1 for addressing this in a separate effort. Further, IMO we can use icons instead of these images. WDYT

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for moving to icons. Using images will slow down page loading time plus increase the size.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's raise a ticket and handle it elsewhere. We will have new set of statuses pretty soon as well.

Added requested changes from PR review and fixed some minor issues
@harshanL harshanL added this to the 0.9.0-m24 milestone May 4, 2018
productStatus.setProductStatus(testPlanUOW.getCurrentStatus(product).toString());
} else {
String msg = "Could not found a product for requested product name in the TestGrid.";
logger.error(msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How meaningful is this error log? Shall we improve the log message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 4be247e

return Response.status(Response.Status.OK).entity(productStatus).build();
} catch (TestGridDAOException e) {
String msg = "Error occurred while fetching the Product statuses ";
logger.error(msg, e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. When running multiple products a production system, this error log won't provide enough data to debug an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 4be247e

<td> <img src={require('../play.png')} width="36" height="36" data-tip="Execute job" =>
{ window.location = '/job/'+ product.productName +'/build' }} /> <ReactTooltip /></td>
<td ><img src={require('../configure.png')} width="36" height="36" => { window.location =
'/job/'+ product.productName +'/configure' }} data-tip="Configure job" style={{ cursor: 'pointer' }}/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this URL correct? The /job/job-name/configure is coming from Jenkins webapp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 12488d2

</Modal>
</div>
)
}
}

export default ProductStatusView;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing new line. Not your code though. :)

6D4E

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 5abab08

@@ -18,120 +18,120 @@

import React, { Component } from 'react';
import Moment from 'moment';
import {FAIL,SUCCESS,ERROR,PENDING,RUNNING,INCOMPLETE,DID_NOT_RUN} from '../constants.js';
import {SUCCESS,ERROR,PENDING,RUNNING,INCOMPLETE,DID_NOT_RUN} from '../constants.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove FAIL?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have some kind of js linting mechanism?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK we don't use js linting mechanism. IMO we can use https://eslint.org/. WDYT?

SingleRecord is a component and we have used it to return respective image for given status. In here we have used a switch statement and FAIL is treated as default. Hence removed the import of FAIL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for eslint.

}
}
}

export default SingleRecord
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 5abab08

this.state = {
testScenarioSummaries: [],
scenarioTestCaseEntries: [],
testSummaryLoadStatus: PENDING,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PENDING status means that the test is still running. Does it make sense to change the default status to DID_NOT_RUN which shows a gray-colored icon? When the actual data comes, we can populate with correct properties. wdyt?

Copy link
Contributor Author
@lasanthaDLPDS lasanthaDLPDS May 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 It is the better approach and let's raise a separate ticket and handle this as well.

let currentInfra = {};
let currentUrl = window.location.href.split("/");
currentInfra.relatedProduct = currentUrl[currentUrl.length - 4];
currentInfra.relatedDeplymentPattern = currentUrl[currentUrl.length - 3];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L63-L64 code logic is vulnerable for any change in URL contexts. It may fail silently. Is there a better way to handle this? Probably we can use some kind of regex or something similar to jax-rs @path annotation value.

Copy link
Contributor Author
@lasanthaDLPDS lasanthaDLPDS May 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page will render when URL pattern matches to https://<host>:<port>/<product-ame>/<deployment-pattern-name>/test-plans/<testplan-id>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok..

}
return response;
}
handleError(response) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we go with two-space indentation for JS files?
JS and HTML files tend to have lot of inner elements. Four-space indentation makes it a bit harder to read.

@sameeraw @lasanthaDLPDS @vidurananayakkara wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Let's add two-space indentation for JS files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool.. Can you change and re-send?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 5c24430

case FAIL:
return <Subheader style={{
fontSize: '20px',
backgroundColor: "#ffd6d3"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it advisable set css styling info within the js files like this? What's the best practice for better maintainability of the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK inline CSS is not a good practice. Let's raise a ticket and handle these kind of things. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

textAlign: "center",
fontSize: "20px",
wordWrap: "break-word",
whiteSpace: "wrap"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hard-coded css within js files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we raise a separate ticket and handle this?

:
<img width="36"
height="36"
src={require('../close.png')}/>}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lasanthaDLPDS As you see, four-space indentation tend to make the codes right-aligned. :)
It's a bit harder to read as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 5c24430


const ScenarioContainer = connect(
mapStateToProps
)(ScenarioView)
)(ScenarioView);

export default ScenarioContainer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 5abab08

@kasunbg kasunbg merged commit 3ad18fb into wso2:master May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants
0