You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SubnavigationIssuesList.tsx 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import styled from '@emotion/styled';
  21. import { themeBorder, themeColor, themeShadow } from 'design-system';
  22. import * as React from 'react';
  23. import ListFooter from '../../../components/controls/ListFooter';
  24. import { Issue, Paging } from '../../../types/types';
  25. import SubnavigationIssue from './SubnavigationIssue';
  26. import SubnavigationIssueComponentName from './SubnavigationIssueComponentName';
  27. import SubnavigationIssuesListHeader from './SubnavigationIssuesListHeader';
  28. interface Props {
  29. fetchMoreIssues: () => void;
  30. issues: Issue[];
  31. loading: boolean;
  32. loadingMore: boolean;
  33. onFlowSelect: (index?: number) => void;
  34. onIssueSelect: (issueKey: string) => void;
  35. onLocationSelect: (index: number) => void;
  36. paging: Paging | undefined;
  37. selected: string | undefined;
  38. selectedFlowIndex: number | undefined;
  39. selectedLocationIndex: number | undefined;
  40. }
  41. export default function SubnavigationIssuesList(props: Props) {
  42. const {
  43. issues,
  44. loading,
  45. loadingMore,
  46. paging,
  47. selected,
  48. selectedFlowIndex,
  49. selectedLocationIndex,
  50. } = props;
  51. return (
  52. <StyledWrapper>
  53. <SubnavigationIssuesListHeader loading={loading} paging={paging} />
  54. <StyledList className="sw-overflow-auto sw-flex-auto">
  55. {issues.map((issue, index) => {
  56. const previousIssue = index > 0 ? issues[index - 1] : undefined;
  57. const displayComponentName =
  58. !previousIssue || previousIssue.component !== issue.component;
  59. return (
  60. <React.Fragment key={index}>
  61. {displayComponentName && (
  62. <li>
  63. <SubnavigationIssueComponentName path={issue.componentLongName} />
  64. </li>
  65. )}
  66. <SubnavigationIssue
  67. issue={issue}
  68. onClick={props.onIssueSelect}
  69. onFlowSelect={props.onFlowSelect}
  70. onLocationSelect={props.onLocationSelect}
  71. selected={issue.key === selected}
  72. selectedFlowIndex={selectedFlowIndex}
  73. selectedLocationIndex={selectedLocationIndex}
  74. />
  75. </React.Fragment>
  76. );
  77. })}
  78. </StyledList>
  79. {paging && paging.total > 0 && (
  80. <StyledFooter
  81. className="sw-my-0 sw-py-4"
  82. count={issues.length}
  83. loadMore={props.fetchMoreIssues}
  84. loading={loadingMore}
  85. total={paging.total}
  86. useMIUIButtons
  87. />
  88. )}
  89. </StyledWrapper>
  90. );
  91. }
  92. const StyledList = styled.ul`
  93. li:not(:last-child) {
  94. border-bottom: ${themeBorder('default')};
  95. }
  96. `;
  97. const StyledWrapper = styled.div`
  98. background-color: ${themeColor('filterbar')};
  99. height: inherit;
  100. display: flex;
  101. flex-direction: column;
  102. `;
  103. const StyledFooter = styled(ListFooter)`
  104. box-shadow: ${themeShadow('scrolling')};
  105. `;