]> source.dussan.org Git - sonarqube.git/commitdiff
[NO-JIRA] Fix react-select typings
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Wed, 27 Apr 2022 06:53:03 +0000 (08:53 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 27 Apr 2022 20:03:09 +0000 (20:03 +0000)
16 files changed:
server/sonar-web/src/main/js/apps/background-tasks/components/StatusFilter.tsx
server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/CustomRuleFormModal-test.tsx.snap
server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.tsx
server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/MeasureViewSelect-test.tsx.snap
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx
server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityGraphs-test.tsx.snap
server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingReferenceBranch.tsx
server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisListRenderer.tsx
server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/__snapshots__/BaselineSettingReferenceBranch-test.tsx.snap
server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/__snapshots__/BranchAnalysisListRenderer-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx
server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx
server/sonar-web/src/main/js/apps/projectsManagement/__tests__/__snapshots__/Search-test.tsx.snap
server/sonar-web/src/main/js/components/controls/Select.tsx

index 4e80efeca5738a81be5badd94d62ecee209ffb11..6e248342f5433d5cdd1c57074c54fac27566738d 100644 (file)
@@ -53,8 +53,8 @@ export default class StatusFilter extends React.PureComponent<Props> {
         className="input-medium"
         onChange={this.handleChange}
         options={options}
-        searchable={false}
         value={options.find(o => o.value === this.props.value)}
+        isSearchable={false}
       />
     );
   }
index bb7dd9de5f4daeddb15d9d7fbefd727f082c290c..b84b21505399fd8f5d541a01c44aeb1aec5a5cdd 100644 (file)
@@ -51,10 +51,10 @@ export default class TypesFilter extends React.PureComponent<Props> {
       <Select
         aria-labelledby="background-task-type-filter-label"
         className="input-large"
-        clearable={false}
+        isClearable={false}
         onChange={this.handleChange}
         options={allOptions}
-        searchable={false}
+        isSearchable={false}
         value={allOptions.find(o => o.value === value)}
       />
     );
index 697183bbaa5717afd687d1fe5a04224b9d8f6d93..921ad40aae30086efbd33f637e27f8f3bbf950cf 100644 (file)
@@ -282,7 +282,7 @@ export default class CustomRuleFormModal extends React.PureComponent<Props, Stat
           aria-labelledby="coding-rules-custom-rule-status"
           onChange={this.handleStatusChange}
           options={statusesOptions}
-          searchable={false}
+          isSearchable={false}
           value={statusesOptions.find(s => s.value === this.state.status)}
         />
       </div>
index 1af1f3d81d717bdbd9b8c3882b2509de3390b416..d3d7ca60de7611e5b053dcc4f91d43f72039b0c6 100644 (file)
@@ -143,6 +143,7 @@ exports[`should handle re-activation 1`] = `
             aria-labelledby="coding-rules-custom-rule-status"
             isClearable={false}
             isDisabled={false}
+            isSearchable={false}
             onChange={[Function]}
             options={
               Array [
@@ -160,7 +161,6 @@ exports[`should handle re-activation 1`] = `
                 },
               ]
             }
-            searchable={false}
             value={
               Object {
                 "label": "rules.status.READY",
@@ -398,6 +398,7 @@ exports[`should render correctly: default 1`] = `
             aria-labelledby="coding-rules-custom-rule-status"
             isClearable={false}
             isDisabled={false}
+            isSearchable={false}
             onChange={[Function]}
             options={
               Array [
@@ -415,7 +416,6 @@ exports[`should render correctly: default 1`] = `
                 },
               ]
             }
