"plugins": [
"react",
- "mocha",
"import"
],
"no-multi-spaces": 1,
"no-self-compare": 2,
"no-unexpected-multiline": 2,
- "max-len": [1, 120, 2],
+ "max-len": 0,
"no-const-assign": 2,
"no-multiple-empty-lines": [1, { "max": 3 }],
"no-spaced-func": 1,
"react/react-in-jsx-scope": 2,
"react/self-closing-comp": 2,
"react/sort-comp": 1
+ },
+
+ "settings": {
+ "import/ignore": [
+ "node_modules",
+ "hbs$"
+ ]
}
}
--- /dev/null
+{
+ "preset": "airbnb",
+ "esnext": true,
+ "excludeFiles": [
+ "src/main/js/libs/**"
+ ],
+
+ "disallowSpacesInFunctionDeclaration": false,
+ "requireTrailingComma": false,
+ "requirePaddingNewLinesAfterBlocks": false,
+ "requireShorthandArrowFunctions": false,
+ "disallowQuotedKeysInObjects": false,
+ "requireSpacesInFunctionDeclaration": {
+ "beforeOpeningRoundBrace": true,
+ "beforeOpeningCurlyBrace": true
+ },
+ "requireDotNotation": {
+ "allExcept": [
+ "snake_case"
+ ]
+ },
+ "disallowSpaceAfterObjectKeys": false,
+ "maximumLineLength": 120,
+ "safeContextKeyword": [
+ "that"
+ ],
+ "requireDollarBeforejQueryAssignment": false,
+ "requireDotNotation": false,
+ "disallowArrayDestructuringReturn": false,
+ "requireEnhancedObjectLiterals": true,
+ "requireObjectKeysOnNewLine": {
+ "allExcept": ["sameLine"]
+ },
+ "requireSpaceBeforeDestructuredValues": true,
+ "requireSpaceBeforeObjectValues": true,
+ "requireSpacesInsideObjectBrackets": "all"
+}
"del": "2.0.2",
"enzyme": "1.2.0",
"eslint": "2.2.0",
- "eslint-plugin-import": "^1.0.0-beta.0",
- "eslint-plugin-mocha": "1.1.0",
+ "eslint-plugin-import": "^1.4.0",
"eslint-plugin-react": "4.0.0",
"event-stream": "3.3.1",
"expose-loader": "0.7.1",
"imports-loader": "0.6.5",
"isparta": "4.0.0",
"jquery": "2.2.0",
+ "jscs": "^2.11.0",
"jsdom": "6.5.1",
"lodash": "4.6.1",
"mocha": "2.3.4",
"build": "gulp build",
"test": "mocha --opts tests/mocha.opts tests",
"coverage": "babel-node node_modules/.bin/isparta cover --root 'src/main/js' --include-all-sources --excludes '**/libs/**' --dir 'target/coverage' node_modules/.bin/_mocha -- --opts tests/mocha.opts tests",
- "lint": "eslint src/main/js"
+ "lint": "eslint src/main/js && jscs src/main/js"
},
"engines": {
"node": ">=4"
*/
import { getJSON, postJSON, post } from '../helpers/request.js';
-
export function getComponents (data) {
const url = window.baseUrl + '/api/components/search';
return getJSON(url, data);
*/
import { getJSON } from '../helpers/request.js';
-
/**
* Return events for a component
* @param {string} componentKey
import { getJSON } from '../helpers/request.js';
-
export function getFacets (query, facets) {
const url = window.baseUrl + '/api/issues/search';
const data = _.extend({}, query, { facets: facets.join(), ps: 1, additionalFields: '_all' });
});
}
-
export function getFacet (query, facet) {
return getFacets(query, [facet]).then(r => {
return { facet: r.facets[0].values, response: r.response };
});
}
-
export function getSeverities (query) {
return getFacet(query, 'severities').then(r => r.facet);
}
-
export function getTags (query) {
return getFacet(query, 'tags').then(r => r.facet);
}
-
export function extractAssignees (facet, response) {
return facet.map(item => {
const user = _.findWhere(response.users, { login: item.val });
});
}
-
export function getAssignees (query) {
return getFacet(query, 'assignees').then(r => extractAssignees(r.facet, r.response));
}
-
export function getIssuesCount (query) {
const url = window.baseUrl + '/api/issues/search';
const data = _.extend({}, query, { ps: 1, facetMode: 'debt' });
*/
import { getJSON } from '../helpers/request.js';
-
export function getMeasures (componentKey, metrics) {
const url = window.baseUrl + '/api/measures/component';
const data = { componentKey, metricKeys: metrics.join(',') };
throw new TypeError(`permissions#${method}: ${message}`);
}
-
export function getUsers (data) {
const url = window.baseUrl + '/api/permissions/users';
return request({ type: 'GET', url, data });
}
-
export function grantToUser (permission, user, project) {
if (typeof permission !== 'string' || !permission.length) {
return typeError('grantToUser', 'please provide permission');
return request({ type: 'POST', url, data });
}
-
export function revokeFromUser (permission, user, project) {
if (typeof permission !== 'string' || !permission.length) {
return typeError('revokeFromUser', 'please provide permission');
return request({ type: 'POST', url, data });
}
-
export function getGroups (data) {
const url = window.baseUrl + '/api/permissions/groups';
return request({ type: 'GET', url, data });
}
-
export function grantToGroup (permission, group, project) {
if (typeof permission !== 'string' || !permission.length) {
return typeError('grantToGroup', 'please provide permission');
return request({ type: 'POST', url, data });
}
-
export function revokeFromGroup (permission, group, project) {
if (typeof permission !== 'string' || !permission.length) {
return typeError('revokeFromGroup', 'please provide permission');
return request({ type: 'POST', url, data });
}
-
export function getPermissionTemplates (query) {
const url = window.baseUrl + '/api/permissions/search_templates';
const data = { };
return request({ type: 'GET', url, data });
}
-
export function createPermissionTemplate (options) {
const url = window.baseUrl + '/api/permissions/create_template';
return request(_.extend({ type: 'POST', url }, options));
return request(_.extend({ type: 'POST', url }, options));
}
-
export function deletePermissionTemplate (options) {
const url = window.baseUrl + '/api/permissions/delete_template';
return request(_.extend({ type: 'POST', url }, options));
}
-
export function setDefaultPermissionTemplate (template, qualifier) {
if (typeof template !== 'string' || !template.length) {
return typeError('setDefaultPermissionTemplate', 'please provide permission template ID');
return request({ type: 'POST', url, data });
}
-
-export function applyTemplateToProject(options) {
+export function applyTemplateToProject (options) {
const url = window.baseUrl + '/api/permissions/apply_template';
return request(_.extend({ type: 'POST', url }, options));
}
*/
import { getJSON, postJSON, post } from '../helpers/request.js';
-
/**
* List tokens for given user login
* @param {string} login
return getJSON(url, data).then(r => r.userTokens);
}
-
/**
* Generate a user token
* @param {string} userLogin
* @param {string} tokenName
* @returns {Promise}
*/
-export function generateToken(userLogin, tokenName) {
+export function generateToken (userLogin, tokenName) {
const url = window.baseUrl + '/api/user_tokens/generate';
const data = { login: userLogin, name: tokenName };
return postJSON(url, data);
}
-
/**
* Revoke a user token
* @param {string} userLogin
* @param {string} tokenName
* @returns {Promise}
*/
-export function revokeToken(userLogin, tokenName) {
+export function revokeToken (userLogin, tokenName) {
const url = window.baseUrl + '/api/user_tokens/revoke';
const data = { login: userLogin, name: tokenName };
return post(url, data);
import { translate } from '../../../helpers/l10n';
import { formatMeasure } from '../../../helpers/measures';
-
const BASE_QUERY = { resolved: false, assignees: '__me__' };
-
function getTotalUrl () {
return window.baseUrl + '/account/issues#resolved=false';
}
return window.baseUrl + `/account/issues#resolved=false|createdAfter=${createdAfter}|createdBefore=${createdBefore}`;
}
-
export default class IssueWidgets extends Component {
state = {
loading: true
import Template from './templates/account-tokens.hbs';
import { getTokens, generateToken, revokeToken } from '../../api/user-tokens';
-
export default Marionette.ItemView.extend({
template: Template,
import TasksContainer from '../containers/TasksContainer';
import ListFooterContainer from '../containers/ListFooterContainer';
-
export default class BackgroundTasksApp extends Component {
componentDidMount () {
this.props.initApp(this.props.options.component);
getDateFilter () {
const DATE_FORMAT = 'YYYY-MM-DD';
- let filter = {};
+ const filter = {};
switch (this.state.dateFilter) {
case DATE.TODAY:
filter.minSubmittedAt = moment().startOf('day').format(DATE_FORMAT);
}
break;
default:
+
// do nothing
}
return filter;
}
attachDatePicker () {
- let opts = {
+ const opts = {
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true,
},
onSearch() {
- let searchInput = this.refs.searchInput;
- let query = searchInput.value;
+ const searchInput = this.refs.searchInput;
+ const query = searchInput.value;
this.props.onSearch(query);
},
CANCELED: 'CANCELED'
};
-
export const ALL_TYPES = 'ALL_TYPES';
-
export const CURRENTS = {
ALL: '__ALL__',
ONLY_CURRENTS: 'CURRENTS'
};
-
export const DATE = {
ANY: 'ANY',
TODAY: 'TODAY',
query: ''
};
-
export const DATE_FORMAT = 'YYYY-MM-DD';
-
export const DEBOUNCE_DELAY = 250;
const ONE_SECOND = 1000;
const ONE_MINUTE = 60 * ONE_SECOND;
-function format(int, suffix) {
+function format (int, suffix) {
return `${int}${suffix}`;
}
-export function formatDuration(value) {
+export function formatDuration (value) {
if (!value) {
return '';
}
import { translate } from '../../../helpers/l10n';
import { getComponentUrl } from '../../../helpers/urls';
-
const METRICS = [
'ncloc',
'code_smells',
'overall_coverage'
];
-
export const INIT = 'INIT';
export const BROWSE = 'BROWSE';
export const SEARCH = 'SEARCH';
export const STOP_FETCHING = 'STOP_FETCHING';
export const RAISE_ERROR = 'RAISE_ERROR';
-
export function initComponentAction (component, breadcrumbs = []) {
return {
type: INIT,
};
}
-
function getPath (componentKey) {
return '/' + encodeURIComponent(componentKey);
}
return translate('not_authorized');
default:
try {
- let json = await response.json();
+ const json = await response.json();
return json['err_msg'] ||
(json.errors && _.pluck(json.errors, 'msg').join('. ')) ||
translate('default_error_message');
import './styles/code.css';
-
const store = configureStore();
const history = useRouterHistory(createHashHistory)({ queryKey: false });
syncReduxAndRouter(history, store);
-
window.sonarqube.appStarted.then(({ el, component }) => {
const CodeWithComponent = () => {
return <Code component={component}/>;
import ComponentName from './ComponentName';
-
const Breadcrumb = ({ component, onBrowse }) => (
<ComponentName
component={component}
onBrowse={onBrowse}/>
);
-
export default Breadcrumb;
import Breadcrumb from './Breadcrumb';
-
const Breadcrumbs = ({ breadcrumbs, onBrowse }) => (
<ul className="code-breadcrumbs">
{breadcrumbs.map((component, index) => (
</ul>
);
-
export default Breadcrumbs;
import Search from './Search';
import { initComponent, browse } from '../actions';
-
class Code extends Component {
componentDidMount () {
const { dispatch, component, routing } = this.props;
import ComponentDetach from './ComponentDetach';
import ComponentPin from './ComponentPin';
-
const TOP_OFFSET = 200;
const BOTTOM_OFFSET = 10;
-
class Component extends React.Component {
componentDidMount () {
this.handleUpdate();
/* eslint object-shorthand: 0 */
return (
- <tr className={classNames({ 'selected': selected })}>
+ <tr className={classNames({ selected })}>
<td className="thin nowrap">
<span className="spacer-right">
{componentAction}
}
}
-
function mapStateToProps (state, ownProps) {
return {
selected: state.current.searchSelectedItem === ownProps.component,
import { getComponentUrl } from '../../../helpers/urls';
import { translate } from '../../../helpers/l10n';
-
const ComponentDetach = ({ component }) => (
<a
className="icon-detach"
href={getComponentUrl(component.refKey || component.key)}/>
);
-
export default ComponentDetach;
import { formatMeasure } from '../../../helpers/measures';
-
const ComponentMeasure = ({ component, metricKey, metricType }) => {
const measure = _.findWhere(component.measures, { metric: metricKey });
return (
);
};
-
export default ComponentMeasure;
import QualifierIcon from '../../../components/shared/qualifier-icon';
import { getComponentUrl } from '../../../helpers/urls';
-
function getTooltip (component) {
const isFile = component.qualifier === 'FIL' || component.qualifier === 'UTS';
if (isFile && component.path) {
return prefix.substr(0, prefix.length - lastPrefixPart.length);
}
-
const Component = ({ component, previous, onBrowse }) => {
const handleClick = (e) => {
e.preventDefault();
);
};
-
export default Component;
import PinIcon from '../../../components/shared/pin-icon';
import { translate } from '../../../helpers/l10n';
-
const ComponentPin = ({ component }) => {
const handleClick = (e) => {
e.preventDefault();
);
};
-
export default ComponentPin;
) : <span/>;
};
-
export default ComponentQualityGate;
import ComponentsEmpty from './ComponentsEmpty';
import ComponentsHeader from './ComponentsHeader';
-
const Components = ({ baseComponent, components, coverageMetric, onBrowse }) => (
<table className="data zebra">
<ComponentsHeader baseComponent={baseComponent}/>
</table>
);
-
export default Components;
import React from 'react';
import { translate } from '../../../helpers/l10n';
-
const ComponentsEmpty = () => (
<tr>
<td colSpan="2">
</tr>
);
-
export default ComponentsEmpty;
import { translate } from '../../../helpers/l10n';
-
const ComponentsHeader = ({ baseComponent }) => (
<thead>
<tr>
</thead>
);
-
export default ComponentsHeader;
import { search, selectCurrent, selectNext, selectPrev } from '../actions';
import { translateWithParameters } from '../../../helpers/l10n';
-
class Search extends Component {
componentDidMount () {
this.refs.input.focus();
dispatch(selectNext());
break;
default:
- // do nothing
+
+ // do nothing
}
}
}
}
-
export default connect(state => {
return { query: state.current.searchQuery };
})(Search);
*/
import React from 'react';
-
const Truncated = ({ children, title }) => (
<span
className="code-truncated"
</span>
);
-
export default Truncated;
import { INIT, BROWSE, SEARCH, UPDATE_QUERY, SELECT_NEXT, SELECT_PREV, START_FETCHING, STOP_FETCHING,
RAISE_ERROR } from '../actions';
-
function hasSourceCode (component) {
return component.qualifier === 'FIL' || component.qualifier === 'UTS';
}
}
}
-
export const initialState = {
fetching: false,
baseComponent: null,
errorMessage: null
};
-
export function current (state = initialState, action) {
+ /* eslint no-case-declarations: 0 */
+ /* FIXME fix it ^^^ */
switch (action.type) {
case INIT:
const coverageMetric = selectCoverageMetric(action.component);
}
}
-
export function bucket (state = [], action) {
switch (action.type) {
case INIT:
'name', 'lang', 'langName', 'sysTags', 'tags', 'status', 'severity'
],
-
_searchParameters () {
const fields = this.ruleFields.slice();
const profile = this.app.state.get('query').qprofile;
this.$('.search-navigator').addClass('search-navigator-extended-view');
},
-
hideDetails () {
this.$('.search-navigator').removeClass('search-navigator-extended-view');
if (this.scroll != null) {
export const DISPLAY_HOME = 'app/DISPLAY_HOME';
export const RECEIVE_METRICS = 'app/RECEIVE_METRICS';
-
/*
* Action Creators
*/
return { type: RECEIVE_METRICS, metrics };
}
-
/*
* Workflow
*/
import React from 'react';
export default function IconBubbles () {
- /* eslint max-len: 0 */
+ /* jscs:disable maximumLineLength */
return (
<svg className="measure-tab-icon"
viewBox="0 0 512 448"
import React from 'react';
export default function IconHistory () {
- /* eslint max-len: 0 */
+ /* jscs:disable maximumLineLength */
return (
<svg className="measure-tab-icon"
viewBox="0 0 512 448"
import React from 'react';
export default function ListIcon () {
- /* eslint max-len: 0 */
+ /* jscs:disable maximumLineLength */
return (
<svg className="measure-tab-icon"
viewBox="0 0 448 448"
import React from 'react';
export default function IconTree () {
- /* eslint max-len: 0 */
+ /* jscs:disable maximumLineLength */
return (
<svg className="measure-tab-icon"
viewBox="0 0 448 448"
import { getLanguages } from '../../../api/languages';
import { translate } from '../../../helpers/l10n';
-
export default class LanguageDistribution extends React.Component {
componentDidMount () {
this.requestLanguages();
export const REQUEST_MEASURE = 'details/REQUEST_MEASURE';
export const RECEIVE_MEASURE = 'details/RECEIVE_MEASURE';
-
/*
* Action Creators
*/
return { type: RECEIVE_MEASURE, measure, secondaryMeasure, periods };
}
-
/*
* Workflow
*/
AllMeasuresDomain.propTypes = {
displayHeader: React.PropTypes.bool
};
-
export const UPDATE_STORE = 'drilldown/tree/UPDATE_STORE';
export const INIT = 'drilldown/tree/INIT';
-
/*
* Action Creators
*/
return { type: INIT, rootComponent, metric, periodIndex };
}
-
/*
* Workflow
*/
childViewContainer: 'tbody'
});
-
this.saveDashboardsState();
},
-
createAllSortables () {
const that = this;
const blocks = $('.' + this.options.block);
.on('dragleave', onDragLeave);
},
-
highlightWidget (widgetId) {
const block = $('#block_' + widgetId);
const options = this.options;
}, this.options.highlightDuration);
},
-
saveDashboardsState () {
const options = this.options;
const result = $('.' + this.options.column).map(function () {
}
},
-
editWidget (widgetId) {
$('#widget_title_' + widgetId).hide();
$('#widget_' + widgetId).hide();
$($(`#block_${widgetId} a.link-action`)[0]).hide();
},
-
cancelEditWidget (widgetId) {
$('widget_title_' + widgetId).show();
$('#widget_' + widgetId).show();
$($(`#block_${widgetId} a.link-action`)[0]).show();
},
-
deleteWidget (element) {
$(element).closest('.' + this.options.block).remove();
this.saveDashboardsState();
}
};
-
window.autoResize = function (everyMs, callback) {
const debounce = _.debounce(callback, everyMs);
$(window).on('resize', debounce);
requestUsers() {
const url = window.baseUrl + '/api/permissions/users';
- let data = { permission: this.props.permission.key, ps: MAX_ITEMS };
+ const data = { permission: this.props.permission.key, ps: MAX_ITEMS };
if (this.props.project) {
data.projectId = this.props.project;
}
requestGroups() {
const url = window.baseUrl + '/api/permissions/groups';
- let data = { permission: this.props.permission.key, ps: MAX_ITEMS };
+ const data = { permission: this.props.permission.key, ps: MAX_ITEMS };
if (this.props.project) {
data.projectId = this.props.project;
}
import Permission from './permission';
-
export default React.createClass({
propTypes: {
permissions: React.PropTypes.arrayOf(React.PropTypes.object).isRequired
},
render() {
- let className = classNames({ 'new-loading': !this.props.ready });
+ const className = classNames({ 'new-loading': !this.props.ready });
return <ul id="global-permissions-list" className={className}>{this.renderPermissions()}</ul>;
}
});
window.sonarqube.appStarted.then(options => App.start(options));
-
window.sonarqube.appStarted.then(options => App.start(options));
-
window.sonarqube.appStarted.then(options => App.start(options));
-
this.metrics.fetch();
};
-
App.requestDomains = function () {
return $.get(window.baseUrl + '/api/metrics/domains').done(function (r) {
App.domains = r.domains;
window.sonarqube.appStarted.then(options => App.start(options));
-
import { formatMeasure } from '../../../helpers/measures';
import { translateWithParameters } from '../../../helpers/l10n';
-
const HEIGHT = 80;
-
export const ComplexityDistribution = React.createClass({
propTypes: {
distribution: React.PropTypes.string.isRequired,
import { TooltipsMixin } from '../../../components/mixins/tooltips-mixin';
import { translate } from '../../../helpers/l10n';
-
export const Event = React.createClass({
propTypes: {
event: React.PropTypes.shape({
import Select from 'react-select';
import { translate } from '../../../helpers/l10n';
-
const TYPES = ['All', 'Version', 'Alert', 'Profile', 'Other'];
-
export const EventsListFilter = React.createClass({
propTypes: {
onFilter: React.PropTypes.func.isRequired,
import { getLanguages } from '../../../api/languages';
import { translate } from '../../../helpers/l10n';
-
export const LanguageDistribution = React.createClass({
propTypes: {
distribution: React.PropTypes.string.isRequired,
import { DomainLeakTitle } from '../main/components';
-
export const Legend = React.createClass({
render() {
return <div className="overview-legend overview-leak">
import { formatMeasure } from '../../../helpers/measures';
import { translate } from '../../../helpers/l10n';
-
const Measure = React.createClass({
render() {
if (this.props.value == null || isNaN(this.props.value)) {
}
});
-
export default React.createClass({
render() {
const metricName = translate('metric', this.props.condition.metric.name, 'name');
import GateEmpty from './gate-empty';
import { translate, translateWithParameters } from '../../../helpers/l10n';
-
export default React.createClass({
renderGateConditions () {
return <GateConditions gate={this.props.gate} component={this.props.component}/>;
return getLabel(period);
}
-
export function getPeriodDate (periods, periodIndex) {
const period = _.findWhere(periods, { index: periodIndex });
if (!period) {
import { formatMeasure } from '../../../helpers/measures';
import { translate, translateWithParameters } from '../../../helpers/l10n';
-
export const CodeSmells = React.createClass({
propTypes: {
leakPeriodLabel: React.PropTypes.string,
import { Timeline } from './timeline';
import { translateWithParameters } from '../../../helpers/l10n';
-
export const Domain = React.createClass({
render () {
return <div className="overview-card">{this.props.children}</div>;
}
});
-
export const DomainTitle = React.createClass({
render () {
return <div className="overview-title">{this.props.children}</div>;
}
});
-
export const DomainLeakTitle = React.createClass({
renderInline (tooltip, fromNow) {
return <span className="overview-domain-leak-title" title={tooltip} data-toggle="tooltip">
}
});
-
export const DomainHeader = React.createClass({
render () {
return <div className="overview-card-header">
}
});
-
export const DomainPanel = React.createClass({
propTypes: {
domain: React.PropTypes.string
}
});
-
export const DomainNutshell = React.createClass({
render () {
return <div className="overview-domain-nutshell">{this.props.children}</div>;
}
});
-
export const MeasuresList = React.createClass({
render () {
return <div className="overview-domain-measures">{this.props.children}</div>;
}
});
-
export const Measure = React.createClass({
propTypes: {
label: React.PropTypes.string,
}
});
-
export const DomainMixin = {
renderTimelineStartDate() {
const momentDate = moment(this.props.historyStartDate);
import { formatMeasure } from '../../../helpers/measures';
import { translate } from '../../../helpers/l10n';
-
export const GeneralCoverage = React.createClass({
propTypes: {
measures: React.PropTypes.object.isRequired,
import { formatMeasure, formatMeasureVariation } from '../../../helpers/measures';
import { translate } from '../../../helpers/l10n';
-
export const GeneralDuplications = React.createClass({
propTypes: {
leakPeriodLabel: React.PropTypes.string,
import { getMeasures } from '../../../api/measures';
import { getTimeMachineData } from '../../../api/time-machine';
-
const METRICS_LIST = [
'overall_coverage',
'new_overall_coverage',
'ncloc'
];
-
export default React.createClass({
propTypes: {
leakPeriodIndex: React.PropTypes.string.isRequired
import { formatMeasure } from '../../../helpers/measures';
import { translate, translateWithParameters } from '../../../helpers/l10n';
-
export const Risk = React.createClass({
propTypes: {
leakPeriodLabel: React.PropTypes.string,
import { LanguageDistribution } from '../components/language-distribution';
import { translate } from '../../../helpers/l10n';
-
export const GeneralStructure = React.createClass({
propTypes: {
leakPeriodLabel: React.PropTypes.string,
import { LineChart } from '../../../components/charts/line-chart';
-
const HEIGHT = 80;
-
export class Timeline extends React.Component {
filterSnapshots () {
return this.props.history.filter(s => {
return permissionTemplates.map(permissionTemplate => {
// it's important to keep the order of the permission template's permissions
// the same as the order of base permissions
- let permissions = basePermissions.map(basePermission => {
- let projectPermission = _.findWhere(permissionTemplate.permissions, { key: basePermission.key });
+ const permissions = basePermissions.map(basePermission => {
+ const projectPermission = _.findWhere(permissionTemplate.permissions, { key: basePermission.key });
return _.extend({ usersCount: 0, groupsCount: 0 }, basePermission, projectPermission);
});
return _.extend({}, permissionTemplate, { permissions });
mergeDefaultsToTemplates(permissionTemplates, defaultTemplates = []) {
return permissionTemplates.map(permissionTemplate => {
- let defaultFor = [];
+ const defaultFor = [];
defaultTemplates.forEach(defaultTemplate => {
if (defaultTemplate.templateId === permissionTemplate.id) {
defaultFor.push(defaultTemplate.qualifier);
requestPermissions() {
getPermissionTemplates().done(r => {
- let permissions = this.sortPermissions(r.permissions);
- let permissionTemplates = this.mergePermissionsToTemplates(r.permissionTemplates, permissions);
- let permissionTemplatesWithDefaults = this.mergeDefaultsToTemplates(permissionTemplates, r.defaultTemplates);
+ const permissions = this.sortPermissions(r.permissions);
+ const permissionTemplates = this.mergePermissionsToTemplates(r.permissionTemplates, permissions);
+ const permissionTemplatesWithDefaults = this.mergeDefaultsToTemplates(permissionTemplates, r.defaultTemplates);
this.setState({
ready: true,
permissionTemplates: permissionTemplatesWithDefaults,
},
renderIfMultipleTopQualifiers() {
- let defaults = this.props.permissionTemplate.defaultFor.map(qualifier => {
+ const defaults = this.props.permissionTemplate.defaultFor.map(qualifier => {
return <li key={qualifier}><QualifierIcon qualifier={qualifier}/> {translate('qualifier', qualifier)}</li>;
});
return (
},
renderIfSingleTopQualifier(availableQualifiers) {
- let qualifiers = availableQualifiers.map(qualifier => {
+ const qualifiers = availableQualifiers.map(qualifier => {
return (
<span key={qualifier} className="text-middle">
<a onClick={this.setDefault.bind(this, qualifier)} className="button" href="#">Set Default</a>
},
renderIfMultipleTopQualifiers(availableQualifiers) {
- let qualifiers = availableQualifiers.map(qualifier => {
+ const qualifiers = availableQualifiers.map(qualifier => {
return (
<li key={qualifier}>
<a onClick={this.setDefault.bind(this, qualifier)} href="#">
},
render() {
- let availableQualifiers = this.getAvailableQualifiers();
+ const availableQualifiers = this.getAvailableQualifiers();
if (availableQualifiers.length === 0) {
return null;
}
},
renderAssociation() {
- let projectKeyPattern = this.props.permissionTemplate.projectKeyPattern;
+ const projectKeyPattern = this.props.permissionTemplate.projectKeyPattern;
if (!projectKeyPattern) {
return null;
}
},
render() {
- let permissions = this.props.permissionTemplate.permissions.map(p => {
+ const permissions = this.props.permissionTemplate.permissions.map(p => {
return (
<td key={p.key}>
<table>
import PermissionsHeader from './permissions-header';
import PermissionTemplate from './permission-template';
-
export default React.createClass({
propTypes: {
permissionTemplates: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
},
render() {
- let permissionTemplates = this.props.permissionTemplates.map(p => {
+ const permissionTemplates = this.props.permissionTemplates.map(p => {
return <PermissionTemplate
key={p.id}
permissionTemplate={p}
topQualifiers={this.props.topQualifiers}
refresh={this.props.refresh}/>;
});
- let className = classNames('data zebra', { 'new-loading': !this.props.ready });
+ const className = classNames('data zebra', { 'new-loading': !this.props.ready });
return (
<table id="permission-templates" className={className}>
<PermissionsHeader permissions={this.props.permissions}/>
},
render() {
- let cellWidth = (80 / this.props.permissions.length) + '%';
- let cells = this.props.permissions.map(p => {
+ const cellWidth = (80 / this.props.permissions.length) + '%';
+ const cells = this.props.permissions.map(p => {
return (
<th key={p.key} style={{ width: cellWidth }}>
{p.name}<br/><span className="small">{p.description}</span>
import ApplyTemplateView from './apply-template-view';
import { translate } from '../../helpers/l10n';
-
const PERMISSIONS_ORDER = ['user', 'codeviewer', 'issueadmin', 'admin', 'scan'];
-
export default React.createClass({
propTypes: {
permissionTemplates: React.PropTypes.arrayOf(React.PropTypes.object).isRequired
mergePermissionsToProjects(projects, basePermissions) {
return projects.map(project => {
// it's important to keep the order of the project permissions the same as the order of base permissions
- let permissions = basePermissions.map(basePermission => {
- let projectPermission = _.findWhere(project.permissions, { key: basePermission.key });
+ const permissions = basePermissions.map(basePermission => {
+ const projectPermission = _.findWhere(project.permissions, { key: basePermission.key });
return _.extend({ usersCount: 0, groupsCount: 0 }, basePermission, projectPermission);
});
return _.extend({}, project, { permissions });
},
requestPermissions(page = 1, query = '', filter = this.state.filter) {
- let url = window.baseUrl + '/api/permissions/search_project_permissions';
+ const url = window.baseUrl + '/api/permissions/search_project_permissions';
let data = { p: page, q: query };
if (filter !== '__ALL__') {
data.qualifier = filter;
}
this.setState({ ready: false }, () => {
$.get(url, data).done(r => {
- let permissions = this.sortPermissions(r.permissions);
+ const permissions = this.sortPermissions(r.permissions);
let projects = this.mergePermissionsToProjects(r.projects, permissions);
if (page > 1) {
projects = [].concat(this.state.projects, projects);
import classNames from 'classnames';
import React from 'react';
-
export default React.createClass({
propTypes: {
count: React.PropTypes.number.isRequired,
if (this.props.componentId) {
return null;
}
- let hasMore = this.props.total > this.props.count;
- let loadMoreLink = <a onClick={this.handleLoadMore} className="spacer-left" href="#">show more</a>;
- let className = classNames('spacer-top note text-center', { 'new-loading': !this.props.ready });
+ const hasMore = this.props.total > this.props.count;
+ const loadMoreLink = <a onClick={this.handleLoadMore} className="spacer-left" href="#">show more</a>;
+ const className = classNames('spacer-top note text-center', { 'new-loading': !this.props.ready });
return (
<footer className={className}>
{this.props.count}/{this.props.total} shown
},
render() {
- let cellWidth = (80 / this.props.permissions.length) + '%';
- let cells = this.props.permissions.map(p => {
+ const cellWidth = (80 / this.props.permissions.length) + '%';
+ const cells = this.props.permissions.map(p => {
return (
<th key={p.key} style={{ width: cellWidth }}>
{p.name}<br/><span className="small">{p.description}</span>
import PermissionsHeader from './permissions-header';
import Project from './project';
-
export default React.createClass({
propTypes: {
projects: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
},
render() {
- let projects = this.props.projects.map(p => {
+ const projects = this.props.projects.map(p => {
return <Project
key={p.id}
project={p}
permissionTemplates={this.props.permissionTemplates}
refresh={this.props.refresh}/>;
});
- let className = classNames('data zebra', { 'new-loading': !this.props.ready });
+ const className = classNames('data zebra', { 'new-loading': !this.props.ready });
return (
<table id="projects" className={className}>
<PermissionsHeader permissions={this.props.permissions}/>
},
render() {
- let permissions = this.props.project.permissions.map(p => {
+ const permissions = this.props.project.permissions.map(p => {
return (
<td key={p.key}>
<table>
import RadioToggle from '../../components/shared/radio-toggle';
-
const rootQualifiersToOptions = (qualifiers) => {
return qualifiers.map(q => {
return {
});
};
-
export const QualifierFilter = ({ rootQualifiers, filter, onFilter }) => {
const options = [{ value: '__ALL__', label: 'All' }, ...rootQualifiersToOptions(rootQualifiers)];
import { QualifierFilter } from './qualifier-filter';
-
export default React.createClass({
propTypes: {
search: React.PropTypes.func.isRequired
},
search() {
- let q = this.refs.input.value;
+ const q = this.refs.input.value;
this.props.search(q);
},
window.sonarqube.appStarted.then(options => {
getCurrentUser().then(user => {
- let el = document.querySelector(options.el);
- let hasProvisionPermission = user.permissions.global.indexOf('provisioning') !== -1;
- let topLevelQualifiers = options.rootQualifiers;
+ const el = document.querySelector(options.el);
+ const hasProvisionPermission = user.permissions.global.indexOf('provisioning') !== -1;
+ const topLevelQualifiers = options.rootQualifiers;
ReactDOM.render(<Main hasProvisionPermission={hasProvisionPermission}
topLevelQualifiers={topLevelQualifiers}/>, el);
});
import { createProject } from '../../api/components';
import Template from './templates/projects-create-form.hbs';
-
export default ModalForm.extend({
template: Template,
},
getFilters() {
- let filters = { ps: PAGE_SIZE };
+ const filters = { ps: PAGE_SIZE };
if (this.state.page !== 1) {
filters.p = this.state.page;
}
this.requestGhosts();
break;
default:
+
// should never happen
}
},
requestGhosts() {
- let data = this.getFilters();
+ const data = this.getFilters();
getGhosts(data).then(r => {
let projects = r.projects.map(project => {
return _.extend(project, { id: project.uuid, qualifier: 'TRK' });
},
requestProvisioned() {
- let data = this.getFilters();
+ const data = this.getFilters();
getProvisioned(data).then(r => {
let projects = r.projects.map(project => {
return _.extend(project, { id: project.uuid, qualifier: 'TRK' });
},
requestAllProjects() {
- let data = this.getFilters();
+ const data = this.getFilters();
data.qualifiers = this.state.qualifiers;
getComponents(data).then(r => {
let projects = r.components;
},
onProjectSelected(project) {
- let newSelection = _.uniq([].concat(this.state.selection, project.id));
+ const newSelection = _.uniq([].concat(this.state.selection, project.id));
this.setState({ selection: newSelection });
},
onProjectDeselected(project) {
- let newSelection = _.without(this.state.selection, project.id);
+ const newSelection = _.without(this.state.selection, project.id);
this.setState({ selection: newSelection });
},
onAllSelected() {
- let newSelection = this.state.projects.map(project => {
+ const newSelection = this.state.projects.map(project => {
return project.id;
});
this.setState({ selection: newSelection });
},
deleteProjects() {
- let ids = this.state.selection.join(',');
+ const ids = this.state.selection.join(',');
deleteComponents({ ids }).then(() => {
this.setState({ page: 1, selection: [] }, this.requestProjects);
});
},
render() {
- let className = classNames('data', 'zebra', { 'new-loading': !this.props.ready });
+ const className = classNames('data', 'zebra', { 'new-loading': !this.props.ready });
return (
<table className={className}>
<tbody>{this.props.projects.map(this.renderProject)}</tbody>
},
search() {
- let q = this.refs.input.value;
+ const q = this.refs.input.value;
this.props.onSearch(q);
},
},
getQualifierOptions() {
- let options = this.props.topLevelQualifiers.map(q => {
+ const options = this.props.topLevelQualifiers.map(q => {
return { value: q, label: translate('qualifiers', q) };
});
return _.sortBy(options, option => {
},
renderCheckbox() {
- let isAllChecked = this.props.projects.length > 0 &&
+ const isAllChecked = this.props.projects.length > 0 &&
this.props.selection.length === this.props.projects.length;
- let thirdState = this.props.projects.length > 0 &&
+ const thirdState = this.props.projects.length > 0 &&
this.props.selection.length > 0 &&
this.props.selection.length < this.props.projects.length;
- let isChecked = isAllChecked || thirdState;
+ const isChecked = isAllChecked || thirdState;
return <Checkbox onCheck={this.onCheck} initiallyChecked={isChecked} thirdState={thirdState}/>;
},
},
renderQualifierFilter() {
- let options = this.getQualifierOptions();
+ const options = this.getQualifierOptions();
if (options.length < 2) {
return null;
}
},
render() {
- let isSomethingSelected = this.props.projects.length > 0 && this.props.selection.length > 0;
+ const isSomethingSelected = this.props.projects.length > 0 && this.props.selection.length > 0;
return (
<div className="panel panel-vertical bordered-bottom spacer-bottom">
<table className="data">
export default function AddConditionForm ({ metrics, onSelect }) {
function handleChange (option) {
const metric = option.value;
+
// e.target.value = '';
onSelect(metric);
}
return metrics.find(metric => metric.key === condition.metric).name;
});
-
return (
<div id="quality-gate-conditions" className="quality-gate-section">
<h3 className="spacer-bottom">
window.sonarqube.appStarted.then(options => App.start(options));
-
import Template from './templates/quality-profiles-profile.hbs';
import { formatMeasure } from '../../helpers/measures';
-
export default Marionette.ItemView.extend({
tagName: 'a',
className: 'list-group-item',
}
});
-
window.sonarqube.appStarted.then(options => App.start(options));
-
ReactDOM.render(<Main/>, el);
});
-
},
onChange() {
- let newValue = this.refs.select.value;
+ const newValue = this.refs.select.value;
setLogLevel(newValue).then(() => {
this.setState({ level: newValue });
});
},
render() {
- let options = LOG_LEVELS.map(level => {
+ const options = LOG_LEVELS.map(level => {
return <option key={level} value={level}>{level}</option>;
});
- let warning = this.state.level !== 'INFO' ? (
+ const warning = this.state.level !== 'INFO' ? (
<div className="alert alert-danger spacer-top" style={{ wordBreak: 'normal' }}>
{translate('system.log_level.warning')}
</div>
export default React.createClass({
render() {
- let rows = Object.keys(this.props.value).map(key => {
+ const rows = Object.keys(this.props.value).map(key => {
return <tr key={key}>
<td className="thin nowrap">{key}</td>
<td><ItemValue value={this.props.value[key]}/></td>
return <ItemLogLevel value={this.props.value}/>;
}
- let rawValue = this.props.value;
+ const rawValue = this.props.value;
let formattedValue;
switch (typeof this.props.value) {
case 'boolean':
},
parseSections (data) {
- let sections = Object.keys(data).map(section => {
+ const sections = Object.keys(data).map(section => {
return { name: section, items: this.parseItems(data[section]) };
});
return this.orderSections(sections);
},
parseItems (data) {
- let items = Object.keys(data).map(item => {
+ const items = Object.keys(data).map(item => {
return { name: item, value: data[item] };
});
return this.orderItems(items);
export default React.createClass({
render() {
- let items = this.props.items.map(item => {
+ const items = this.props.items.map(item => {
return <tr key={item.name}>
<td className="thin">
<div style={{ width: '25vw', overflow: 'hidden', textOverflow: 'ellipsis' }}>{item.name}</div>
window.sonarqube.appStarted.then(options => App.start(options));
-
e.stopPropagation();
$('body').click();
const index = $(e.currentTarget).data('idx');
+
// if show changelog of update, show details of this update
// otherwise show changelog of the available release
const update = this.model.has('release') ? this.model.toJSON() : this.model.get('updates')[index];
}
});
-
childView: ListItemView
});
-
export default Plugins;
-
window.sonarqube.appStarted.then(options => App.start(options));
-
import ListItemView from './list-item-view';
import Template from './templates/users-list.hbs';
-
export default Marionette.CompositeView.extend({
template: Template,
childView: ListItemView,
}
});
-
import Template from './templates/users-tokens.hbs';
import { getTokens, generateToken, revokeToken } from '../../api/user-tokens';
-
export default Modal.extend({
template: Template,
})
.filter(domain => domain.filteredActions.length);
-
return (
<div className="api-documentation-results panel">
<div className="list-group">
import RestartingTemplate from './templates/restarting.hbs';
import { restartAndWait } from '../../api/system';
-
const RestartModal = ModalForm.extend({
template: Template,
restartingTemplate: RestartingTemplate,
});
-
/*
* SelectList Item View
*/
}
});
-
/*
* SelectList View
*/
});
-
/*
* SelectList Entry Point
*/
return this;
};
-
/*
* SelectList API Methods
*/
return this;
};
-
/*
* SelectList Defaults
*/
if (!this.props.xTicks.length) {
return null;
}
- let ticks = this.props.xTicks.map((tick, index) => {
- let point = this.props.data[index];
- let x = Math.round(xScale(point.x) + xScale.rangeBand() / 2);
- let y = yScale.range()[0];
- let d = this.props.data[index];
- let tooltipAtts = {};
+ const ticks = this.props.xTicks.map((tick, index) => {
+ const point = this.props.data[index];
+ const x = Math.round(xScale(point.x) + xScale.rangeBand() / 2);
+ const y = yScale.range()[0];
+ const d = this.props.data[index];
+ const tooltipAtts = {};
if (d.tooltip) {
tooltipAtts['title'] = d.tooltip;
tooltipAtts['data-toggle'] = 'tooltip';
if (!this.props.xValues.length) {
return null;
}
- let ticks = this.props.xValues.map((value, index) => {
- let point = this.props.data[index];
- let x = Math.round(xScale(point.x) + xScale.rangeBand() / 2);
- let y = yScale(point.y);
- let d = this.props.data[index];
- let tooltipAtts = {};
+ const ticks = this.props.xValues.map((value, index) => {
+ const point = this.props.data[index];
+ const x = Math.round(xScale(point.x) + xScale.rangeBand() / 2);
+ const y = yScale(point.y);
+ const d = this.props.data[index];
+ const tooltipAtts = {};
if (d.tooltip) {
tooltipAtts['title'] = d.tooltip;
tooltipAtts['data-toggle'] = 'tooltip';
},
renderBars (xScale, yScale) {
- let bars = this.props.data.map((d, index) => {
- let x = Math.round(xScale(d.x));
- let maxY = yScale.range()[0];
- let y = Math.round(yScale(d.y)) - /* minimum bar height */ 1;
- let height = maxY - y;
- let tooltipAtts = {};
+ const bars = this.props.data.map((d, index) => {
+ const x = Math.round(xScale(d.x));
+ const maxY = yScale.range()[0];
+ const y = Math.round(yScale(d.y)) - /* minimum bar height */ 1;
+ const height = maxY - y;
+ const tooltipAtts = {};
if (d.tooltip) {
tooltipAtts['title'] = d.tooltip;
tooltipAtts['data-toggle'] = 'tooltip';
return <div/>;
}
- let availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
- let availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
+ const availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
+ const availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
const innerPadding = (availableWidth - this.props.barsWidth * this.props.data.length) /
(this.props.data.length - 1);
const relativeInnerPadding = innerPadding / (innerPadding + this.props.barsWidth);
- let maxY = d3.max(this.props.data, d => d.y);
- let xScale = d3.scale.ordinal()
+ const maxY = d3.max(this.props.data, d => d.y);
+ const xScale = d3.scale.ordinal()
.domain(this.props.data.map(d => d.x))
.rangeBands([0, availableWidth], relativeInnerPadding, 0);
- let yScale = d3.scale.linear()
+ const yScale = d3.scale.linear()
.domain([0, maxY])
.range([availableHeight, 0]);
import { ResizeMixin } from './../mixins/resize-mixin';
import { TooltipsMixin } from './../mixins/tooltips-mixin';
-
const TICKS_COUNT = 5;
-
export const Bubble = React.createClass({
propTypes: {
x: React.PropTypes.number.isRequired,
}
});
-
export const BubbleChart = React.createClass({
propTypes: {
items: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
},
getTicks(scale, format) {
- let ticks = scale.ticks(TICKS_COUNT).map(tick => format(tick));
+ const ticks = scale.ticks(TICKS_COUNT).map(tick => format(tick));
const uniqueTicksCount = _.uniq(ticks).length;
const ticksCount = uniqueTicksCount < TICKS_COUNT ? uniqueTicksCount - 1 : TICKS_COUNT;
return scale.ticks(ticksCount);
return null;
}
- let lines = ticks.map((tick, index) => {
- let x = xScale(tick);
- let y1 = yScale.range()[0];
- let y2 = yScale.range()[1];
+ const lines = ticks.map((tick, index) => {
+ const x = xScale(tick);
+ const y1 = yScale.range()[0];
+ const y2 = yScale.range()[1];
return <line key={index}
x1={x}
x2={x}
return null;
}
- let lines = ticks.map((tick, index) => {
- let y = yScale(tick);
- let x1 = xScale.range()[0];
- let x2 = xScale.range()[1];
+ const lines = ticks.map((tick, index) => {
+ const y = yScale(tick);
+ const x1 = xScale.range()[0];
+ const x2 = xScale.range()[1];
return <line key={index}
x1={x1}
x2={x2}
return null;
}
- let ticks = xTicks.map((tick, index) => {
- let x = xScale(tick);
- let y = yScale.range()[0];
- let innerText = this.props.formatXTick(tick);
+ const ticks = xTicks.map((tick, index) => {
+ const x = xScale(tick);
+ const y = yScale.range()[0];
+ const innerText = this.props.formatXTick(tick);
return <text key={index}
className="bubble-chart-tick"
x={x}
return null;
}
- let ticks = yTicks.map((tick, index) => {
- let x = xScale.range()[0];
- let y = yScale(tick);
- let innerText = this.props.formatYTick(tick);
+ const ticks = yTicks.map((tick, index) => {
+ const x = xScale.range()[0];
+ const y = yScale(tick);
+ const innerText = this.props.formatYTick(tick);
return <text key={index}
className="bubble-chart-tick bubble-chart-tick-y"
x={x}
return <div/>;
}
- let availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
- let availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
+ const availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
+ const availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
- let xScale = d3.scale.linear()
+ const xScale = d3.scale.linear()
.domain([0, d3.max(this.props.items, d => d.x)])
.range([0, availableWidth])
.nice();
- let yScale = d3.scale.linear()
+ const yScale = d3.scale.linear()
.domain([0, d3.max(this.props.items, d => d.y)])
.range([availableHeight, 0])
.nice();
- let sizeScale = d3.scale.linear()
+ const sizeScale = d3.scale.linear()
.domain([0, d3.max(this.props.items, d => d.size)])
.range(this.props.sizeRange);
- let xScaleOriginal = xScale.copy();
- let yScaleOriginal = yScale.copy();
+ const xScaleOriginal = xScale.copy();
+ const yScaleOriginal = yScale.copy();
xScale.range(this.getXRange(xScale, sizeScale, availableWidth));
yScale.range(this.getYRange(yScale, sizeScale, availableHeight));
- let bubbles = _.sortBy(this.props.items, (a, b) => b.size - a.size)
+ const bubbles = _.sortBy(this.props.items, (a, b) => b.size - a.size)
.map((item, index) => {
return <Bubble key={index}
link={item.link}
onClick={this.props.onBubbleClick}/>;
});
- let xTicks = this.getTicks(xScale, this.props.formatXTick);
- let yTicks = this.getTicks(yScale, this.props.formatYTick);
+ const xTicks = this.getTicks(xScale, this.props.formatXTick);
+ const yTicks = this.getTicks(yScale, this.props.formatYTick);
return <svg className="bubble-chart" width={this.state.width} height={this.state.height}>
<g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}>
import { ResizeMixin } from './../mixins/resize-mixin';
import { TooltipsMixin } from './../mixins/tooltips-mixin';
-
const Sector = React.createClass({
render() {
- let arc = d3.svg.arc()
+ const arc = d3.svg.arc()
.outerRadius(this.props.radius)
.innerRadius(this.props.radius - this.props.thickness);
return <path d={arc(this.props.data)} style={{ fill: this.props.fill }}/>;
}
});
-
export const DonutChart = React.createClass({
propTypes: {
data: React.PropTypes.arrayOf(React.PropTypes.object).isRequired
return <div/>;
}
- let availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
- let availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
+ const availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
+ const availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
- let size = Math.min(availableWidth, availableHeight);
- let radius = Math.floor(size / 2);
+ const size = Math.min(availableWidth, availableHeight);
+ const radius = Math.floor(size / 2);
- let pie = d3.layout.pie()
+ const pie = d3.layout.pie()
.sort(null)
.value(d => d.value);
- let sectors = pie(this.props.data).map((d, i) => {
+ const sectors = pie(this.props.data).map((d, i) => {
return <Sector key={i}
data={d}
radius={radius}
if (!this.props.yTicks.length) {
return null;
}
- let ticks = this.props.yTicks.map((tick, index) => {
+ const ticks = this.props.yTicks.map((tick, index) => {
const point = this.props.data[index];
const x = xScale.range()[0];
const y = Math.round(yScale(point.y) + yScale.rangeBand() / 2 + this.props.barsHeight / 2);
if (!this.props.yValues.length) {
return null;
}
- let ticks = this.props.yValues.map((value, index) => {
- let point = this.props.data[index];
- let x = xScale(point.x);
- let y = Math.round(yScale(point.y) + yScale.rangeBand() / 2 + this.props.barsHeight / 2);
+ const ticks = this.props.yValues.map((value, index) => {
+ const point = this.props.data[index];
+ const x = xScale(point.x);
+ const y = Math.round(yScale(point.y) + yScale.rangeBand() / 2 + this.props.barsHeight / 2);
return <text key={index}
onClick={this.props.onBarClick && this.handleClick.bind(this, point)}
className="bar-chart-tick histogram-value"
},
renderBars (xScale, yScale) {
- let bars = this.props.data.map((d, index) => {
- let x = Math.round(xScale(d.x)) + /* minimum bar width */ 1;
- let y = Math.round(yScale(d.y) + yScale.rangeBand() / 2);
+ const bars = this.props.data.map((d, index) => {
+ const x = Math.round(xScale(d.x)) + /* minimum bar width */ 1;
+ const y = Math.round(yScale(d.y) + yScale.rangeBand() / 2);
return <rect key={index}
className="bar-chart-bar"
onClick={this.props.onBarClick && this.handleClick.bind(this, d)}
return <div/>;
}
- let availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
- let availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
+ const availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
+ const availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
- let maxX = d3.max(this.props.data, d => d.x);
- let xScale = d3.scale.linear()
+ const maxX = d3.max(this.props.data, d => d.x);
+ const xScale = d3.scale.linear()
.domain([0, maxX])
.range([0, availableWidth]);
- let yScale = d3.scale.ordinal()
+ const yScale = d3.scale.ordinal()
.domain(this.props.data.map(d => d.y))
.rangeRoundBands([0, availableHeight]);
import { ResizeMixin } from './../mixins/resize-mixin';
import { TooltipsMixin } from './../mixins/tooltips-mixin';
-
export const LineChart = React.createClass({
propTypes: {
data: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
return null;
}
- let area = d3.svg.area()
+ const area = d3.svg.area()
.x(d => xScale(d.x))
.y0(yScale.range()[0])
.y1(d => yScale(d.y))
let data = this.props.data;
if (this.props.backdropConstraints) {
- let c = this.props.backdropConstraints;
+ const c = this.props.backdropConstraints;
data = data.filter(d => c[0] <= d.x && d.x <= c[1]);
}
return <path className="line-chart-backdrop" d={area(data)}/>;
if (!this.props.displayPoints) {
return null;
}
- let points = this.props.data.map((point, index) => {
- let x = xScale(point.x);
- let y = yScale(point.y);
+ const points = this.props.data.map((point, index) => {
+ const x = xScale(point.x);
+ const y = yScale(point.y);
return <circle key={index}
className="line-chart-point"
r="3"
if (!this.props.displayVerticalGrid) {
return null;
}
- let lines = this.props.data.map((point, index) => {
- let x = xScale(point.x);
- let y1 = yScale.range()[0];
- let y2 = yScale(point.y);
+ const lines = this.props.data.map((point, index) => {
+ const x = xScale(point.x);
+ const y1 = yScale.range()[0];
+ const y2 = yScale(point.y);
return <line key={index}
className="line-chart-grid"
x1={x}
if (!this.props.xTicks.length) {
return null;
}
- let ticks = this.props.xTicks.map((tick, index) => {
- let point = this.props.data[index];
- let x = xScale(point.x);
- let y = yScale.range()[0];
+ const ticks = this.props.xTicks.map((tick, index) => {
+ const point = this.props.data[index];
+ const x = xScale(point.x);
+ const y = yScale.range()[0];
return <text key={index}
className="line-chart-tick"
x={x}
if (!this.props.xValues.length) {
return null;
}
- let ticks = this.props.xValues.map((value, index) => {
- let point = this.props.data[index];
- let x = xScale(point.x);
- let y = yScale(point.y);
+ const ticks = this.props.xValues.map((value, index) => {
+ const point = this.props.data[index];
+ const x = xScale(point.x);
+ const y = yScale(point.y);
return <text key={index}
className="line-chart-tick"
x={x}
},
renderLine (xScale, yScale) {
- let p = d3.svg.line()
+ const p = d3.svg.line()
.x(d => xScale(d.x))
.y(d => yScale(d.y))
.interpolate(this.props.interpolate);
return <div/>;
}
- let availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
- let availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
+ const availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
+ const availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
let maxY;
- let xScale = d3.scale.linear()
+ const xScale = d3.scale.linear()
.domain(d3.extent(this.props.data, d => d.x))
.range([0, availableWidth]);
- let yScale = d3.scale.linear()
+ const yScale = d3.scale.linear()
.range([availableHeight, 0]);
if (this.props.domain) {
import QualifierIcon from '../shared/qualifier-icon';
-
export const TreemapBreadcrumbs = React.createClass({
propTypes: {
breadcrumbs: React.PropTypes.arrayOf(React.PropTypes.shape({
},
render() {
- let breadcrumbs = this.props.breadcrumbs.map(this.renderBreadcrumbsItems);
+ const breadcrumbs = this.props.breadcrumbs.map(this.renderBreadcrumbsItems);
return <div className="treemap-breadcrumbs">
{this.props.breadcrumbs.length ? this.renderHome() : null}
{breadcrumbs}
import { TooltipsMixin } from './../mixins/tooltips-mixin';
import { translate } from '../../helpers/l10n';
-
const SIZE_SCALE = d3.scale.linear()
.domain([3, 15])
.range([11, 18])
.clamp(true);
-
function mostCommitPrefix (strings) {
const sortedStrings = strings.slice(0).sort();
const firstString = sortedStrings[0];
return prefix.substr(0, prefix.length - lastPrefixPart.length);
}
-
export const TreemapRect = React.createClass({
propTypes: {
x: React.PropTypes.number.isRequired,
'data-title': this.props.tooltip
};
}
- let cellStyles = {
+ const cellStyles = {
left: this.props.x,
top: this.props.y,
width: this.props.width,
lineHeight: `${this.props.height}px`,
cursor: typeof this.props.onClick === 'function' ? 'pointer' : 'default'
};
- let isTextVisible = this.props.width >= 40 && this.props.height >= 40;
+ const isTextVisible = this.props.width >= 40 && this.props.height >= 40;
return <div className="treemap-cell"
{...tooltipAttrs}
style={cellStyles}
onClick={this.props.onClick}>
<div className="treemap-inner" dangerouslySetInnerHTML={{ __html: this.props.label }}
- style={{ maxWidth: this.props.width, visibility: isTextVisible ? 'visible': 'hidden' }}/>
+ style={{ maxWidth: this.props.width, visibility: isTextVisible ? 'visible' : 'hidden' }}/>
{this.renderLink()}
</div>;
}
});
-
export const Treemap = React.createClass({
propTypes: {
items: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
return this.renderWhenNoData();
}
- let treemap = d3.layout.treemap()
+ const treemap = d3.layout.treemap()
.round(true)
.value(d => d.size)
.sort((a, b) => a.value - b.value)
.size([this.state.width, this.state.height]);
- let nodes = treemap
+ const nodes = treemap
.nodes({ children: this.props.items })
.filter(d => !d.children)
.filter(d => !!d.dx && !!d.dy);
- let prefix = mostCommitPrefix(this.props.items.map(item => item.label));
- let prefixLength = prefix.length;
+ const prefix = mostCommitPrefix(this.props.items.map(item => item.label));
+ const prefixLength = prefix.length;
- let rectangles = nodes.map(node => {
+ const rectangles = nodes.map(node => {
const key = node.label;
- let label = prefixLength ? `${prefix}<br>${node.label.substr(prefixLength)}` : node.label;
+ const label = prefixLength ? `${prefix}<br>${node.label.substr(prefixLength)}` : node.label;
const onClick = this.props.canBeClicked(node) ? () => this.props.onRectangleClick(node) : null;
return <TreemapRect key={key}
x={node.x}
}
});
-
export const WordCloud = React.createClass({
propTypes: {
items: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
},
render () {
- let len = this.props.items.length;
- let sortedItems = _.sortBy(this.props.items, (item, idx) => {
- let index = len - idx;
+ const len = this.props.items.length;
+ const sortedItems = _.sortBy(this.props.items, (item, idx) => {
+ const index = len - idx;
return (index % 2) * (len - index) + index / 2;
});
- let sizeScale = d3.scale.linear()
+ const sizeScale = d3.scale.linear()
.domain([0, d3.max(this.props.items, d => d.size)])
.range(this.props.sizeRange);
- let words = sortedItems
+ const words = sortedItems
.map((item, index) => <Word key={index}
text={item.text}
size={sizeScale(item.size)}
return deferred.promise();
}
-
* @private
*/
_action (options) {
- const model = this;
+ const that = this;
const success = function (r) {
- const attrs = model.parse(r);
- model.reset(attrs);
+ const attrs = that.parse(r);
+ that.reset(attrs);
if (options.success) {
- options.success(model, r, options);
+ options.success(that, r, options);
}
};
const opts = _.extend({ type: 'POST' }, options, { success });
const xhr = options.xhr = Backbone.ajax(opts);
- model.trigger('request', model, xhr, opts);
+ this.trigger('request', this, xhr, opts);
return xhr;
},
});
},
-
/**
* Set type of issue
* @param {String|null} issueType Issue type
return this._action(opts);
},
-
/**
* Do a custom (plugin) action
* @param {String} actionKey Action Key
return locations;
}
});
-
-
import React from 'react';
import ReactDOM from 'react-dom';
-
export const TooltipsMixin = {
componentDidMount () {
this.initTooltips();
}
};
-
export const TooltipsContainer = React.createClass({
componentDidMount () {
this.initTooltips();
const PAGE_SIZE = 100;
-
const Suggestions = Backbone.Collection.extend({
comparator: 'text',
this.page = 0;
},
-
parse (r) {
this.more = r.more;
return r.results;
},
-
fetch (options) {
this.data = _.extend({
p: 1,
return Backbone.Collection.prototype.fetch.call(this, settings);
},
-
fetchNextPage (options) {
if (this.more) {
this.data.p += 1;
});
-
const UserSuggestions = Suggestions.extend({
url () {
});
-
const ProjectSuggestions = Suggestions.extend({
url () {
});
-
const ComponentSuggestions = Suggestions.extend({
url () {
});
-
const AjaxSelectDetailsFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
template: Template,
listTemplate: ListTemplate,
searchKey: 's',
-
render () {
ChoiceFilters.DetailsChoiceFilterView.prototype.render.apply(this, arguments);
.on('scroll', throttledScroll);
},
-
search () {
const that = this;
this.query = this.$('.navigator-filter-search input').val();
}
},
-
showSearchError () {
this.$el.removeClass('fetching');
this.$('.navigator-filter-search').addClass('fetching-error');
},
-
scroll () {
const that = this;
const el = this.$('.choices');
}
},
-
keydown (e) {
if (_([38, 40, 13]).indexOf(e.keyCode) !== -1) {
e.preventDefault();
}
},
-
resetChoices () {
const that = this;
this.options.filterView.choices.reset(this.options.filterView.choices.filter(function (item) {
});
},
-
onShow () {
ChoiceFilters.DetailsChoiceFilterView.prototype.onShow.apply(this, arguments);
this.resetChoices();
});
-
const AjaxSelectFilterView = ChoiceFilters.ChoiceFilterView.extend({
initialize (options) {
});
},
-
isDefaultValue () {
return this.getSelected().length === 0;
},
-
renderInput () {
const value = this.model.get('value') || [];
const input = $('<input>')
input.appendTo(this.$el);
},
-
restoreFromQuery (q) {
let param = _.findWhere(q, { key: this.model.get('property') });
}
},
-
restore (value, param) {
const that = this;
if (_.isString(value)) {
}
},
-
restoreFromText (value, text) {
const that = this;
_.each(value, function (v, i) {
this.onRestore(value);
},
-
restoreByRequests (value) {
const that = this;
const requests = _.map(value, function (v) {
});
},
-
onRestore () {
this.projectsView.updateLists();
this.renderBase();
},
-
clear () {
this.model.unset('value');
if (this.choices) {
this.render();
},
-
createRequest () {
}
});
-
const ComponentFilterView = AjaxSelectFilterView.extend({
initialize () {
this.choices = new ComponentSuggestions();
},
-
createRequest (v) {
const that = this;
return $
});
-
const ProjectFilterView = AjaxSelectFilterView.extend({
initialize () {
this.choices = new ProjectSuggestions();
},
-
createRequest (v) {
const that = this;
return $
});
-
const AssigneeFilterView = AjaxSelectFilterView.extend({
initialize () {
});
-
/*
* Export public classes
*/
AssigneeFilterView
};
-
});
-
const Filters = Backbone.Collection.extend({
model: Filter
});
-
const DetailsFilterView = Marionette.ItemView.extend({
template: DetailsTemplate,
className: 'navigator-filter-details',
-
initialize () {
this.$el.on('click', function (e) {
e.stopPropagation();
this.$el.attr('id', 'filter-' + this.model.get('property'));
},
-
onShow () {
},
}
});
-
const BaseFilterView = Marionette.ItemView.extend({
template: Template,
className: 'navigator-filter',
-
events () {
return {
'click': 'toggleDetails',
};
},
-
modelEvents: {
'change:enabled': 'focus',
'change:value': 'renderBase',
'change:filters': 'render'
},
-
initialize (options) {
Marionette.ItemView.prototype.initialize.apply(this, arguments);
- const detailsView = (options && options.projectsView) || DetailsFilterView;
- this.projectsView = new detailsView({
+ const DetailsView = (options && options.projectsView) || DetailsFilterView;
+ this.projectsView = new DetailsView({
model: this.model,
filterView: this
});
this.model.view = this;
},
-
attachDetailsView () {
this.projectsView.$el.detach().appendTo($('body'));
},
-
render () {
this.renderBase();
this.model.get('optional'));
},
-
renderBase () {
Marionette.ItemView.prototype.render.apply(this, arguments);
this.renderInput();
this.$el.attr('data-property', this.model.get('property'));
},
-
renderInput () {
},
-
focus () {
this.render();
},
-
toggleDetails (e) {
e.stopPropagation();
this.options.filterBarView.selected = this.options.filterBarView.getEnabledFilters().index(this.$el);
}
},
-
showDetails () {
this.registerShowedDetails();
this.projectsView.onShow();
},
-
registerShowedDetails () {
this.options.filterBarView.hideDetails();
this.options.filterBarView.showedView = this;
},
-
hideDetails () {
this.projectsView.$el.removeClass('active');
this.$el.removeClass('active');
this.projectsView.onHide();
},
-
isActive () {
return this.$el.is('.active');
},
-
renderValue () {
return this.model.get('value') || 'unset';
},
-
isDefaultValue () {
return true;
},
-
restoreFromQuery (q) {
const param = _.findWhere(q, { key: this.model.get('property') });
if (param && param.value) {
}
},
-
restore (value) {
this.model.set({ value }, { silent: true });
this.renderBase();
},
-
clear () {
this.model.unset('value');
},
-
disable (e) {
e.stopPropagation();
this.hideDetails();
});
},
-
formatValue () {
const q = {};
if (this.model.has('property') && this.model.has('value') && this.model.get('value')) {
return q;
},
-
serializeData () {
return _.extend({}, this.model.toJSON(), {
value: this.renderValue(),
});
-
/*
* Export public classes
*/
BaseFilterView,
DetailsFilterView
};
-
-
template: Template,
className: 'navigator-filter navigator-filter-inline',
-
events () {
return {
'click .navigator-filter-disable': 'disable'
};
},
-
showDetails () {
},
-
renderInput () {
if (this.model.get('enabled')) {
$('<input>')
}
},
-
renderValue () {
return this.model.get('value');
},
-
isDefaultValue () {
return false;
},
-
restore (value) {
this.model.set({
value,
});
-
template: Template,
itemTemplate: ItemTemplate,
-
events () {
return {
'click label': 'onCheck'
};
},
-
render () {
BaseFilters.DetailsFilterView.prototype.render.apply(this, arguments);
this.updateLists();
},
-
renderList (collection, selector) {
const that = this;
const container = this.$(selector);
});
},
-
updateLists () {
const choices = new Backbone.Collection(this.options.filterView.choices.reject(function (item) {
return item.get('id')[0] === '!';
this.updateCurrent(current);
},
-
onCheck (e) {
const checkbox = $(e.currentTarget);
const id = checkbox.data('id');
this.updateLists();
},
-
updateValue () {
this.model.set('value', this.options.filterView.getSelected().map(function (m) {
return m.get('id');
}));
},
-
updateCurrent (index) {
this.currentChoice = index;
this.$('label').removeClass('current')
.eq(this.currentChoice).addClass('current');
},
-
onShow () {
this.bindedOnKeyDown = _.bind(this.onKeyDown, this);
$('body').on('keydown', this.bindedOnKeyDown);
},
-
onHide () {
$('body').off('keydown', this.bindedOnKeyDown);
},
-
onKeyDown (e) {
switch (e.keyCode) {
case 38:
this.selectCurrent();
break;
default:
+
// Not a functional key - then skip
break;
}
},
-
selectNextChoice () {
if (this.$('label').length > this.currentChoice + 1) {
this.updateCurrent(this.currentChoice + 1);
}
},
-
scrollNext () {
const currentLabel = this.$('label').eq(this.currentChoice);
if (currentLabel.length > 0) {
}
},
-
selectPrevChoice () {
if (this.currentChoice > 0) {
this.updateCurrent(this.currentChoice - 1);
}
},
-
scrollPrev () {
const currentLabel = this.$('label').eq(this.currentChoice);
if (currentLabel.length > 0) {
}
},
-
selectCurrent () {
const cb = this.$('label').eq(this.currentChoice);
cb.click();
},
-
serializeData () {
return _.extend({}, this.model.toJSON(), {
choices: new Backbone.Collection(this.options.filterView.choices.reject(function (item) {
});
-
const ChoiceFilterView = BaseFilters.BaseFilterView.extend({
initialize (options) {
);
},
-
getSelected () {
return this.choices.filter(function (m) {
return m.get('checked');
});
},
-
renderInput () {
const input = $('<select>')
.prop('name', this.model.get('property'))
input.appendTo(this.$el);
},
-
renderValue () {
const value = this.getSelected().map(function (item) {
return item.get('text');
return this.isDefaultValue() ? defaultValue : value.join(', ');
},
-
isDefaultValue () {
const selected = this.getSelected();
return selected.length === 0;
},
-
disable () {
this.choices.each(function (item) {
item.set('checked', false);
BaseFilters.BaseFilterView.prototype.disable.apply(this, arguments);
},
-
restoreFromQuery (q) {
let param = _.findWhere(q, { key: this.model.get('property') });
}
},
-
restore (value) {
if (_.isString(value)) {
value = value.split(',');
}
},
-
clear () {
if (this.choices) {
this.choices.each(function (item) {
}
},
-
formatValue () {
const q = {};
if (this.model.has('property') && this.model.has('value') && this.model.get('value').length > 0) {
});
-
/*
* Export public classes
*/
const DetailsFavoriteFilterView = BaseFilters.DetailsFilterView.extend({
template: DetailsTemplate,
-
events: {
'click label[data-id]': 'applyFavorite',
'click .manage label': 'manage'
},
-
applyFavorite (e) {
const id = $(e.target).data('id');
window.location = window.baseUrl + this.model.get('favoriteUrl') + '/' + id;
},
-
manage () {
window.location = window.baseUrl + this.model.get('manageUrl');
},
-
serializeData () {
const choices = this.model.get('choices');
const choicesArray =
});
-
const FavoriteFilterView = ChoiceFilters.ChoiceFilterView.extend({
template: Template,
className: 'navigator-filter navigator-filter-favorite',
-
initialize () {
ChoiceFilters.ChoiceFilterView.prototype.initialize.call(this, {
projectsView: DetailsFavoriteFilterView
});
},
-
renderValue () {
return '';
},
-
renderInput () {
},
-
isDefaultValue () {
return false;
}
});
-
/*
* Export public classes
*/
FavoriteFilterView
};
-
export default Marionette.CompositeView.extend({
childViewContainer: '.navigator-filters-list',
-
collectionEvents: {
'change:enabled': 'changeEnabled'
},
-
getChildView (item) {
return item.get('type') || BaseFilters.BaseFilterView;
},
-
childViewOptions () {
return {
filterBarView: this,
};
},
-
initialize () {
Marionette.CompositeView.prototype.initialize.apply(this, arguments);
});
},
-
getEnabledFilters () {
return this.$(this.childViewContainer).children()
.not('.navigator-filter-disabled')
.not('.navigator-filter-favorite');
},
-
selectFirst () {
this.selected = -1;
this.selectNext();
},
-
selectPrev () {
const filters = this.getEnabledFilters();
if (this.selected > 0) {
}
},
-
selectNext () {
const filters = this.getEnabledFilters();
if (this.selected < filters.length - 1) {
}
},
-
addMoreCriteriaFilter () {
const disabledFilters = this.collection.where({ enabled: false });
if (disabledFilters.length > 0) {
}
},
-
onAddChild (childView) {
if (childView.model.get('type') === MoreCriteriaFilters.FavoriteFilterView) {
$('.navigator-header').addClass('navigator-header-favorite');
}
},
-
restoreFromQuery (q) {
this.collection.each(function (item) {
item.set('enabled', !item.get('optional'));
});
},
-
hideDetails () {
if (_.isObject(this.showedView)) {
this.showedView.hideDetails();
}
},
-
enableFilter (id) {
const filter = this.collection.get(id);
const filterView = filter.view;
filterView.showDetails();
},
-
changeEnabled () {
const disabledFilters = _.reject(this.collection.where({ enabled: false }), function (filter) {
return filter.get('type') === MoreCriteriaFilters.MoreCriteriaFilterView;
const DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({
template: Template,
-
events: {
'change :input': 'inputChanged'
},
-
inputChanged () {
const metric = this.$('[name=metric]').val();
const isDifferentialMetric = metric.indexOf('new_') === 0;
this.model.set('value', value);
},
-
updateDataType (value) {
const metric = _.find(window.SS.metrics, function (m) {
return m.metric.name === value.metric;
}
},
-
onRender () {
const periodZeroLabel = this.$('[name=period]').children('[value="0"]').html();
this.periodZeroOption = `<option value="0">${periodZeroLabel}</option>`;
this.inputChanged();
},
-
onShow () {
const select = this.$('[name=metric]');
if (this.model.get('value').metric === '') {
});
-
export default BaseFilters.BaseFilterView.extend({
initialize () {
this.groupMetrics();
},
-
groupMetrics () {
const metrics = _.map(this.model.get('metrics'), function (metric) {
return metric.metric;
this.model.set('groupedMetrics', groupedMetrics);
},
-
renderValue () {
return this.isDefaultValue() ?
translate('measure_filter.criteria.metric.not_set') :
this.model.get('value').valText;
},
-
renderInput () {
const that = this;
const value = this.model.get('value');
}
},
-
isDefaultValue () {
const value = this.model.get('value');
if (!_.isObject(value)) {
return !(value.metric && value.op && (value.val != null));
},
-
restoreFromQuery (q) {
const that = this;
const value = {};
});
-
const DetailsMoreCriteriaFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
template: DetailsTemplate,
-
events: {
'click label[data-id]:not(.inactive)': 'enableFilter'
},
-
enableById (id) {
this.model.view.options.filterBarView.enableFilter(id);
this.model.view.hideDetails();
},
-
enableByProperty (property) {
const filter = _.find(this.model.get('filters'), function (f) {
return f.get('property') === property;
}
},
-
enableFilter (e) {
const id = $(e.target).data('id');
this.enableById(id);
this.updateCurrent(0);
},
-
selectCurrent () {
this.$('label').eq(this.currentChoice).click();
},
-
serializeData () {
const filters = this.model.get('filters').map(function (filter) {
return _.extend(filter.toJSON(), { id: filter.cid });
});
-
const MoreCriteriaFilterView = ChoiceFilters.ChoiceFilterView.extend({
template: Template,
className: 'navigator-filter navigator-filter-more-criteria',
-
initialize () {
ChoiceFilters.ChoiceFilterView.prototype.initialize.call(this, {
projectsView: DetailsMoreCriteriaFilterView
});
},
-
renderValue () {
return '';
},
-
renderInput () {
},
-
renderBase () {
ChoiceFilters.ChoiceFilterView.prototype.renderBase.call(this);
this.$el.prop('title', '');
},
-
isDefaultValue () {
return false;
}
});
-
/*
* Export public classes
*/
MoreCriteriaFilterView
};
-
const DetailsRangeFilterView = BaseFilters.DetailsFilterView.extend({
template: Template,
-
events: {
'change input': 'change'
},
-
change () {
const value = {};
const valueFrom = this.$('input').eq(0).val();
this.model.set('value', value);
},
-
populateInputs () {
const value = this.model.get('value');
const propertyFrom = this.model.get('propertyFrom');
this.$('input').eq(1).val(valueTo || '');
},
-
onShow () {
this.$(':input:first').focus();
}
});
-
const RangeFilterView = BaseFilters.BaseFilterView.extend({
initialize () {
});
},
-
renderValue () {
if (!this.isDefaultValue()) {
const value = _.values(this.model.get('value'));
}
},
-
renderInput () {
const value = this.model.get('value');
const propertyFrom = this.model.get('propertyFrom');
.appendTo(this.$el);
},
-
isDefaultValue () {
const value = this.model.get('value');
const propertyFrom = this.model.get('propertyFrom');
return !valueFrom && !valueTo;
},
-
restoreFromQuery (q) {
const paramFrom = _.findWhere(q, { key: this.model.get('propertyFrom') });
const paramTo = _.findWhere(q, { key: this.model.get('propertyTo') });
}
},
-
restore (value) {
if (this.choices && this.selection && value.length > 0) {
const that = this;
}
},
-
formatValue () {
return this.model.get('value');
},
-
clear () {
this.model.unset('value');
this.projectsView.render();
});
-
const DateRangeFilterView = RangeFilterView.extend({
render () {
});
},
-
renderValue () {
if (!this.isDefaultValue()) {
const value = _.values(this.model.get('value'));
});
-
/*
* Export public classes
*/
DateRangeFilterView
};
-
const DetailsStringFilterView = BaseFilters.DetailsFilterView.extend({
template: Template,
-
events: {
'change input': 'change'
},
-
change (e) {
this.model.set('value', $(e.target).val());
},
-
onShow () {
BaseFilters.DetailsFilterView.prototype.onShow.apply(this, arguments);
this.$(':input').focus();
},
-
serializeData () {
return _.extend({}, this.model.toJSON(), {
value: this.model.get('value') || ''
});
-
export default BaseFilters.BaseFilterView.extend({
initialize () {
});
},
-
renderValue () {
return this.isDefaultValue() ? '—' : this.model.get('value');
},
-
renderInput () {
$('<input>')
.prop('name', this.model.get('property'))
.appendTo(this.$el);
},
-
isDefaultValue () {
return !this.model.get('value');
},
-
restore (value) {
this.model.set({
value,
});
},
-
clear () {
this.model.unset('value');
this.projectsView.render();
});
-
*/
let listener;
-
export const RouterMixin = {
getDefaultProps() {
return { urlRoot: '/' };
},
componentDidMount () {
+ /* jscs:disable safeContextKeyword */
listener = this;
window.addEventListener('popstate', this.handleRouteChange);
},
}
};
-
export function navigate (route) {
if (listener) {
listener.navigate(route);
},
search() {
- let query = this.refs.search.value;
+ const query = this.refs.search.value;
this.props.search(query);
},
},
render() {
- let selectionDisabled = !!this.props.query;
+ const selectionDisabled = !!this.props.query;
- let selectionOptions = [
+ const selectionOptions = [
{ value: 'selected', label: 'Selected' },
{ value: 'deselected', label: 'Not Selected' },
{ value: 'all', label: 'All' }
},
renderLoadMoreLink() {
- let hasMore = this.props.total > this.props.count;
+ const hasMore = this.props.total > this.props.count;
if (!hasMore) {
return null;
}
},
render() {
- let renderedItem = this.props.renderItem(this.props.item);
+ const renderedItem = this.props.renderItem(this.props.item);
return (
<li className="panel panel-vertical">
<div className="display-inline-block text-middle spacer-right">
},
render() {
- let renderedItems = this.props.items.map(item => {
- let key = this.props.getItemKey(item);
+ const renderedItems = this.props.items.map(item => {
+ const key = this.props.getItemKey(item);
return <Item key={key} {...this.props} item={item} />;
});
return (
deselectItem: React.PropTypes.func.isRequired
},
-
getInitialState() {
return { items: [], total: 0, selection: 'selected', query: null };
},
},
loadItems() {
- let options = {
+ const options = {
selection: this.state.selection,
query: this.state.query,
page: 1
},
loadMoreItems() {
- let options = {
+ const options = {
selection: this.state.selection,
query: this.state.query,
page: this.state.page + 1
};
this.props.loadItems(options, (items, paging) => {
- let newItems = [].concat(this.state.items, items);
+ const newItems = [].concat(this.state.items, items);
this.setState({ items: newItems, total: paging.total, page: paging.pageIndex });
});
},
},
renderSVG() {
- /* eslint max-len: 0 */
+ /* jscs:disable maximumLineLength */
return (
<svg width="16" height="16" style={{ fillRule: 'evenodd', clipRule: 'evenodd', strokeLinejoin: 'round', strokeMiterlimit: 1.41421 }}>
<path d="M15.4275,5.77678C15.4275,5.90773 15.3501,6.05059 15.1953,6.20536L11.9542,9.36608L12.7221,13.8304C12.728,13.872 12.731,13.9316 12.731,14.0089C12.731,14.1339 12.6998,14.2396 12.6373,14.3259C12.5748,14.4122 12.484,14.4554 12.3649,14.4554C12.2518,14.4554 12.1328,14.4197 12.0078,14.3482L7.99888,12.2411L3.98995,14.3482C3.85901,14.4197 3.73996,14.4554 3.63281,14.4554C3.50781,14.4554 3.41406,14.4122 3.35156,14.3259C3.28906,14.2396 3.25781,14.1339 3.25781,14.0089C3.25781,13.9732 3.26377,13.9137 3.27567,13.8304L4.04353,9.36608L0.793531,6.20536C0.644719,6.04464 0.570313,5.90178 0.570313,5.77678C0.570313,5.55654 0.736979,5.41964 1.07031,5.36606L5.55245,4.71428L7.56138,0.651781C7.67447,0.407729 7.8203,0.285703 7.99888,0.285703C8.17745,0.285703 8.32328,0.407729 8.43638,0.651781L10.4453,4.71428L14.9274,5.36606C15.2608,5.41964 15.4274,5.55654 15.4274,5.77678L15.4275,5.77678Z"
},
renderSVG() {
- /* eslint max-len: 0 */
+ /* jscs:disable maximumLineLength */
return (
<svg width="16" height="16" style={{ fillRule: 'evenodd', clipRule: 'evenodd', strokeLinejoin: 'round', strokeMiterlimit: 1.41421 }}>
<path d="M15.4275,5.77678C15.4275,5.90773 15.3501,6.05059 15.1953,6.20536L11.9542,9.36608L12.7221,13.8304C12.728,13.872 12.731,13.9316 12.731,14.0089C12.731,14.1339 12.6998,14.2396 12.6373,14.3259C12.5748,14.4122 12.484,14.4554 12.3649,14.4554C12.2518,14.4554 12.1328,14.4197 12.0078,14.3482L7.99888,12.2411L3.98995,14.3482C3.85901,14.4197 3.73996,14.4554 3.63281,14.4554C3.50781,14.4554 3.41406,14.4122 3.35156,14.3259C3.28906,14.2396 3.25781,14.1339 3.25781,14.0089C3.25781,13.9732 3.26377,13.9137 3.27567,13.8304L4.04353,9.36608L0.793531,6.20536C0.644719,6.04464 0.570313,5.90178 0.570313,5.77678C0.570313,5.55654 0.736979,5.41964 1.07031,5.36606L5.55245,4.71428L7.56138,0.651781C7.67447,0.407729 7.8203,0.285703 7.99888,0.285703C8.17745,0.285703 8.32328,0.407729 8.43638,0.651781L10.4453,4.71428L14.9274,5.36606C15.2608,5.41964 15.4274,5.55654 15.4274,5.77678L15.4275,5.77678Z"
export default class Assignee extends React.Component {
render () {
- let avatar = this.props.user ?
+ const avatar = this.props.user ?
<span className="spacer-right"><Avatar email={this.props.user.email} size={16}/></span> : null;
- let name = this.props.user ? this.props.user.name : translate('unassigned');
+ const name = this.props.user ? this.props.user.name : translate('unassigned');
return <span>{avatar}{name}</span>;
}
}
},
render() {
- let classNames = ['icon-checkbox'];
+ const classNames = ['icon-checkbox'];
if (this.state.checked) {
classNames.push('icon-checkbox-checked');
}
if (this.props.thirdState) {
classNames.push('icon-checkbox-single');
}
- let className = classNames.join(' ');
+ const className = classNames.join(' ');
return <a onClick={this.toggle} className={className} href="#"/>;
}
});
import { IssuesLink } from './issues-link';
import { getComponentDrilldownUrl } from '../../helpers/urls';
-
const ISSUE_MEASURES = [
'violations',
'new_violations',
'new_vulnerabilities'
];
-
export const DrilldownLink = React.createClass({
isIssueMeasure() {
return ISSUE_MEASURES.indexOf(this.props.metric) !== -1;
},
renderSVG() {
- /* eslint max-len: 0 */
+ /* jscs:disable maximumLineLength */
return (
<svg width="16" height="16" style={{ fillRule: 'evenodd', clipRule: 'evenodd', strokeLinejoin: 'round', strokeMiterlimit: 1.41421 }}>
<path d="M15.4275,5.77678C15.4275,5.90773 15.3501,6.05059 15.1953,6.20536L11.9542,9.36608L12.7221,13.8304C12.728,13.872 12.731,13.9316 12.731,14.0089C12.731,14.1339 12.6998,14.2396 12.6373,14.3259C12.5748,14.4122 12.484,14.4554 12.3649,14.4554C12.2518,14.4554 12.1328,14.4197 12.0078,14.3482L7.99888,12.2411L3.98995,14.3482C3.85901,14.4197 3.73996,14.4554 3.63281,14.4554C3.50781,14.4554 3.41406,14.4122 3.35156,14.3259C3.28906,14.2396 3.25781,14.1339 3.25781,14.0089C3.25781,13.9732 3.26377,13.9137 3.27567,13.8304L4.04353,9.36608L0.793531,6.20536C0.644719,6.04464 0.570313,5.90178 0.570313,5.77678C0.570313,5.55654 0.736979,5.41964 1.07031,5.36606L5.55245,4.71428L7.56138,0.651781C7.67447,0.407729 7.8203,0.285703 7.99888,0.285703C8.17745,0.285703 8.32328,0.407729 8.43638,0.651781L10.4453,4.71428L14.9274,5.36606C15.2608,5.41964 15.4274,5.55654 15.4274,5.77678L15.4275,5.77678Z"
import { getComponentIssuesUrl } from '../../helpers/urls';
-
export const IssuesLink = React.createClass({
render() {
- let url = getComponentIssuesUrl(this.props.component, this.props.params);
+ const url = getComponentIssuesUrl(this.props.component, this.props.params);
return <a className={this.props.className} href={url}>{this.props.children}</a>;
}
});
import { translate } from '../../helpers/l10n';
import { formatMeasure } from '../../helpers/measures';
-
export default React.createClass({
propTypes: {
count: React.PropTypes.number.isRequired,
},
render() {
- let hasMore = this.props.total > this.props.count;
- let loadMoreLink = <a onClick={this.handleLoadMore} className="spacer-left" href="#">show more</a>;
- let className = classNames('spacer-top note text-center', { 'new-loading': !this.props.ready });
+ const hasMore = this.props.total > this.props.count;
+ const loadMoreLink = <a onClick={this.handleLoadMore} className="spacer-left" href="#">show more</a>;
+ const className = classNames('spacer-top note text-center', { 'new-loading': !this.props.ready });
return (
<footer className={className}>
{formatMeasure(this.props.count, 'INT')} of {formatMeasure(this.props.total, 'INT')} shown
export default React.createClass({
render() {
- /* eslint max-len: 0 */
+ /* jscs:disable maximumLineLength */
return (
<svg width="16" height="16" className="icon-pending">
<g transform="matrix(0.0364583,0,0,0.0364583,1,-0.166667)">
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint max-len: 0 */
+/* jscs:disable maximumLineLength */
import React from 'react';
const PinIcon = () => (
);
export default PinIcon;
-
*/
import React from 'react';
-
export const QualityGateLink = React.createClass({
render() {
- let url = `${window.baseUrl}/quality_gates/show/${this.props.gate}`;
+ const url = `${window.baseUrl}/quality_gates/show/${this.props.gate}`;
return <a href={url}>{this.props.children}</a>;
}
});
*/
import React from 'react';
-
export const QualityProfileLink = React.createClass({
render() {
- let url = `${window.baseUrl}/profiles/show?key=${encodeURIComponent(this.props.profile)}`;
+ const url = `${window.baseUrl}/profiles/show?key=${encodeURIComponent(this.props.profile)}`;
return <a href={url}>{this.props.children}</a>;
}
});
},
onChange(e) {
- let newValue = e.currentTarget.value;
+ const newValue = e.currentTarget.value;
this.props.onCheck(newValue);
},
renderOption(option) {
- let checked = option.value === this.props.value;
- let htmlId = this.props.name + '__' + option.value;
+ const checked = option.value === this.props.value;
+ const htmlId = this.props.name + '__' + option.value;
return (
<li key={option.value}>
<input onChange={this.onChange}
},
render() {
- let options = this.props.options.map(this.renderOption);
+ const options = this.props.options.map(this.renderOption);
return (
<ul className="radio-toggle">{options}</ul>
);
import { formatMeasure } from '../../helpers/measures';
-
export const Rating = React.createClass({
render() {
if (this.props.value == null || isNaN(this.props.value)) {
return null;
}
- let formatted = formatMeasure(this.props.value, 'RATING');
- let className = 'rating rating-' + formatted;
+ const formatted = formatMeasure(this.props.value, 'RATING');
+ const className = 'rating rating-' + formatted;
return <span className={className}>{formatted}</span>;
}
});
that.model.set('fav', false);
that.render();
});
- }
- else {
+ } else {
$.ajax({
url: API_FAVORITE,
type: 'POST',
}
});
-
return { from: Math.max(s1, s2), to: Math.min(e1, e2) };
}
-
/**
* Get the substring of a string
* @param {string} str A string
return from >= acc ? str.substr(from - acc, to - from) : str.substr(0, to - from);
}
-
/**
* Split a code html into tokens
* @param {string} code
return tokens;
}
-
/**
* Highlight issue locations in the list of tokens
* @param {Array} tokens
return tokens;
}
-
/**
* Generate an html string from the list of tokens
* @param {Array} tokens
}).join('');
}
-
/**
* Take the initial source code, split by tokens,
* highlight issues and generate result html
return generateHTML(highlightIssueLocations(splitByTokens(_code), _issueLocations, _className));
}
-
export default doTheStuff;
-
import ModalView from '../common/modals';
import Template from './templates/source-viewer-measures.hbs';
-
export default ModalView.extend({
template: Template,
testsOrder: ['ERROR', 'FAILURE', 'OK', 'SKIPPED'],
return metrics;
},
-
calcAdditionalMeasures (measures) {
if (measures.lines_to_cover && measures.uncovered_lines) {
measures.covered_lines = measures.lines_to_cover_raw - measures.uncovered_lines_raw;
return measures;
},
-
prepareMetrics (metrics) {
metrics = _.filter(metrics, function (metric) {
return metric.value != null;
);
},
-
requestMeasures () {
const that = this;
const url = window.baseUrl + '/api/resources';
}
});
-
getPermalink (e) {
e.preventDefault();
- const url = `${window.baseUrl}/component/index?id=${encodeURIComponent(this.model.key())}&line=${this.options.line}`;
+ const url =
+ `${window.baseUrl}/component/index?id=${encodeURIComponent(this.model.key())}&line=${this.options.line}`;
const windowParams = 'resizable=1,scrollbars=1,status=1';
window.open(url, this.model.get('name'), windowParams);
}
});
-
-
import ViewerView from './views/viewer-view';
import RuleView from './views/rule-view';
-
let instance = null;
const Workspace = function () {
if (instance != null) {
export default Workspace.getInstance();
-
return formatMeasure(value, formatter);
};
-
* From http://stackoverflow.com/questions/990904/javascript-remove-accents-in-strings
*/
/* eslint max-len: 0 */
+ /* jscs:disable maximumLineLength */
const defaultDiacriticsRemovalap = [
{
'base': 'A',
import _ from 'underscore';
import { translate, translateWithParameters } from './l10n';
-
/**
* Format a measure value for a given type
* @param {string|number} value
return useFormatter(value, formatter);
}
-
/**
* Format a measure variation for a given type
* @param {string|number} value
return useFormatter(value, formatter);
}
-
/**
* Return a localized metric name
* @param {string} metricKey
return translate('metric', metricKey, 'name');
}
-
/**
* Group list of metrics by their domain
* @param {Array} metrics
return _.sortBy(domains, 'domain');
}
-
/**
* Return corresponding "short" for better display in UI
* @param {string} type
return type;
}
-
/*
* Helpers
*/
return FORMATTERS[type] || noFormatter;
}
-
/*
* Formatters
*/
-
function noFormatter (value) {
return value;
}
function levelFormatter (value) {
const l10nKey = 'metric.level.' + value;
const result = translate(l10nKey);
+
// if couldn't translate, return the initial value
return l10nKey !== result ? result : value;
}
return value < 0 ? `-${formattedValue}` : `+${formattedValue}`;
}
-
/*
* Debt Formatters
*/
*/
import _ from 'underscore';
-
export function collapsePath (path, limit = 30) {
if (typeof path !== 'string') {
return '';
return body.join('/');
}
-
/**
* Return a collapsed path without a file name
* @example
}
}
-
/**
* Return a file name for a given file path
* * @example
}
}
-
export function splitPath (path) {
if (typeof path === 'string') {
const tokens = path.split('/');
credentials: 'same-origin'
};
-
/**
* Default request headers
* @type {{Accept: string}}
'Accept': 'application/json'
};
-
/**
* Create a query string from an object
* @param {object} parameters
.join('&');
}
-
/**
* Request
*/
}
}
-
/**
* Make a request
* @param {string} url
return new Request(url);
}
-
/**
* Check that response status is ok
* @param response
}
}
-
/**
* Parse response as JSON
* @param response
return response.json();
}
-
/**
* Shortcut to do a GET request and return response json
* @param url
.then(parseJSON);
}
-
/**
* Shortcut to do a POST request and return response json
* @param url
.then(parseJSON);
}
-
/**
* Shortcut to do a POST request and return response json
* @param url
.then(checkStatus);
}
-
/**
* Delay promise for testing purposes
* @param response
return window.baseUrl + '/dashboard?id=' + encodeURIComponent(componentKey);
}
-
/**
* Generate URL for a component's issues page
* @param {string} componentKey
return window.baseUrl + '/component_issues?id=' + encodeURIComponent(componentKey) + '#' + serializedQuery;
}
-
/**
* Generate URL for a component's drilldown page
* @param {string} componentKey
return `${window.baseUrl}/component_measures/metric/${metric}?id=${encodeURIComponent(componentKey)}`;
}
-
/**
* Generate URL for a component's dashboard
* @param {string} componentKey
return url;
}
-
/**
* Generate URL for a fixed component's dashboard (overview)
* @param {string} componentKey
return window.baseUrl + '/overview' + dashboardKey + '?id=' + encodeURIComponent(componentKey);
}
-
/**
* Generate URL for a component's dashboards management page
* @param {string} componentKey
// set the Backbone's $
Backbone.$ = $;
-
function requestLocalizationBundle () {
if (!window.sonarqube.bannedNavigation) {
installGlobal();
.then(startNavigation)
.then(prepareAppOptions);
-
// expose libraries
window.require = module => {
switch (module) {
import SettingsNav from './settings/settings-nav';
import { getGlobalNavigation, getComponentNavigation, getSettingsNavigation } from '../../api/nav';
-
export default class App {
start () {
- let options = window.sonarqube;
+ const options = window.sonarqube;
require('../../components/workspace/main');
return new Promise((resolve) => {
- let response = {};
- let requests = [];
+ const response = {};
+ const requests = [];
requests.push(
App.renderGlobalNav(options).then(r => response.global = r)
static renderSettingsNav (options) {
return getSettingsNavigation().then(r => {
- let el = document.getElementById('context-navigation');
- let opts = _.extend(r, options);
+ const el = document.getElementById('context-navigation');
+ const opts = _.extend(r, options);
if (el) {
ReactDOM.render(<SettingsNav {...opts}/>, el);
}
'/project/deletion'
];
-
export default React.createClass({
mixins: [LinksMixin],
isFixedDashboardActive() {
const path = window.location.pathname;
- return path.indexOf(window.baseUrl + '/overview') === 0|| path.indexOf(window.baseUrl + '/governance') === 0;
+ return path.indexOf(window.baseUrl + '/overview') === 0 || path.indexOf(window.baseUrl + '/governance') === 0;
},
isCustomDashboardActive(customDashboard) {
const path = window.location.pathname;
const params = qs.parse(window.location.search.substr(1));
- return path.indexOf(window.baseUrl + '/dashboard') === 0 && params['did'] === `${customDashboard.key}`;
+ return path.indexOf(window.baseUrl + '/dashboard') === 0 && params.did === `${customDashboard.key}`;
},
isCustomDashboardsActive () {
export default React.createClass({
render() {
- let metaList = [];
- let canSeeBackgroundTasks = this.props.conf.showBackgroundTasks;
- let backgroundTasksUrl = `${window.baseUrl}/project/background_tasks?id=${encodeURIComponent(this.props.component.key)}`;
+ const metaList = [];
+ const canSeeBackgroundTasks = this.props.conf.showBackgroundTasks;
+ const backgroundTasksUrl =
+ `${window.baseUrl}/project/background_tasks?id=${encodeURIComponent(this.props.component.key)}`;
if (this.props.isInProgress) {
- let tooltip = canSeeBackgroundTasks ?
+ const tooltip = canSeeBackgroundTasks ?
translateWithParameters('component_navigation.status.in_progress.admin', backgroundTasksUrl) :
translate('component_navigation.status.in_progress');
metaList.push(
</li>
);
} else if (this.props.isPending) {
- let tooltip = canSeeBackgroundTasks ?
+ const tooltip = canSeeBackgroundTasks ?
translateWithParameters('component_navigation.status.pending.admin', backgroundTasksUrl) :
translate('component_navigation.status.pending');
metaList.push(
</li>
);
} else if (this.props.isFailed) {
- let tooltip = canSeeBackgroundTasks ?
+ const tooltip = canSeeBackgroundTasks ?
translateWithParameters('component_navigation.status.failed.admin', backgroundTasksUrl) :
translate('component_navigation.status.failed');
metaList.push(
},
populateRecentHistory() {
- let qualifier = _.last(this.props.component.breadcrumbs).qualifier;
+ const qualifier = _.last(this.props.component.breadcrumbs).qualifier;
if (['TRK', 'VW', 'DEV'].indexOf(qualifier) !== -1) {
RecentHistory.add(this.props.component.key, this.props.component.name, qualifier.toLowerCase());
}
export default React.createClass({
renderLogo() {
- let url = this.props.logoUrl || `${window.baseUrl}/images/logo.svg`;
- let width = this.props.logoWidth || 100;
- let height = 30;
- let title = translate('layout.sonar.slogan');
+ const url = this.props.logoUrl || `${window.baseUrl}/images/logo.svg`;
+ const width = this.props.logoWidth || 100;
+ const height = 30;
+ const title = translate('layout.sonar.slogan');
return <img src={url}
width={width}
height={height}
},
renderSearchView() {
- let searchContainer = this.refs.container;
+ const searchContainer = this.refs.container;
this.searchView = new SearchView({
model: new Backbone.Model(this.props),
hide: this.closeSearch
collection.push(_.extend(item, {
q: domain.q,
extra: index === 0 ? domain.name : null,
- url: window.baseUrl + '/dashboard/index?id=' + encodeURIComponent(item.key) + window.dashboardParameters(true)
+ url: window.baseUrl + '/dashboard/index?id=' + encodeURIComponent(item.key) +
+ window.dashboardParameters(true)
}));
});
});
template: ShortcutsHelpTemplate
});
-
},
renderLink(url, title, highlightUrl = url) {
- let fullUrl = window.baseUrl + url;
- let check = _.isFunction(highlightUrl) ? highlightUrl : this.activeLink;
+ const fullUrl = window.baseUrl + url;
+ const check = _.isFunction(highlightUrl) ? highlightUrl : this.activeLink;
return (
<li key={url} className={check(highlightUrl)}>
<a href={fullUrl}>{title}</a>
},
renderNewLink(url, title, highlightUrl = url) {
- let fullUrl = window.baseUrl + url;
- let check = _.isFunction(highlightUrl) ? highlightUrl : this.activeLink;
+ const fullUrl = window.baseUrl + url;
+ const check = _.isFunction(highlightUrl) ? highlightUrl : this.activeLink;
return (
<li key={highlightUrl} className={check(highlightUrl)}>
<a href={fullUrl} className="nowrap">{title} <span className="spacer-left badge">New</span></a>
}
});
-
const processes = new Processes();
const processesView = new ProcessesView({
collection: processes
}
}
-
$.ajaxSetup({
beforeSend (jqXHR) {
jqXHR.processId = addBackgroundProcess();
}
});
-
$(function () {
processesView.render().$el.insertBefore('#footer');
});
import { translate } from '../../helpers/l10n';
-
const FACET_LIMIT = 15;
const defaultComparator = function (item) {
BaseWidget.prototype.colorsLevel = ['#d4333f', '#ff9900', '#85bb43', '##b4b4b4'];
BaseWidget.prototype.colorUnknown = '#777';
-
BaseWidget.prototype.addField = function (name, defaultValue) {
const privateName = '_' + name;
this[privateName] = defaultValue;
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+ /* jscs:disable safeContextKeyword */
import $ from 'jquery';
import { collapsedDirFromPath, fileFromPath } from '../../helpers/path';
};
};
-
window.SonarWidgets.BubbleChart.prototype.hasValidData = function () {
const widget = this;
let noInvalidEntry = true;
return !!noInvalidEntry && !!atLeastOneValueOnX && !!atLeastOneValueOnY;
};
-
window.SonarWidgets.BubbleChart.prototype.init = function (container) {
this.width(container.property('offsetWidth'));
.attr('transform', trans(this.margin().left, this.margin().top));
};
-
window.SonarWidgets.BubbleChart.prototype.initMetrics = function () {
const widget = this;
};
};
-
window.SonarWidgets.BubbleChart.prototype.initScales = function () {
const widget = this;
this
}
};
-
window.SonarWidgets.BubbleChart.prototype.initBubbles = function () {
const widget = this;
this.items = this.plotWrap.selectAll('.item')
.data(this.components());
-
// Render bubbles
this.items.enter().append('g')
.attr('class', 'item')
});
};
-
window.SonarWidgets.BubbleChart.prototype.initBubbleEvents = function () {
const widget = this;
this.items
});
};
-
window.SonarWidgets.BubbleChart.prototype.initAxes = function () {
// X
this.xAxis = d3.svg.axis()
.style('font-weight', 'bold')
.style('text-anchor', 'middle');
-
// Y
this.yAxis = d3.svg.axis()
.scale(this.y)
.style('text-anchor', 'middle');
};
-
window.SonarWidgets.BubbleChart.prototype.initGrid = function () {
this.gxGridLines = this.gxGrid.selectAll('line').data(this.x.ticks()).enter()
.append('line');
.style('stroke-opacity', 0.25);
};
-
window.SonarWidgets.BubbleChart.prototype.render = function (container) {
const containerS = container;
return this;
};
-
window.SonarWidgets.BubbleChart.prototype.adjustScalesAfterUpdate = function () {
const widget = this;
+
// X
const minX = d3.min(this.components(), function (d) {
return widget.x(widget.getXMetric(d)) - widget.size(widget.getSizeMetric(d));
const dMaxY = maxY > this.y.range()[0] ? maxY - this.y.range()[0] : 0;
this.y.range([this.availableHeight - dMaxY, dMinY]);
-
// Format improvement for log scales
// X
if (this.xLog()) {
this.y.nice();
};
-
window.SonarWidgets.BubbleChart.prototype.updateScales = function () {
const widget = this;
this.x.range([0, this.availableWidth]);
}
};
-
window.SonarWidgets.BubbleChart.prototype.updateBubbles = function () {
const widget = this;
this.items
});
};
-
window.SonarWidgets.BubbleChart.prototype.updateAxes = function () {
// X
this.gxAxis.attr('transform', trans(0, this.availableHeight + this.margin().bottom - 40));
.attr('transform', trans(-45, this.availableHeight / 2) + ' rotate(-90)');
};
-
window.SonarWidgets.BubbleChart.prototype.updateGrid = function () {
const widget = this;
this.gxGridLines
});
};
-
window.SonarWidgets.BubbleChart.prototype.update = function (container) {
container = d3.select(container);
this.updateGrid();
};
-
window.SonarWidgets.BubbleChart.defaults = {
width: 350,
height: 150,
bubbleColorUndefined: '#b3b3b3'
};
-
// Some helper functions
// Gets or sets parameter
*/
/*global d3:false */
/*jshint eqnull:true */
+/* jscs:disable safeContextKeyword */
window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
this._lineHeight = 20;
-
// Export global variables
this.metrics = function (_) {
return param.call(this, '_metrics', _);
container = d3.select(container);
-
const validData = this.components().reduce(function (p, c) {
return p && !!c.measures[widget.metricsPriority()[0]];
}, true);
return;
}
-
this.width(container.property('offsetWidth'));
this.svg = container.append('svg')
this.gWrap
.attr('transform', trans(this.margin().left, this.margin().top));
-
// Configure metrics
this.mainMetric = this.metricsPriority()[0];
this.getMainMetric = function (d) {
return d.measures[widget.mainMetric].val;
};
-
// Configure scales
this.color = d3.scale.category10();
-
// Configure arc
this.arc = d3.svg.arc()
.innerRadius(0);
-
// Configure pie
this.pie = d3.layout.pie()
.sort(null)
.value(function (d) { return widget.getMainMetric(d); });
-
// Configure legend
this.legendWrap = this.gWrap.append('g');
-
// Configure details
this._metricsCount = Object.keys(this.metrics()).length + 1;
this._detailsHeight = this._lineHeight * this._metricsCount;
.style('text-anchor', 'middle')
.text(this.metrics()[this.mainMetric].name);
-
// Update widget
this.update(containerS);
return this;
};
-
window.SonarWidgets.PieChart.prototype.updateLegend = function () {
const widget = this;
this.legendWrap
});
};
-
window.SonarWidgets.PieChart.prototype.updateDetails = function () {
const widget = this;
this.detailsWrap
.style('font-size', fz + 'px');
};
-
window.SonarWidgets.PieChart.prototype.configureEvents = function () {
const widget = this;
const updateMetrics = function (metrics) {
});
};
-
window.SonarWidgets.PieChart.prototype.update = function (container) {
container = d3.select(container);
const width = container.property('offsetWidth');
this.width(width > 100 ? width : 100);
-
// Update svg canvas
this.svg
.attr('width', this.width())
.attr('height', this.height());
-
// Update available size
this.availableWidth = this.width() - this.margin().left - this.margin().right -
this.legendWidth() - this.legendMargin();
this._legendSymbols = Math.floor((this.width() - this.margin().left - this.margin().right -
this.legendMargin() - 2 * this.radius) / 6.2);
-
// Update plot
this.plotWrap
.attr('transform', trans(this.radius, this.radius));
-
// Update arc
this.arc
.innerRadius(this.radius / 2)
.outerRadius(this.radius);
-
// Configure sectors
this.sectors = this.plotWrap.selectAll('.arc')
.data(this.pie(this.components()));
this.sectors
.exit().remove();
-
this.updateLegend();
this.updateDetails();
this.configureEvents();
};
-
window.SonarWidgets.PieChart.defaults = {
width: 350,
height: 300,
legendMargin: 30
};
-
// Some helper functions
// Gets or sets parameter
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+ /* jscs:disable safeContextKeyword */
import moment from 'moment';
window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
this.container = d3.select(container);
-
// Set default values
this._data = [];
this._metrics = [];
};
-
window.SonarWidgets.StackArea.prototype.initScales = function () {
const widget = this;
const colorsLength = widget.colors().length;
};
};
-
window.SonarWidgets.StackArea.prototype.initAxis = function () {
this.timeAxis = d3.svg.axis()
.scale(this.time)
.ticks(5);
};
-
window.SonarWidgets.StackArea.prototype.initArea = function () {
const widget = this;
this.area = d3.svg.area()
.y(function (d) { return widget.y(d.y0 + d.y); });
};
-
window.SonarWidgets.StackArea.prototype.initInfo = function () {
const widget = this;
this.infoWrap
});
};
-
window.SonarWidgets.StackArea.prototype.initEvents = function () {
const widget = this;
this.events = widget.snapshots()
.attr('class', 'event-tick')
.attr('y2', -8);
-
this.selectSnapshot = function (cl) {
const dataX = widget.data()[0][cl].x;
const sx = widget.time(dataX);
.attr('x1', sx)
.attr('x2', sx);
-
// Update metric labels
const metricsLines = widget.data().map(function (d, i) {
const value = d[cl].fy || d[cl].y;
widget.infoMetrics[i].select('text').text(d);
});
-
// Update snapshot info
this.snapshots().forEach(function (d, i) {
if (d.d - dataX === 0) {
.text(this.snapshots()[snapshotIndex].e.join(', '));
}
-
// Update info
widget.infoDate
.text(moment(widget.data()[0][cl].x).format('LL'));
widget.infoTotal
.text('Total: ' + totalValue);
-
// Update event
this.events.forEach(function (d, i) {
if (d.d - dataX === 0) {
d3.select(widget.gevents[0][eventIndex]).attr('y2', -12);
};
-
// Set event listeners
this.svg.on('mousemove', function () {
const mx = d3.mouse(widget.plotWrap.node())[0];
});
};
-
window.SonarWidgets.StackArea.prototype.render = function () {
this.svg = this.container.append('svg')
.attr('class', 'sonar-d3');
return this;
};
-
window.SonarWidgets.StackArea.prototype.update = function () {
const widget = this;
const width = this.container.property('offsetWidth');
this.width(width > 100 ? width : 100);
-
// Update svg canvas
this.svg
.attr('width', this.width())
.attr('height', this.height());
-
// Update available size
this.availableWidth = this.width() - this.margin().left - this.margin().right;
this.availableHeight = this.height() - this.margin().top - this.margin().bottom;
-
// Update scales
this.time.range([0, this.availableWidth]);
this.y.range([widget.availableHeight, 0]);
-
// Update the axis
this.gtimeAxis.attr('transform', trans(0, this.availableHeight + this.margin().bottom - 30));
this.gtimeAxis.transition().call(this.timeAxis);
-
// Update area
this.garea = this.plotWrap.selectAll('.area')
.data(this.stackData)
.style('fill', 'none')
.style('stroke', '#808080');
-
// Update scanner
this.scanner.attr('y2', this.availableHeight + 10);
-
// Update events
this.gevents
.transition()
return trans(widget.time(d.d), widget.availableHeight + 10);
});
-
// Select latest values if this it the first update
if (!this.firstUpdate) {
this.selectSnapshot(widget.data()[0].length - 1);
};
-
window.SonarWidgets.StackArea.defaults = {
width: 350,
height: 150,
margin: { top: 80, right: 10, bottom: 40, left: 40 }
};
-
// Some helper functions
// Gets or sets parameter
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+ /* jscs:disable safeContextKeyword */
import moment from 'moment';
window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
-
window.SonarWidgets.Timeline.prototype.initScalesAndAxis = function () {
// Configure scales
const timeDomain = this.data()
.ticks(5);
};
-
window.SonarWidgets.Timeline.prototype.initEvents = function () {
const widget = this;
this.events(this.events().filter(function (event) {
this.gevents.exit().remove();
-
this.selectSnapshot = function (cl) {
const sx = widget.time(widget.data()[0][cl].x);
});
};
-
// Set event listeners
this.svg.on('mousemove', function () {
const mx = d3.mouse(widget.plotWrap.node())[0];
});
};
-
window.SonarWidgets.Timeline.prototype.render = function () {
const widget = this;
widget.markers.push(marker);
});
-
// Configure scanner
this.scanner
.attr('class', 'scanner')
.attr('y1', 0);
-
// Configure info
this.infoWrap
.attr('transform', trans(0, -30));
return this;
};
-
window.SonarWidgets.Timeline.prototype.showLimitHistoryMessage = function () {
const minEvent = d3.min(this.events(), function (d) {
return d.d;
}
};
-
window.SonarWidgets.Timeline.prototype.update = function () {
const widget = this;
const width = this.container.property('offsetWidth');
this.width(width > 100 ? width : 100);
-
// Update svg canvas
this.svg
.attr('width', this.width())
.attr('height', this.height());
-
// Update available width
this.availableWidth = this.width() - this.margin().left - this.margin().right;
-
// Update metric lines
let metricY = -1;
this.infoMetrics.forEach(function (metric, i) {
// Update available width
this.availableHeight = this.height() - this.margin().top - this.margin().bottom - metricY;
-
// Update scales
this.time
.range([0, this.availableWidth]);
scale.range([widget.availableHeight, 0]);
});
-
// Update plot
this.plotWrap
.transition()
.attr('transform', trans(0, metricY));
-
// Update the axis
this.gtimeAxis.attr('transform', trans(0, this.availableHeight + this.margin().bottom - 30 + metricY));
this.gtimeAxis.transition().call(this.timeAxis);
-
// Update lines and points
this.data().forEach(function (_, i) {
widget.glines[i]
.attr('transform', function (d) { return trans(widget.time(d.x), widget.y[i](d.y)); });
});
-
// Update scanner
this.scanner
.attr('y2', this.availableHeight + 10);
-
// Update events
this.infoEvent
.attr('transform', trans(0, metricY > -1 ? metricY : 18));
.transition()
.attr('transform', function (d) { return trans(widget.time(d.d), widget.availableHeight + 10 + metricY); });
-
// Select latest values if this it the first update
if (!this.firstUpdate) {
this.selectSnapshot(widget.data()[0].length - 1);
};
-
window.SonarWidgets.Timeline.defaults = {
width: 350,
height: 150,
margin: { top: 50, right: 10, bottom: 40, left: 10 }
};
-
// Some helper functions
// Gets or sets parameter
this._height = null;
this._options = {};
-
// Export global variables
this.type = function (_) {
return param.call(this, '_type', _);
};
};
-
- window.SonarWidgets.Widget.prototype.render = function(container) {
+ window.SonarWidgets.Widget.prototype.render = function (container) {
const that = this;
this.showSpinner(container);
- d3.json(this.source(), function(error, response) {
+ d3.json(this.source(), function (error, response) {
if (response && !error) {
that.hideSpinner();
if (typeof response.components === 'undefined' || response.components.length > 0) {
});
};
-
- window.SonarWidgets.Widget.prototype.showSpinner = function(container) {
+ window.SonarWidgets.Widget.prototype.showSpinner = function (container) {
this.spinner = d3.select(container).append('i').classed('spinner', true);
};
-
- window.SonarWidgets.Widget.prototype.hideSpinner = function() {
+ window.SonarWidgets.Widget.prototype.hideSpinner = function () {
if (this.spinner) {
this.spinner.remove();
}
};
-
- window.SonarWidgets.Widget.prototype.update = function(container) {
+ window.SonarWidgets.Widget.prototype.update = function (container) {
return this.widget && this.widget.update(container);
};
-
-
// Some helper functions
// Gets or sets parameter
- function param(name, value) {
+ function param (name, value) {
if (value == null) {
return this[name];
} else {