@@ -89,7 +89,9 @@ | |||
"less-loader": "2.2.3", | |||
"path-exists": "2.1.0", | |||
"postcss-loader": "0.8.0", | |||
"prettier-eslint-cli": "^3.1.3", | |||
"prettier": "1.2.2", | |||
"prettier-eslint": "5.1.0", | |||
"prettier-eslint-cli": "3.4.1", | |||
"react-addons-test-utils": "15.4.2", | |||
"react-dev-utils": "0.2.1", | |||
"react-transform-hmr": "1.0.4", |
@@ -72,7 +72,7 @@ export function getTags(query: {}): Promise<*> { | |||
export function extractAssignees(facet: Array<{ val: string }>, response: IssuesResponse) { | |||
return facet.map(item => { | |||
const user = response.users ? response.users.find(user => user.login = item.val) : null; | |||
const user = response.users ? response.users.find(user => user.login === item.val) : null; | |||
return { ...item, user }; | |||
}); | |||
} |
@@ -34,7 +34,8 @@ export function fetchQualityGates() { | |||
...qualityGate, | |||
isDefault: qualityGate.id === r.default | |||
}; | |||
})); | |||
}) | |||
); | |||
} | |||
export function fetchQualityGate(id) { |
@@ -43,20 +43,17 @@ export function restart() { | |||
const POLLING_INTERVAL = 2000; | |||
function pollStatus(cb) { | |||
setTimeout( | |||
() => { | |||
getSystemStatus() | |||
.then(r => { | |||
if (r.status === 'UP') { | |||
cb(); | |||
} else { | |||
pollStatus(cb); | |||
} | |||
}) | |||
.catch(() => pollStatus(cb)); | |||
}, | |||
POLLING_INTERVAL | |||
); | |||
setTimeout(() => { | |||
getSystemStatus() | |||
.then(r => { | |||
if (r.status === 'UP') { | |||
cb(); | |||
} else { | |||
pollStatus(cb); | |||
} | |||
}) | |||
.catch(() => pollStatus(cb)); | |||
}, POLLING_INTERVAL); | |||
} | |||
function promiseStatus() { |
@@ -66,7 +66,8 @@ export function fetchWebApi(showInternal: boolean = true): Promise<Array<Domain> | |||
const internal = !domain.actions.find(action => !action.internal); | |||
return { ...domain, deprecated, internal }; | |||
})); | |||
}) | |||
); | |||
} | |||
export function fetchResponseExample(domain: string, action: string): Promise<{ example: string }> { |
@@ -49,7 +49,8 @@ class App extends React.PureComponent { | |||
this.props.fetchAppState(), | |||
this.props.fetchOrganizations(), | |||
this.props.fetchLanguages() | |||
])) | |||
]) | |||
) | |||
.then(this.finishLoading, this.finishLoading); | |||
} | |||
@@ -25,10 +25,8 @@ import { getCurrentUser } from '../../store/rootReducer'; | |||
class Landing extends React.PureComponent { | |||
static propTypes = { | |||
currentUser: React.PropTypes.oneOfType([ | |||
React.PropTypes.bool, | |||
React.PropTypes.object | |||
]).isRequired | |||
currentUser: React.PropTypes.oneOfType([React.PropTypes.bool, React.PropTypes.object]) | |||
.isRequired | |||
}; | |||
componentDidMount() { |
@@ -38,7 +38,7 @@ class ProjectContainer extends React.PureComponent { | |||
configuration: {}, | |||
qualifier: string | |||
}, | |||
fetchProject: (string) => Promise<*> | |||
fetchProject: string => Promise<*> | |||
}; | |||
componentDidMount() { | |||
this.fetchProject(); |
@@ -33,7 +33,7 @@ type Props = { | |||
key: string, | |||
title: string | |||
}, | |||
onFail: (string) => void, | |||
onFail: string => void, | |||
options?: {}, | |||
router: Object | |||
}; | |||
@@ -86,7 +86,7 @@ class Extension extends React.PureComponent { | |||
render() { | |||
return ( | |||
<div> | |||
<div ref={container => this.container = container} /> | |||
<div ref={container => (this.container = container)} /> | |||
</div> | |||
); | |||
} |
@@ -41,7 +41,8 @@ type Props = { | |||
function ProjectAdminPageExtension(props: Props) { | |||
const { extensionKey, pluginKey } = props.params; | |||
const { component } = props; | |||
const extension = component.configuration && | |||
const extension = | |||
component.configuration && | |||
component.configuration.extensions.find(p => p.key === `${pluginKey}/${extensionKey}`); | |||
return extension | |||
? <Extension extension={extension} options={{ component }} /> |
@@ -26,7 +26,8 @@ export default class ComponentNavMeta extends React.PureComponent { | |||
render() { | |||
const metaList = []; | |||
const canSeeBackgroundTasks = this.props.conf.showBackgroundTasks; | |||
const backgroundTasksUrl = window.baseUrl + | |||
const backgroundTasksUrl = | |||
window.baseUrl + | |||
`/project/background_tasks?id=${encodeURIComponent(this.props.component.key)}`; | |||
if (this.props.isInProgress) { |
@@ -39,8 +39,8 @@ class GlobalNavBranding extends React.PureComponent { | |||
render() { | |||
const homeController = this.props.currentUser.isLoggedIn ? '/projects' : '/about'; | |||
const homeLinkClassName = 'navbar-brand' + | |||
(this.props.customLogoUrl ? ' navbar-brand-custom' : ''); | |||
const homeLinkClassName = | |||
'navbar-brand' + (this.props.customLogoUrl ? ' navbar-brand-custom' : ''); | |||
return ( | |||
<div className="navbar-header"> | |||
<Link to={homeController} className={homeLinkClassName}>{this.renderLogo()}</Link> |
@@ -30,7 +30,7 @@ class GlobalNavUser extends React.PureComponent { | |||
name: string | |||
}, | |||
location: Object, | |||
router: { push: (string) => void } | |||
router: { push: string => void } | |||
}; | |||
handleLogin = e => { | |||
@@ -38,8 +38,8 @@ class GlobalNavUser extends React.PureComponent { | |||
const shouldReturnToCurrentPage = window.location.pathname !== `${window.baseUrl}/about`; | |||
if (shouldReturnToCurrentPage) { | |||
const returnTo = encodeURIComponent(window.location.pathname + window.location.search); | |||
window.location = window.baseUrl + | |||
`/sessions/new?return_to=${returnTo}${window.location.hash}`; | |||
window.location = | |||
window.baseUrl + `/sessions/new?return_to=${returnTo}${window.location.hash}`; | |||
} else { | |||
window.location = `${window.baseUrl}/sessions/new`; | |||
} |
@@ -126,12 +126,9 @@ export default Marionette.LayoutView.extend({ | |||
onRender() { | |||
const that = this; | |||
this.resultsRegion.show(this.resultsView); | |||
setTimeout( | |||
() => { | |||
that.$('.js-search-input').focus(); | |||
}, | |||
0 | |||
); | |||
setTimeout(() => { | |||
that.$('.js-search-input').focus(); | |||
}, 0); | |||
}, | |||
onKeyDown(e) { | |||
@@ -191,7 +188,8 @@ export default Marionette.LayoutView.extend({ | |||
const recentHistory = RecentHistory.get(); | |||
const customOrganizations = areThereCustomOrganizations(); | |||
const history = recentHistory.map((historyItem, index) => { | |||
const url = window.baseUrl + | |||
const url = | |||
window.baseUrl + | |||
'/dashboard/index?id=' + | |||
encodeURIComponent(historyItem.key) + | |||
window.dashboardParameters(true); | |||
@@ -229,7 +227,8 @@ export default Marionette.LayoutView.extend({ | |||
const collection = []; | |||
r.results.forEach(({ items, q }) => { | |||
items.forEach((item, index) => { | |||
const showOrganization = customOrganizations && | |||
const showOrganization = | |||
customOrganizations && | |||
item.organization != null && | |||
SHOW_ORGANIZATION_FOR_QUALIFIERS.includes(q); | |||
const organization = showOrganization ? getOrganization(item.organization) : null; |
@@ -20,7 +20,7 @@ | |||
import moment from 'moment'; | |||
const getPreferredLanguage = () => | |||
window.navigator.languages ? window.navigator.languages[0] : window.navigator.language; | |||
(window.navigator.languages ? window.navigator.languages[0] : window.navigator.language); | |||
const configureLocale = () => { | |||
moment.locale(getPreferredLanguage()); |
@@ -30,4 +30,4 @@ const ensureHistory = () => { | |||
return history; | |||
}; | |||
export default () => history ? history : ensureHistory(); | |||
export default () => (history ? history : ensureHistory()); |
@@ -28,4 +28,4 @@ const createStore = () => { | |||
return store; | |||
}; | |||
export default () => store ? store : createStore(); | |||
export default () => (store ? store : createStore()); |
@@ -55,7 +55,8 @@ const Process = Backbone.Model.extend({ | |||
let msg = message || translate('process.fail'); | |||
if (msg === 'process.fail') { | |||
// no translation | |||
msg = 'An error happened, some parts of the page might not render correctly. ' + | |||
msg = | |||
'An error happened, some parts of the page might not render correctly. ' + | |||
'Please contact the administrator if you keep on experiencing this error.'; | |||
} | |||
clearInterval(this.get('timer')); | |||
@@ -64,12 +65,9 @@ const Process = Backbone.Model.extend({ | |||
message: msg | |||
}); | |||
this.set('state', 'failed'); | |||
setTimeout( | |||
() => { | |||
that.finish({ force: true }); | |||
}, | |||
5000 | |||
); | |||
setTimeout(() => { | |||
that.finish({ force: true }); | |||
}, 5000); | |||
} | |||
}); | |||
@@ -123,12 +121,9 @@ function addBackgroundProcess() { | |||
const uid = uniqueId('process'); | |||
const process = new Process({ | |||
id: uid, | |||
timer: setTimeout( | |||
() => { | |||
process.timeout(); | |||
}, | |||
defaults.timeout | |||
) | |||
timer: setTimeout(() => { | |||
process.timeout(); | |||
}, defaults.timeout) | |||
}); | |||
processes.add(process); | |||
return uid; |
@@ -21,11 +21,10 @@ | |||
import { getValues } from '../../api/settings'; | |||
import { receiveValues } from '../settings/store/values/actions'; | |||
export const fetchAboutPageSettings = (): Function => | |||
(dispatch: Function): Promise<*> => { | |||
const keys = ['sonar.lf.aboutText']; | |||
export const fetchAboutPageSettings = (): Function => (dispatch: Function): Promise<*> => { | |||
const keys = ['sonar.lf.aboutText']; | |||
return getValues(keys.join()).then(values => { | |||
dispatch(receiveValues(values)); | |||
}); | |||
}; | |||
return getValues(keys.join()).then(values => { | |||
dispatch(receiveValues(values)); | |||
}); | |||
}; |
@@ -25,8 +25,8 @@ import { getRulesUrl } from '../../../helpers/urls'; | |||
const link = 'https://redirect.sonarsource.com/doc/rules.html'; | |||
const owaspTags = 'owasp-a1,owasp-a2,owasp-a3,owasp-a4,owasp-a5,' + | |||
'owasp-a6,owasp-a7,owasp-a8,owasp-a9,owasp-a10'; | |||
const owaspTags = | |||
'owasp-a1,owasp-a2,owasp-a3,owasp-a4,owasp-a5,owasp-a6,owasp-a7,owasp-a8,owasp-a9,owasp-a10'; | |||
const sans25Tags = 'sans-top25-porous,sans-top25-risky,sans-top25-insecure'; | |||
type Props = { |
@@ -21,7 +21,8 @@ const routes = [ | |||
{ | |||
getIndexRoute(_, callback) { | |||
require.ensure([], require => | |||
callback(null, { component: require('./components/AboutApp').default })); | |||
callback(null, { component: require('./components/AboutApp').default }) | |||
); | |||
} | |||
} | |||
]; |
@@ -78,7 +78,8 @@ class Projects extends React.PureComponent { | |||
value: project.key, | |||
label: project.name, | |||
organization: project.organization | |||
}))) | |||
})) | |||
) | |||
.then(options => { | |||
cb(null, { options }); | |||
}); |
@@ -28,36 +28,33 @@ import { | |||
} from '../../../store/notifications/duck'; | |||
import type { Notification } from '../../../store/notifications/duck'; | |||
export const fetchNotifications = () => | |||
(dispatch: Function) => { | |||
const onFulfil = (response: GetNotificationsResponse) => { | |||
const organizations = response.notifications | |||
.filter(n => n.organization) | |||
.map(n => n.organization); | |||
export const fetchNotifications = () => (dispatch: Function) => { | |||
const onFulfil = (response: GetNotificationsResponse) => { | |||
const organizations = response.notifications | |||
.filter(n => n.organization) | |||
.map(n => n.organization); | |||
dispatch(fetchOrganizations(organizations)).then(() => { | |||
dispatch( | |||
receiveNotifications( | |||
response.notifications, | |||
response.channels, | |||
response.globalTypes, | |||
response.perProjectTypes | |||
) | |||
); | |||
}); | |||
}; | |||
return api.getNotifications().then(onFulfil, onFail(dispatch)); | |||
dispatch(fetchOrganizations(organizations)).then(() => { | |||
dispatch( | |||
receiveNotifications( | |||
response.notifications, | |||
response.channels, | |||
response.globalTypes, | |||
response.perProjectTypes | |||
) | |||
); | |||
}); | |||
}; | |||
export const addNotification = (n: Notification) => | |||
(dispatch: Function) => | |||
api | |||
.addNotification(n.channel, n.type, n.project) | |||
.then(() => dispatch(addNotificationAction(n)), onFail(dispatch)); | |||
return api.getNotifications().then(onFulfil, onFail(dispatch)); | |||
}; | |||
export const addNotification = (n: Notification) => (dispatch: Function) => | |||
api | |||
.addNotification(n.channel, n.type, n.project) | |||
.then(() => dispatch(addNotificationAction(n)), onFail(dispatch)); | |||
export const removeNotification = (n: Notification) => | |||
(dispatch: Function) => | |||
api | |||
.removeNotification(n.channel, n.type, n.project) | |||
.then(() => dispatch(removeNotificationAction(n)), onFail(dispatch)); | |||
export const removeNotification = (n: Notification) => (dispatch: Function) => | |||
api | |||
.removeNotification(n.channel, n.type, n.project) | |||
.then(() => dispatch(removeNotificationAction(n)), onFail(dispatch)); |
@@ -41,7 +41,7 @@ class CreateOrganizationForm extends React.PureComponent { | |||
state: State; | |||
props: { | |||
createOrganization: () => Promise<*>, | |||
router: { push: (string) => void } | |||
router: { push: string => void } | |||
}; | |||
constructor(props) { |
@@ -64,11 +64,11 @@ class UserOrganizations extends React.PureComponent { | |||
render() { | |||
const title = translate('my_account.organizations') + ' - ' + translate('my_account.page'); | |||
const anyoneCanCreate = this.props.anyoneCanCreate != null && | |||
this.props.anyoneCanCreate.value === 'true'; | |||
const anyoneCanCreate = | |||
this.props.anyoneCanCreate != null && this.props.anyoneCanCreate.value === 'true'; | |||
const canCreateOrganizations = !this.state.loading && | |||
(anyoneCanCreate || isUserAdmin(this.props.currentUser)); | |||
const canCreateOrganizations = | |||
!this.state.loading && (anyoneCanCreate || isUserAdmin(this.props.currentUser)); | |||
return ( | |||
<div className="account-body account-container"> |
@@ -23,22 +23,22 @@ import { receiveMyOrganizations } from '../../../store/organizations/duck'; | |||
import { getValues } from '../../../api/settings'; | |||
import { receiveValues } from '../../settings/store/values/actions'; | |||
export const fetchMyOrganizations = (): Function => | |||
(dispatch: Function): Promise<*> => { | |||
return api.getMyOrganizations().then(keys => { | |||
if (keys.length > 0) { | |||
return api.getOrganizations(keys).then(({ organizations }) => { | |||
return dispatch(receiveMyOrganizations(organizations)); | |||
}); | |||
} else { | |||
return dispatch(receiveMyOrganizations([])); | |||
} | |||
}); | |||
}; | |||
export const fetchMyOrganizations = (): Function => (dispatch: Function): Promise<*> => { | |||
return api.getMyOrganizations().then(keys => { | |||
if (keys.length > 0) { | |||
return api.getOrganizations(keys).then(({ organizations }) => { | |||
return dispatch(receiveMyOrganizations(organizations)); | |||
}); | |||
} else { | |||
return dispatch(receiveMyOrganizations([])); | |||
} | |||
}); | |||
}; | |||
export const fetchIfAnyoneCanCreateOrganizations = (): Function => | |||
(dispatch: Function): Promise<*> => { | |||
return getValues('sonar.organizations.anyoneCanCreate').then(values => { | |||
dispatch(receiveValues(values)); | |||
}); | |||
}; | |||
export const fetchIfAnyoneCanCreateOrganizations = (): Function => ( | |||
dispatch: Function | |||
): Promise<*> => { | |||
return getValues('sonar.organizations.anyoneCanCreate').then(values => { | |||
dispatch(receiveValues(values)); | |||
}); | |||
}; |
@@ -26,7 +26,8 @@ const routes = [ | |||
{ | |||
getIndexRoute(_, callback) { | |||
require.ensure([], require => | |||
callback(null, { component: require('./profile/Profile').default })); | |||
callback(null, { component: require('./profile/Profile').default }) | |||
); | |||
} | |||
}, | |||
{ | |||
@@ -39,28 +40,32 @@ const routes = [ | |||
path: 'projects', | |||
getComponent(_, callback) { | |||
require.ensure([], require => | |||
callback(null, require('./projects/ProjectsContainer').default)); | |||
callback(null, require('./projects/ProjectsContainer').default) | |||
); | |||
} | |||
}, | |||
{ | |||
path: 'notifications', | |||
getComponent(_, callback) { | |||
require.ensure([], require => | |||
callback(null, require('./notifications/Notifications').default)); | |||
callback(null, require('./notifications/Notifications').default) | |||
); | |||
} | |||
}, | |||
{ | |||
path: 'organizations', | |||
getComponent(_, callback) { | |||
require.ensure([], require => | |||
callback(null, require('./organizations/UserOrganizations').default)); | |||
callback(null, require('./organizations/UserOrganizations').default) | |||
); | |||
}, | |||
childRoutes: [ | |||
{ | |||
path: 'create', | |||
getComponent(_, callback) { | |||
require.ensure([], require => | |||
callback(null, require('./organizations/CreateOrganizationForm').default)); | |||
callback(null, require('./organizations/CreateOrganizationForm').default) | |||
); | |||
} | |||
} | |||
] |
@@ -61,13 +61,10 @@ describe('Search', () => { | |||
const component = shallow(<Search {...defaultProps} onFilterUpdate={searchSpy} />); | |||
const searchInput = component.find('.js-search'); | |||
change(searchInput, 'some search query'); | |||
setTimeout( | |||
() => { | |||
expect(searchSpy).toBeCalledWith({ query: 'some search query' }); | |||
done(); | |||
}, | |||
DEBOUNCE_DELAY | |||
); | |||
setTimeout(() => { | |||
expect(searchSpy).toBeCalledWith({ query: 'some search query' }); | |||
done(); | |||
}, DEBOUNCE_DELAY); | |||
}); | |||
it('should reload', () => { |
@@ -43,7 +43,7 @@ import { fetchOrganizations } from '../../../store/rootActions'; | |||
type Props = { | |||
component: Object, | |||
location: Object, | |||
fetchOrganizations: (Array<string>) => string | |||
fetchOrganizations: Array<string> => string | |||
}; | |||
type State = { | |||
@@ -91,7 +91,8 @@ class BackgroundTasksApp extends React.PureComponent { | |||
componentDidUpdate(prevProps: Props) { | |||
if ( | |||
prevProps.component !== this.props.component || prevProps.location !== this.props.location | |||
prevProps.component !== this.props.component || | |||
prevProps.location !== this.props.location | |||
) { | |||
this.loadTasksDebounced(); | |||
} | |||
@@ -107,8 +108,8 @@ class BackgroundTasksApp extends React.PureComponent { | |||
const status = this.props.location.query.status || DEFAULT_FILTERS.status; | |||
const taskType = this.props.location.query.taskType || DEFAULT_FILTERS.taskType; | |||
const currents = this.props.location.query.currents || DEFAULT_FILTERS.currents; | |||
const minSubmittedAt = this.props.location.query.minSubmittedAt || | |||
DEFAULT_FILTERS.minSubmittedAt; | |||
const minSubmittedAt = | |||
this.props.location.query.minSubmittedAt || DEFAULT_FILTERS.minSubmittedAt; | |||
const maxExecutedAt = this.props.location.query.maxExecutedAt || DEFAULT_FILTERS.maxExecutedAt; | |||
const query = this.props.location.query.query || DEFAULT_FILTERS.query; | |||
@@ -22,7 +22,7 @@ import React from 'react'; | |||
import Checkbox from '../../../components/controls/Checkbox'; | |||
import { CURRENTS } from '../constants'; | |||
const CurrentsFilter = ({ value, onChange }: { value: ?string, onChange: (string) => void }) => { | |||
const CurrentsFilter = ({ value, onChange }: { value: ?string, onChange: string => void }) => { | |||
function handleChange(value) { | |||
const newValue = value ? CURRENTS.ONLY_CURRENTS : CURRENTS.ALL; | |||
onChange(newValue); |
@@ -21,9 +21,11 @@ | |||
import moment from 'moment'; | |||
import React from 'react'; | |||
const TaskDate = ( | |||
{ date, baseDate, format }: { date: string, baseDate: string, format: string } | |||
) => { | |||
const TaskDate = ({ | |||
date, | |||
baseDate, | |||
format | |||
}: { date: string, baseDate: string, format: string }) => { | |||
const m = moment(date); | |||
const baseM = moment(baseDate); | |||
const diff = date && baseDate ? m.diff(baseM, 'days') : 0; |
@@ -23,9 +23,11 @@ import Select from 'react-select'; | |||
import { ALL_TYPES } from '../constants'; | |||
import { translate } from '../../../helpers/l10n'; | |||
const TypesFilter = ( | |||
{ value, onChange, types }: { value: string, onChange: Function, types: string[] } | |||
) => { | |||
const TypesFilter = ({ | |||
value, | |||
onChange, | |||
types | |||
}: { value: string, onChange: Function, types: string[] }) => { | |||
const options = types.map(t => { | |||
return { | |||
value: t, |
@@ -21,7 +21,8 @@ const routes = [ | |||
{ | |||
getIndexRoute(_, callback) { | |||
require.ensure([], require => | |||
callback(null, { component: require('./components/BackgroundTasksApp').default })); | |||
callback(null, { component: require('./components/BackgroundTasksApp').default }) | |||
); | |||
} | |||
} | |||
]; |
@@ -22,7 +22,7 @@ import { STATUSES, ALL_TYPES, CURRENTS } from './constants'; | |||
import { Task } from './types'; | |||
export function updateTask(tasks: Task[], newTask: Task) { | |||
return tasks.map(task => task.id === newTask.id ? newTask : task); | |||
return tasks.map(task => (task.id === newTask.id ? newTask : task)); | |||
} | |||
export function mapFiltersToParameters(filters: Object = {}) { |
@@ -89,8 +89,8 @@ class App extends React.PureComponent { | |||
loadComponent(componentKey) { | |||
this.setState({ loading: true }); | |||
const isView = this.props.component.qualifier === 'VW' || | |||
this.props.component.qualifier === 'SVW'; | |||
const isView = | |||
this.props.component.qualifier === 'VW' || this.props.component.qualifier === 'SVW'; | |||
retrieveComponent(componentKey, isView) | |||
.then(r => { | |||
if (this.mounted) { | |||
@@ -133,8 +133,8 @@ class App extends React.PureComponent { | |||
handleLoadMore() { | |||
const { baseComponent, page } = this.state; | |||
const isView = this.props.component.qualifier === 'VW' || | |||
this.props.component.qualifier === 'SVW'; | |||
const isView = | |||
this.props.component.qualifier === 'VW' || this.props.component.qualifier === 'SVW'; | |||
loadMoreChildren(baseComponent.key, page + 1, isView) | |||
.then(r => { | |||
if (this.mounted) { |
@@ -42,12 +42,9 @@ export default class Component extends React.PureComponent { | |||
// scroll viewport so the current selected component is visible | |||
if (selected) { | |||
setTimeout( | |||
() => { | |||
this.handleScroll(); | |||
}, | |||
0 | |||
); | |||
setTimeout(() => { | |||
this.handleScroll(); | |||
}, 0); | |||
} | |||
} | |||
@@ -27,7 +27,8 @@ const ComponentMeasure = ({ component, metricKey, metricType }) => { | |||
const finalMetricKey = isProject && isReleasability ? 'alert_status' : metricKey; | |||
const finalMetricType = isProject && isReleasability ? 'LEVEL' : metricType; | |||
const measure = Array.isArray(component.measures) && | |||
const measure = | |||
Array.isArray(component.measures) && | |||
component.measures.find(measure => measure.metric === finalMetricKey); | |||
if (!measure) { |
@@ -21,7 +21,8 @@ const routes = [ | |||
{ | |||
getIndexRoute(_, callback) { | |||
require.ensure([], require => | |||
callback(null, { component: require('./components/App').default })); | |||
callback(null, { component: require('./components/App').default }) | |||
); | |||
} | |||
} | |||
]; |
@@ -35,7 +35,7 @@ class CodingRulesAppContainer extends React.PureComponent { | |||
organizationKey?: string | |||
}, | |||
router: { | |||
replace: (string) => void | |||
replace: string => void | |||
} | |||
}; | |||
@@ -39,7 +39,7 @@ export default BaseFacet.extend({ | |||
const languages = languagesQuery != null ? languagesQuery.split(',') : []; | |||
const lang = languages.length === 1 ? languages[0] : null; | |||
const values = this.options.app.qualityProfiles | |||
.filter(profile => lang != null ? profile.lang === lang : true) | |||
.filter(profile => (lang != null ? profile.lang === lang : true)) | |||
.map(profile => ({ | |||
label: profile.name, | |||
extra: that.options.app.languages[profile.lang], |
@@ -44,7 +44,7 @@ export default CustomValuesFacet.extend({ | |||
getLabelsSource() { | |||
const source = {}; | |||
this.options.app.repositories.forEach(repo => source[repo.key] = repo.name); | |||
this.options.app.repositories.forEach(repo => (source[repo.key] = repo.name)); | |||
return source; | |||
}, | |||
@@ -36,11 +36,13 @@ import FiltersView from './filters-view'; | |||
const App = new Marionette.Application(); | |||
App.on('start', function(options: { | |||
el: HTMLElement, | |||
organization: ?string, | |||
isDefaultOrganization: boolean | |||
}) { | |||
App.on('start', function( | |||
options: { | |||
el: HTMLElement, | |||
organization: ?string, | |||
isDefaultOrganization: boolean | |||
} | |||
) { | |||
const data = options.organization ? { organization: options.organization } : {}; | |||
$.get(window.baseUrl + '/api/rules/app', data) | |||
.done(r => { |
@@ -85,10 +85,10 @@ export default ModalFormView.extend({ | |||
return `<i class="icon-severity-${state.id.toLowerCase()}"></i> ${state.text}`; | |||
} | |||
}; | |||
const severity = (this.model && this.model.get('severity')) || | |||
this.options.templateRule.get('severity'); | |||
const status = (this.model && this.model.get('status')) || | |||
this.options.templateRule.get('status'); | |||
const severity = | |||
(this.model && this.model.get('severity')) || this.options.templateRule.get('severity'); | |||
const status = | |||
(this.model && this.model.get('status')) || this.options.templateRule.get('status'); | |||
this.ui.customRuleCreationSeverity.val(severity); | |||
this.ui.customRuleCreationSeverity.select2({ |
@@ -60,8 +60,8 @@ export default ModalForm.extend({ | |||
return `<i class="icon-severity-${state.id.toLowerCase()}"></i> ${state.text}`; | |||
} | |||
}; | |||
const severity = (this.model && this.model.get('severity')) || | |||
this.options.rule.get('severity'); | |||
const severity = | |||
(this.model && this.model.get('severity')) || this.options.rule.get('severity'); | |||
this.ui.qualityProfileSeverity.val(severity); | |||
this.ui.qualityProfileSeverity.select2({ | |||
width: '250px', | |||
@@ -69,12 +69,9 @@ export default ModalForm.extend({ | |||
formatResult: format, | |||
formatSelection: format | |||
}); | |||
setTimeout( | |||
() => { | |||
that.$('a').first().focus(); | |||
}, | |||
0 | |||
); | |||
setTimeout(() => { | |||
that.$('a').first().focus(); | |||
}, 0); | |||
}, | |||
activate(e) { |
@@ -129,8 +129,8 @@ export default Marionette.ItemView.extend({ | |||
} | |||
const parentKey = myProfile.parentKey; | |||
const parent = { ...this.options.app.qualityProfiles.find(p => p.key === parentKey) }; | |||
const parentActiveInfo = this.model.collection.findWhere({ qProfile: parentKey }) || | |||
new Backbone.Model(); | |||
const parentActiveInfo = | |||
this.model.collection.findWhere({ qProfile: parentKey }) || new Backbone.Model(); | |||
Object.assign(parent, parentActiveInfo.toJSON()); | |||
return parent; | |||
}, |
@@ -29,9 +29,7 @@ export default function IconBubbles() { | |||
clipRule="evenodd" | |||
strokeLinejoin="round" | |||
strokeMiterlimit="1.414"> | |||
<path | |||
d="M352 256c52.984 0 96 43.016 96 96s-43.016 96-96 96-96-43.016-96-96 43.016-96 96-96zM128 96c70.645 0 128 57.355 128 128 0 70.645-57.355 128-128 128C57.355 352 0 294.645 0 224 0 153.355 57.355 96 128 96zM352 0c52.984 0 96 43.016 96 96s-43.016 96-96 96-96-43.016-96-96 43.016-96 96-96z" | |||
/> | |||
<path d="M352 256c52.984 0 96 43.016 96 96s-43.016 96-96 96-96-43.016-96-96 43.016-96 96-96zM128 96c70.645 0 128 57.355 128 128 0 70.645-57.355 128-128 128C57.355 352 0 294.645 0 224 0 153.355 57.355 96 128 96zM352 0c52.984 0 96 43.016 96 96s-43.016 96-96 96-96-43.016-96-96 43.016-96 96-96z" /> | |||
</svg> | |||
); | |||
} |
@@ -29,9 +29,7 @@ export default function IconHistory() { | |||
clipRule="evenodd" | |||
strokeLinejoin="round" | |||
strokeMiterlimit="1.414"> | |||
<path | |||
d="M512 384v32H0V32h32v352h480zM480 72v108.75q0 5.25-4.875 7.375t-8.875-1.875L436 156 277.75 314.25q-2.5 2.5-5.75 2.5t-5.75-2.5L208 256 104 360l-48-48 146.25-146.25q2.5-2.5 5.75-2.5t5.75 2.5L272 224l116-116-30.25-30.25q-4-4-1.875-8.875T363.25 64H472q3.5 0 5.75 2.25T480 72z" | |||
/> | |||
<path d="M512 384v32H0V32h32v352h480zM480 72v108.75q0 5.25-4.875 7.375t-8.875-1.875L436 156 277.75 314.25q-2.5 2.5-5.75 2.5t-5.75-2.5L208 256 104 360l-48-48 146.25-146.25q2.5-2.5 5.75-2.5t5.75 2.5L272 224l116-116-30.25-30.25q-4-4-1.875-8.875T363.25 64H472q3.5 0 5.75 2.25T480 72z" /> | |||
</svg> | |||
); | |||
} |
@@ -29,9 +29,7 @@ export default function ListIcon() { | |||
clipRule="evenodd" | |||
strokeLinejoin="round" | |||
strokeMiterlimit="1.414"> | |||
<path | |||
d="M448 48c0-8.83-7.17-16-16-16H16C7.17 32 0 39.17 0 48v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16V48zM448 144c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32zM448 240c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32zM448 336.03c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32z" | |||
/> | |||
<path d="M448 48c0-8.83-7.17-16-16-16H16C7.17 32 0 39.17 0 48v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16V48zM448 144c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32zM448 240c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32zM448 336.03c0-8.83-7.17-16-16-16H16c-8.83 0-16 7.17-16 16v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16v-32z" /> | |||
</svg> | |||
); | |||
} |
@@ -29,9 +29,7 @@ export default function IconTree() { | |||
clipRule="evenodd" | |||
strokeLinejoin="round" | |||
strokeMiterlimit="1.414"> | |||
<path | |||
d="M448 48c0-8.83-7.17-16-16-16H16C7.17 32 0 39.17 0 48v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16V48zM448 144c0-8.83-6.146-16-13.714-16H77.714C70.144 128 64 135.17 64 144v32c0 8.83 6.145 16 13.714 16h356.572c7.568 0 13.714-7.17 13.714-16v-32zM448 240c0-8.83-5.12-16-11.428-16H139.428C133.12 224 128 231.17 128 240v32c0 8.83 5.12 16 11.428 16h297.144c6.307 0 11.428-7.17 11.428-16v-32zM448 336.03c0-8.83-4.097-16-9.142-16H201.143c-5.046 0-9.143 7.17-9.143 16v32c0 8.83 4.097 16 9.143 16h237.715c5.045 0 9.142-7.17 9.142-16v-32z" | |||
/> | |||
<path d="M448 48c0-8.83-7.17-16-16-16H16C7.17 32 0 39.17 0 48v32c0 8.83 7.17 16 16 16h416c8.83 0 16-7.17 16-16V48zM448 144c0-8.83-6.146-16-13.714-16H77.714C70.144 128 64 135.17 64 144v32c0 8.83 6.145 16 13.714 16h356.572c7.568 0 13.714-7.17 13.714-16v-32zM448 240c0-8.83-5.12-16-11.428-16H139.428C133.12 224 128 231.17 128 240v32c0 8.83 5.12 16 11.428 16h297.144c6.307 0 11.428-7.17 11.428-16v-32zM448 336.03c0-8.83-4.097-16-9.142-16H201.143c-5.046 0-9.143 7.17-9.143 16v32c0 8.83 4.097 16 9.143 16h237.715c5.045 0 9.142-7.17 9.142-16v-32z" /> | |||
</svg> | |||
); | |||
} |
@@ -88,9 +88,9 @@ export default class MeasureHistory extends React.PureComponent { | |||
return Promise.resolve([]); | |||
} | |||
return getProjectActivity(this.props.component.key, { category: 'VERSION' }).then(({ | |||
analyses | |||
}) => { | |||
return getProjectActivity(this.props.component.key, { | |||
category: 'VERSION' | |||
}).then(({ analyses }) => { | |||
const events = analyses.map(analysis => { | |||
const version = analysis.events.find(event => event.category === 'VERSION'); | |||
return { version: version.name, date: moment(analysis.date).toDate() }; |
@@ -55,7 +55,8 @@ const HomeMeasuresList = ({ domain, component }) => { | |||
const configMain = config.main || []; | |||
const [mainMeasures, otherMeasures] = partition(filteredMeasures, measure => | |||
configMain.includes(measure.metric.key)); | |||
configMain.includes(measure.metric.key) | |||
); | |||
const configOrder = config.order || []; | |||
const sortedMainMeasures = sortMeasures(mainMeasures, configOrder); |
@@ -49,7 +49,8 @@ function groupByDomains(measures) { | |||
'name' | |||
); | |||
const [knownDomains, unknownDomains] = partition(domains, domain => | |||
KNOWN_DOMAINS.includes(domain.name)); | |||
KNOWN_DOMAINS.includes(domain.name) | |||
); | |||
return [ | |||
...sortBy(knownDomains, domain => KNOWN_DOMAINS.indexOf(domain.name)), | |||
...sortBy(unknownDomains, domain => domain.name) |
@@ -31,14 +31,16 @@ const routes = [ | |||
{ | |||
getIndexRoute(_, callback) { | |||
require.ensure([], require => | |||
callback(null, { component: require('./home/AllMeasuresContainer').default })); | |||
callback(null, { component: require('./home/AllMeasuresContainer').default }) | |||
); | |||
} | |||
}, | |||
{ | |||
path: 'domain/:domainName', | |||
getComponent(_, callback) { | |||
require.ensure([], require => | |||
callback(null, require('./home/DomainMeasuresContainer').default)); | |||
callback(null, require('./home/DomainMeasuresContainer').default) | |||
); | |||
} | |||
} | |||
] | |||
@@ -47,7 +49,8 @@ const routes = [ | |||
path: 'metric/:metricKey', | |||
getComponent(_, callback) { | |||
require.ensure([], require => | |||
callback(null, require('./details/MeasureDetailsContainer').default)); | |||
callback(null, require('./details/MeasureDetailsContainer').default) | |||
); | |||
}, | |||
childRoutes: [ | |||
{ | |||
@@ -65,28 +68,32 @@ const routes = [ | |||
path: 'list', | |||
getComponent(_, callback) { | |||
require.ensure([], require => | |||
callback(null, require('./details/drilldown/ListViewContainer').default)); | |||
callback(null, require('./details/drilldown/ListViewContainer').default) | |||
); | |||
} | |||
}, | |||
{ | |||
path: 'tree', | |||
getComponent(_, callback) { | |||
require.ensure([], require => | |||
callback(null, require('./details/drilldown/TreeViewContainer').default)); | |||
callback(null, require('./details/drilldown/TreeViewContainer').default) | |||
); | |||
} | |||
}, | |||
{ | |||
path: 'history', | |||
getComponent(_, callback) { | |||
require.ensure([], require => | |||
callback(null, require('./details/history/MeasureHistoryContainer').default)); | |||
callback(null, require('./details/history/MeasureHistoryContainer').default) | |||
); | |||
} | |||
}, | |||
{ | |||
path: 'treemap', | |||
getComponent(_, callback) { | |||
require.ensure([], require => | |||
callback(null, require('./details/treemap/MeasureTreemapContainer').default)); | |||
callback(null, require('./details/treemap/MeasureTreemapContainer').default) | |||
); | |||
} | |||
} | |||
] |
@@ -21,7 +21,8 @@ const routes = [ | |||
{ | |||
getIndexRoute(_, callback) { | |||
require.ensure([], require => | |||
callback(null, { component: require('./components/CustomMeasuresAppContainer').default })); | |||
callback(null, { component: require('./components/CustomMeasuresAppContainer').default }) | |||
); | |||
} | |||
} | |||
]; |
@@ -39,8 +39,8 @@ export default Marionette.CompositeView.extend({ | |||
this.$el.removeClass('new-loading'); | |||
const query = this.collection.q || ''; | |||
const shouldHideAnyone = this.collection.organization || | |||
!'anyone'.includes(query.toLowerCase()); | |||
const shouldHideAnyone = | |||
this.collection.organization || !'anyone'.includes(query.toLowerCase()); | |||
this.$('.js-anyone').toggleClass('hidden', shouldHideAnyone); | |||
}, | |||
@@ -65,7 +65,7 @@ type Props = { | |||
currentUser: CurrentUser, | |||
fetchIssues: () => Promise<*>, | |||
location: { pathname: string, query: { [string]: string } }, | |||
onRequestFail: (Error) => void, | |||
onRequestFail: Error => void, | |||
router: { push: () => void, replace: () => void } | |||
}; | |||
@@ -404,7 +404,8 @@ export default class App extends React.PureComponent { | |||
getCheckedIssues = () => { | |||
const issues = this.state.checked.map(checked => | |||
this.state.issues.find(issue => issue.key === checked)); | |||
this.state.issues.find(issue => issue.key === checked) | |||
); | |||
const paging = { pageIndex: 1, pageSize: issues.length, total: issues.length }; | |||
return Promise.resolve({ issues, paging }); | |||
}; | |||
@@ -465,7 +466,7 @@ export default class App extends React.PureComponent { | |||
handleIssueChange = (issue: Issue) => { | |||
this.setState(state => ({ | |||
issues: state.issues.map(candidate => candidate.key === issue.key ? issue : candidate) | |||
issues: state.issues.map(candidate => (candidate.key === issue.key ? issue : candidate)) | |||
})); | |||
}; | |||
@@ -36,16 +36,13 @@ const mapStateToProps = (state, ownProps) => ({ | |||
currentUser: getCurrentUser(state) | |||
}); | |||
const fetchIssues = (query: Query) => | |||
(dispatch: Dispatch<*>) => | |||
searchIssues({ ...query, additionalFields: '_all' }).then( | |||
response => { | |||
const parsedIssues = response.issues.map(issue => | |||
parseIssueFromResponse(issue, response.components, response.users, response.rules)); | |||
return { ...response, issues: parsedIssues }; | |||
}, | |||
onFail(dispatch) | |||
const fetchIssues = (query: Query) => (dispatch: Dispatch<*>) => | |||
searchIssues({ ...query, additionalFields: '_all' }).then(response => { | |||
const parsedIssues = response.issues.map(issue => | |||
parseIssueFromResponse(issue, response.components, response.users, response.rules) | |||
); | |||
return { ...response, issues: parsedIssues }; | |||
}, onFail(dispatch)); | |||
const onRequestFail = (error: Error) => (dispatch: Dispatch<*>) => onFail(dispatch)(error); | |||
@@ -42,7 +42,7 @@ type Props = {| | |||
fetchIssues: ({}) => Promise<*>, | |||
onClose: () => void, | |||
onDone: () => void, | |||
onRequestFail: (Error) => void | |||
onRequestFail: Error => void | |||
|}; | |||
type State = {| | |||
@@ -65,8 +65,8 @@ type State = {| | |||
type?: string | |||
|}; | |||
const hasAction = (action: string) => | |||
(issue: Issue): boolean => issue.actions && issue.actions.includes(action); | |||
const hasAction = (action: string) => (issue: Issue): boolean => | |||
issue.actions && issue.actions.includes(action); | |||
export default class BulkChangeModal extends React.PureComponent { | |||
mounted: boolean; | |||
@@ -115,9 +115,8 @@ export default class BulkChangeModal extends React.PureComponent { | |||
const options = []; | |||
if (currentUser.isLoggedIn) { | |||
const canBeAssignedToMe = issues.filter( | |||
issue => issue.assignee !== currentUser.login | |||
).length > 0; | |||
const canBeAssignedToMe = | |||
issues.filter(issue => issue.assignee !== currentUser.login).length > 0; | |||
if (canBeAssignedToMe) { | |||
options.push({ | |||
email: currentUser.email, | |||
@@ -140,29 +139,25 @@ export default class BulkChangeModal extends React.PureComponent { | |||
this.setState({ assignee }); | |||
}; | |||
handleFieldCheck = (field: string) => | |||
(checked: boolean) => { | |||
if (!checked) { | |||
this.setState({ [field]: undefined }); | |||
} else if (field === 'notifications') { | |||
this.setState({ [field]: true }); | |||
} | |||
}; | |||
handleFieldCheck = (field: string) => (checked: boolean) => { | |||
if (!checked) { | |||
this.setState({ [field]: undefined }); | |||
} else if (field === 'notifications') { | |||
this.setState({ [field]: true }); | |||
} | |||
}; | |||
handleFieldChange = (field: string) => | |||
(event: { target: HTMLInputElement }) => { | |||
this.setState({ [field]: event.target.value }); | |||
}; | |||
handleFieldChange = (field: string) => (event: { target: HTMLInputElement }) => { | |||
this.setState({ [field]: event.target.value }); | |||
}; | |||
handleSelectFieldChange = (field: string) => | |||
({ value }: { value: string }) => { | |||
this.setState({ [field]: value }); | |||
}; | |||
handleSelectFieldChange = (field: string) => ({ value }: { value: string }) => { | |||
this.setState({ [field]: value }); | |||
}; | |||
handleMultiSelectFieldChange = (field: string) => | |||
(options: Array<{ value: string }>) => { | |||
this.setState({ [field]: options.map(option => option.value) }); | |||
}; | |||
handleMultiSelectFieldChange = (field: string) => (options: Array<{ value: string }>) => { | |||
this.setState({ [field]: options.map(option => option.value) }); | |||
}; | |||
handleSubmit = (e: Event) => { | |||
e.preventDefault(); | |||
@@ -473,8 +468,8 @@ export default class BulkChangeModal extends React.PureComponent { | |||
renderForm = () => { | |||
const { issues, paging, submitting } = this.state; | |||
const limitReached: boolean = paging != null && | |||
paging.total > paging.pageIndex * paging.pageSize; | |||
const limitReached: boolean = | |||
paging != null && paging.total > paging.pageIndex * paging.pageSize; | |||
return ( | |||
<form id="bulk-change-form" onSubmit={this.handleSubmit}> |
@@ -37,8 +37,8 @@ export default class ComponentBreadcrumbs extends React.PureComponent { | |||
const { component, issue } = this.props; | |||
const displayOrganization = component == null || ['VW', 'SVW'].includes(component.qualifier); | |||
const displayProject = component == null || | |||
!['TRK', 'BRC', 'DIR'].includes(component.qualifier); | |||
const displayProject = | |||
component == null || !['TRK', 'BRC', 'DIR'].includes(component.qualifier); | |||
const displaySubProject = component == null || !['BRC', 'DIR'].includes(component.qualifier); | |||
return ( |
@@ -28,9 +28,9 @@ type Props = {| | |||
component?: Component, | |||
issues: Array<Issue>, | |||
onFilterChange: (changes: {}) => void, | |||
onIssueChange: (Issue) => void, | |||
onIssueCheck?: (string) => void, | |||
onIssueClick: (string) => void, | |||
onIssueChange: Issue => void, | |||
onIssueCheck?: string => void, | |||
onIssueClick: string => void, | |||
selectedIssue: ?Issue | |||
|}; | |||
@@ -25,8 +25,8 @@ import type { Issue } from '../../../components/issue/types'; | |||
type Props = {| | |||
loadIssues: () => Promise<*>, | |||
onIssueChange: (Issue) => void, | |||
onIssueSelect: (string) => void, | |||
onIssueChange: Issue => void, | |||
onIssueSelect: string => void, | |||
openIssue: Issue | |||
|}; | |||
@@ -51,7 +51,7 @@ export default class IssuesSourceViewer extends React.PureComponent { | |||
const { openIssue } = this.props; | |||
return ( | |||
<div ref={node => this.node = node}> | |||
<div ref={node => (this.node = node)}> | |||
<SourceViewer | |||
aroundLine={openIssue.line} | |||
component={openIssue.component} |
@@ -28,9 +28,9 @@ type Props = {| | |||
checked: boolean, | |||
component?: Component, | |||
issue: IssueType, | |||
onChange: (IssueType) => void, | |||
onCheck?: (string) => void, | |||
onClick: (string) => void, | |||
onChange: IssueType => void, | |||
onCheck?: string => void, | |||
onClick: string => void, | |||
onFilterChange: (changes: {}) => void, | |||
previousIssue: ?Object, | |||
selected: boolean |
@@ -24,18 +24,17 @@ import { translate } from '../../../helpers/l10n'; | |||
type Props = {| | |||
myIssues: boolean, | |||
onMyIssuesChange: (boolean) => void | |||
onMyIssuesChange: boolean => void | |||
|}; | |||
export default class MyIssuesFilter extends React.PureComponent { | |||
props: Props; | |||
handleClick = (myIssues: boolean) => | |||
(e: Event & { currentTarget: HTMLElement }) => { | |||
e.preventDefault(); | |||
e.currentTarget.blur(); | |||
this.props.onMyIssuesChange(myIssues); | |||
}; | |||
handleClick = (myIssues: boolean) => (e: Event & { currentTarget: HTMLElement }) => { | |||
e.preventDefault(); | |||
e.currentTarget.blur(); | |||
this.props.onMyIssuesChange(myIssues); | |||
}; | |||
render() { | |||
const { myIssues } = this.props; |
@@ -26,7 +26,8 @@ const routes = [ | |||
callback(null, { | |||
component: require('./components/AppContainer').default, | |||
onEnter | |||
})); | |||
}) | |||
); | |||
} | |||
} | |||
]; |
@@ -127,7 +127,7 @@ export default class AssigneeFacet extends React.PureComponent { | |||
const assignees = sortBy( | |||
Object.keys(stats), | |||
// put unassigned first | |||
key => key === '' ? 0 : 1, | |||
key => (key === '' ? 0 : 1), | |||
// the sort by number | |||
key => -stats[key] | |||
); |
@@ -70,38 +70,36 @@ export default class CreationDateFacet extends React.PureComponent { | |||
}); | |||
}; | |||
handleBarClick = ( | |||
{ createdAfter, createdBefore }: { createdAfter: Object, createdBefore?: Object } | |||
) => { | |||
handleBarClick = ({ | |||
createdAfter, | |||
createdBefore | |||
}: { createdAfter: Object, createdBefore?: Object }) => { | |||
this.resetTo({ | |||
createdAfter: createdAfter.format(DATE_FORMAT), | |||
createdBefore: createdBefore && createdBefore.format(DATE_FORMAT) | |||
}); | |||
}; | |||
handlePeriodChange = (property: string) => | |||
(value: string) => { | |||
this.props.onChange({ | |||
createdAt: undefined, | |||
createdInLast: undefined, | |||
sinceLeakPeriod: undefined, | |||
[property]: value | |||
}); | |||
}; | |||
handlePeriodClick = (period?: string) => | |||
(e: Event & { target: HTMLElement }) => { | |||
e.preventDefault(); | |||
e.target.blur; | |||
this.resetTo({ createdInLast: period }); | |||
}; | |||
handleLeakPeriodClick = () => | |||
(e: Event & { target: HTMLElement }) => { | |||
e.preventDefault(); | |||
e.target.blur; | |||
this.resetTo({ sinceLeakPeriod: true }); | |||
}; | |||
handlePeriodChange = (property: string) => (value: string) => { | |||
this.props.onChange({ | |||
createdAt: undefined, | |||
createdInLast: undefined, | |||
sinceLeakPeriod: undefined, | |||
[property]: value | |||
}); | |||
}; | |||
handlePeriodClick = (period?: string) => (e: Event & { target: HTMLElement }) => { | |||
e.preventDefault(); | |||
e.target.blur; | |||
this.resetTo({ createdInLast: period }); | |||
}; | |||
handleLeakPeriodClick = () => (e: Event & { target: HTMLElement }) => { | |||
e.preventDefault(); | |||
e.target.blur; | |||
this.resetTo({ sinceLeakPeriod: true }); | |||
}; | |||
renderBarChart() { | |||
const { createdBefore, stats } = this.props; | |||
@@ -123,9 +121,8 @@ export default class CreationDateFacet extends React.PureComponent { | |||
: createdBefore ? moment(createdBefore) : undefined; | |||
const endMoment = nextStartMoment && nextStartMoment.clone().subtract(1, 'days'); | |||
let tooltip = formatMeasure(stats[startDate], 'SHORT_INT') + | |||
'<br>' + | |||
startMoment.format('LL'); | |||
let tooltip = | |||
formatMeasure(stats[startDate], 'SHORT_INT') + '<br>' + startMoment.format('LL'); | |||
if (endMoment) { | |||
const isSameDay = endMoment.diff(startMoment, 'days') <= 1; | |||
@@ -149,7 +146,7 @@ export default class CreationDateFacet extends React.PureComponent { | |||
const maxValue = max(data.map(d => d.y)); | |||
const format = this.props.facetMode === 'count' ? 'SHORT_INT' : 'SHORT_WORK_DUR'; | |||
const xValues = data.map(d => d.y === maxValue ? formatMeasure(maxValue, format) : ''); | |||
const xValues = data.map(d => (d.y === maxValue ? formatMeasure(maxValue, format) : '')); | |||
return ( | |||
<BarChart | |||
@@ -248,7 +245,8 @@ export default class CreationDateFacet extends React.PureComponent { | |||
} | |||
render() { | |||
const hasValue = this.props.createdAfter.length > 0 || | |||
const hasValue = | |||
this.props.createdAfter.length > 0 || | |||
this.props.createdAt.length > 0 || | |||
this.props.createdBefore.length > 0 || | |||
this.props.createdInLast.length > 0 || |
@@ -72,13 +72,15 @@ export default class ProjectFacet extends React.PureComponent { | |||
label: component.name, | |||
organization: component.organization, | |||
value: component.refId | |||
}))) | |||
})) | |||
) | |||
: searchComponents({ ps: 50, q: query, qualifiers: 'TRK' }).then(response => | |||
response.components.map(component => ({ | |||
label: component.name, | |||
organization: component.organization, | |||
value: component.id | |||
}))); | |||
})) | |||
); | |||
}; | |||
handleSelect = (rule: string) => { |
@@ -67,7 +67,8 @@ export default class RuleFacet extends React.PureComponent { | |||
languages: languages.length ? languages.join() : undefined, | |||
q: query | |||
}).then(response => | |||
response.rules.map(rule => ({ label: `(${rule.langName}) ${rule.name}`, value: rule.key }))); | |||
response.rules.map(rule => ({ label: `(${rule.langName}) ${rule.name}`, value: rule.key })) | |||
); | |||
}; | |||
handleSelect = (rule: string) => { |
@@ -63,8 +63,8 @@ export default class Sidebar extends React.PureComponent { | |||
render() { | |||
const { component, facets, openFacets, query } = this.props; | |||
const displayProjectsFacet: boolean = component == null || | |||
!['TRK', 'BRC', 'DIR', 'DEV_PRJ'].includes(component.qualifier); | |||
const displayProjectsFacet: boolean = | |||
component == null || !['TRK', 'BRC', 'DIR', 'DEV_PRJ'].includes(component.qualifier); | |||
const displayModulesFacet = component == null || component.qualifier !== 'DIR'; | |||
const displayDirectoriesFacet = component == null || component.qualifier !== 'DIR'; | |||
const displayAuthorFacet = component == null || component.qualifier !== 'DEV'; |
@@ -60,7 +60,8 @@ export default class TagFacet extends React.PureComponent { | |||
handleSearch = (query: string) => { | |||
return searchIssueTags({ ps: 50, q: query }).then(tags => | |||
tags.map(tag => ({ label: tag, value: tag }))); | |||
tags.map(tag => ({ label: tag, value: tag })) | |||
); | |||
}; | |||
handleSelect = (tag: string) => { |
@@ -28,7 +28,7 @@ type Props = {| | |||
facetMode: string, | |||
halfWidth: boolean, | |||
name: string | React.Element<*>, | |||
onClick: (string) => void, | |||
onClick: string => void, | |||
stat: ?number, | |||
value: string | |||
|}; | |||
@@ -55,7 +55,8 @@ export default class FacetItem extends React.PureComponent { | |||
'search-navigator-facet-half': this.props.halfWidth | |||
}); | |||
const formattedStat = stat && | |||
const formattedStat = | |||
stat && | |||
formatMeasure(stat, this.props.facetMode === 'effort' ? 'SHORT_WORK_DUR' : 'SHORT_INT'); | |||
return this.props.disabled |
@@ -56,14 +56,14 @@ export type Paging = { | |||
}; | |||
const parseAsBoolean = (value: ?string, defaultValue: boolean = true): boolean => | |||
value === 'false' ? false : value === 'true' ? true : defaultValue; | |||
(value === 'false' ? false : value === 'true' ? true : defaultValue); | |||
const parseAsString = (value: ?string): string => value || ''; | |||
const parseAsStringArray = (value: ?string): Array<string> => value ? value.split(',') : []; | |||
const parseAsStringArray = (value: ?string): Array<string> => (value ? value.split(',') : []); | |||
const parseAsFacetMode = (facetMode: string) => | |||
facetMode === 'debt' || facetMode === 'effort' ? 'effort' : 'count'; | |||
(facetMode === 'debt' || facetMode === 'effort' ? 'effort' : 'count'); | |||
export const parseQuery = (query: RawQuery): Query => ({ | |||
assigned: parseAsBoolean(query.assigned), | |||
@@ -96,7 +96,7 @@ export const areMyIssuesSelected = (query: RawQuery): boolean => query.myIssues | |||
const serializeString = (value: string): ?string => value || undefined; | |||
const serializeValue = (value: Array<string>): ?string => value.length ? value.join() : undefined; | |||
const serializeValue = (value: Array<string>): ?string => (value.length ? value.join() : undefined); | |||
export const serializeQuery = (query: Query): RawQuery => { | |||
const filter = { | |||
@@ -151,9 +151,9 @@ export const areQueriesEqual = (a: RawQuery, b: RawQuery) => { | |||
return keysA.every( | |||
key => | |||
Array.isArray(parsedA[key]) && Array.isArray(parsedB[key]) | |||
(Array.isArray(parsedA[key]) && Array.isArray(parsedB[key]) | |||
? areArraysEqual(parsedA[key], parsedB[key]) | |||
: parsedA[key] === parsedB[key] | |||
: parsedA[key] === parsedB[key]) | |||
); | |||
}; | |||
@@ -217,7 +217,8 @@ export const searchAssignees = (query: string, component?: Component) => { | |||
avatar: user.avatar, | |||
label: user.name, | |||
value: user.login | |||
}))) | |||
})) | |||
) | |||
: searchUsers(query, 50).then(response => | |||
response.users.map(user => ({ | |||
// TODO this WS returns no avatar | |||
@@ -225,5 +226,6 @@ export const searchAssignees = (query: string, component?: Component) => { | |||
email: user.email, | |||
label: user.name, | |||
value: user.login | |||
}))); | |||
})) | |||
); | |||
}; |
@@ -34,12 +34,9 @@ export default Marionette.ItemView.extend({ | |||
type: 'GET', | |||
url: window.baseUrl + '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status') | |||
}; | |||
this.pollingInternal = setInterval( | |||
() => { | |||
this.refresh(); | |||
}, | |||
5000 | |||
); | |||
this.pollingInternal = setInterval(() => { | |||
this.refresh(); | |||
}, 5000); | |||
this.wasStarting = false; | |||
}, | |||
@@ -84,12 +81,9 @@ export default Marionette.ItemView.extend({ | |||
}, | |||
goHome() { | |||
setInterval( | |||
() => { | |||
window.location = window.baseUrl + '/'; | |||
}, | |||
2500 | |||
); | |||
setInterval(() => { | |||
window.location = window.baseUrl + '/'; | |||
}, 2500); | |||
}, | |||
serializeData() { |
@@ -21,7 +21,8 @@ const routes = [ | |||
{ | |||
getIndexRoute(_, callback) { | |||
require.ensure([], require => | |||
callback(null, { component: require('./components/MetricsAppContainer').default })); | |||
callback(null, { component: require('./components/MetricsAppContainer').default }) | |||
); | |||
} | |||
} | |||
]; |
@@ -32,75 +32,69 @@ import type { Member } from '../../store/organizationsMembers/actions'; | |||
const PAGE_SIZE = 50; | |||
const onRejected = (dispatch: Function) => | |||
(error: Object) => { | |||
onFail(dispatch)(error); | |||
return Promise.reject(); | |||
}; | |||
const onRejected = (dispatch: Function) => (error: Object) => { | |||
onFail(dispatch)(error); | |||
return Promise.reject(); | |||
}; | |||
const onMembersFail = (organization: string, dispatch: Function) => | |||
(error: Object) => { | |||
onFail(dispatch)(error); | |||
dispatch(membersActions.updateState(organization, { loading: false })); | |||
}; | |||
const onMembersFail = (organization: string, dispatch: Function) => (error: Object) => { | |||
onFail(dispatch)(error); | |||
dispatch(membersActions.updateState(organization, { loading: false })); | |||
}; | |||
export const fetchOrganization = (key: string): Function => | |||
(dispatch: Function): Promise<*> => { | |||
const onFulfilled = ([organization, navigation]) => { | |||
if (organization) { | |||
const organizationWithPermissions = { ...organization, ...navigation }; | |||
dispatch(actions.receiveOrganizations([organizationWithPermissions])); | |||
} | |||
}; | |||
return Promise.all([api.getOrganization(key), api.getOrganizationNavigation(key)]).then( | |||
onFulfilled, | |||
onFail(dispatch) | |||
); | |||
export const fetchOrganization = (key: string): Function => (dispatch: Function): Promise<*> => { | |||
const onFulfilled = ([organization, navigation]) => { | |||
if (organization) { | |||
const organizationWithPermissions = { ...organization, ...navigation }; | |||
dispatch(actions.receiveOrganizations([organizationWithPermissions])); | |||
} | |||
}; | |||
export const fetchOrganizationGroups = (organization: string): Function => | |||
(dispatch: Function): Promise<*> => { | |||
return searchUsersGroups({ organization }).then( | |||
response => { | |||
dispatch(actions.receiveOrganizationGroups(organization, response.groups)); | |||
}, | |||
onFail(dispatch) | |||
); | |||
}; | |||
return Promise.all([api.getOrganization(key), api.getOrganizationNavigation(key)]).then( | |||
onFulfilled, | |||
onFail(dispatch) | |||
); | |||
}; | |||
export const createOrganization = (fields: {}): Function => | |||
(dispatch: Function): Promise<*> => { | |||
const onFulfilled = (organization: Organization) => { | |||
dispatch(actions.createOrganization(organization)); | |||
dispatch( | |||
addGlobalSuccessMessage(translateWithParameters('organization.created', organization.name)) | |||
); | |||
}; | |||
export const fetchOrganizationGroups = (organization: string): Function => ( | |||
dispatch: Function | |||
): Promise<*> => { | |||
return searchUsersGroups({ organization }).then(response => { | |||
dispatch(actions.receiveOrganizationGroups(organization, response.groups)); | |||
}, onFail(dispatch)); | |||
}; | |||
return api.createOrganization(fields).then(onFulfilled, onRejected(dispatch)); | |||
export const createOrganization = (fields: {}): Function => (dispatch: Function): Promise<*> => { | |||
const onFulfilled = (organization: Organization) => { | |||
dispatch(actions.createOrganization(organization)); | |||
dispatch( | |||
addGlobalSuccessMessage(translateWithParameters('organization.created', organization.name)) | |||
); | |||
}; | |||
export const updateOrganization = (key: string, changes: {}): Function => | |||
(dispatch: Function): Promise<*> => { | |||
const onFulfilled = () => { | |||
dispatch(actions.updateOrganization(key, changes)); | |||
dispatch(addGlobalSuccessMessage(translate('organization.updated'))); | |||
}; | |||
return api.createOrganization(fields).then(onFulfilled, onRejected(dispatch)); | |||
}; | |||
return api.updateOrganization(key, changes).then(onFulfilled, onFail(dispatch)); | |||
export const updateOrganization = (key: string, changes: {}): Function => ( | |||
dispatch: Function | |||
): Promise<*> => { | |||
const onFulfilled = () => { | |||
dispatch(actions.updateOrganization(key, changes)); | |||
dispatch(addGlobalSuccessMessage(translate('organization.updated'))); | |||
}; | |||
export const deleteOrganization = (key: string): Function => | |||
(dispatch: Function): Promise<*> => { | |||
const onFulfilled = () => { | |||
dispatch(actions.deleteOrganization(key)); | |||
dispatch(addGlobalSuccessMessage(translate('organization.deleted'))); | |||
}; | |||
return api.updateOrganization(key, changes).then(onFulfilled, onFail(dispatch)); | |||
}; | |||
return api.deleteOrganization(key).then(onFulfilled, onFail(dispatch)); | |||
export const deleteOrganization = (key: string): Function => (dispatch: Function): Promise<*> => { | |||
const onFulfilled = () => { | |||
dispatch(actions.deleteOrganization(key)); | |||
dispatch(addGlobalSuccessMessage(translate('organization.deleted'))); | |||
}; | |||
return api.deleteOrganization(key).then(onFulfilled, onFail(dispatch)); | |||
}; | |||
const fetchMembers = ( | |||
dispatch: Function, | |||
receiveAction: Function, | |||
@@ -119,71 +113,69 @@ const fetchMembers = ( | |||
if (query) { | |||
data.q = query; | |||
} | |||
return api.searchMembers(data).then( | |||
response => { | |||
dispatch( | |||
receiveAction(key, response.users, { | |||
loading: false, | |||
total: response.paging.total, | |||
pageIndex: response.paging.pageIndex, | |||
query: query || null | |||
}) | |||
); | |||
}, | |||
onMembersFail(key, dispatch) | |||
); | |||
return api.searchMembers(data).then(response => { | |||
dispatch( | |||
receiveAction(key, response.users, { | |||
loading: false, | |||
total: response.paging.total, | |||
pageIndex: response.paging.pageIndex, | |||
query: query || null | |||
}) | |||
); | |||
}, onMembersFail(key, dispatch)); | |||
}; | |||
export const fetchOrganizationMembers = (key: string, query?: string) => | |||
(dispatch: Function) => fetchMembers(dispatch, membersActions.receiveMembers, key, query); | |||
export const fetchMoreOrganizationMembers = (key: string, query?: string) => | |||
(dispatch: Function, getState: Function) => | |||
fetchMembers( | |||
dispatch, | |||
membersActions.receiveMoreMembers, | |||
key, | |||
query, | |||
getOrganizationMembersState(getState(), key).pageIndex + 1 | |||
); | |||
export const fetchOrganizationMembers = (key: string, query?: string) => (dispatch: Function) => | |||
fetchMembers(dispatch, membersActions.receiveMembers, key, query); | |||
export const addOrganizationMember = (key: string, member: Member) => | |||
(dispatch: Function) => { | |||
return api | |||
.addMember({ login: member.login, organization: key }) | |||
.then(user => dispatch(membersActions.addMember(key, user)), onFail(dispatch)); | |||
}; | |||
export const fetchMoreOrganizationMembers = (key: string, query?: string) => ( | |||
dispatch: Function, | |||
getState: Function | |||
) => | |||
fetchMembers( | |||
dispatch, | |||
membersActions.receiveMoreMembers, | |||
key, | |||
query, | |||
getOrganizationMembersState(getState(), key).pageIndex + 1 | |||
); | |||
export const removeOrganizationMember = (key: string, member: Member) => | |||
(dispatch: Function) => { | |||
dispatch(membersActions.removeMember(key, member)); | |||
return api.removeMember({ login: member.login, organization: key }).catch((error: Object) => { | |||
onFail(dispatch)(error); | |||
dispatch(membersActions.addMember(key, member)); | |||
}); | |||
}; | |||
export const addOrganizationMember = (key: string, member: Member) => (dispatch: Function) => { | |||
return api | |||
.addMember({ login: member.login, organization: key }) | |||
.then(user => dispatch(membersActions.addMember(key, user)), onFail(dispatch)); | |||
}; | |||
export const removeOrganizationMember = (key: string, member: Member) => (dispatch: Function) => { | |||
dispatch(membersActions.removeMember(key, member)); | |||
return api.removeMember({ login: member.login, organization: key }).catch((error: Object) => { | |||
onFail(dispatch)(error); | |||
dispatch(membersActions.addMember(key, member)); | |||
}); | |||
}; | |||
export const updateOrganizationMemberGroups = ( | |||
organization: Organization, | |||
member: Member, | |||
add: Array<string>, | |||
remove: Array<string> | |||
) => | |||
(dispatch: Function) => { | |||
dispatch( | |||
receiveUser({ | |||
...member, | |||
groupCount: (member.groupCount || 0) + add.length - remove.length | |||
}) | |||
); | |||
const promises = [ | |||
...add.map(name => | |||
addUserToGroup({ name, login: member.login, organization: organization.key })), | |||
...remove.map(name => | |||
removeUserFromGroup({ name, login: member.login, organization: organization.key })) | |||
]; | |||
return Promise.all(promises).catch(error => { | |||
dispatch(receiveUser(member)); | |||
onFail(dispatch)(error); | |||
}); | |||
}; | |||
) => (dispatch: Function) => { | |||
dispatch( | |||
receiveUser({ | |||
...member, | |||
groupCount: (member.groupCount || 0) + add.length - remove.length | |||
}) | |||
); | |||
const promises = [ | |||
...add.map(name => | |||
addUserToGroup({ name, login: member.login, organization: organization.key }) | |||
), | |||
...remove.map(name => | |||
removeUserFromGroup({ name, login: member.login, organization: organization.key }) | |||
) | |||
]; | |||
return Promise.all(promises).catch(error => { | |||
dispatch(receiveUser(member)); | |||
onFail(dispatch)(error); | |||
}); | |||
}; |
@@ -27,7 +27,7 @@ type Props = { | |||
members: Array<Member>, | |||
organizationGroups: Array<OrgGroup>, | |||
organization: Organization, | |||
removeMember: (Member) => void, | |||
removeMember: Member => void, | |||
updateMemberGroups: (member: Member, add: Array<string>, remove: Array<string>) => void | |||
}; | |||
@@ -31,7 +31,7 @@ type Props = { | |||
member: Member, | |||
organization: Organization, | |||
organizationGroups: Array<OrgGroup>, | |||
removeMember: (Member) => void, | |||
removeMember: Member => void, | |||
updateMemberGroups: (member: Member, add: Array<string>, remove: Array<string>) => void | |||
}; | |||
@@ -34,9 +34,9 @@ class OrganizationDelete extends React.PureComponent { | |||
name: string | |||
}, | |||
router: { | |||
replace: (string) => void | |||
replace: string => void | |||
}, | |||
deleteOrganization: (string) => Promise<*> | |||
deleteOrganization: string => Promise<*> | |||
}; | |||
state = { |
@@ -38,7 +38,7 @@ class OrganizationPage extends React.PureComponent { | |||
location: Object, | |||
organization: null | Organization, | |||
params: { organizationKey: string }, | |||
fetchOrganization: (string) => Promise<*> | |||
fetchOrganization: string => Promise<*> | |||
}; | |||
state = { |
@@ -131,11 +131,13 @@ export default class OrganizationNavigation extends React.PureComponent { | |||
render() { | |||
const { organization, location } = this.props; | |||
const isHomeActive = location.pathname === `organizations/${organization.key}/projects` || | |||
const isHomeActive = | |||
location.pathname === `organizations/${organization.key}/projects` || | |||
location.pathname === `organizations/${organization.key}/projects/favorite`; | |||
const adminActive = ADMIN_PATHS.some(path => | |||
location.pathname.endsWith(`organizations/${organization.key}/${path}`)); | |||
location.pathname.endsWith(`organizations/${organization.key}/${path}`) | |||
); | |||
const moreActive = !adminActive && location.pathname.includes('/extension/'); | |||
@@ -24,11 +24,10 @@ import { onFail } from '../../store/rootActions'; | |||
const PAGE_SIZE = 5; | |||
export const fetchRecentProjectActivity = (project: string) => | |||
(dispatch: Function) => | |||
api | |||
.getProjectActivity(project, { pageSize: PAGE_SIZE }) | |||
.then( | |||
({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), | |||
onFail(dispatch) | |||
); | |||
export const fetchRecentProjectActivity = (project: string) => (dispatch: Function) => | |||
api | |||
.getProjectActivity(project, { pageSize: PAGE_SIZE }) | |||
.then( | |||
({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), | |||
onFail(dispatch) | |||
); |
@@ -95,7 +95,8 @@ export default class OverviewApp extends React.PureComponent { | |||
componentDidUpdate(prevProps) { | |||
if (this.props.component.key !== prevProps.component.key) { | |||
this.loadMeasures(this.props.component.key).then(() => | |||
this.loadHistory(this.props.component)); | |||
this.loadHistory(this.props.component) | |||
); | |||
} | |||
} | |||
@@ -52,7 +52,8 @@ class MetaQualityProfiles extends React.PureComponent { | |||
loadDeprecatedRules() { | |||
const requests = this.props.profiles.map(profile => | |||
this.loadDeprecatedRulesForProfile(profile.key)); | |||
this.loadDeprecatedRulesForProfile(profile.key) | |||
); | |||
Promise.all(requests).then(responses => { | |||
if (this.mounted) { | |||
const deprecatedByKey = {}; |
@@ -103,15 +103,15 @@ export default class MetaTags extends React.PureComponent { | |||
if (this.canUpdateTags()) { | |||
return ( | |||
<div className="overview-meta-card overview-meta-tags" ref={card => this.card = card}> | |||
<div className="overview-meta-card overview-meta-tags" ref={card => (this.card = card)}> | |||
<button | |||
className="button-link" | |||
onClick={this.handleClick} | |||
ref={tagsList => this.tagsList = tagsList}> | |||
ref={tagsList => (this.tagsList = tagsList)}> | |||
<TagsList tags={tags.length ? tags : [translate('no_tags')]} allowUpdate={true} /> | |||
</button> | |||
{popupOpen && | |||
<div ref={tagsSelector => this.tagsSelector = tagsSelector}> | |||
<div ref={tagsSelector => (this.tagsSelector = tagsSelector)}> | |||
<ProjectTagsSelectorContainer | |||
position={popupPosition} | |||
project={key} |
@@ -50,7 +50,8 @@ export default class QualityGateConditions extends React.PureComponent { | |||
componentDidUpdate(prevProps) { | |||
if ( | |||
prevProps.conditions !== this.props.conditions || prevProps.component !== this.props.component | |||
prevProps.conditions !== this.props.conditions || | |||
prevProps.component !== this.props.component | |||
) { | |||
this.loadFailedMeasures(); | |||
} |
@@ -21,7 +21,8 @@ const routes = [ | |||
{ | |||
getIndexRoute(_, callback) { | |||
require.ensure([], require => | |||
callback(null, { component: require('./components/AppContainer').default })); | |||
callback(null, { component: require('./components/AppContainer').default }) | |||
); | |||
} | |||
} | |||
]; |
@@ -124,7 +124,8 @@ export default class ActionsCell extends React.PureComponent { | |||
this.renderSetDefaultLink( | |||
qualifier, | |||
<span>{translate('permission_templates.set_default')}</span> | |||
)); | |||
) | |||
); | |||
} | |||
renderIfMultipleTopQualifiers(availableQualifiers) { | |||
@@ -138,7 +139,8 @@ export default class ActionsCell extends React.PureComponent { | |||
{' '} | |||
{translate('qualifiers', qualifier)} | |||
</span> | |||
)); | |||
) | |||
); | |||
} | |||
render() { |
@@ -153,11 +153,11 @@ class Template extends React.PureComponent { | |||
const isFiltered = store.filter !== 'all'; | |||
const matchQuery = !store.query || | |||
CREATOR_NAME.toLocaleLowerCase().includes(store.query.toLowerCase()); | |||
const matchQuery = | |||
!store.query || CREATOR_NAME.toLocaleLowerCase().includes(store.query.toLowerCase()); | |||
const matchPermission = store.selectedPermission == null || | |||
creatorPermissions.includes(store.selectedPermission); | |||
const matchPermission = | |||
store.selectedPermission == null || creatorPermissions.includes(store.selectedPermission); | |||
return !isFiltered && matchQuery && matchPermission; | |||
} |
@@ -22,8 +22,10 @@ import Template from '../templates/permission-templates-groups.hbs'; | |||
import '../../../components/SelectList'; | |||
function getSearchUrl(permission, permissionTemplate) { | |||
return `${window.baseUrl}/api/permissions/template_groups?` + | |||
`ps=100&permission=${permission.key}&templateId=${permissionTemplate.id}`; | |||
return ( | |||
`${window.baseUrl}/api/permissions/template_groups?` + | |||
`ps=100&permission=${permission.key}&templateId=${permissionTemplate.id}` | |||
); | |||
} | |||
export default Modal.extend({ |
@@ -53,7 +53,8 @@ export default Modal.extend({ | |||
onRender() { | |||
Modal.prototype.onRender.apply(this, arguments); | |||
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); | |||
const searchUrl = window.baseUrl + | |||
const searchUrl = | |||
window.baseUrl + | |||
'/api/permissions/template_users?ps=100&permission=' + | |||
this.options.permission.key + | |||
'&templateId=' + |
@@ -38,121 +38,125 @@ import { | |||
getPermissionsAppSelectedPermission | |||
} from '../../../../store/rootReducer'; | |||
type Dispatch = (Object) => void; | |||
type Dispatch = Object => void; | |||
type GetState = () => Object; | |||
export const loadHolders = (organization?: string) => | |||
(dispatch: Dispatch, getState: GetState) => { | |||
const query = getPermissionsAppQuery(getState()); | |||
const filter = getPermissionsAppFilter(getState()); | |||
const selectedPermission = getPermissionsAppSelectedPermission(getState()); | |||
export const loadHolders = (organization?: string) => (dispatch: Dispatch, getState: GetState) => { | |||
const query = getPermissionsAppQuery(getState()); | |||
const filter = getPermissionsAppFilter(getState()); | |||
const selectedPermission = getPermissionsAppSelectedPermission(getState()); | |||
dispatch({ type: REQUEST_HOLDERS, query }); | |||
dispatch({ type: REQUEST_HOLDERS, query }); | |||
const requests = []; | |||
const requests = []; | |||
if (filter !== 'groups') { | |||
requests.push(api.getGlobalPermissionsUsers(query, selectedPermission, organization)); | |||
} else { | |||
requests.push(Promise.resolve([])); | |||
} | |||
if (filter !== 'groups') { | |||
requests.push(api.getGlobalPermissionsUsers(query, selectedPermission, organization)); | |||
} else { | |||
requests.push(Promise.resolve([])); | |||
} | |||
if (filter !== 'users') { | |||
requests.push(api.getGlobalPermissionsGroups(query, selectedPermission, organization)); | |||
} else { | |||
requests.push(Promise.resolve([])); | |||
} | |||
if (filter !== 'users') { | |||
requests.push(api.getGlobalPermissionsGroups(query, selectedPermission, organization)); | |||
} else { | |||
requests.push(Promise.resolve([])); | |||
} | |||
return Promise.all(requests) | |||
.then(responses => | |||
dispatch({ | |||
type: RECEIVE_HOLDERS_SUCCESS, | |||
users: responses[0], | |||
groups: responses[1], | |||
query | |||
})) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const updateQuery = (query: string = '', organization?: string) => | |||
(dispatch: Dispatch) => { | |||
dispatch({ type: UPDATE_QUERY, query }); | |||
if (query.length === 0 || query.length > 2) { | |||
dispatch(loadHolders(organization)); | |||
} | |||
}; | |||
return Promise.all(requests) | |||
.then(responses => | |||
dispatch({ | |||
type: RECEIVE_HOLDERS_SUCCESS, | |||
users: responses[0], | |||
groups: responses[1], | |||
query | |||
}) | |||
) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const updateFilter = (filter: string, organization?: string) => | |||
(dispatch: Dispatch) => { | |||
dispatch({ type: UPDATE_FILTER, filter }); | |||
export const updateQuery = (query: string = '', organization?: string) => (dispatch: Dispatch) => { | |||
dispatch({ type: UPDATE_QUERY, query }); | |||
if (query.length === 0 || query.length > 2) { | |||
dispatch(loadHolders(organization)); | |||
}; | |||
} | |||
}; | |||
export const selectPermission = (permission: string, organization?: string) => | |||
(dispatch: Dispatch, getState: GetState) => { | |||
const selectedPermission = getPermissionsAppSelectedPermission(getState()); | |||
if (selectedPermission !== permission) { | |||
dispatch({ type: SELECT_PERMISSION, permission }); | |||
} else { | |||
dispatch({ type: SELECT_PERMISSION, permission: null }); | |||
} | |||
dispatch(loadHolders(organization)); | |||
}; | |||
export const updateFilter = (filter: string, organization?: string) => (dispatch: Dispatch) => { | |||
dispatch({ type: UPDATE_FILTER, filter }); | |||
dispatch(loadHolders(organization)); | |||
}; | |||
export const grantToUser = (login: string, permission: string, organization?: string) => | |||
(dispatch: Dispatch) => { | |||
api | |||
.grantPermissionToUser(null, login, permission, organization) | |||
.then(() => { | |||
dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const selectPermission = (permission: string, organization?: string) => ( | |||
dispatch: Dispatch, | |||
getState: GetState | |||
) => { | |||
const selectedPermission = getPermissionsAppSelectedPermission(getState()); | |||
if (selectedPermission !== permission) { | |||
dispatch({ type: SELECT_PERMISSION, permission }); | |||
} else { | |||
dispatch({ type: SELECT_PERMISSION, permission: null }); | |||
} | |||
dispatch(loadHolders(organization)); | |||
}; | |||
export const revokeFromUser = (login: string, permission: string, organization?: string) => | |||
(dispatch: Dispatch) => { | |||
api | |||
.revokePermissionFromUser(null, login, permission, organization) | |||
.then(() => { | |||
dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const grantToUser = (login: string, permission: string, organization?: string) => ( | |||
dispatch: Dispatch | |||
) => { | |||
api | |||
.grantPermissionToUser(null, login, permission, organization) | |||
.then(() => { | |||
dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const grantToGroup = (groupName: string, permission: string, organization?: string) => | |||
(dispatch: Dispatch) => { | |||
api | |||
.grantPermissionToGroup(null, groupName, permission, organization) | |||
.then(() => { | |||
dispatch({ | |||
type: GRANT_PERMISSION_TO_GROUP, | |||
groupName, | |||
permission | |||
}); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
export const revokeFromUser = (login: string, permission: string, organization?: string) => ( | |||
dispatch: Dispatch | |||
) => { | |||
api | |||
.revokePermissionFromUser(null, login, permission, organization) | |||
.then(() => { | |||
dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const grantToGroup = (groupName: string, permission: string, organization?: string) => ( | |||
dispatch: Dispatch | |||
) => { | |||
api | |||
.grantPermissionToGroup(null, groupName, permission, organization) | |||
.then(() => { | |||
dispatch({ | |||
type: GRANT_PERMISSION_TO_GROUP, | |||
groupName, | |||
permission | |||
}); | |||
}; | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const revokeFromGroup = (groupName: string, permission: string, organization?: string) => | |||
(dispatch: Dispatch) => { | |||
api | |||
.revokePermissionFromGroup(null, groupName, permission, organization) | |||
.then(() => { | |||
dispatch({ | |||
type: REVOKE_PERMISSION_FROM_GROUP, | |||
groupName, | |||
permission | |||
}); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
export const revokeFromGroup = (groupName: string, permission: string, organization?: string) => ( | |||
dispatch: Dispatch | |||
) => { | |||
api | |||
.revokePermissionFromGroup(null, groupName, permission, organization) | |||
.then(() => { | |||
dispatch({ | |||
type: REVOKE_PERMISSION_FROM_GROUP, | |||
groupName, | |||
permission | |||
}); | |||
}; | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; |
@@ -51,8 +51,8 @@ class PageHeader extends React.PureComponent { | |||
render() { | |||
const configuration = this.props.project.configuration; | |||
const canApplyPermissionTemplate = configuration != null && | |||
configuration.canApplyPermissionTemplate; | |||
const canApplyPermissionTemplate = | |||
configuration != null && configuration.canApplyPermissionTemplate; | |||
const description = ['VW', 'SVW'].includes(this.props.project.qualifier) | |||
? translate('roles.page.description_portfolio') |
@@ -38,145 +38,148 @@ import { | |||
getPermissionsAppSelectedPermission | |||
} from '../../../../store/rootReducer'; | |||
type Dispatch = (Object) => void; | |||
type Dispatch = Object => void; | |||
type GetState = () => Object; | |||
export const loadHolders = (project: string, organization?: string) => | |||
(dispatch: Dispatch, getState: GetState) => { | |||
const query = getPermissionsAppQuery(getState()); | |||
const filter = getPermissionsAppFilter(getState()); | |||
const selectedPermission = getPermissionsAppSelectedPermission(getState()); | |||
export const loadHolders = (project: string, organization?: string) => ( | |||
dispatch: Dispatch, | |||
getState: GetState | |||
) => { | |||
const query = getPermissionsAppQuery(getState()); | |||
const filter = getPermissionsAppFilter(getState()); | |||
const selectedPermission = getPermissionsAppSelectedPermission(getState()); | |||
dispatch({ type: REQUEST_HOLDERS, query }); | |||
dispatch({ type: REQUEST_HOLDERS, query }); | |||
const requests = []; | |||
const requests = []; | |||
if (filter !== 'groups') { | |||
requests.push( | |||
api.getPermissionsUsersForComponent(project, query, selectedPermission, organization) | |||
); | |||
} else { | |||
requests.push(Promise.resolve([])); | |||
} | |||
if (filter !== 'groups') { | |||
requests.push( | |||
api.getPermissionsUsersForComponent(project, query, selectedPermission, organization) | |||
); | |||
} else { | |||
requests.push(Promise.resolve([])); | |||
} | |||
if (filter !== 'users') { | |||
requests.push( | |||
api.getPermissionsGroupsForComponent(project, query, selectedPermission, organization) | |||
); | |||
} else { | |||
requests.push(Promise.resolve([])); | |||
} | |||
if (filter !== 'users') { | |||
requests.push( | |||
api.getPermissionsGroupsForComponent(project, query, selectedPermission, organization) | |||
); | |||
} else { | |||
requests.push(Promise.resolve([])); | |||
} | |||
return Promise.all(requests) | |||
.then(responses => | |||
dispatch({ | |||
type: RECEIVE_HOLDERS_SUCCESS, | |||
users: responses[0], | |||
groups: responses[1], | |||
query | |||
})) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const updateQuery = (project: string, query: string, organization?: string) => | |||
(dispatch: Dispatch) => { | |||
dispatch({ type: UPDATE_QUERY, query }); | |||
if (query.length === 0 || query.length > 2) { | |||
dispatch(loadHolders(project, organization)); | |||
} | |||
}; | |||
return Promise.all(requests) | |||
.then(responses => | |||
dispatch({ | |||
type: RECEIVE_HOLDERS_SUCCESS, | |||
users: responses[0], | |||
groups: responses[1], | |||
query | |||
}) | |||
) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const updateFilter = (project: string, filter: string, organization?: string) => | |||
(dispatch: Dispatch) => { | |||
dispatch({ type: UPDATE_FILTER, filter }); | |||
export const updateQuery = (project: string, query: string, organization?: string) => ( | |||
dispatch: Dispatch | |||
) => { | |||
dispatch({ type: UPDATE_QUERY, query }); | |||
if (query.length === 0 || query.length > 2) { | |||
dispatch(loadHolders(project, organization)); | |||
}; | |||
} | |||
}; | |||
export const selectPermission = (project: string, permission: string, organization?: string) => | |||
(dispatch: Dispatch, getState: GetState) => { | |||
const selectedPermission = getPermissionsAppSelectedPermission(getState()); | |||
if (selectedPermission !== permission) { | |||
dispatch({ type: SELECT_PERMISSION, permission }); | |||
} else { | |||
dispatch({ type: SELECT_PERMISSION, permission: null }); | |||
} | |||
dispatch(loadHolders(project, organization)); | |||
}; | |||
export const updateFilter = (project: string, filter: string, organization?: string) => ( | |||
dispatch: Dispatch | |||
) => { | |||
dispatch({ type: UPDATE_FILTER, filter }); | |||
dispatch(loadHolders(project, organization)); | |||
}; | |||
export const selectPermission = (project: string, permission: string, organization?: string) => ( | |||
dispatch: Dispatch, | |||
getState: GetState | |||
) => { | |||
const selectedPermission = getPermissionsAppSelectedPermission(getState()); | |||
if (selectedPermission !== permission) { | |||
dispatch({ type: SELECT_PERMISSION, permission }); | |||
} else { | |||
dispatch({ type: SELECT_PERMISSION, permission: null }); | |||
} | |||
dispatch(loadHolders(project, organization)); | |||
}; | |||
export const grantToUser = ( | |||
project: string, | |||
login: string, | |||
permission: string, | |||
organization?: string | |||
) => | |||
(dispatch: Dispatch) => { | |||
api | |||
.grantPermissionToUser(project, login, permission, organization) | |||
.then(() => { | |||
dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
) => (dispatch: Dispatch) => { | |||
api | |||
.grantPermissionToUser(project, login, permission, organization) | |||
.then(() => { | |||
dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const revokeFromUser = ( | |||
project: string, | |||
login: string, | |||
permission: string, | |||
organization?: string | |||
) => | |||
(dispatch: Dispatch) => { | |||
api | |||
.revokePermissionFromUser(project, login, permission, organization) | |||
.then(() => { | |||
dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
) => (dispatch: Dispatch) => { | |||
api | |||
.revokePermissionFromUser(project, login, permission, organization) | |||
.then(() => { | |||
dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const grantToGroup = ( | |||
project: string, | |||
groupName: string, | |||
permission: string, | |||
organization?: string | |||
) => | |||
(dispatch: Dispatch) => { | |||
api | |||
.grantPermissionToGroup(project, groupName, permission, organization) | |||
.then(() => { | |||
dispatch({ | |||
type: GRANT_PERMISSION_TO_GROUP, | |||
groupName, | |||
permission | |||
}); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
) => (dispatch: Dispatch) => { | |||
api | |||
.grantPermissionToGroup(project, groupName, permission, organization) | |||
.then(() => { | |||
dispatch({ | |||
type: GRANT_PERMISSION_TO_GROUP, | |||
groupName, | |||
permission | |||
}); | |||
}; | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; | |||
export const revokeFromGroup = ( | |||
project: string, | |||
groupName: string, | |||
permission: string, | |||
organization?: string | |||
) => | |||
(dispatch: Dispatch) => { | |||
api | |||
.revokePermissionFromGroup(project, groupName, permission, organization) | |||
.then(() => { | |||
dispatch({ | |||
type: REVOKE_PERMISSION_FROM_GROUP, | |||
groupName, | |||
permission | |||
}); | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
) => (dispatch: Dispatch) => { | |||
api | |||
.revokePermissionFromGroup(project, groupName, permission, organization) | |||
.then(() => { | |||
dispatch({ | |||
type: REVOKE_PERMISSION_FROM_GROUP, | |||
groupName, | |||
permission | |||
}); | |||
}; | |||
}) | |||
.catch(e => { | |||
return parseError(e).then(message => dispatch(raiseError(message))); | |||
}); | |||
}; |
@@ -34,7 +34,8 @@ export const projectPermissionsRoutes = [ | |||
{ | |||
getIndexRoute(_, callback) { | |||
require.ensure([], require => | |||
callback(null, { component: require('./project/components/App').default })); | |||
callback(null, { component: require('./project/components/App').default }) | |||
); | |||
} | |||
} | |||
]; |
@@ -18,10 +18,7 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
export const reloadUpdateKeyPage = componentKey => { | |||
setTimeout( | |||
() => { | |||
window.location = window.baseUrl + '/project/key?id=' + encodeURIComponent(componentKey); | |||
}, | |||
3000 | |||
); | |||
setTimeout(() => { | |||
window.location = window.baseUrl + '/project/key?id=' + encodeURIComponent(componentKey); | |||
}, 3000); | |||
}; |
@@ -47,19 +47,18 @@ export const receiveProjectProfiles = (projectKey, profiles) => ({ | |||
profiles | |||
}); | |||
export const fetchProjectProfiles = (projectKey, organization) => | |||
dispatch => { | |||
Promise.all([ | |||
organization ? getQualityProfiles({ organization }) : getQualityProfiles(), | |||
organization | |||
? getQualityProfiles({ organization, projectKey }) | |||
: getQualityProfiles({ projectKey }) | |||
]).then(responses => { | |||
const [allProfiles, projectProfiles] = responses; | |||
dispatch(receiveProfiles(allProfiles)); | |||
dispatch(receiveProjectProfiles(projectKey, projectProfiles)); | |||
}); | |||
}; | |||
export const fetchProjectProfiles = (projectKey, organization) => dispatch => { | |||
Promise.all([ | |||
organization ? getQualityProfiles({ organization }) : getQualityProfiles(), | |||
organization | |||
? getQualityProfiles({ organization, projectKey }) | |||
: getQualityProfiles({ projectKey }) | |||
]).then(responses => { | |||
const [allProfiles, projectProfiles] = responses; | |||
dispatch(receiveProfiles(allProfiles)); | |||
dispatch(receiveProjectProfiles(projectKey, projectProfiles)); | |||
}); | |||
}; | |||
export const SET_PROJECT_PROFILE = 'projectAdmin/SET_PROJECT_PROFILE'; | |||
const setProjectProfileAction = (projectKey, oldProfileKey, newProfileKey) => ({ | |||
@@ -69,26 +68,25 @@ const setProjectProfileAction = (projectKey, oldProfileKey, newProfileKey) => ({ | |||
newProfileKey | |||
}); | |||
export const setProjectProfile = (projectKey, oldKey, newKey) => | |||
(dispatch, getState) => { | |||
const state = getState(); | |||
const newProfile = getProjectAdminProfileByKey(state, newKey); | |||
const request = newProfile.isDefault | |||
? dissociateProject(oldKey, projectKey) | |||
: associateProject(newKey, projectKey); | |||
request.then(() => { | |||
dispatch(setProjectProfileAction(projectKey, oldKey, newKey)); | |||
dispatch( | |||
addGlobalSuccessMessage( | |||
translateWithParameters( | |||
'project_quality_profile.successfully_updated', | |||
newProfile.languageName | |||
) | |||
export const setProjectProfile = (projectKey, oldKey, newKey) => (dispatch, getState) => { | |||
const state = getState(); | |||
const newProfile = getProjectAdminProfileByKey(state, newKey); | |||
const request = newProfile.isDefault | |||
? dissociateProject(oldKey, projectKey) | |||
: associateProject(newKey, projectKey); | |||
request.then(() => { | |||
dispatch(setProjectProfileAction(projectKey, oldKey, newKey)); | |||
dispatch( | |||
addGlobalSuccessMessage( | |||
translateWithParameters( | |||
'project_quality_profile.successfully_updated', | |||
newProfile.languageName | |||
) | |||
); | |||
}); | |||
}; | |||
) | |||
); | |||
}); | |||
}; | |||
export const RECEIVE_GATES = 'projectAdmin/RECEIVE_GATES'; | |||
export const receiveGates = gates => ({ | |||
@@ -103,14 +101,13 @@ export const receiveProjectGate = (projectKey, gate) => ({ | |||
gate | |||
}); | |||
export const fetchProjectGate = projectKey => | |||
dispatch => { | |||
Promise.all([fetchQualityGates(), getGateForProject(projectKey)]).then(responses => { | |||
const [allGates, projectGate] = responses; | |||
dispatch(receiveGates(allGates)); | |||
dispatch(receiveProjectGate(projectKey, projectGate)); | |||
}); | |||
}; | |||
export const fetchProjectGate = projectKey => dispatch => { | |||
Promise.all([fetchQualityGates(), getGateForProject(projectKey)]).then(responses => { | |||
const [allGates, projectGate] = responses; | |||
dispatch(receiveGates(allGates)); | |||
dispatch(receiveProjectGate(projectKey, projectGate)); | |||
}); | |||
}; | |||
export const SET_PROJECT_GATE = 'projectAdmin/SET_PROJECT_GATE'; | |||
const setProjectGateAction = (projectKey, gateId) => ({ | |||
@@ -119,17 +116,16 @@ const setProjectGateAction = (projectKey, gateId) => ({ | |||
gateId | |||
}); | |||
export const setProjectGate = (projectKey, oldId, newId) => | |||
dispatch => { | |||
const request = newId != null | |||
? associateGateWithProject(newId, projectKey) | |||
: dissociateGateWithProject(oldId, projectKey); | |||
export const setProjectGate = (projectKey, oldId, newId) => dispatch => { | |||
const request = newId != null | |||
? associateGateWithProject(newId, projectKey) | |||
: dissociateGateWithProject(oldId, projectKey); | |||
request.then(() => { | |||
dispatch(setProjectGateAction(projectKey, newId)); | |||
dispatch(addGlobalSuccessMessage(translate('project_quality_gate.successfully_updated'))); | |||
}); | |||
}; | |||
request.then(() => { | |||
dispatch(setProjectGateAction(projectKey, newId)); | |||
dispatch(addGlobalSuccessMessage(translate('project_quality_gate.successfully_updated'))); | |||
}); | |||
}; | |||
export const RECEIVE_PROJECT_LINKS = 'projectAdmin/RECEIVE_PROJECT_LINKS'; | |||
export const receiveProjectLinks = (projectKey, links) => ({ | |||
@@ -138,12 +134,11 @@ export const receiveProjectLinks = (projectKey, links) => ({ | |||
links | |||
}); | |||
export const fetchProjectLinks = projectKey => | |||
dispatch => { | |||
getProjectLinks(projectKey).then(links => { | |||
dispatch(receiveProjectLinks(projectKey, links)); | |||
}); | |||
}; | |||
export const fetchProjectLinks = projectKey => dispatch => { | |||
getProjectLinks(projectKey).then(links => { | |||
dispatch(receiveProjectLinks(projectKey, links)); | |||
}); | |||
}; | |||
export const ADD_PROJECT_LINK = 'projectAdmin/ADD_PROJECT_LINK'; | |||
const addProjectLink = (projectKey, link) => ({ | |||
@@ -152,12 +147,11 @@ const addProjectLink = (projectKey, link) => ({ | |||
link | |||
}); | |||
export const createProjectLink = (projectKey, name, url) => | |||
dispatch => { | |||
return createLink(projectKey, name, url).then(link => { | |||
dispatch(addProjectLink(projectKey, link)); | |||
}); | |||
}; | |||
export const createProjectLink = (projectKey, name, url) => dispatch => { | |||
return createLink(projectKey, name, url).then(link => { | |||
dispatch(addProjectLink(projectKey, link)); | |||
}); | |||
}; | |||
export const DELETE_PROJECT_LINK = 'projectAdmin/DELETE_PROJECT_LINK'; | |||
export const deleteProjectLink = (projectKey, linkId) => ({ | |||
@@ -173,13 +167,12 @@ const receiveProjectModules = (projectKey, modules) => ({ | |||
modules | |||
}); | |||
export const fetchProjectModules = projectKey => | |||
dispatch => { | |||
const options = { qualifiers: 'BRC', s: 'name', ps: 500 }; | |||
getTree(projectKey, options).then(r => { | |||
dispatch(receiveProjectModules(projectKey, r.components)); | |||
}); | |||
}; | |||
export const fetchProjectModules = projectKey => dispatch => { | |||
const options = { qualifiers: 'BRC', s: 'name', ps: 500 }; | |||
getTree(projectKey, options).then(r => { | |||
dispatch(receiveProjectModules(projectKey, r.components)); | |||
}); | |||
}; | |||
export const CHANGE_KEY = 'projectAdmin/CHANGE_KEY'; | |||
const changeKeyAction = (key, newKey) => ({ | |||
@@ -188,7 +181,6 @@ const changeKeyAction = (key, newKey) => ({ | |||
newKey | |||
}); | |||
export const changeKey = (key, newKey) => | |||
dispatch => { | |||
return changeKeyApi(key, newKey).then(() => dispatch(changeKeyAction(key, newKey))); | |||
}; | |||
export const changeKey = (key, newKey) => dispatch => { | |||
return changeKeyApi(key, newKey).then(() => dispatch(changeKeyAction(key, newKey))); | |||
}; |
@@ -50,7 +50,8 @@ export const getAllProfiles = state => nextGetAllProfiles(state.profiles); | |||
export const getProjectProfiles = (state, projectKey) => | |||
getProfiles(state.profilesByProject, projectKey).map(profileKey => | |||
getProfileByKey(state, profileKey)); | |||
getProfileByKey(state, profileKey) | |||
); | |||
export const getGateById = (state, gateId) => getGate(state.gates, gateId); | |||
@@ -30,67 +30,69 @@ import { | |||
import { onFail } from '../../store/rootActions'; | |||
import { getProjectActivity } from '../../store/rootReducer'; | |||
const rejectOnFail = (dispatch: Function) => | |||
(error: Object) => { | |||
onFail(dispatch)(error); | |||
return Promise.reject(); | |||
}; | |||
const rejectOnFail = (dispatch: Function) => (error: Object) => { | |||
onFail(dispatch)(error); | |||
return Promise.reject(); | |||
}; | |||
export const fetchProjectActivity = (project: string, filter: ?string) => | |||
(dispatch: Function): void => { | |||
api | |||
.getProjectActivity(project, { category: filter }) | |||
.then( | |||
({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), | |||
onFail(dispatch) | |||
); | |||
}; | |||
export const fetchProjectActivity = (project: string, filter: ?string) => ( | |||
dispatch: Function | |||
): void => { | |||
api | |||
.getProjectActivity(project, { category: filter }) | |||
.then( | |||
({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), | |||
onFail(dispatch) | |||
); | |||
}; | |||
export const fetchMoreProjectActivity = (project: string, filter: ?string) => | |||
(dispatch: Function, getState: Function): void => { | |||
const projectActivity = getProjectActivity(getState()); | |||
const { pageIndex } = getPaging(projectActivity, project); | |||
export const fetchMoreProjectActivity = (project: string, filter: ?string) => ( | |||
dispatch: Function, | |||
getState: Function | |||
): void => { | |||
const projectActivity = getProjectActivity(getState()); | |||
const { pageIndex } = getPaging(projectActivity, project); | |||
api | |||
.getProjectActivity(project, { category: filter, pageIndex: pageIndex + 1 }) | |||
.then( | |||
({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), | |||
onFail(dispatch) | |||
); | |||
}; | |||
api | |||
.getProjectActivity(project, { category: filter, pageIndex: pageIndex + 1 }) | |||
.then( | |||
({ analyses, paging }) => dispatch(receiveProjectActivity(project, analyses, paging)), | |||
onFail(dispatch) | |||
); | |||
}; | |||
export const addCustomEvent = (analysis: string, name: string, category?: string) => | |||
(dispatch: Function): Promise<*> => { | |||
return api | |||
.createEvent(analysis, name, category) | |||
.then( | |||
({ analysis, ...event }) => dispatch(addEvent(analysis, event)), | |||
rejectOnFail(dispatch) | |||
); | |||
}; | |||
export const addCustomEvent = (analysis: string, name: string, category?: string) => ( | |||
dispatch: Function | |||
): Promise<*> => { | |||
return api | |||
.createEvent(analysis, name, category) | |||
.then(({ analysis, ...event }) => dispatch(addEvent(analysis, event)), rejectOnFail(dispatch)); | |||
}; | |||
export const deleteEvent = (analysis: string, event: string) => | |||
(dispatch: Function): Promise<*> => { | |||
return api | |||
.deleteEvent(event) | |||
.then(() => dispatch(deleteEventAction(analysis, event)), rejectOnFail(dispatch)); | |||
}; | |||
export const deleteEvent = (analysis: string, event: string) => ( | |||
dispatch: Function | |||
): Promise<*> => { | |||
return api | |||
.deleteEvent(event) | |||
.then(() => dispatch(deleteEventAction(analysis, event)), rejectOnFail(dispatch)); | |||
}; | |||
export const addVersion = (analysis: string, version: string) => | |||
(dispatch: Function): Promise<*> => { | |||
return dispatch(addCustomEvent(analysis, version, 'VERSION')); | |||
}; | |||
export const addVersion = (analysis: string, version: string) => ( | |||
dispatch: Function | |||
): Promise<*> => { | |||
return dispatch(addCustomEvent(analysis, version, 'VERSION')); | |||
}; | |||
export const changeEvent = (event: string, name: string) => | |||
(dispatch: Function): Promise<*> => { | |||
return api | |||
.changeEvent(event, name) | |||
.then(() => dispatch(changeEventAction(event, { name })), rejectOnFail(dispatch)); | |||
}; | |||
export const changeEvent = (event: string, name: string) => (dispatch: Function): Promise<*> => { | |||
return api | |||
.changeEvent(event, name) | |||
.then(() => dispatch(changeEventAction(event, { name })), rejectOnFail(dispatch)); | |||
}; | |||
export const deleteAnalysis = (project: string, analysis: string) => | |||
(dispatch: Function): Promise<*> => { | |||
return api | |||
.deleteAnalysis(analysis) | |||
.then(() => dispatch(deleteAnalysisAction(project, analysis)), rejectOnFail(dispatch)); | |||
}; | |||
export const deleteAnalysis = (project: string, analysis: string) => ( | |||
dispatch: Function | |||
): Promise<*> => { | |||
return api | |||
.deleteAnalysis(analysis) | |||
.then(() => dispatch(deleteAnalysisAction(project, analysis)), rejectOnFail(dispatch)); | |||
}; |
@@ -78,8 +78,8 @@ export default class Event extends React.PureComponent { | |||
render() { | |||
const { event, canAdmin } = this.props; | |||
const canChange = ['OTHER', 'VERSION'].includes(event.category); | |||
const canDelete = event.category === 'OTHER' || | |||
(event.category === 'VERSION' && !this.props.isFirst); | |||
const canDelete = | |||
event.category === 'OTHER' || (event.category === 'VERSION' && !this.props.isFirst); | |||
const showActions = canAdmin && (canChange || canDelete); | |||
return ( |