-            searchable={false}
             value={
               Object {
                 "label": "rules.status.READY",
index c215877eb7cb3dcdf03fd3c89cd7282d5b42f225..8c0d2a31e8a85731007f332ba32d42159681ab37 100644 (file)
@@ -94,7 +94,7 @@ export default class MeasureViewSelect extends React.PureComponent<Props> {
     return (
       <Select
         aria-labelledby="measures-view-selection-label"
-        autoBlur={true}
+        blurInputOnSelect={true}
         className={className}
         onChange={this.handleChange}
         components={{
index f72fdab814b72bc8d6a44337c492f5c51a530969..ca6e1b17787c6cf78859f57698bf7f0083a87565 100644 (file)
@@ -3,7 +3,7 @@
 exports[`should render correctly: has no list 1`] = `
 <Select
   aria-labelledby="measures-view-selection-label"
-  autoBlur={true}
+  blurInputOnSelect={true}
   components={
     Object {
       "Option": [Function],
@@ -32,7 +32,7 @@ exports[`should render correctly: has no list 1`] = `
 exports[`should render correctly: has no tree 1`] = `
 <Select
   aria-labelledby="measures-view-selection-label"
-  autoBlur={true}
+  blurInputOnSelect={true}
   components={
     Object {
       "Option": [Function],
@@ -63,7 +63,7 @@ exports[`should render correctly: has no tree 1`] = `
 exports[`should render correctly: has no treemap 1`] = `
 <Select
   aria-labelledby="measures-view-selection-label"
-  autoBlur={true}
+  blurInputOnSelect={true}
   components={
     Object {
       "Option": [Function],
index 57b70d18ebeb0b4cce4d15154e76ce4dc3b276c9..2ac68912d7c965b5fdd904105eed99aa47c4d416 100644 (file)
@@ -142,16 +142,14 @@ export default class ProjectActivityGraphs extends React.PureComponent<Props, St
       .map(graph => graph[0].type);
   };
 
-  addCustomMetric = (metric: string) => {
-    const customMetrics = [...this.props.query.customMetrics, metric];
-    saveActivityGraph(PROJECT_ACTIVITY_GRAPH, this.props.project, GraphType.custom, customMetrics);
-    this.props.updateQuery({ customMetrics });
-  };
-
-  removeCustomMetric = (removedMetric: string) => {
-    const customMetrics = this.props.query.customMetrics.filter(metric => metric !== removedMetric);
-    saveActivityGraph(PROJECT_ACTIVITY_GRAPH, this.props.project, GraphType.custom, customMetrics);
-    this.props.updateQuery({ customMetrics });
+  updateSelectedMetrics = (selectedMetrics: string[]) => {
+    saveActivityGraph(
+      PROJECT_ACTIVITY_GRAPH,
+      this.props.project,
+      GraphType.custom,
+      selectedMetrics
+    );
+    this.props.updateQuery({ customMetrics: selectedMetrics });
   };
 
   updateGraph = (graph: GraphType) => {
@@ -195,12 +193,10 @@ export default class ProjectActivityGraphs extends React.PureComponent<Props, St
     return (
       <div className="project-activity-layout-page-main-inner boxed-group boxed-group-inner">
         <GraphsHeader
-          addCustomMetric={this.addCustomMetric}
           className="big-spacer-bottom"
           graph={query.graph}
           metrics={metrics}
           metricsTypeFilter={this.getMetricsTypeFilter()}
-          removeCustomMetric={this.removeCustomMetric}
           selectedMetrics={this.props.query.customMetrics}
           updateGraph={this.updateGraph}
         />
@@ -213,7 +209,6 @@ export default class ProjectActivityGraphs extends React.PureComponent<Props, St
           leakPeriodDate={leakPeriodDate}
           loading={loading}
           measuresHistory={this.props.measuresHistory}
-          removeCustomMetric={this.removeCustomMetric}
           selectedDate={this.props.query.selectedDate}
           series={series}
           updateGraphZoom={this.updateGraphZoom}
index b817fd80c5ebb2b904d7ed8a79e096abce0ff57b..cbc6c857b88da145f89b2f92e37377b6d11dd059 100644 (file)
@@ -5,7 +5,6 @@ exports[`should render correctly the graph and legends 1`] = `
   className="project-activity-layout-page-main-inner boxed-group boxed-group-inner"
 >
   <GraphsHeader
-    addCustomMetric={[Function]}
     className="big-spacer-bottom"
     graph="issues"
     metrics={
@@ -18,7 +17,6 @@ exports[`should render correctly the graph and legends 1`] = `
         },
       ]
     }
-    removeCustomMetric={[Function]}
     selectedMetrics={Array []}
     updateGraph={[Function]}
   />
@@ -108,7 +106,6 @@ exports[`should render correctly the graph and legends 1`] = `
         },
       ]
     }
-    removeCustomMetric={[Function]}
     series={
       Array [
         Object {
index 9cf2517a172cbbba036ecf3e6e13872a56276df5..7a34d01e6d350c29d111bfcd99a080e5f0447520 100644 (file)
@@ -112,8 +112,7 @@ export default function BaselineSettingReferenceBranch(props: BaselineSettingRef
                 <strong>{translate('baseline.reference_branch.choose')}</strong>
                 <MandatoryFieldMarker />
               </label>
-              <Select<BranchOption>
-                autofocus={false}
+              <Select
                 className="little-spacer-top spacer-bottom"
                 options={branchList}
                 onChange={(option: BranchOption) => props.onChangeReferenceBranch(option.value)}
index b9031a25063edce25d8a7181b8779b6a5b8bf75f..f33c1ddb72a2e0f28820efd899b74750a0c2c583 100644 (file)
@@ -19,8 +19,8 @@
  */
 import classNames from 'classnames';
 import * as React from 'react';
-import Select from '../../../components/controls/Select';
 import Radio from '../../../components/controls/Radio';
+import Select from '../../../components/controls/Select';
 import Tooltip from '../../../components/controls/Tooltip';
 import DateFormatter from '../../../components/intl/DateFormatter';
 import TimeFormatter from '../../../components/intl/TimeFormatter';
@@ -113,7 +113,7 @@ export default function BranchAnalysisListRenderer(props: BranchAnalysisListRend
           {translate('baseline.analysis_from')}
         </label>
         <Select
-          autoBlur={true}
+          blurInputOnSelect={true}
           inputId="branch-analysis-from-input"
           className="input-medium spacer-left"
           onChange={props.handleRangeChange}
index d4f3b6d553441a4aa2ace6bc480f2805e29363e6..a481b29936d239f2235040f398c761310a8e6775 100644 (file)
@@ -109,7 +109,6 @@ exports[`should render correctly: Branch level - no other branches 1`] = `
       <MandatoryFieldMarker />
     </label>
     <Select
-      autofocus={false}
       className="little-spacer-top spacer-bottom"
       components={
         Object {
@@ -163,7 +162,6 @@ exports[`should render correctly: Branch level 1`] = `
       <MandatoryFieldMarker />
     </label>
     <Select
-      autofocus={false}
       className="little-spacer-top spacer-bottom"
       components={
         Object {
@@ -227,7 +225,6 @@ exports[`should render correctly: Project level 1`] = `
       <MandatoryFieldMarker />
     </label>
     <Select
-      autofocus={false}
       className="little-spacer-top spacer-bottom"
       components={
         Object {
index fff6d543a90b275f5661a925aece73701a57e537..3085961afa51b9d9f4455716e88994e46bf32cb4 100644 (file)
@@ -12,7 +12,7 @@ exports[`should render correctly: Analyses 1`] = `
       baseline.analysis_from
     </label>
     <Select
-      autoBlur={true}
+      blurInputOnSelect={true}
       className="input-medium spacer-left"
       inputId="branch-analysis-from-input"
       isSearchable={false}
@@ -320,7 +320,7 @@ exports[`should render correctly: empty 1`] = `
       baseline.analysis_from
     </label>
     <Select
-      autoBlur={true}
+      blurInputOnSelect={true}
       className="input-medium spacer-left"
       inputId="branch-analysis-from-input"
       isSearchable={false}
@@ -376,7 +376,7 @@ exports[`should render correctly: loading 1`] = `
       baseline.analysis_from
     </label>
     <Select
-      autoBlur={true}
+      blurInputOnSelect={true}
       className="input-medium spacer-left"
       inputId="branch-analysis-from-input"
       isSearchable={false}
index cfe93e04d91568277e9948fe7d87c68f7ff96518..cc9baa67013f8d6b27aa684ea64dabcfdbc57622 100644 (file)
@@ -46,7 +46,7 @@ export default class SearchableFilterFooter extends React.PureComponent<Props> {
           isLoading={this.props.isLoading}
           onChange={this.handleOptionChange}
           onInputChange={this.props.onInputChange}
-          onOpen={this.props.onOpen}
+          onMenuOpen={this.props.onOpen}
           options={this.props.options}
           placeholder={translate('search_verb')}
         />
index 123ae2ec62382a4791ebf6b51939edc2426854f7..9a51ec49016f340c4ffc83121db8eaf92f157622 100644 (file)
@@ -153,7 +153,7 @@ export class Search extends React.PureComponent<Props, State> {
       <td className="thin nowrap text-middle">
         <Select
           className="input-medium it__project-qualifier-select"
-          disabled={!this.props.ready}
+          isDisabled={!this.props.ready}
           name="projects-qualifier"
           onChange={this.handleQualifierChange}
           isSearchable={false}
@@ -162,7 +162,6 @@ export class Search extends React.PureComponent<Props, State> {
             SingleValue: this.singleValueRenderer
           }}
           options={this.getQualifierOptions()}
-          searchable={false}
           value={options.find(option => option.value === this.props.qualifiers)}
         />
       </td>
index 1f5862a128567c2ce24ef9314c8281b71524c6d3..830774bb1aafb87d4645adfd9b48d938adb3fd39 100644 (file)
@@ -59,7 +59,7 @@ exports[`render qualifiers filter 1`] = `
                 "SingleValue": [Function],
               }
             }
-            disabled={false}
+            isDisabled={false}
             isSearchable={false}
             name="projects-qualifier"
             onChange={[Function]}
@@ -79,7 +79,6 @@ exports[`render qualifiers filter 1`] = `
                 },
               ]
             }
-            searchable={false}
             value={
               Object {
                 "label": "qualifiers.TRK",
index 0807f4f6deeaf14a65470d9e682a5e53c3e4b9f3..87cf5d50d15da1ad6a1e80d87bbea187666d7a86 100644 (file)
@@ -24,8 +24,8 @@ import * as React from 'react';
 import ReactSelect, {
   GroupTypeBase,
   IndicatorProps,
+  NamedProps,
   OptionTypeBase,
-  Props,
   StylesConfig
 } from 'react-select';
 import AsyncReactSelect, { AsyncProps } from 'react-select/async';
@@ -99,7 +99,7 @@ export default class Select<
   Option,
   IsMulti extends boolean = false,
   Group extends GroupTypeBase<Option> = GroupTypeBase<Option>
-> extends React.Component<Props<Option, IsMulti, Group> & StyleExtensionProps> {
+> extends React.Component<NamedProps<Option, IsMulti, Group> & StyleExtensionProps> {
   render() {
     return (
       <ReactSelect
@@ -142,7 +142,7 @@ export function SearchSelect<
   Option,
   IsMulti extends boolean,
   Group extends GroupTypeBase<Option> = GroupTypeBase<Option>
->(props: Props<Option, IsMulti, Group> & AsyncProps<Option, Group> & StyleExtensionProps) {
+>(props: NamedProps<Option, IsMulti, Group> & AsyncProps<Option, Group> & StyleExtensionProps) {
   return (
     <AsyncReactSelect
       {...omit(props, 'className', 'large')}
@@ -161,7 +161,7 @@ export function SearchSelect<
 }
 
 export function selectStyle<Option, IsMulti extends boolean, Group extends GroupTypeBase<Option>>(
-  props?: Props<Option, IsMulti, Group> & AsyncProps<Option, Group> & StyleExtensionProps
+  props?: NamedProps<Option, IsMulti, Group> & AsyncProps<Option, Group> & StyleExtensionProps
 ): StylesConfig<Option, IsMulti, Group> {
   return {
     container: () => ({