From 0c66605ff3957624bc9b8536ea273f576463380f Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 1 Nov 2017 20:13:17 +0100 Subject: [PATCH] SONAR-10023 Clear actions must be consistent --- .../nav/component/ComponentNavBranch.tsx | 2 +- .../ComponentNavBranch-test.tsx.snap | 2 +- .../__tests__/SettingsEditionsNotif-test.tsx | 2 +- .../src/main/js/app/styles/init/forms.css | 15 +- .../src/main/js/app/styles/init/icons.css | 24 -- server/sonar-web/src/main/js/app/theme.js | 4 + .../js/apps/account/notifications/Projects.js | 2 +- .../apps/background-tasks/components/Stats.js | 18 +- .../background-tasks/components/Workers.tsx | 29 ++- .../__snapshots__/Workers-test.tsx.snap | 176 +++++++------- .../components/MeasureHeader.js | 2 +- .../__snapshots__/MeasureHeader-test.js.snap | 4 +- .../overview/main/BugsAndVulnerabilities.js | 4 +- .../src/main/js/apps/overview/main/enhance.js | 5 +- .../components/HistoryButtonLink.tsx | 2 +- .../components/MeasuresButtonLink.tsx | 2 +- .../HistoryButtonLink-test.tsx.snap | 2 +- .../MeasuresButtonLink-test.tsx.snap | 2 +- .../apps/projectActivity/components/Event.js | 17 +- .../components/GraphsLegendItem.tsx | 20 +- .../components/ProjectActivityAnalysis.js | 4 +- .../GraphsLegendItem-test.tsx.snap | 34 ++- .../components/projectActivity.css | 15 +- .../components/LongBranchesPattern.tsx | 13 +- .../__tests__/LongBranchesPattern-test.tsx | 4 +- .../LongBranchesPattern-test.tsx.snap | 9 +- .../components/ProjectsSortingSelect.tsx | 19 +- .../__tests__/ProjectsSortingSelect-test.tsx | 3 +- .../ProjectsSortingSelect-test.tsx.snap | 30 +-- .../js/apps/projectsManagement/Header.tsx | 21 +- .../__snapshots__/Header-test.tsx.snap | 25 +- .../__tests__/ThresholdInput-test.js | 7 +- .../details/ProfilePermissionsGroup.tsx | 16 +- .../details/ProfilePermissionsUser.tsx | 16 +- .../ProfilePermissionsGroup-test.tsx | 4 +- .../__tests__/ProfilePermissionsUser-test.tsx | 4 +- .../ProfilePermissionsGroup-test.tsx.snap | 9 +- .../ProfilePermissionsUser-test.tsx.snap | 9 +- .../components/inputs/MultiValueInput.js | 16 +- .../components/inputs/PropertySetInput.js | 18 +- .../js/apps/system/components/PageActions.tsx | 23 +- .../__snapshots__/PageActions-test.tsx.snap | 54 +++-- .../components/info-items/SysInfoItem.tsx | 4 +- .../info-items/__tests__/SysInfoItem-test.tsx | 4 +- .../__snapshots__/SysInfoItem-test.tsx.snap | 4 +- .../onboarding/NewOrganizationForm.js | 13 +- .../tutorials/onboarding/NewProjectForm.js | 13 +- .../tutorials/onboarding/ProjectKeyStep.js | 156 ------------- .../js/apps/tutorials/onboarding/TokenStep.js | 9 +- .../__tests__/NewOrganizationForm-test.js | 5 +- .../__tests__/NewProjectForm-test.js | 5 +- .../__tests__/ProjectKeyStep-test.js | 63 ----- .../onboarding/__tests__/TokenStep-test.js | 5 +- .../NewOrganizationForm-test.js.snap | 90 ++++---- .../__snapshots__/NewProjectForm-test.js.snap | 90 ++++---- .../__snapshots__/ProjectKeyStep-test.js.snap | 215 ------------------ .../__snapshots__/TokenStep-test.js.snap | 70 +++--- .../users/components/UsersAppContainer.js | 2 + .../js/apps/users/templates/users-form.hbs | 16 +- .../components/controls/ActionsDropdown.tsx | 4 +- .../main/js/components/controls/DateInput.tsx | 17 +- .../main/js/components/controls/Select.tsx | 17 +- .../js/components/controls/react-select.css | 4 +- .../icons-components/AlertErrorIcon.tsx | 18 +- .../icons-components/AlertWarnIcon.tsx | 19 +- .../icons-components/BranchIcon.tsx | 6 +- .../icons-components/BubblesIcon.tsx | 18 +- .../components/icons-components/BugIcon.tsx | 19 +- ...ChartLegendIcon.js => ChartLegendIcon.tsx} | 25 +- .../components/icons-components/CheckIcon.tsx | 18 +- .../{CloseIcon.tsx => ClearIcon.tsx} | 22 +- .../icons-components/CodeSmellIcon.tsx | 17 +- .../icons-components/DeleteIcon.tsx | 17 +- .../components/icons-components/EditIcon.tsx | 20 +- .../components/icons-components/GroupIcon.tsx | 21 +- .../components/icons-components/HelpIcon.tsx | 20 +- .../icons-components/HistoryIcon.tsx | 18 +- .../components/icons-components/LinkIcon.tsx | 26 +-- .../{ListIcon.js => ListIcon.tsx} | 21 +- .../icons-components/LongLivingBranchIcon.tsx | 24 +- .../icons-components/OpenCloseIcon.tsx | 29 ++- ...ganizationIcon.js => OrganizationIcon.tsx} | 21 +- .../icons-components/PendingIcon.tsx | 25 +- ...ojectEventIcon.js => ProjectEventIcon.tsx} | 21 +- .../icons-components/PullRequestIcon.tsx | 20 +- .../icons-components/SettingsIcon.tsx | 24 +- .../ShortLivingBranchIcon.tsx | 24 +- .../{SortAscIcon.js => SortAscIcon.tsx} | 21 +- .../{SortDescIcon.js => SortDescIcon.tsx} | 21 +- .../{TreeIcon.js => TreeIcon.tsx} | 19 +- .../{TreemapIcon.js => TreemapIcon.tsx} | 20 +- .../icons-components/VulnerabilityIcon.tsx | 23 +- .../icons-components/__mocks__/ClearIcon.tsx | 22 ++ .../js/components/icons-components/icons.ts | 93 +++----- .../js/components/icons-components/types.ts | 24 ++ .../issue/components/IssueCommentLine.js | 20 +- .../__tests__/IssueCommentLine-test.js | 5 +- .../IssueCommentLine-test.js.snap | 32 +-- .../src/main/js/components/nav/NavBar.tsx | 3 +- .../main/js/components/nav/NavBarNotif.tsx | 39 ++-- .../ChangeIcon.tsx => ui/buttons.css} | 52 +++-- .../src/main/js/components/ui/buttons.tsx | 79 +++++++ .../pageobjects/projects/ProjectsPage.java | 2 +- .../tests/projectSearch/ProjectsPageTest.java | 6 +- 104 files changed, 1018 insertions(+), 1449 deletions(-) delete mode 100644 server/sonar-web/src/main/js/apps/tutorials/onboarding/ProjectKeyStep.js delete mode 100644 server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/ProjectKeyStep-test.js delete mode 100644 server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/ProjectKeyStep-test.js.snap rename server/sonar-web/src/main/js/components/icons-components/{ChartLegendIcon.js => ChartLegendIcon.tsx} (78%) rename server/sonar-web/src/main/js/components/icons-components/{CloseIcon.tsx => ClearIcon.tsx} (57%) rename server/sonar-web/src/main/js/components/icons-components/{ListIcon.js => ListIcon.tsx} (84%) rename server/sonar-web/src/main/js/components/icons-components/{OrganizationIcon.js => OrganizationIcon.tsx} (83%) rename server/sonar-web/src/main/js/components/icons-components/{ProjectEventIcon.js => ProjectEventIcon.tsx} (84%) rename server/sonar-web/src/main/js/components/icons-components/{SortAscIcon.js => SortAscIcon.tsx} (86%) rename server/sonar-web/src/main/js/components/icons-components/{SortDescIcon.js => SortDescIcon.tsx} (86%) rename server/sonar-web/src/main/js/components/icons-components/{TreeIcon.js => TreeIcon.tsx} (84%) rename server/sonar-web/src/main/js/components/icons-components/{TreemapIcon.js => TreemapIcon.tsx} (75%) create mode 100644 server/sonar-web/src/main/js/components/icons-components/__mocks__/ClearIcon.tsx create mode 100644 server/sonar-web/src/main/js/components/icons-components/types.ts rename server/sonar-web/src/main/js/components/{icons-components/ChangeIcon.tsx => ui/buttons.css} (51%) create mode 100644 server/sonar-web/src/main/js/components/ui/buttons.tsx diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx index 8372ba11539..c621bcf4170 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx @@ -196,7 +196,7 @@ export default class ComponentNavBranch extends React.PureComponent - + {currentBranch.name} {this.renderNoBranchSupportPopup()} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranch-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranch-test.tsx.snap index baa03cf6636..3571893cc96 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranch-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBranch-test.tsx.snap @@ -48,7 +48,7 @@ exports[`renders no branch support popup 1`] = ` } } className="little-spacer-right" - color="#cdcdcd" + fill="#cdcdcd" /> { setEditionStatus={setEditionStatus} /> ); - click(wrapper.find('a')); + click(wrapper.find('button')); expect(dismissMsg).toHaveBeenCalled(); await new Promise(setImmediate); expect(setEditionStatus).toHaveBeenCalledWith({ diff --git a/server/sonar-web/src/main/js/app/styles/init/forms.css b/server/sonar-web/src/main/js/app/styles/init/forms.css index b539c0ec578..a9a610f6632 100644 --- a/server/sonar-web/src/main/js/app/styles/init/forms.css +++ b/server/sonar-web/src/main/js/app/styles/init/forms.css @@ -292,24 +292,17 @@ input[type='submit'].button-grey.button-active { cursor: default; } -.button-icon { - border: none; - color: var(--secondFontColor); -} - .button-small { - height: 20px; + height: var(--smallControlHeight); line-height: 18px; + padding: 0 6px; + font-size: 11px; } .button-small > svg { margin-top: 2px; } -.button-compact { - padding: 0 6px; -} - .button-group { display: inline-block; vertical-align: middle; @@ -395,7 +388,7 @@ textarea.input-super-large { min-width: 300px; } -.input-clear { +.input-ghost { padding: 0 !important; border: none !important; background-color: transparent !important; diff --git a/server/sonar-web/src/main/js/app/styles/init/icons.css b/server/sonar-web/src/main/js/app/styles/init/icons.css index 7fdffc1f0be..82baae3dac5 100644 --- a/server/sonar-web/src/main/js/app/styles/init/icons.css +++ b/server/sonar-web/src/main/js/app/styles/init/icons.css @@ -789,30 +789,6 @@ a:hover > .icon-radio { background-repeat: no-repeat; } -.icon-pending { - position: relative; - top: -1px; -} - -.icon-pending path { - fill: var(--secondFontColor); - animation: animation-pending 2s linear infinite; -} - -@keyframes animation-pending { - 0% { - fill: var(--secondFontColor); - } - - 50% { - fill: #aaa; - } - - 100% { - fill: var(--secondFontColor); - } -} - /* * Spinner */ diff --git a/server/sonar-web/src/main/js/app/theme.js b/server/sonar-web/src/main/js/app/theme.js index df4935a6b16..024f34c7d80 100644 --- a/server/sonar-web/src/main/js/app/theme.js +++ b/server/sonar-web/src/main/js/app/theme.js @@ -35,6 +35,8 @@ module.exports = { gray94: '#efefef', gray80: '#cdcdcd', gray71: '#b4b4b4', + gray67: '#aaa', + gray60: '#999', barBackgroundColor: '#f3f3f3', barBorderColor: '#e6e6e6', @@ -52,6 +54,8 @@ module.exports = { bigFontSize: '16px', controlHeight: '24px', + smallControlHeight: '20px', + tinyControlHeight: '16px', // different defaultShadow: '0 6px 12px rgba(0, 0, 0, 0.175)', diff --git a/server/sonar-web/src/main/js/apps/account/notifications/Projects.js b/server/sonar-web/src/main/js/apps/account/notifications/Projects.js index c55e6c8aaa0..14a7f74020c 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/Projects.js +++ b/server/sonar-web/src/main/js/apps/account/notifications/Projects.js @@ -21,7 +21,7 @@ import React from 'react'; import { connect } from 'react-redux'; import { differenceBy } from 'lodash'; import ProjectNotifications from './ProjectNotifications'; -import Select, { AsyncSelect } from '../../../components/controls/Select'; +import { AsyncSelect } from '../../../components/controls/Select'; import Organization from '../../../components/shared/Organization'; import { translate } from '../../../helpers/l10n'; import { getSuggestions } from '../../../api/components'; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.js b/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.js index 8c239e9d812..7d10b92b669 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.js @@ -20,7 +20,7 @@ /* @flow */ import React from 'react'; import Tooltip from '../../../components/controls/Tooltip'; -import DeleteIcon from '../../../components/icons-components/DeleteIcon'; +import { DeleteButton } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; /*:: @@ -41,12 +41,6 @@ export default class Stats extends React.PureComponent { /*:: props: Props; */ /*:: state: State; */ - handleCancelAllPending = (event /*: Object */) => { - event.preventDefault(); - event.currentTarget.blur(); - this.props.onCancelAllPending(); - }; - handleShowFailing = (event /*: Object */) => { event.preventDefault(); event.currentTarget.blur(); @@ -65,12 +59,10 @@ export default class Stats extends React.PureComponent { {translate('background_tasks.pending')} {this.props.isSystemAdmin && ( - - - + )} diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx index a5eef35810f..e77351cfaf7 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx @@ -26,7 +26,7 @@ import { getWorkers } from '../../../api/ce'; import { translate } from '../../../helpers/l10n'; import HelpIcon from '../../../components/icons-components/HelpIcon'; import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; -import EditIcon from '../../../components/icons-components/EditIcon'; +import { EditButton } from '../../../components/ui/buttons'; interface State { canSetWorkerCount: boolean; @@ -80,8 +80,7 @@ export default class Workers extends React.PureComponent<{}, State> { ? this.setState({ formOpen: false, workerCount: newWorkerCount }) : this.setState({ formOpen: false }); - handleChangeClick = (event: React.SyntheticEvent) => { - event.preventDefault(); + handleChangeClick = () => { this.setState({ formOpen: true }); }; @@ -111,23 +110,23 @@ export default class Workers extends React.PureComponent<{}, State> { )} - {translate('background_tasks.number_of_workers')} + + {translate('background_tasks.number_of_workers')} - {loading ? ( - - ) : ( - {workerCount} - )} + {loading ? ( + + ) : ( + {workerCount} + )} + {!loading && canSetWorkerCount && ( - - - + )} diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Workers-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Workers-test.tsx.snap index 73abbbf04b4..3aa130c12ac 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Workers-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Workers-test.tsx.snap @@ -2,50 +2,48 @@ exports[`opens form 1`] = `
- background_tasks.number_of_workers - - 1 - + background_tasks.number_of_workers + + 1 + + - - - + />
`; exports[`opens form 2`] = `
- background_tasks.number_of_workers - - 1 - + background_tasks.number_of_workers + + 1 + + - - - + /> - background_tasks.number_of_workers - + + background_tasks.number_of_workers + +
`; exports[`renders 2`] = `
- background_tasks.number_of_workers - - 1 - + background_tasks.number_of_workers + + 1 + + - - - + />
`; @@ -98,25 +99,24 @@ exports[`renders 3`] = ` className="icon-alert-warn little-spacer-right bt-workers-warning-icon" /> - background_tasks.number_of_workers - - 2 - + background_tasks.number_of_workers + + 2 + + - - - + /> `; @@ -131,12 +131,16 @@ exports[`renders 4`] = ` className="icon-alert-warn little-spacer-right bt-workers-warning-icon" /> - background_tasks.number_of_workers - - 2 - + background_tasks.number_of_workers + + 2 + + @@ -162,25 +166,24 @@ exports[`renders 4`] = ` exports[`updates worker count 1`] = `
- background_tasks.number_of_workers - - 1 - + background_tasks.number_of_workers + + 1 + + - - - + /> - background_tasks.number_of_workers - - 7 - + background_tasks.number_of_workers + + 7 + + - - - + />
`; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.js b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.js index bbbded8e6c1..97457c84d76 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.js +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.js @@ -66,7 +66,7 @@ export default function MeasureHeader(props /*: Props*/) { placement="right" overlay={translate('component_measures.show_metric_history')}> diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/MeasureHeader-test.js.snap b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/MeasureHeader-test.js.snap index ec3b0d5395c..e58ba900cd7 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/MeasureHeader-test.js.snap +++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/MeasureHeader-test.js.snap @@ -100,7 +100,7 @@ exports[`should render correctly 1`] = ` placement="right" > {translate('metric.bugs.name')} {translate('metric.vulnerabilities.name')} diff --git a/server/sonar-web/src/main/js/apps/overview/main/enhance.js b/server/sonar-web/src/main/js/apps/overview/main/enhance.js index 15104554cc6..0e5e31983a6 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/enhance.js +++ b/server/sonar-web/src/main/js/apps/overview/main/enhance.js @@ -65,7 +65,7 @@ export default function enhance(ComposedComponent) {
{label} @@ -170,8 +170,7 @@ export default function enhance(ComposedComponent) { }; renderHistoryLink = metricKey => { - const linkClass = - 'button button-small button-compact spacer-left overview-domain-measure-history-link'; + const linkClass = 'button button-small spacer-left overview-domain-measure-history-link'; return ( diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/MeasuresButtonLink.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/MeasuresButtonLink.tsx index a4fc94fcf77..951cb0d0f8d 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/MeasuresButtonLink.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/MeasuresButtonLink.tsx @@ -30,7 +30,7 @@ interface Props { export default function MeasuresButtonLink({ component, metric }: Props) { return ( diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/HistoryButtonLink-test.tsx.snap b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/HistoryButtonLink-test.tsx.snap index d64b7c80c4e..e62b2d558c6 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/HistoryButtonLink-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/__snapshots__/HistoryButtonLink-test.tsx.snap @@ -2,7 +2,7 @@ exports[`renders 1`] = ` { - e.stopPropagation(); + startChanging = () => { this.setState({ changing: true }); }; @@ -71,8 +69,7 @@ export default class Event extends React.PureComponent { } }; - startDeleting = (e /*: MouseEvent */) => { - e.stopPropagation(); + startDeleting = () => { this.setState({ deleting: true }); }; @@ -97,14 +94,10 @@ export default class Event extends React.PureComponent { {showActions && (
{canChange && ( - + )} {canDelete && ( - + )}
)} diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendItem.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendItem.tsx index a2c10331cd4..862239270d7 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendItem.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsLegendItem.tsx @@ -19,9 +19,11 @@ */ import * as React from 'react'; import * as classNames from 'classnames'; +import * as theme from '../../../app/theme'; import AlertWarnIcon from '../../../components/icons-components/AlertWarnIcon'; import ChartLegendIcon from '../../../components/icons-components/ChartLegendIcon'; -import CloseIcon from '../../../components/icons-components/CloseIcon'; +import { ButtonIcon } from '../../../components/ui/buttons'; +import ClearIcon from '../../../components/icons-components/ClearIcon'; interface Props { className?: string; @@ -33,8 +35,7 @@ interface Props { } export default class GraphsLegendItem extends React.PureComponent { - handleClick = (e: React.MouseEvent) => { - e.preventDefault(); + handleClick = () => { if (this.props.removeMetric) { this.props.removeMetric(this.props.metric); } @@ -53,16 +54,19 @@ export default class GraphsLegendItem extends React.PureComponent { ) : ( )} - {this.props.name} + {this.props.name} {isActionable && ( - - - + + + )} ); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js index 1f9453b9630..b26471cec14 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js @@ -76,10 +76,10 @@ export default class ProjectActivityAnalysis extends React.PureComponent {
-
+
{(canAddVersion || canAddEvent || canDeleteAnalyses) && ( -
+
{canAddVersion && ( - Bugs + + Bugs + `; @@ -16,18 +20,22 @@ exports[`should render correctly an actionable legend 1`] = ` className="project-activity-graph-legend-actionable myclass" > - Foo - + Foo + + - - + `; @@ -38,6 +46,10 @@ exports[`should render correctly legends with warning 1`] = ` - Foo + + Foo + `; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/projectActivity.css b/server/sonar-web/src/main/js/apps/projectActivity/components/projectActivity.css index e1e5cf542d2..721095c5bcb 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/projectActivity.css +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/projectActivity.css @@ -71,7 +71,8 @@ } .project-activity-graph-legend-actionable { - padding: 4px 12px; + display: inline-block; + padding: 4px 8px 4px 12px; border-width: 1px; border-style: solid; border-radius: 12px; @@ -164,7 +165,7 @@ } .project-activity-analysis-actions { - float: right; + float: left; } .project-activity-time { @@ -193,7 +194,7 @@ } .project-activity-event { - line-height: 20px; + line-height: 18px; display: flex; } @@ -223,14 +224,6 @@ display: inline-block; } -.project-activity-event-actions button { - height: 20px; -} - -.project-activity-event-actions button + button { - margin-left: 4px; -} - .project-activity-event-inner-icon .project-activity-event-icon { margin-top: 3px; } diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx index da026682bfe..302f3ddae98 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx @@ -20,7 +20,7 @@ import * as React from 'react'; import LongBranchesPatternForm from './LongBranchesPatternForm'; import { getValues, SettingValue } from '../../../api/settings'; -import ChangeIcon from '../../../components/icons-components/ChangeIcon'; +import { EditButton } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; interface Props { @@ -64,9 +64,7 @@ export default class LongBranchesPattern extends React.PureComponent) => { - event.preventDefault(); - event.currentTarget.blur(); + handleChangeClick = () => { this.setState({ formOpen: true }); }; @@ -88,12 +86,7 @@ export default class LongBranchesPattern extends React.PureComponent{setting.value} - - - + {this.state.formOpen && ( ({ getValues: jest.fn(() => Promise.resolve([])) @@ -43,7 +42,8 @@ it('opens form', () => { const wrapper = shallow(); wrapper.setState({ loading: false, setting: { value: 'release-.*' } }); - click(wrapper.find('a')); + wrapper.find('EditButton').prop('onClick')(); + wrapper.update(); expect(wrapper.find('LongBranchesPatternForm').exists()).toBeTruthy(); wrapper.find('LongBranchesPatternForm').prop('onClose')(); diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap index 312bdd3d079..8d1c83d3003 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap @@ -9,12 +9,9 @@ exports[`renders 1`] = ` release-.* - - - + />
`; diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.tsx index 9c213790359..5fdcec83a09 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectsSortingSelect.tsx @@ -20,10 +20,12 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import ProjectsSortingSelectOption, { Option } from './ProjectsSortingSelectOption'; +import * as theme from '../../../app/theme'; import SortAscIcon from '../../../components/icons-components/SortAscIcon'; import SortDescIcon from '../../../components/icons-components/SortDescIcon'; import Select from '../../../components/controls/Select'; import Tooltip from '../../../components/controls/Tooltip'; +import { ButtonIcon } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; import { SORTING_METRICS, SORTING_LEAK_METRICS, parseSorting } from '../utils'; @@ -50,9 +52,7 @@ export default class ProjectsSortingSelect extends React.PureComponent { })); }; - handleDescToggle = (event: React.SyntheticEvent) => { - event.preventDefault(); - event.currentTarget.blur(); + handleDescToggle = () => { const sorting = this.getSorting(); this.props.onChange(sorting.sortValue, !sorting.sortDesc); }; @@ -79,13 +79,12 @@ export default class ProjectsSortingSelect extends React.PureComponent { overlay={ sortDesc ? translate('projects.sort_descending') : translate('projects.sort_ascending') }> - - {sortDesc ? ( - - ) : ( - - )} - + + {sortDesc ? : } +
); diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectsSortingSelect-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectsSortingSelect-test.tsx index 649d9bec8e3..aa943c230dd 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectsSortingSelect-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectsSortingSelect-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ProjectsSortingSelect from '../ProjectsSortingSelect'; -import { click } from '../../../../helpers/testUtils'; it('should render correctly for overall view', () => { expect( @@ -85,6 +84,6 @@ it('reverses sorting', () => { view="overall" /> ); - click(wrapper.find('a')); + wrapper.find('ButtonIcon').prop('onClick')(); expect(onChange).toBeCalledWith('size', false); }); diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectsSortingSelect-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectsSortingSelect-test.tsx.snap index e5219e7902b..cc30f32ad4c 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectsSortingSelect-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectsSortingSelect-test.tsx.snap @@ -62,15 +62,15 @@ exports[`should handle the descending sort direction 1`] = ` overlay="projects.sort_descending" placement="bottom" > - - +
`; @@ -137,15 +137,15 @@ exports[`should render correctly for leak view 1`] = ` overlay="projects.sort_ascending" placement="bottom" > - - +
`; @@ -212,15 +212,15 @@ exports[`should render correctly for overall view 1`] = ` overlay="projects.sort_ascending" placement="bottom" > - - +
`; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx index 5dd7604092d..f2f56ee80b3 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx @@ -21,7 +21,7 @@ import * as React from 'react'; import ChangeVisibilityForm from './ChangeVisibilityForm'; import { Organization, Visibility } from '../../app/types'; import { translate } from '../../helpers/l10n'; -import EditIcon from '../../components/icons-components/EditIcon'; +import { EditButton } from '../../components/ui/buttons'; export interface Props { hasProvisionPermission?: boolean; @@ -42,8 +42,7 @@ export default class Header extends React.PureComponent { this.props.onProjectCreate(); }; - handleChangeVisibilityClick = (event: React.SyntheticEvent) => { - event.preventDefault(); + handleChangeVisibilityClick = () => { this.setState({ visibilityForm: true }); }; @@ -60,14 +59,14 @@ export default class Header extends React.PureComponent {
- {translate('organization.default_visibility_of_new_projects')}{' '} - {translate('visibility', organization.projectVisibility)} - - - + + {translate('organization.default_visibility_of_new_projects')}{' '} + {translate('visibility', organization.projectVisibility)} + + {this.props.hasProvisionPermission && ( +
)} diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/PropertySetInput.js b/server/sonar-web/src/main/js/apps/settings/components/inputs/PropertySetInput.js index 4016656f336..075e95c3df0 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/PropertySetInput.js +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/PropertySetInput.js @@ -21,7 +21,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import PrimitiveInput from './PrimitiveInput'; import { getEmptyValue, getUniqueName } from '../../utils'; -import DeleteIcon from '../../../../components/icons-components/DeleteIcon'; +import { DeleteButton } from '../../../../components/ui/buttons'; export default class PropertySetInput extends React.PureComponent { static propTypes = { @@ -38,10 +38,7 @@ export default class PropertySetInput extends React.PureComponent { return getUniqueName(this.props.setting.definition, field.key); } - handleDeleteValue(e, index) { - e.preventDefault(); - e.target.blur(); - + handleDeleteValue(index) { const newValue = [...this.ensureValue()]; newValue.splice(index, 1); this.props.onChange(newValue); @@ -70,13 +67,12 @@ export default class PropertySetInput extends React.PureComponent { /> ))} - + {!isLast && ( - + )} diff --git a/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx index c27c7dd4521..864467319f0 100644 --- a/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx @@ -20,7 +20,7 @@ import * as React from 'react'; import ChangeLogLevelForm from './ChangeLogLevelForm'; import RestartForm from '../../../components/common/RestartForm'; -import EditIcon from '../../../components/icons-components/EditIcon'; +import { EditButton } from '../../../components/ui/buttons'; import { getBaseUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; @@ -54,8 +54,7 @@ export default class PageActions extends React.PureComponent { } } - handleLogsLevelOpen = (event: React.SyntheticEvent) => { - event.preventDefault(); + handleLogsLevelOpen = () => { this.setState({ openLogsLevelForm: true }); }; @@ -78,16 +77,16 @@ export default class PageActions extends React.PureComponent { return (
- {translate('system.logs_level')} - {':'} - {this.state.logLevel} - + {translate('system.logs_level')} + {':'} + {this.state.logLevel} + + - - + className="spacer-left button-small" + onClick={this.handleLogsLevelOpen} + /> {this.props.canDownloadLogs && (
diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap index d665e37ec15..3556043a83b 100644 --- a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap @@ -5,23 +5,22 @@ exports[`should render correctly 1`] = ` className="page-actions" > - system.logs_level - : - - INFO - - + INFO + + + - - + />
- system.logs_level - : - - INFO - - + INFO + + + - - + /> ; } else { - return ; + return ; } } diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx index acbf8d43ab9..e7401281c00 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx @@ -51,10 +51,10 @@ it('should render object correctly', () => { it('should render `true`', () => { const wrapper = mount(); - expect(wrapper.find('CheckIcon')).toHaveLength(1); + expect(wrapper.find('CheckIcon').exists()).toBeTruthy(); }); it('should render `false`', () => { const wrapper = mount(); - expect(wrapper.find('CloseIcon')).toHaveLength(1); + expect(wrapper.find('ClearIcon').exists()).toBeTruthy(); }); diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap index f2164f53967..0e730faf515 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap @@ -131,9 +131,11 @@ Array [ { - event.preventDefault(); + handleOrganizationDelete = () => { const { organization } = this.state; if (organization) { this.setState({ loading: true }); @@ -129,16 +128,14 @@ export default class NewOrganizationForm extends React.PureComponent { const valid = unique && organization.length >= 2; return done ? ( -
+
{organization} {loading ? ( ) : ( - + )} - +
) : (
{ - event.preventDefault(); + handleProjectDelete = () => { const { projectKey } = this.state; this.setState({ loading: true }); deleteProject(projectKey).then(() => { @@ -111,16 +110,14 @@ export default class NewProjectForm extends React.PureComponent { const valid = projectKey.length > 0; const form = done ? ( - +
{projectKey} {loading ? ( ) : ( - + )} - +
) : (
void, - onDone: (projectKey: string) => void, - organization?: string, - projectKey?: string -}; -*/ - -/*:: -type State = { - done: boolean, - loading: boolean, - projectKey: string -}; -*/ - -export default class ProjectKeyStep extends React.PureComponent { - /*:: mounted: boolean; */ - /*:: props: Props; */ - /*:: state: State; */ - - constructor(props /*: Props */) { - super(props); - this.state = { - done: props.projectKey != null, - loading: false, - projectKey: props.projectKey || '' - }; - } - - componentDidMount() { - this.mounted = true; - } - - componentWillUnmount() { - this.mounted = false; - } - - stopLoading = () => { - if (this.mounted) { - this.setState({ loading: false }); - } - }; - - sanitizeProjectKey = (projectKey /*: string */) => projectKey.replace(/[^a-zA-Z0-9-_\.:]/, ''); - - handleProjectKeyChange = (event /*: { target: HTMLInputElement } */) => { - this.setState({ projectKey: this.sanitizeProjectKey(event.target.value) }); - }; - - handleProjectCreate = (event /*: Event */) => { - event.preventDefault(); - const { projectKey } = this.state; - const data /*: { [string]: string } */ = { - name: projectKey, - project: projectKey - }; - if (this.props.organization) { - data.organization = this.props.organization; - } - this.setState({ loading: true }); - createProject(data).then(() => { - if (this.mounted) { - this.setState({ done: true, loading: false }); - this.props.onDone(projectKey); - } - }, this.stopLoading); - }; - - handleProjectDelete = (event /*: Event */) => { - event.preventDefault(); - const { projectKey } = this.state; - this.setState({ loading: true }); - deleteProject(projectKey).then(() => { - if (this.mounted) { - this.setState({ done: false, loading: false, projectKey: '' }); - this.props.onDelete(); - } - }, this.stopLoading); - }; - - render() { - const { done, loading, projectKey } = this.state; - - const valid = projectKey.length > 0; - - const form = done ? ( - - {projectKey} - {loading ? ( - - ) : ( - - )} - - ) : ( -
- - {loading ? ( - - ) : ( - - )} -
- {translate('onboarding.project_key_requirement')} -
- - ); - - return ( -
-

{translate('onboarding.language.project_key')}

- {form} -
- ); - } -} diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/TokenStep.js b/server/sonar-web/src/main/js/apps/tutorials/onboarding/TokenStep.js index 1bbaa9df1b4..dd72bd238e8 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/TokenStep.js +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/TokenStep.js @@ -23,7 +23,7 @@ import classNames from 'classnames'; import Step from './Step'; import { getTokens, generateToken, revokeToken } from '../../../api/user-tokens'; import AlertErrorIcon from '../../../components/icons-components/AlertErrorIcon'; -import CloseIcon from '../../../components/icons-components/CloseIcon'; +import { DeleteButton } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; /*:: @@ -110,8 +110,7 @@ export default class TokenStep extends React.PureComponent { } }; - handleTokenRevoke = (event /*: Event */) => { - event.preventDefault(); + handleTokenRevoke = () => { const { tokenName } = this.state; if (tokenName) { this.setState({ loading: true }); @@ -249,9 +248,7 @@ export default class TokenStep extends React.PureComponent { {loading ? ( ) : ( - + )} ) : ( diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/NewOrganizationForm-test.js b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/NewOrganizationForm-test.js index f6f6eba3125..8f8e996d587 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/NewOrganizationForm-test.js +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/NewOrganizationForm-test.js @@ -29,6 +29,8 @@ jest.mock('../../../../api/organizations', () => ({ getOrganization: () => Promise.resolve(null) })); +jest.mock('../../../../components/icons-components/ClearIcon'); + it('creates new organization', async () => { const onDone = jest.fn(); const wrapper = mount(); @@ -47,7 +49,8 @@ it('deletes organization', async () => { const wrapper = mount(); wrapper.setState({ done: true, loading: false, organization: 'foo' }); expect(wrapper).toMatchSnapshot(); - submit(wrapper.find('form')); + wrapper.find('DeleteButton').prop('onClick')(); + wrapper.update(); expect(wrapper).toMatchSnapshot(); // spinner await new Promise(setImmediate); wrapper.update(); diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/NewProjectForm-test.js b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/NewProjectForm-test.js index 89952611111..3bdb9048b36 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/NewProjectForm-test.js +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/NewProjectForm-test.js @@ -28,6 +28,8 @@ jest.mock('../../../../api/components', () => ({ deleteProject: () => Promise.resolve() })); +jest.mock('../../../../components/icons-components/ClearIcon'); + it('creates new project', async () => { const onDone = jest.fn(); const wrapper = mount(); @@ -46,7 +48,8 @@ it('deletes project', async () => { const wrapper = mount(); wrapper.setState({ done: true, loading: false, projectKey: 'foo' }); expect(wrapper).toMatchSnapshot(); - submit(wrapper.find('form')); + wrapper.find('DeleteButton').prop('onClick')(); + wrapper.update(); expect(wrapper).toMatchSnapshot(); // spinner await new Promise(setImmediate); wrapper.update(); diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/ProjectKeyStep-test.js b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/ProjectKeyStep-test.js deleted file mode 100644 index 962b33b1acb..00000000000 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/ProjectKeyStep-test.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -// @flow -import React from 'react'; -import { mount } from 'enzyme'; -import ProjectKeyStep from '../ProjectKeyStep'; -import { change, doAsync, submit } from '../../../../helpers/testUtils'; - -jest.mock('../../../../api/components', () => ({ - createProject: () => Promise.resolve(), - deleteProject: () => Promise.resolve() -})); - -jest.mock( - '../../../../components/icons-components/DeleteIcon', - () => - function DeleteIcon() { - return null; - } -); - -it('creates new project', async () => { - const onDone = jest.fn(); - const wrapper = mount(); - expect(wrapper).toMatchSnapshot(); - change(wrapper.find('input'), 'foo'); - submit(wrapper.find('form')); - expect(wrapper).toMatchSnapshot(); // spinner - await new Promise(setImmediate); - wrapper.update(); - expect(wrapper).toMatchSnapshot(); - expect(onDone).toBeCalledWith('foo'); -}); - -it('deletes project', async () => { - const onDelete = jest.fn(); - const wrapper = mount(); - wrapper.setState({ done: true, loading: false, projectKey: 'foo' }); - expect(wrapper).toMatchSnapshot(); - submit(wrapper.find('form')); - expect(wrapper).toMatchSnapshot(); // spinner - await new Promise(setImmediate); - wrapper.update(); - expect(wrapper).toMatchSnapshot(); - expect(onDelete).toBeCalled(); -}); diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/TokenStep-test.js b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/TokenStep-test.js index 801da708998..5cb3709c78e 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/TokenStep-test.js +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/TokenStep-test.js @@ -29,6 +29,8 @@ jest.mock('../../../../api/user-tokens', () => ({ revokeToken: () => Promise.resolve() })); +jest.mock('../../../../components/icons-components/ClearIcon'); + const currentUser = { login: 'user' }; it('generates token', async () => { @@ -67,7 +69,8 @@ it('revokes token', async () => { await new Promise(setImmediate); wrapper.setState({ token: 'abcd1234', tokenName: 'my token' }); expect(wrapper).toMatchSnapshot(); - submit(wrapper.find('form')); + wrapper.find('DeleteButton').prop('onClick')(); + wrapper.update(); expect(wrapper).toMatchSnapshot(); // spinner await new Promise(setImmediate); wrapper.update(); diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/NewOrganizationForm-test.js.snap b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/NewOrganizationForm-test.js.snap index fde0778232a..8386f670119 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/NewOrganizationForm-test.js.snap +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/NewOrganizationForm-test.js.snap @@ -70,35 +70,35 @@ exports[`creates new organization 3`] = ` onDelete={[Function]} onDone={[Function]} > -
+
foo - - + + + + +
`; @@ -107,35 +107,35 @@ exports[`deletes organization 1`] = ` onDelete={[Function]} onDone={[Function]} > -
+
foo - - + + + + +
`; @@ -144,9 +144,7 @@ exports[`deletes organization 2`] = ` onDelete={[Function]} onDone={[Function]} > -
+
@@ -155,7 +153,7 @@ exports[`deletes organization 2`] = ` - +
`; diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/NewProjectForm-test.js.snap b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/NewProjectForm-test.js.snap index 1943af530a5..1074cf5cefc 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/NewProjectForm-test.js.snap +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/NewProjectForm-test.js.snap @@ -94,35 +94,35 @@ exports[`creates new project 3`] = ` > onboarding.language.project_key -
+
foo - - + + + + +
`; @@ -140,35 +140,35 @@ exports[`deletes project 1`] = ` > onboarding.language.project_key -
+
foo - - + + + + +
`; @@ -186,9 +186,7 @@ exports[`deletes project 2`] = ` > onboarding.language.project_key -
+
@@ -197,7 +195,7 @@ exports[`deletes project 2`] = ` - +
`; diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/ProjectKeyStep-test.js.snap b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/ProjectKeyStep-test.js.snap deleted file mode 100644 index 21ad43db2e6..00000000000 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/ProjectKeyStep-test.js.snap +++ /dev/null @@ -1,215 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`creates new project 1`] = ` - -
-

- onboarding.language.project_key -

-
- - -
- onboarding.project_key_requirement -
-
-
-
-`; - -exports[`creates new project 2`] = ` - -
-

- onboarding.language.project_key -

-
- - -
- onboarding.project_key_requirement -
- -
-
-`; - -exports[`creates new project 3`] = ` - -
-

- onboarding.language.project_key -

-
- - foo - - -
-
-
-`; - -exports[`deletes project 1`] = ` - -
-

- onboarding.language.project_key -

-
- - foo - - -
-
-
-`; - -exports[`deletes project 2`] = ` - -
-

- onboarding.language.project_key -

-
- - foo - - - -
-
-`; - -exports[`deletes project 3`] = ` - -
-

- onboarding.language.project_key -

-
- - -
- onboarding.project_key_requirement -
-
-
-
-`; diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/TokenStep-test.js.snap b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/TokenStep-test.js.snap index 637a26c6425..c0f9d5a2e4e 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/TokenStep-test.js.snap +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/__tests__/__snapshots__/TokenStep-test.js.snap @@ -264,27 +264,28 @@ exports[`generates token 3`] = ` > abcd1234 - + + + +
abcd1234 - + + + +
{{t 'my_profile.scm_accounts'}} + {{#each scmAccounts}} - + {{/each}}
diff --git a/server/sonar-web/src/main/js/components/controls/ActionsDropdown.tsx b/server/sonar-web/src/main/js/components/controls/ActionsDropdown.tsx index fbcb30b299c..04a4426cf44 100644 --- a/server/sonar-web/src/main/js/components/controls/ActionsDropdown.tsx +++ b/server/sonar-web/src/main/js/components/controls/ActionsDropdown.tsx @@ -35,13 +35,13 @@ export default function ActionsDropdown(props: Props) {
-
    {props.children}
+
    {props.children}
); } diff --git a/server/sonar-web/src/main/js/components/controls/DateInput.tsx b/server/sonar-web/src/main/js/components/controls/DateInput.tsx index 1bb65c64457..7f9c1fdc324 100644 --- a/server/sonar-web/src/main/js/components/controls/DateInput.tsx +++ b/server/sonar-web/src/main/js/components/controls/DateInput.tsx @@ -21,8 +21,10 @@ import * as $ from 'jquery'; import * as React from 'react'; import * as classNames from 'classnames'; import { pick } from 'lodash'; +import * as theme from '../../app/theme'; +import ClearIcon from '../icons-components/ClearIcon'; +import { ButtonIcon } from '../ui/buttons'; import './styles.css'; -import CloseIcon from '../icons-components/CloseIcon'; interface Props { className?: string; @@ -65,9 +67,7 @@ export default class DateInput extends React.PureComponent { this.props.onChange(value); }; - handleResetClick = (event: React.SyntheticEvent) => { - event.preventDefault(); - event.currentTarget.blur(); + handleResetClick = () => { this.props.onChange(undefined); }; @@ -109,9 +109,12 @@ export default class DateInput extends React.PureComponent { {this.props.value !== undefined && ( - - - + + + )} ); diff --git a/server/sonar-web/src/main/js/components/controls/Select.tsx b/server/sonar-web/src/main/js/components/controls/Select.tsx index 406c81fa362..240b4164bf2 100644 --- a/server/sonar-web/src/main/js/components/controls/Select.tsx +++ b/server/sonar-web/src/main/js/components/controls/Select.tsx @@ -25,11 +25,26 @@ import ReactSelect, { ReactCreatableSelectProps, ReactAsyncSelectProps } from 'react-select'; +import * as theme from '../../app/theme'; +import ClearIcon from '../icons-components/ClearIcon'; +import { ButtonIcon } from '../ui/buttons'; import './react-select.css'; +function renderInput() { + return ( + + + + ); +} + export default function Select(props: ReactSelectProps) { // TODO try to define good defaults, if any - return ; + // ReactSelect doesn't declare `clearRenderer` prop + const ReactSelectAny = ReactSelect as any; + // hide the "x" icon when select is empty + const clearable = props.clearable ? Boolean(props.value) : false; + return ; } export function Creatable(props: ReactCreatableSelectProps) { diff --git a/server/sonar-web/src/main/js/components/controls/react-select.css b/server/sonar-web/src/main/js/components/controls/react-select.css index 3d3816e8aa4..4e130a23369 100644 --- a/server/sonar-web/src/main/js/components/controls/react-select.css +++ b/server/sonar-web/src/main/js/components/controls/react-select.css @@ -214,8 +214,8 @@ position: relative; text-align: center; vertical-align: middle; - width: 9px; - padding-left: 4px; + width: 16px; + height: 16px; padding-right: 4px; } diff --git a/server/sonar-web/src/main/js/components/icons-components/AlertErrorIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/AlertErrorIcon.tsx index ce08d3d97ba..3c05c751176 100644 --- a/server/sonar-web/src/main/js/components/icons-components/AlertErrorIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/AlertErrorIcon.tsx @@ -19,22 +19,20 @@ */ import * as React from 'react'; import * as theme from '../../app/theme'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function AlertErrorIcon({ className, size = 16 }: Props) { +export default function AlertErrorIcon({ className, fill = theme.red, size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/AlertWarnIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/AlertWarnIcon.tsx index 98a12595841..f9b3f92ab85 100644 --- a/server/sonar-web/src/main/js/components/icons-components/AlertWarnIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/AlertWarnIcon.tsx @@ -18,23 +18,20 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function AlertWarnIcon({ className, size = 16 }: Props) { - /* eslint-disable max-len */ +export default function AlertWarnIcon({ className, fill = '#ed7d20', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/BranchIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/BranchIcon.tsx index 62c4bf0d741..81353baf6b4 100644 --- a/server/sonar-web/src/main/js/components/icons-components/BranchIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/BranchIcon.tsx @@ -20,15 +20,13 @@ import * as React from 'react'; import ShortLivingBranchIcon from './ShortLivingBranchIcon'; import LongLivingBranchIcon from './LongLivingBranchIcon'; +import { IconProps } from './types'; // import PullRequestIcon from './PullRequestIcon'; import { Branch } from '../../app/types'; import { isShortLivingBranch } from '../../helpers/branches'; -interface Props { +interface Props extends IconProps { branch: Branch; - className?: string; - color?: string; - size?: number; } export default function BranchIcon({ branch, ...props }: Props) { diff --git a/server/sonar-web/src/main/js/components/icons-components/BubblesIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/BubblesIcon.tsx index 2372a606683..a62c84d6c3b 100644 --- a/server/sonar-web/src/main/js/components/icons-components/BubblesIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/BubblesIcon.tsx @@ -18,22 +18,20 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function BubblesIcon({ className, size = 16 }: Props) { +export default function BubblesIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/BugIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/BugIcon.tsx index eb5f504ecb8..8cf7db7cbc3 100644 --- a/server/sonar-web/src/main/js/components/icons-components/BugIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/BugIcon.tsx @@ -18,23 +18,20 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function BugIcon({ className, size = 16 }: Props) { - /* eslint-disable max-len */ +export default function BugIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/ChartLegendIcon.js b/server/sonar-web/src/main/js/components/icons-components/ChartLegendIcon.tsx similarity index 78% rename from server/sonar-web/src/main/js/components/icons-components/ChartLegendIcon.js rename to server/sonar-web/src/main/js/components/icons-components/ChartLegendIcon.tsx index 93b40513c93..a2206adc21b 100644 --- a/server/sonar-web/src/main/js/components/icons-components/ChartLegendIcon.js +++ b/server/sonar-web/src/main/js/components/icons-components/ChartLegendIcon.tsx @@ -17,24 +17,25 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; +import { IconProps } from './types'; -/*:: -type Props = { className?: string, size?: number }; -*/ - -export default function ChartLegendIcon({ className, size = 16 } /*: Props */) { - /* eslint-disable max-len */ +export default function ChartLegendIcon({ + className, + fill = 'currentColor', + size = 16 +}: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/CheckIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/CheckIcon.tsx index 487fac702cf..6d41dea3b75 100644 --- a/server/sonar-web/src/main/js/components/icons-components/CheckIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/CheckIcon.tsx @@ -18,22 +18,20 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function CheckIcon({ className, size = 16 }: Props) { +export default function CheckIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> ; diff --git a/server/sonar-web/src/main/js/components/icons-components/CloseIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/ClearIcon.tsx similarity index 57% rename from server/sonar-web/src/main/js/components/icons-components/CloseIcon.tsx rename to server/sonar-web/src/main/js/components/icons-components/ClearIcon.tsx index 5ab53930909..741e9178272 100644 --- a/server/sonar-web/src/main/js/components/icons-components/CloseIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/ClearIcon.tsx @@ -1,7 +1,7 @@ /* * SonarQube * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com + * mailto:contact AT sonarsource DOT com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,23 +18,21 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function CloseIcon({ className, size = 16 }: Props) { +export default function ClearIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> ); diff --git a/server/sonar-web/src/main/js/components/icons-components/CodeSmellIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/CodeSmellIcon.tsx index 767a69fd195..4b45a10c99c 100644 --- a/server/sonar-web/src/main/js/components/icons-components/CodeSmellIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/CodeSmellIcon.tsx @@ -18,23 +18,18 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function CodeSmellIcon({ className, size = 16 }: Props) { - /* eslint-disable max-len */ +export default function CodeSmellIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + xmlns="http://www.w3.org/2000/svg"> diff --git a/server/sonar-web/src/main/js/components/icons-components/DeleteIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/DeleteIcon.tsx index 75b3e6dcb74..224589add4b 100644 --- a/server/sonar-web/src/main/js/components/icons-components/DeleteIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/DeleteIcon.tsx @@ -19,24 +19,13 @@ */ import * as React from 'react'; import * as theme from '../../app/theme'; +import { ClearIcon } from './icons'; interface Props { className?: string; size?: number; } -export default function DeleteIcon({ className, size = 12 }: Props) { - return ( - - - - ); +export default function DeleteIcon(props: Props) { + return ; } diff --git a/server/sonar-web/src/main/js/components/icons-components/EditIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/EditIcon.tsx index c327d09c778..d542d0ca73a 100644 --- a/server/sonar-web/src/main/js/components/icons-components/EditIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/EditIcon.tsx @@ -18,23 +18,21 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function EditIcon({ className, size = 14 }: Props) { +export default function EditIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> ); diff --git a/server/sonar-web/src/main/js/components/icons-components/GroupIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/GroupIcon.tsx index cb971f1c4d9..6074a1acba7 100644 --- a/server/sonar-web/src/main/js/components/icons-components/GroupIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/GroupIcon.tsx @@ -18,19 +18,22 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import * as theme from '../../app/theme'; +import { IconProps } from './types'; -interface Props { - className?: string; - fill?: string; - size?: number; -} - -export default function GroupIcon({ className, fill = '#aaa', size = 36 }: Props) { +export default function GroupIcon({ className, fill = theme.gray67, size = 36 }: IconProps) { return ( - + diff --git a/server/sonar-web/src/main/js/components/icons-components/HelpIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/HelpIcon.tsx index 5097fde124e..f8413c6624a 100644 --- a/server/sonar-web/src/main/js/components/icons-components/HelpIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/HelpIcon.tsx @@ -18,19 +18,21 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - fill?: string; - size?: number; -} - -export default function HelpIcon({ className, fill = 'currentColor', size = 16 }: Props) { +export default function HelpIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( - + diff --git a/server/sonar-web/src/main/js/components/icons-components/HistoryIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/HistoryIcon.tsx index aac6843a977..5af52b075c1 100644 --- a/server/sonar-web/src/main/js/components/icons-components/HistoryIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/HistoryIcon.tsx @@ -18,22 +18,20 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function IconHistory({ className, size = 16 }: Props) { +export default function IconHistory({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/LinkIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/LinkIcon.tsx index cbbb2606f69..5ad893afd47 100644 --- a/server/sonar-web/src/main/js/components/icons-components/LinkIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/LinkIcon.tsx @@ -18,24 +18,24 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function LinkIcon({ className, size = 14 }: Props) { +export default function LinkIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( - + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> + + + ); } diff --git a/server/sonar-web/src/main/js/components/icons-components/ListIcon.js b/server/sonar-web/src/main/js/components/icons-components/ListIcon.tsx similarity index 84% rename from server/sonar-web/src/main/js/components/icons-components/ListIcon.js rename to server/sonar-web/src/main/js/components/icons-components/ListIcon.tsx index 66c62be5dcc..d5b9160bf57 100644 --- a/server/sonar-web/src/main/js/components/icons-components/ListIcon.js +++ b/server/sonar-web/src/main/js/components/icons-components/ListIcon.tsx @@ -17,24 +17,21 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; +import { IconProps } from './types'; -/*:: -type Props = { className?: string, size?: number }; -*/ - -export default function ListIcon({ className, size = 16 } /*: Props */) { - /* eslint-disable max-len */ +export default function ListIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/LongLivingBranchIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/LongLivingBranchIcon.tsx index 9e263ee825a..f3f084c8446 100644 --- a/server/sonar-web/src/main/js/components/icons-components/LongLivingBranchIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/LongLivingBranchIcon.tsx @@ -19,25 +19,25 @@ */ import * as React from 'react'; import * as theme from '../../app/theme'; +import { IconProps } from './types'; -interface Props { - className?: string; - color?: string; - size?: number; -} - -export default function LongLivingBranchIcon({ className, color = theme.blue, size = 16 }: Props) { - /* eslint-disable max-len */ +export default function LongLivingBranchIcon({ + className, + fill = theme.blue, + size = 16 +}: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/OpenCloseIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/OpenCloseIcon.tsx index ba583b3de7c..5c35472e73c 100644 --- a/server/sonar-web/src/main/js/components/icons-components/OpenCloseIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/OpenCloseIcon.tsx @@ -18,26 +18,37 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; +interface Props extends IconProps { open: boolean; - size?: number; } -export default function OpenCloseIcon({ className, open, size = 14 }: Props) { +export default function OpenCloseIcon({ + className, + fill = 'currentColor', + open, + size = 14 +}: Props) { return ( + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> {open ? ( - + ) : ( - + )} ); diff --git a/server/sonar-web/src/main/js/components/icons-components/OrganizationIcon.js b/server/sonar-web/src/main/js/components/icons-components/OrganizationIcon.tsx similarity index 83% rename from server/sonar-web/src/main/js/components/icons-components/OrganizationIcon.js rename to server/sonar-web/src/main/js/components/icons-components/OrganizationIcon.tsx index a9bd0122161..dc89017c23d 100644 --- a/server/sonar-web/src/main/js/components/icons-components/OrganizationIcon.js +++ b/server/sonar-web/src/main/js/components/icons-components/OrganizationIcon.tsx @@ -17,25 +17,22 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import * as theme from '../../app/theme'; +import { IconProps } from './types'; -/*:: -type Props = { className?: string, size?: number }; -*/ - -export default function OrganizationIcon({ className, size = 16 } /*: Props */) { - /* eslint-disable max-len */ +export default function OrganizationIcon({ className, fill = theme.blue, size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/PendingIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/PendingIcon.tsx index 3e34178aa1c..ffbdb484f6b 100644 --- a/server/sonar-web/src/main/js/components/icons-components/PendingIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/PendingIcon.tsx @@ -18,23 +18,24 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import * as classNames from 'classnames'; +import * as theme from '../../app/theme'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function PendingIcon({ className, size = 16 }: Props) { +export default function PendingIcon({ className, fill = theme.gray67, size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> - + ); diff --git a/server/sonar-web/src/main/js/components/icons-components/ProjectEventIcon.js b/server/sonar-web/src/main/js/components/icons-components/ProjectEventIcon.tsx similarity index 84% rename from server/sonar-web/src/main/js/components/icons-components/ProjectEventIcon.js rename to server/sonar-web/src/main/js/components/icons-components/ProjectEventIcon.tsx index b2a99892e17..234e0e61410 100644 --- a/server/sonar-web/src/main/js/components/icons-components/ProjectEventIcon.js +++ b/server/sonar-web/src/main/js/components/icons-components/ProjectEventIcon.tsx @@ -17,22 +17,23 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; -/*:: -type Props = { className?: string, size?: number }; -*/ +interface Props { + className?: string; + size?: number; +} -export default function ProjectEventIcon({ className, size = 14 } /*: Props */) { - /* eslint-disable max-len */ +export default function ProjectEventIcon({ className, size = 14 }: Props) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/SettingsIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/SettingsIcon.tsx index 3c8d8d5ac5b..15fb20321f2 100644 --- a/server/sonar-web/src/main/js/components/icons-components/SettingsIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/SettingsIcon.tsx @@ -18,32 +18,22 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - fill?: string; - size?: number; - style?: React.CSSProperties; -} - -export default function SettingsIcon({ - className, - fill = 'currentColor', - size = 14, - style -}: Props) { +export default function SettingsIcon({ className, fill = 'currentColor', size = 14 }: IconProps) { return ( + viewBox="0 0 14 14" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/ShortLivingBranchIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/ShortLivingBranchIcon.tsx index 0427d451e38..d6204bce7b6 100644 --- a/server/sonar-web/src/main/js/components/icons-components/ShortLivingBranchIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/ShortLivingBranchIcon.tsx @@ -18,26 +18,26 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; import * as theme from '../../app/theme'; -interface Props { - className?: string; - color?: string; - size?: number; -} - -export default function ShortLivingBranchIcon({ className, color = theme.blue, size = 16 }: Props) { - /* eslint-disable max-len */ +export default function ShortLivingBranchIcon({ + className, + fill = theme.blue, + size = 16 +}: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/SortAscIcon.js b/server/sonar-web/src/main/js/components/icons-components/SortAscIcon.tsx similarity index 86% rename from server/sonar-web/src/main/js/components/icons-components/SortAscIcon.js rename to server/sonar-web/src/main/js/components/icons-components/SortAscIcon.tsx index b426db01fef..6241465c390 100644 --- a/server/sonar-web/src/main/js/components/icons-components/SortAscIcon.js +++ b/server/sonar-web/src/main/js/components/icons-components/SortAscIcon.tsx @@ -17,24 +17,21 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; +import { IconProps } from './types'; -/*:: -type Props = { className?: string, size?: number }; -*/ - -export default function SortAscIcon({ className, size = 16 } /*: Props */) { - /* eslint-disable max-len */ +export default function SortAscIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/SortDescIcon.js b/server/sonar-web/src/main/js/components/icons-components/SortDescIcon.tsx similarity index 86% rename from server/sonar-web/src/main/js/components/icons-components/SortDescIcon.js rename to server/sonar-web/src/main/js/components/icons-components/SortDescIcon.tsx index 041054adf4f..7495f7569f4 100644 --- a/server/sonar-web/src/main/js/components/icons-components/SortDescIcon.js +++ b/server/sonar-web/src/main/js/components/icons-components/SortDescIcon.tsx @@ -17,24 +17,21 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; +import { IconProps } from './types'; -/*:: -type Props = { className?: string, size?: number }; -*/ - -export default function SortDescIcon({ className, size = 16 } /*: Props */) { - /* eslint-disable max-len */ +export default function SortDescIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/TreeIcon.js b/server/sonar-web/src/main/js/components/icons-components/TreeIcon.tsx similarity index 84% rename from server/sonar-web/src/main/js/components/icons-components/TreeIcon.js rename to server/sonar-web/src/main/js/components/icons-components/TreeIcon.tsx index 53ff8dbf8aa..5b8fd954576 100644 --- a/server/sonar-web/src/main/js/components/icons-components/TreeIcon.js +++ b/server/sonar-web/src/main/js/components/icons-components/TreeIcon.tsx @@ -17,22 +17,21 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; +import { IconProps } from './types'; -/*:: type Props = { className?: string, size?: number }; */ - -export default function TreeIcon({ className, size = 16 } /*: Props */) { - /* eslint-disable max-len */ +export default function TreeIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/TreemapIcon.js b/server/sonar-web/src/main/js/components/icons-components/TreemapIcon.tsx similarity index 75% rename from server/sonar-web/src/main/js/components/icons-components/TreemapIcon.js rename to server/sonar-web/src/main/js/components/icons-components/TreemapIcon.tsx index 524112c41db..441eb22e25b 100644 --- a/server/sonar-web/src/main/js/components/icons-components/TreemapIcon.js +++ b/server/sonar-web/src/main/js/components/icons-components/TreemapIcon.tsx @@ -17,25 +17,21 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; +import { IconProps } from './types'; -/*:: type Props = { className?: string, size?: number }; */ - -export default function TreemapIcon({ className, size = 14 } /*: Props */) { - /* eslint-disable max-len */ +export default function TreemapIcon({ className, fill = 'currentColor', size = 14 }: IconProps) { return ( + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/VulnerabilityIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/VulnerabilityIcon.tsx index f0fbe93ef53..0e043340b1f 100644 --- a/server/sonar-web/src/main/js/components/icons-components/VulnerabilityIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/VulnerabilityIcon.tsx @@ -18,23 +18,24 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IconProps } from './types'; -interface Props { - className?: string; - size?: number; -} - -export default function VulnerabilityIcon({ className, size = 16 }: Props) { - /* eslint-disable max-len */ +export default function VulnerabilityIcon({ + className, + fill = 'currentColor', + size = 16 +}: IconProps) { return ( + height={size} + viewBox="0 0 16 16" + version="1.1" + xmlnsXlink="http://www.w3.org/1999/xlink" + xmlSpace="preserve"> diff --git a/server/sonar-web/src/main/js/components/icons-components/__mocks__/ClearIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/__mocks__/ClearIcon.tsx new file mode 100644 index 00000000000..2fca30f2ec6 --- /dev/null +++ b/server/sonar-web/src/main/js/components/icons-components/__mocks__/ClearIcon.tsx @@ -0,0 +1,22 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +export default function ClearIcon() { + return null; +} diff --git a/server/sonar-web/src/main/js/components/icons-components/icons.ts b/server/sonar-web/src/main/js/components/icons-components/icons.ts index e783a6e9adb..d84d2ac30c4 100644 --- a/server/sonar-web/src/main/js/components/icons-components/icons.ts +++ b/server/sonar-web/src/main/js/components/icons-components/icons.ts @@ -17,62 +17,37 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import _AlertErrorIcon from './AlertErrorIcon'; -import _AlertWarnIcon from './AlertWarnIcon'; -import _BranchIcon from './BranchIcon'; -import _BubblesIcon from './BubblesIcon'; -import _BugIcon from './BugIcon'; -import _ChangeIcon from './ChangeIcon'; -import _ChartLegendIcon from './ChartLegendIcon'; -import _CheckIcon from './CheckIcon'; -import _CloseIcon from './CloseIcon'; -import _CodeSmellIcon from './CodeSmellIcon'; -import _DeleteIcon from './DeleteIcon'; -import _FavoriteIcon from './FavoriteIcon'; -import _HelpIcon from './HelpIcon'; -import _HistoryIcon from './HistoryIcon'; -import _LinkIcon from './LinkIcon'; -import _ListIcon from './ListIcon'; -import _LongLivingBranchIcon from './LongLivingBranchIcon'; -import _OpenCloseIcon from './OpenCloseIcon'; -import _OrganizationIcon from './OrganizationIcon'; -import _PendingIcon from './PendingIcon'; -import _ProjectEventIcon from './ProjectEventIcon'; -import _PullRequestIcon from './PullRequestIcon'; -import _QualifierIcon from './QualifierIcon'; -import _ShortLivingBranchIcon from './ShortLivingBranchIcon'; -import _SortAscIcon from './SortAscIcon'; -import _SortDescIcon from './SortDescIcon'; -import _TreeIcon from './TreeIcon'; -import _TreemapIcon from './TreemapIcon'; -import _VulnerabilityIcon from './VulnerabilityIcon'; - -export const AlertErrorIcon = _AlertErrorIcon; -export const AlertWarnIcon = _AlertWarnIcon; -export const BranchIcon = _BranchIcon; -export const BubblesIcon = _BubblesIcon; -export const BugIcon = _BugIcon; -export const ChangeIcon = _ChangeIcon; -export const ChartLegendIcon = _ChartLegendIcon; -export const CheckIcon = _CheckIcon; -export const CloseIcon = _CloseIcon; -export const CodeSmellIcon = _CodeSmellIcon; -export const DeleteIcon = _DeleteIcon; -export const FavoriteIcon = _FavoriteIcon; -export const HelpIcon = _HelpIcon; -export const HistoryIcon = _HistoryIcon; -export const LinkIcon = _LinkIcon; -export const ListIcon = _ListIcon; -export const LongLivingBranchIcon = _LongLivingBranchIcon; -export const OpenCloseIcon = _OpenCloseIcon; -export const OrganizationIcon = _OrganizationIcon; -export const PendingIcon = _PendingIcon; -export const ProjectEventIcon = _ProjectEventIcon; -export const PullRequestIcon = _PullRequestIcon; -export const QualifierIcon = _QualifierIcon; -export const ShortLivingBranchIcon = _ShortLivingBranchIcon; -export const SortAscIcon = _SortAscIcon; -export const SortDescIcon = _SortDescIcon; -export const TreeIcon = _TreeIcon; -export const TreemapIcon = _TreemapIcon; -export const VulnerabilityIcon = _VulnerabilityIcon; +export { default as AlertErrorIcon } from './AlertErrorIcon'; +export { default as AlertWarnIcon } from './AlertWarnIcon'; +export { default as BranchIcon } from './BranchIcon'; +export { default as BubblesIcon } from './BubblesIcon'; +export { default as BugIcon } from './BugIcon'; +// @deprecated use EditIcon +export { default as ChangeIcon } from './EditIcon'; +export { default as ChartLegendIcon } from './ChartLegendIcon'; +export { default as CheckIcon } from './CheckIcon'; +export { default as ClearIcon } from './ClearIcon'; +// @deprecated use ClearIcon +export { default as CloseIcon } from './ClearIcon'; +export { default as CodeSmellIcon } from './CodeSmellIcon'; +// @deprecated use ClearIcon +export { default as DeleteIcon } from './DeleteIcon'; +export { default as EditIcon } from './EditIcon'; +export { default as FavoriteIcon } from './FavoriteIcon'; +export { default as HelpIcon } from './HelpIcon'; +export { default as HistoryIcon } from './HistoryIcon'; +export { default as LinkIcon } from './LinkIcon'; +export { default as ListIcon } from './ListIcon'; +export { default as LongLivingBranchIcon } from './LongLivingBranchIcon'; +export { default as OpenCloseIcon } from './OpenCloseIcon'; +export { default as OrganizationIcon } from './OrganizationIcon'; +export { default as PendingIcon } from './PendingIcon'; +export { default as ProjectEventIcon } from './ProjectEventIcon'; +export { default as PullRequestIcon } from './PullRequestIcon'; +export { default as QualifierIcon } from './QualifierIcon'; +export { default as ShortLivingBranchIcon } from './ShortLivingBranchIcon'; +export { default as SortAscIcon } from './SortAscIcon'; +export { default as SortDescIcon } from './SortDescIcon'; +export { default as TreeIcon } from './TreeIcon'; +export { default as TreemapIcon } from './TreemapIcon'; +export { default as VulnerabilityIcon } from './VulnerabilityIcon'; diff --git a/server/sonar-web/src/main/js/components/icons-components/types.ts b/server/sonar-web/src/main/js/components/icons-components/types.ts new file mode 100644 index 00000000000..27f6a73cbd6 --- /dev/null +++ b/server/sonar-web/src/main/js/components/icons-components/types.ts @@ -0,0 +1,24 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +export interface IconProps { + className?: string; + fill?: string; + size?: number; +} diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js b/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js index 79c2f1c7b18..5ae0471483b 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.js @@ -22,7 +22,7 @@ import React from 'react'; import Avatar from '../../../components/ui/Avatar'; import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; import EditIcon from '../../../components/icons-components/EditIcon'; -import DeleteIcon from '../../../components/icons-components/DeleteIcon'; +import { EditButton, DeleteButton } from '../../../components/ui/buttons'; import CommentDeletePopup from '../popups/CommentDeletePopup'; import CommentPopup from '../popups/CommentPopup'; import DateFromNow from '../../../components/intl/DateFromNow'; @@ -119,11 +119,10 @@ export default class IssueCommentLine extends React.PureComponent { toggleComment={this.toggleEditPopup} /> }> - + )} {comment.updatable && ( @@ -134,11 +133,10 @@ export default class IssueCommentLine extends React.PureComponent { position="bottomright" togglePopup={this.toggleDeletePopup} popup={}> - + )}
diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.js index 3075e60cc89..fc39cfdd0e4 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.js @@ -53,9 +53,10 @@ it('should open the right popups when the buttons are clicked', () => { const element = shallow( ); - click(element.find('button.js-issue-comment-edit')); + element.find('.js-issue-comment-edit').prop('onClick')(); expect(element.state()).toMatchSnapshot(); - click(element.find('button.js-issue-comment-delete')); + element.find('.js-issue-comment-delete').prop('onClick')(); expect(element.state()).toMatchSnapshot(); + element.update(); expect(element).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentLine-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentLine-test.js.snap index 2ffdaa63fd4..71f4ef39f22 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentLine-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueCommentLine-test.js.snap @@ -79,12 +79,10 @@ exports[`should open the right popups when the buttons are clicked 3`] = ` position="bottomright" togglePopup={[Function]} > - + /> - + />
@@ -221,12 +217,10 @@ exports[`should render correctly a comment that is updatable 1`] = ` position="bottomright" togglePopup={[Function]} > - + /> - + /> diff --git a/server/sonar-web/src/main/js/components/nav/NavBar.tsx b/server/sonar-web/src/main/js/components/nav/NavBar.tsx index e44a3e9d722..19397032533 100644 --- a/server/sonar-web/src/main/js/components/nav/NavBar.tsx +++ b/server/sonar-web/src/main/js/components/nav/NavBar.tsx @@ -19,14 +19,13 @@ */ import * as React from 'react'; import * as classNames from 'classnames'; -import NavBarNotif from './NavBarNotif'; import './NavBar.css'; interface Props { children?: any; className?: string; height: number; - notif?: React.ReactElement; + notif?: React.ReactNode; } export default function NavBar({ children, className, height, notif, ...other }: Props) { diff --git a/server/sonar-web/src/main/js/components/nav/NavBarNotif.tsx b/server/sonar-web/src/main/js/components/nav/NavBarNotif.tsx index c276e20f62f..a58f469c182 100644 --- a/server/sonar-web/src/main/js/components/nav/NavBarNotif.tsx +++ b/server/sonar-web/src/main/js/components/nav/NavBarNotif.tsx @@ -19,7 +19,7 @@ */ import * as React from 'react'; import * as classNames from 'classnames'; -import CloseIcon from '../icons-components/CloseIcon'; +import { DeleteButton } from '../ui/buttons'; interface Props { children?: React.ReactNode; @@ -27,31 +27,18 @@ interface Props { onCancel?: () => {}; } -export default class NavBarNotif extends React.PureComponent { - handleCancel = (event: React.SyntheticEvent) => { - event.preventDefault(); - if (this.props.onCancel) { - this.props.onCancel(); - } - }; - - render() { - if (!this.props.children) { - return null; - } - return ( -
-
-
- {this.props.children} - {this.props.onCancel && ( - - - - )} -
+export default function NavBarNotif(props: Props) { + if (!props.children) { + return null; + } + return ( +
+
+
+ {props.children} + {props.onCancel && }
- ); - } +
+ ); } diff --git a/server/sonar-web/src/main/js/components/icons-components/ChangeIcon.tsx b/server/sonar-web/src/main/js/components/ui/buttons.css similarity index 51% rename from server/sonar-web/src/main/js/components/icons-components/ChangeIcon.tsx rename to server/sonar-web/src/main/js/components/ui/buttons.css index a36bd201b71..fd15962d0f5 100644 --- a/server/sonar-web/src/main/js/components/icons-components/ChangeIcon.tsx +++ b/server/sonar-web/src/main/js/components/ui/buttons.css @@ -17,26 +17,40 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as React from 'react'; -import * as theme from '../../app/theme'; +.button-icon { + display: inline-flex; + justify-content: center; + align-items: center; + vertical-align: middle; + width: var(--controlHeight); + height: var(--controlHeight); + padding: 0; + border: none; + color: inherit; +} + +.button-icon.button-small { + width: var(--smallControlHeight); + height: var(--smallControlHeight); + padding: 0; +} + +.button-icon.button-small svg { + margin-top: 0; +} + +.button-icon.button-tiny { + width: var(--tinyControlHeight); + height: var(--tinyControlHeight); + padding: 0; +} -interface Props { - className?: string; - size?: number; +.button-icon:hover, +.button-icon:focus { + background-color: currentColor; } -export default function ChangeIcon({ className, size = 12 }: Props) { - return ( - - - - ); +.button-icon:hover svg, +.button-icon:focus svg { + color: #fff; } diff --git a/server/sonar-web/src/main/js/components/ui/buttons.tsx b/server/sonar-web/src/main/js/components/ui/buttons.tsx new file mode 100644 index 00000000000..e4cd085eb05 --- /dev/null +++ b/server/sonar-web/src/main/js/components/ui/buttons.tsx @@ -0,0 +1,79 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import * as classNames from 'classnames'; +import * as theme from '../../app/theme'; +import ClearIcon from '../icons-components/ClearIcon'; +import './buttons.css'; +import EditIcon from '../icons-components/EditIcon'; + +interface ButtonIconProps { + children: React.ReactNode; + className?: string; + color?: string; + onClick?: () => void; + [x: string]: any; +} + +export class ButtonIcon extends React.PureComponent { + handleClick = (event: React.SyntheticEvent) => { + event.preventDefault(); + event.currentTarget.blur(); + event.stopPropagation(); + if (this.props.onClick) { + this.props.onClick(); + } + }; + + render() { + const { children, className, color = theme.darkBlue, ...props } = this.props; + return ( + + ); + } +} + +interface ActionButtonProps { + className?: string; + onClick?: () => void; + [x: string]: any; +} + +export function DeleteButton(props: ActionButtonProps) { + return ( + + + + ); +} + +export function EditButton(props: ActionButtonProps) { + return ( + + + + ); +} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/projects/ProjectsPage.java b/tests/src/test/java/org/sonarqube/pageobjects/projects/ProjectsPage.java index d019dcd74c8..767c2fbf2d8 100644 --- a/tests/src/test/java/org/sonarqube/pageobjects/projects/ProjectsPage.java +++ b/tests/src/test/java/org/sonarqube/pageobjects/projects/ProjectsPage.java @@ -110,7 +110,7 @@ public class ProjectsPage { } public ProjectsPage invertSorting() { - getOpenTopBar().$(".js-projects-sorting-select a.button-icon").should(Condition.exist).click(); + getOpenTopBar().$(".js-projects-sorting-invert").should(Condition.exist).click(); return this; } diff --git a/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java b/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java index dde5ace24cb..c14cc18e9fc 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java @@ -21,20 +21,20 @@ package org.sonarqube.tests.projectSearch; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import org.sonarqube.tests.Category1Suite; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.RuleChain; +import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.pageobjects.projects.ProjectsPage; +import org.sonarqube.tests.Category1Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.WsUsers; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.project.DeleteRequest; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.projects.ProjectsPage; import static com.codeborne.selenide.Selenide.clearBrowserLocalStorage; import static com.codeborne.selenide.WebDriverRunner.url; -- 2.39.5