diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/projects')
28 files changed, 185 insertions, 107 deletions
diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.js b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.js index 37472169965..b08dbaff992 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.js +++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.js @@ -29,9 +29,10 @@ import { parseUrlQuery } from '../store/utils'; import { translate } from '../../../helpers/l10n'; import * as utils from '../utils'; import * as storage from '../../../helpers/storage'; -import type { RawQuery } from '../../../helpers/query'; +/*:: import type { RawQuery } from '../../../helpers/query'; */ import '../styles.css'; +/*:: type Props = {| isFavorite: boolean, location: { pathname: string, query: RawQuery }, @@ -43,14 +44,17 @@ type Props = {| }, currentUser?: { isLoggedIn: boolean } |}; +*/ +/*:: type State = { query: RawQuery }; +*/ export default class AllProjects extends React.PureComponent { - props: Props; - state: State = { query: {} }; + /*:: props: Props; */ + state /*: State */ = { query: {} }; componentDidMount() { this.handleQueryChange(true); @@ -58,7 +62,7 @@ export default class AllProjects extends React.PureComponent { footer && footer.classList.add('search-navigator-footer'); } - componentDidUpdate(prevProps: Props) { + componentDidUpdate(prevProps /*: Props */) { if (prevProps.location.query !== this.props.location.query) { this.handleQueryChange(false); } @@ -91,8 +95,10 @@ export default class AllProjects extends React.PureComponent { return options; }; - handlePerspectiveChange = ({ view, visualization }: { view: string, visualization?: string }) => { - const query: { view: ?string, visualization: ?string, sort?: ?string } = { + handlePerspectiveChange = ( + { view, visualization } /*: { view: string, visualization?: string } */ + ) => { + const query /*: { view: ?string, visualization: ?string, sort?: ?string } */ = { view: view === 'overall' ? undefined : view, visualization }; @@ -114,13 +120,13 @@ export default class AllProjects extends React.PureComponent { storage.saveVisualization(visualization); }; - handleSortChange = (sort: string, desc: boolean) => { + handleSortChange = (sort /*: string */, desc /*: boolean */) => { const asString = (desc ? '-' : '') + sort; this.updateLocationQuery({ sort: asString }); storage.saveSort(asString); }; - handleQueryChange(initialMount: boolean) { + handleQueryChange(initialMount /*: boolean */) { const query = parseUrlQuery(this.props.location.query); const savedOptions = this.getSavedOptions(); const savedOptionsSet = savedOptions.sort || savedOptions.view || savedOptions.visualization; @@ -134,7 +140,7 @@ export default class AllProjects extends React.PureComponent { } } - updateLocationQuery = (newQuery: { [string]: ?string }) => { + updateLocationQuery = (newQuery /*: { [string]: ?string } */) => { this.props.router.push({ pathname: this.props.location.pathname, query: { diff --git a/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.js b/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.js index d306afcd9db..d040e9e7330 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.js +++ b/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.js @@ -25,8 +25,9 @@ import AllProjectsContainer from './AllProjectsContainer'; import { getCurrentUser } from '../../../store/rootReducer'; import { isFavoriteSet, isAllSet } from '../../../helpers/storage'; import { searchProjects } from '../../../api/components'; -import type { RawQuery } from '../../../helpers/query'; +/*:: import type { RawQuery } from '../../../helpers/query'; */ +/*:: type Props = { currentUser: { isLoggedIn: boolean }, location: { query: {} }, @@ -34,17 +35,20 @@ type Props = { replace: (location: { pathname?: string, query?: RawQuery }) => void } }; +*/ +/*:: type State = { shouldBeRedirected?: boolean, shouldForceSorting?: string }; +*/ class DefaultPageSelector extends React.PureComponent { - props: Props; - state: State; + /*:: props: Props; */ + /*:: state: State; */ - constructor(props: Props) { + constructor(props /*: Props */) { super(props); this.state = {}; } @@ -53,7 +57,7 @@ class DefaultPageSelector extends React.PureComponent { this.defineIfShouldBeRedirected(); } - componentDidUpdate(prevProps: Props) { + componentDidUpdate(prevProps /*: Props */) { if (prevProps.location !== this.props.location) { this.defineIfShouldBeRedirected(); } else if (this.state.shouldBeRedirected === true) { diff --git a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.js b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.js index d3eb8d65b83..b2e9de9b6e4 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.js +++ b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.js @@ -22,8 +22,9 @@ import React from 'react'; import { IndexLink, Link } from 'react-router'; import { translate } from '../../../helpers/l10n'; import { saveAll, saveFavorite } from '../../../helpers/storage'; -import type { RawQuery } from '../../../helpers/query'; +/*:: import type { RawQuery } from '../../../helpers/query'; */ +/*:: type Props = { user: { isLoggedIn?: boolean @@ -31,9 +32,10 @@ type Props = { organization?: { key: string }, query: RawQuery }; +*/ export default class FavoriteFilter extends React.PureComponent { - props: Props; + /*:: props: Props; */ handleSaveFavorite = () => { if (!this.props.organization) { diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.js b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.js index 588920ead76..7fddfd1553b 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.js @@ -25,8 +25,9 @@ import Tooltip from '../../../components/controls/Tooltip'; import PerspectiveSelect from './PerspectiveSelect'; import ProjectsSortingSelect from './ProjectsSortingSelect'; import { translate } from '../../../helpers/l10n'; -import type { RawQuery } from '../../../helpers/query'; +/*:: import type { RawQuery } from '../../../helpers/query'; */ +/*:: type Props = {| currentUser?: { isLoggedIn: boolean }, isFavorite?: boolean, @@ -40,8 +41,9 @@ type Props = {| view: string, visualization?: string |}; +*/ -export default function PageHeader(props: Props) { +export default function PageHeader(props /*: Props */) { const renderSortingSelect = () => { const { projectsAppState, projects, currentUser, view } = props; const limitReached = diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.js b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.js index ab9dcd4326a..28c3f42a14d 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.js +++ b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.js @@ -37,8 +37,9 @@ import SecurityFilter from '../filters/SecurityFilter'; import SizeFilter from '../filters/SizeFilter'; import TagsFilterContainer from '../filters/TagsFilterContainer'; import { translate } from '../../../helpers/l10n'; -import type { RawQuery } from '../../../helpers/query'; +/*:: import type { RawQuery } from '../../../helpers/query'; */ +/*:: type Props = { isFavorite: boolean, organization?: { key: string }, @@ -46,14 +47,11 @@ type Props = { view: string, visualization: string }; +*/ -export default function PageSidebar({ - query, - isFavorite, - organization, - view, - visualization -}: Props) { +export default function PageSidebar( + { query, isFavorite, organization, view, visualization } /*: Props */ +) { const isFiltered = Object.keys(query) .filter(key => !['view', 'visualization', 'sort'].includes(key)) .some(key => query[key] != null); @@ -62,11 +60,12 @@ export default function PageSidebar({ const pathname = basePathName + (isFavorite ? '/favorite' : ''); const facetProps = { query, isFavorite, organization }; - let linkQuery: ?{ view: string, visualization?: string }; + let linkQuery; if (view !== 'overall') { linkQuery = { view }; if (view === 'visualizations') { + // $FlowFixMe linkQuery.visualization = visualization; } } diff --git a/server/sonar-web/src/main/js/apps/projects/components/PerspectiveSelect.js b/server/sonar-web/src/main/js/apps/projects/components/PerspectiveSelect.js index 6dff8ffa6de..c892a1eafba 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PerspectiveSelect.js +++ b/server/sonar-web/src/main/js/apps/projects/components/PerspectiveSelect.js @@ -24,20 +24,24 @@ import PerspectiveSelectOption from './PerspectiveSelectOption'; import { translate } from '../../../helpers/l10n'; import { VIEWS, VISUALIZATIONS } from '../utils'; +/*:: export type Option = { label: string, type: string, value: string }; +*/ +/*:: type Props = {| className?: string, onChange: ({ view: string, visualization?: string }) => void, view: string, visualization?: string |}; +*/ export default class PerspectiveSelect extends React.PureComponent { - options: Array<Option>; - props: Props; + /*:: options: Array<Option>; */ + /*:: props: Props; */ - constructor(props: Props) { + constructor(props /*: Props */) { super(props); this.options = [ ...VIEWS.map(opt => ({ @@ -53,7 +57,7 @@ export default class PerspectiveSelect extends React.PureComponent { ]; } - handleChange = (option: Option) => { + handleChange = (option /*: Option */) => { if (option.type === 'view') { this.props.onChange({ view: option.value }); } else if (option.type === 'visualization') { diff --git a/server/sonar-web/src/main/js/apps/projects/components/PerspectiveSelectOption.js b/server/sonar-web/src/main/js/apps/projects/components/PerspectiveSelectOption.js index bef22ae59a9..6fd3307a98d 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PerspectiveSelectOption.js +++ b/server/sonar-web/src/main/js/apps/projects/components/PerspectiveSelectOption.js @@ -21,8 +21,9 @@ import React from 'react'; import BubblesIcon from '../../../components/icons-components/BubblesIcon'; import ListIcon from '../../../components/icons-components/ListIcon'; -import type { Option } from './PerspectiveSelect'; +/*:: import type { Option } from './PerspectiveSelect'; */ +/*:: type Props = { option: Option, children?: Element | Text, @@ -31,21 +32,22 @@ type Props = { onFocus: (Option, MouseEvent) => void, onSelect: (Option, MouseEvent) => void }; +*/ export default class PerspectiveSelectOption extends React.PureComponent { - props: Props; + /*:: props: Props; */ - handleMouseDown = (event: MouseEvent) => { + handleMouseDown = (event /*: MouseEvent */) => { event.preventDefault(); event.stopPropagation(); this.props.onSelect(this.props.option, event); }; - handleMouseEnter = (event: MouseEvent) => { + handleMouseEnter = (event /*: MouseEvent */) => { this.props.onFocus(this.props.option, event); }; - handleMouseMove = (event: MouseEvent) => { + handleMouseMove = (event /*: MouseEvent */) => { if (this.props.isFocused) { return; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardContainer.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardContainer.js index 9e71d2559ba..a47d8a82e33 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardContainer.js @@ -23,7 +23,7 @@ import ProjectCardLeak from './ProjectCardLeak'; import ProjectCardOverall from './ProjectCardOverall'; import { getComponent, getComponentMeasures } from '../../../store/rootReducer'; -function ProjectCard(props: { type?: string }) { +function ProjectCard(props /*: { type?: string } */) { if (props.type === 'leak') { return <ProjectCardLeak {...props} />; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.js index 6de5f6a687f..b6af4d5cd10 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.js @@ -30,6 +30,7 @@ import TagsList from '../../../components/tags/TagsList'; import PrivateBadge from '../../../components/common/PrivateBadge'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +/*:: type Props = { measures: { [string]: string }, organization?: { key: string }, @@ -44,8 +45,9 @@ type Props = { visibility?: boolean } }; +*/ -export default function ProjectCardLeak({ measures, organization, project }: Props) { +export default function ProjectCardLeak({ measures, organization, project } /*: Props */) { if (project == null) { return null; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeakMeasures.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeakMeasures.js index 36de893963f..88d1afde4f3 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeakMeasures.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeakMeasures.js @@ -26,11 +26,13 @@ import Rating from '../../../components/ui/Rating'; import VulnerabilityIcon from '../../../components/icons-components/VulnerabilityIcon'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { measures?: { [string]: string } }; +*/ -export default function ProjectCardLeakMeasures({ measures }: Props) { +export default function ProjectCardLeakMeasures({ measures } /*: Props */) { if (measures == null) { return null; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.js index 49c9d27fcc8..5d8cddae025 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.js @@ -30,6 +30,7 @@ import TagsList from '../../../components/tags/TagsList'; import PrivateBadge from '../../../components/common/PrivateBadge'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +/*:: type Props = { measures: { [string]: string }, organization?: { key: string }, @@ -43,8 +44,9 @@ type Props = { visibility?: boolean } }; +*/ -export default function ProjectCardOverall({ measures, organization, project }: Props) { +export default function ProjectCardOverall({ measures, organization, project } /*: Props */) { if (project == null) { return null; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.js index 701e707657b..fbfce28ae57 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.js @@ -27,11 +27,13 @@ import DuplicationsRating from '../../../components/ui/DuplicationsRating'; import SizeRating from '../../../components/ui/SizeRating'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { measures?: { [string]: string } }; +*/ -export default function ProjectCardOverallMeasures({ measures }: Props) { +export default function ProjectCardOverallMeasures({ measures } /*: Props */) { if (measures == null) { return null; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardQualityGate.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardQualityGate.js index 585c2648e1c..d73a9223c2c 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardQualityGate.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardQualityGate.js @@ -24,7 +24,7 @@ import Tooltip from '../../../components/controls/Tooltip'; import { formatMeasure } from '../../../helpers/measures'; import { translateWithParameters } from '../../../helpers/l10n'; -export default function ProjectCardQualityGate({ status }: { status?: string }) { +export default function ProjectCardQualityGate({ status } /*: { status?: string } */) { if (!status) { return null; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectTagsSelectorContainer.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectTagsSelectorContainer.js index 14b7d37e613..2cb4ab4e54a 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectTagsSelectorContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectTagsSelectorContainer.js @@ -25,24 +25,28 @@ import TagsSelector from '../../../components/tags/TagsSelector'; import { searchProjectTags } from '../../../api/components'; import { setProjectTags } from '../store/actions'; +/*:: type Props = { position: {}, project: string, selectedTags: Array<string>, setProjectTags: (string, Array<string>) => void }; +*/ +/*:: type State = { searchResult: Array<string> }; +*/ const LIST_SIZE = 10; class ProjectTagsSelectorContainer extends React.PureComponent { - props: Props; - state: State; + /*:: props: Props; */ + /*:: state: State; */ - constructor(props: Props) { + constructor(props /*: Props */) { super(props); this.state = { searchResult: [] }; this.onSearch = debounce(this.onSearch, 250); @@ -52,7 +56,7 @@ class ProjectTagsSelectorContainer extends React.PureComponent { this.onSearch(''); } - onSearch = (query: string) => { + onSearch = (query /*: string */) => { searchProjectTags({ q: query || '', ps: Math.min(this.props.selectedTags.length - 1 + LIST_SIZE, 100) @@ -63,11 +67,11 @@ class ProjectTagsSelectorContainer extends React.PureComponent { }); }; - onSelect = (tag: string) => { + onSelect = (tag /*: string */) => { this.props.setProjectTags(this.props.project, [...this.props.selectedTags, tag]); }; - onUnselect = (tag: string) => { + onUnselect = (tag /*: string */) => { this.props.setProjectTags(this.props.project, without(this.props.selectedTags, tag)); }; diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.js index 1b2f615bced..c806f94b6d7 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.js @@ -24,6 +24,7 @@ import NoFavoriteProjects from './NoFavoriteProjects'; import EmptyInstance from './EmptyInstance'; import EmptySearch from '../../../components/common/EmptySearch'; +/*:: type Props = { projects?: Array<string>, isFavorite: boolean, @@ -31,9 +32,10 @@ type Props = { organization?: { key: string }, cardType?: string }; +*/ export default class ProjectsList extends React.PureComponent { - props: Props; + /*:: props: Props; */ renderNoProjects() { if (this.props.isFavorite && !this.props.isFiltered) { diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.js index fa9fb3b7f00..f4f21fa2bd2 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.js @@ -28,8 +28,11 @@ import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; import { SORTING_METRICS, SORTING_LEAK_METRICS, parseSorting } from '../utils'; +/*:: export type Option = { label: string, value: string, class?: string, short?: string }; +*/ +/*:: type Props = { className?: string, onChange: (sort: string, desc: boolean) => void, @@ -37,22 +40,25 @@ type Props = { view: string, defaultOption: string }; +*/ +/*:: type State = { sortValue: string, sortDesc: boolean }; +*/ export default class ProjectsSortingSelect extends React.PureComponent { - props: Props; - state: State; + /*:: props: Props; */ + /*:: state: State; */ - constructor(props: Props) { + constructor(props /*: Props */) { super(props); this.state = parseSorting(props.selectedSort); } - componentDidUpdate(prevProps: Props) { + componentDidUpdate(prevProps /*: Props */) { if (prevProps.selectedSort !== this.props.selectedSort) { this.setState(parseSorting(this.props.selectedSort)); } @@ -60,23 +66,23 @@ export default class ProjectsSortingSelect extends React.PureComponent { getOptions = () => { const sortMetrics = this.props.view === 'leak' ? SORTING_LEAK_METRICS : SORTING_METRICS; - return sortBy( - sortMetrics, - opt => (opt.value === this.props.defaultOption ? 0 : 1) - ).map((opt: { value: string, class?: string }) => ({ + return sortBy(sortMetrics, opt => (opt.value === this.props.defaultOption ? 0 : 1)).map(( + opt /*: { value: string, class?: string } */ + ) => ({ value: opt.value, label: translate('projects.sorting', opt.value), class: opt.class })); }; - handleDescToggle = (evt: Event & { currentTarget: HTMLElement }) => { + handleDescToggle = (evt /*: Event & { currentTarget: HTMLElement } */) => { evt.preventDefault(); evt.currentTarget.blur(); this.props.onChange(this.state.sortValue, !this.state.sortDesc); }; - handleSortChange = (option: Option) => this.props.onChange(option.value, this.state.sortDesc); + handleSortChange = (option /*: Option */) => + this.props.onChange(option.value, this.state.sortDesc); render() { const { sortDesc } = this.state; diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelectOption.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelectOption.js index 9789a3d30fb..aebb6bb478b 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelectOption.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelectOption.js @@ -20,8 +20,9 @@ //@flow import React from 'react'; import classNames from 'classnames'; -import type { Option } from './ProjectsSortingSelect'; +/*:: import type { Option } from './ProjectsSortingSelect'; */ +/*:: type Props = { option: Option, children?: Element | Text, @@ -30,21 +31,22 @@ type Props = { onFocus: (Option, MouseEvent) => void, onSelect: (Option, MouseEvent) => void }; +*/ export default class ProjectsSortingSelectOption extends React.PureComponent { - props: Props; + /*:: props: Props; */ - handleMouseDown = (event: MouseEvent) => { + handleMouseDown = (event /*: MouseEvent */) => { event.preventDefault(); event.stopPropagation(); this.props.onSelect(this.props.option, event); }; - handleMouseEnter = (event: MouseEvent) => { + handleMouseEnter = (event /*: MouseEvent */) => { this.props.onFocus(this.props.option, event); }; - handleMouseMove = (event: MouseEvent) => { + handleMouseMove = (event /*: MouseEvent */) => { if (this.props.isFocused) { return; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/Filter.js b/server/sonar-web/src/main/js/apps/projects/filters/Filter.js index a00b11ef2a3..d39cd7ee2d2 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/Filter.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/Filter.js @@ -68,7 +68,7 @@ export default class Filter extends React.PureComponent { ); } - blurOnClick = (evt: Event & { currentTarget: HTMLElement }) => evt.currentTarget.blur(); + blurOnClick = (evt /*: Event & { currentTarget: HTMLElement } */) => evt.currentTarget.blur(); getPath(option) { const { property, value } = this.props; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/FilterHeader.js b/server/sonar-web/src/main/js/apps/projects/filters/FilterHeader.js index 11d9d790662..51b3512ca0e 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/FilterHeader.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/FilterHeader.js @@ -20,13 +20,15 @@ //@flow import React from 'react'; +/*:: type Props = { name: string, children?: React.Element<*> }; +*/ export default class FilterHeader extends React.PureComponent { - props: Props; + /*:: props: Props; */ render() { return ( diff --git a/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.js b/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.js index 6548c9441e0..833a7d810e7 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.js @@ -27,6 +27,7 @@ import SearchableFilterOption from './SearchableFilterOption'; import { getLanguageByKey } from '../../../store/languages/reducer'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { query: {}, languages: {}, @@ -37,14 +38,18 @@ type Props = { organization?: {}, maxFacetValue?: number }; +*/ const LIST_SIZE = 10; export default class LanguagesFilter extends React.PureComponent { - props: Props; + /*:: props: Props; */ property = 'languages'; - getSearchOptions(facet?: {}, languages: {}): Array<{ label: string, value: string }> { + getSearchOptions( + facet /*: ?{} */, + languages /*: {} */ + ) /*: Array<{ label: string, value: string }> */ { let languageKeys = Object.keys(languages); if (facet) { languageKeys = difference(languageKeys, Object.keys(facet)); @@ -54,13 +59,13 @@ export default class LanguagesFilter extends React.PureComponent { .map(key => ({ label: languages[key].name, value: key })); } - getSortedOptions(facet: {} = {}) { + getSortedOptions(facet /*: {} */ = {}) { return sortBy(Object.keys(facet), [option => -facet[option], option => option]); } - getFacetValueForOption = (facet: {} = {}, option: string) => facet[option]; + getFacetValueForOption = (facet /*: {} */ = {}, option /*: string */) => facet[option]; - renderOption = (option: string) => + renderOption = (option /*: string */) => <SearchableFilterOption optionKey={option} option={getLanguageByKey(this.props.languages, option)} diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SearchFilter.js b/server/sonar-web/src/main/js/apps/projects/filters/SearchFilter.js index 506bec6175f..5439403b3ad 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SearchFilter.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/SearchFilter.js @@ -21,28 +21,32 @@ import React from 'react'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +/*:: type Props = { className?: string, handleSearch: (userString?: string) => void, query: { search?: string } }; +*/ +/*:: type State = { userQuery?: string }; +*/ export default class SearchFilter extends React.PureComponent { - props: Props; - state: State; + /*:: props: Props; */ + /*:: state: State; */ - constructor(props: Props) { + constructor(props /*: Props */) { super(props); this.state = { userQuery: props.query.search }; } - componentWillReceiveProps(nextProps: Props) { + componentWillReceiveProps(nextProps /*: Props */) { if ( this.props.query.search === this.state.userQuery && nextProps.query.search !== this.props.query.search @@ -53,7 +57,7 @@ export default class SearchFilter extends React.PureComponent { } } - handleQueryChange = ({ target }: { target: HTMLInputElement }) => { + handleQueryChange = ({ target } /*: { target: HTMLInputElement } */) => { this.setState({ userQuery: target.value }); if (!target.value || target.value.length >= 2) { this.props.handleSearch(target.value); diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.js b/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.js index 74b16a51ae3..6e64dbf9bec 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/SearchFilterContainer.js @@ -24,6 +24,7 @@ import { debounce } from 'lodash'; import { getFilterUrl } from './utils'; import SearchFilter from './SearchFilter'; +/*:: type Props = {| className?: string, query: { search?: string }, @@ -31,17 +32,18 @@ type Props = {| isFavorite?: boolean, organization?: {} |}; +*/ class SearchFilterContainer extends React.PureComponent { - handleSearch: (userQuery?: string) => void; - props: Props; + /*:: handleSearch: (userQuery?: string) => void; */ + /*:: props: Props; */ - constructor(props: Props) { + constructor(props /*: Props */) { super(props); this.handleSearch = debounce(this.handleSearch.bind(this), 250); } - handleSearch(userQuery?: string) { + handleSearch(userQuery /*: ?string */) { const path = getFilterUrl(this.props, { search: userQuery || null }); this.props.router.push(path); } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.js b/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.js index e5b739e8429..25b7ff076d7 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.js @@ -23,6 +23,7 @@ import Select from 'react-select'; import { getFilterUrl } from './utils'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { property: string, query: {}, @@ -34,11 +35,12 @@ type Props = { isFavorite?: boolean, organization?: {} }; +*/ export default class SearchableFilterFooter extends React.PureComponent { - props: Props; + /*:: props: Props; */ - handleOptionChange: ({ value: string }) => void = ({ value }) => { + handleOptionChange /*: ({ value: string }) => void */ = ({ value }) => { const urlOptions = (this.props.query[this.props.property] || []).concat(value).join(','); const path = getFilterUrl(this.props, { [this.props.property]: urlOptions }); this.props.router.push(path); diff --git a/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.js b/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.js index 7fb48d31783..22c5bfcb377 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.js @@ -27,6 +27,7 @@ import SearchableFilterOption from './SearchableFilterOption'; import { searchProjectTags } from '../../../api/components'; import { translate } from '../../../helpers/l10n'; +/*:: type Props = { query: {}, router: { push: ({ pathname: string, query?: {} }) => void }, @@ -36,21 +37,24 @@ type Props = { organization?: {}, maxFacetValue?: number }; +*/ +/*:: type State = { isLoading: boolean, search: string, tags: Array<string> }; +*/ const LIST_SIZE = 10; export default class TagsFilter extends React.PureComponent { - props: Props; - state: State; - property: string; + /*:: props: Props; */ + /*:: state: State; */ + /*:: property: string; */ - constructor(props: Props) { + constructor(props /*: Props */) { super(props); this.state = { isLoading: false, @@ -61,7 +65,10 @@ export default class TagsFilter extends React.PureComponent { this.handleSearch = debounce(this.handleSearch.bind(this), 250); } - getSearchOptions(facet?: {}, tags: Array<string>): Array<{ label: string, value: string }> { + getSearchOptions( + facet /*: ?{} */, + tags /*: Array<string> */ + ) /*: Array<{ label: string, value: string }> */ { let tagsCopy = [...tags]; if (facet) { tagsCopy = difference(tagsCopy, Object.keys(facet)); @@ -69,7 +76,7 @@ export default class TagsFilter extends React.PureComponent { return tagsCopy.slice(0, LIST_SIZE).map(tag => ({ label: tag, value: tag })); } - handleSearch = (search?: string) => { + handleSearch = (search /*: ?string */) => { if (search !== this.state.search) { search = search || ''; this.setState({ search, isLoading: true }); @@ -82,13 +89,13 @@ export default class TagsFilter extends React.PureComponent { } }; - getSortedOptions(facet: {} = {}) { + getSortedOptions(facet /*: {} */ = {}) { return sortBy(Object.keys(facet), [option => -facet[option], option => option]); } - getFacetValueForOption = (facet: {}, option: string) => facet[option]; + getFacetValueForOption = (facet /*: {} */, option /*: string */) => facet[option]; - renderOption = (option: string) => <SearchableFilterOption optionKey={option} />; + renderOption = (option /*: string */) => <SearchableFilterOption optionKey={option} />; render() { return ( diff --git a/server/sonar-web/src/main/js/apps/projects/utils.js b/server/sonar-web/src/main/js/apps/projects/utils.js index 02f2ae59d59..b322061f662 100644 --- a/server/sonar-web/src/main/js/apps/projects/utils.js +++ b/server/sonar-web/src/main/js/apps/projects/utils.js @@ -70,11 +70,11 @@ export const VISUALIZATIONS = [ 'duplications' ]; -export const localizeSorting = (sort?: string) => { +export const localizeSorting = (sort /*: ?string */) => { return translate('projects.sort', sort || 'name'); }; -export const parseSorting = (sort: string): { sortValue: string, sortDesc: boolean } => { +export function parseSorting(sort /*: string */) /*: { sortValue: string, sortDesc: boolean } */ { const desc = sort[0] === '-'; return { sortValue: desc ? sort.substr(1) : sort, sortDesc: desc }; -}; +} diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/Risk.js b/server/sonar-web/src/main/js/apps/projects/visualizations/Risk.js index d69b6bfce49..880b07fa10a 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/Risk.js +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/Risk.js @@ -26,12 +26,14 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; import { RATING_COLORS } from '../../../helpers/constants'; import { getProjectUrl } from '../../../helpers/urls'; +/*:: type Project = { key: string, measures: { [string]: string }, name: string, organization?: { name: string } }; +*/ const X_METRIC = 'sqale_index'; const X_METRIC_TYPE = 'SHORT_WORK_DUR'; @@ -44,24 +46,25 @@ const COLOR_METRIC_2 = 'security_rating'; const COLOR_METRIC_TYPE = 'RATING'; export default class Risk extends React.PureComponent { - props: { + /*:: props: { displayOrganizations: boolean, projects: Array<Project> }; +*/ - getMetricTooltip(metric: { key: string, type: string }, value: ?number) { + getMetricTooltip(metric /*: { key: string, type: string } */, value /*: ?number */) { const name = translate('metric', metric.key, 'name'); const formattedValue = value != null ? formatMeasure(value, metric.type) : '–'; return `<div>${name}: ${formattedValue}</div>`; } getTooltip( - project: Project, - x: ?number, - y: ?number, - size: ?number, - color1: ?number, - color2: ?number + project /*: Project */, + x /*: ?number */, + y /*: ?number */, + size /*: ?number */, + color1 /*: ?number */, + color2 /*: ?number */ ) { const fullProjectName = this.props.displayOrganizations && project.organization diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/SimpleBubbleChart.js b/server/sonar-web/src/main/js/apps/projects/visualizations/SimpleBubbleChart.js index 44ddf736040..a1ccdf18a0b 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/SimpleBubbleChart.js +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/SimpleBubbleChart.js @@ -26,17 +26,21 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; import { RATING_COLORS } from '../../../helpers/constants'; import { getProjectUrl } from '../../../helpers/urls'; +/*:: type Metric = { key: string, type: string }; +*/ +/*:: type Project = { key: string, measures: { [string]: string }, name: string, organization?: { name: string } }; +*/ export default class SimpleBubbleChart extends React.PureComponent { - props: { + /*:: props: { displayOrganizations: boolean, projects: Array<Project>, sizeMetric: Metric, @@ -45,14 +49,21 @@ export default class SimpleBubbleChart extends React.PureComponent { yMetric: Metric, colorMetric?: string }; +*/ - getMetricTooltip(metric: Metric, value: ?number) { + getMetricTooltip(metric /*: Metric */, value /*: ?number */) { const name = translate('metric', metric.key, 'name'); const formattedValue = value != null ? formatMeasure(value, metric.type) : '–'; return `<div>${name}: ${formattedValue}</div>`; } - getTooltip(project: Project, x: ?number, y: ?number, size: ?number, color?: number) { + getTooltip( + project /*: Project */, + x /*: ?number */, + y /*: ?number */, + size /*: ?number */, + color /*: ?number */ + ) { const fullProjectName = this.props.displayOrganizations && project.organization ? `${project.organization.name} / <strong>${project.name}</strong>` diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.js b/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.js index ee32e11c30f..661a67d0b21 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.js +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.js @@ -29,15 +29,16 @@ import { localizeSorting } from '../utils'; import { translate, translateWithParameters } from '../../../helpers/l10n'; export default class Visualizations extends React.PureComponent { - props: { + /*:: props: { displayOrganizations: boolean, projects?: Array<*>, sort?: string, total?: number, visualization: string }; +*/ - renderVisualization(projects: Array<*>) { + renderVisualization(projects /*: Array<*> */) { const visualizationToComponent = { risk: Risk, reliability: Reliability, |