]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17478 Remove "Period" category and make "New Code" a stand-alone filter
authorWouter Admiraal <wouter.admiraal@sonarsource.com>
Thu, 20 Oct 2022 09:15:19 +0000 (11:15 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 21 Oct 2022 20:03:18 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/issues/sidebar/PeriodFilter.tsx
server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/PeriodFilter-test.tsx
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index ea5a1b6f3beb4f00cbce232679ced4296cca1f49..c75cd9a2b6dabf3d61239e77831ee566cb5e3d6c 100644 (file)
@@ -19,7 +19,6 @@
  */
 import * as React from 'react';
 import FacetBox from '../../../components/facet/FacetBox';
-import FacetHeader from '../../../components/facet/FacetHeader';
 import FacetItem from '../../../components/facet/FacetItem';
 import FacetItemsList from '../../../components/facet/FacetItemsList';
 import { translate } from '../../../helpers/l10n';
@@ -42,8 +41,6 @@ const PROPERTY = 'period';
 export default function PeriodFilter(props: PeriodFilterProps) {
   const { fetching, newCodeSelected, stats = {} } = props;
 
-  const [open, setOpen] = React.useState(true);
-
   const { onChange } = props;
   const handleClick = React.useCallback(() => {
     // We need to clear creation date filters they conflict with the new code period
@@ -56,32 +53,18 @@ export default function PeriodFilter(props: PeriodFilterProps) {
     });
   }, [newCodeSelected, onChange]);
 
-  const handleClear = React.useCallback(() => {
-    onChange({ [Period.NewCode]: undefined });
-  }, [onChange]);
-
   return (
     <FacetBox property={PROPERTY}>
-      <FacetHeader
-        fetching={fetching}
-        name={translate('issues.facet', PROPERTY)}
-        onClear={handleClear}
-        onClick={() => setOpen(!open)}
-        open={open}
-        values={newCodeSelected ? [translate('issues.new_code')] : undefined}
-      />
-
-      {open && (
-        <FacetItemsList>
-          <FacetItem
-            active={newCodeSelected}
-            name={translate('issues.new_code')}
-            onClick={handleClick}
-            stat={formatFacetStat(stats[Period.NewCode])}
-            value={Period.NewCode}
-          />
-        </FacetItemsList>
-      )}
+      <FacetItemsList>
+        <FacetItem
+          active={newCodeSelected}
+          loading={fetching}
+          name={translate('issues.new_code')}
+          onClick={handleClick}
+          stat={formatFacetStat(stats[Period.NewCode])}
+          value={Period.NewCode}
+        />
+      </FacetItemsList>
     </FacetBox>
   );
 }
index 0bdcd8c7463d92ecce9550df1dd3ca3eeecedba8..346fcea74b9f2d6403051201a8b9903776cbc5a3 100644 (file)
@@ -23,18 +23,6 @@ import userEvent from '@testing-library/user-event';
 import * as React from 'react';
 import PeriodFilter, { PeriodFilterProps } from '../PeriodFilter';
 
-it('should be collapsible', async () => {
-  const user = userEvent.setup();
-
-  renderPeriodFilter();
-
-  expect(screen.getByText('issues.new_code')).toBeInTheDocument();
-
-  await user.click(screen.getByText('issues.facet.period'));
-
-  expect(screen.queryByText('issues.new_code')).not.toBeInTheDocument();
-});
-
 it('should filter when clicked', async () => {
   const user = userEvent.setup();
   const onChange = jest.fn();
@@ -52,19 +40,6 @@ it('should filter when clicked', async () => {
   });
 });
 
-it('should be clearable', async () => {
-  const user = userEvent.setup();
-  const onChange = jest.fn();
-
-  renderPeriodFilter({ onChange, newCodeSelected: true });
-
-  await user.click(screen.getByText('clear'));
-
-  expect(onChange).toHaveBeenCalledWith({
-    inNewCodePeriod: undefined
-  });
-});
-
 function renderPeriodFilter(overrides: Partial<PeriodFilterProps> = {}) {
   return render(
     <PeriodFilter
index c79c05f3719fefcf84e465f2445358cdbc9d7874..3746c23d676b72405b49f2d70c7f2aa0b5baa2ab 100644 (file)
@@ -934,7 +934,7 @@ issues.to_navigate=to navigate
 issues.to_navigate_back=to navigate back
 issues.to_navigate_issue_locations=to navigate issue locations
 issues.to_switch_flows=to switch flows
-issues.new_code=New code
+issues.new_code=Issues in new code
 issues.new_code_period=New Code Period
 issues.max_new_code_period=Max New Code Period
 issues.my_issues=My Issues