@rh-support/troubleshoot 2.2.47 → 2.2.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"RelatedTickets.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CaseEditView/Tabs/RelatedTickets/RelatedTickets.tsx"],"names":[],"mappings":"AAqCA,QAAA,MAAM,cAAc,mBA8KnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"RelatedTickets.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CaseEditView/Tabs/RelatedTickets/RelatedTickets.tsx"],"names":[],"mappings":"AAsCA,QAAA,MAAM,cAAc,mBAsLnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -12,8 +12,9 @@ import { Badge, EmptyState, EmptyStateHeader, EmptyStateIcon, EmptyStateVariant,
12
12
  import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon';
13
13
  import { Table, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table';
14
14
  import { useFetch } from '@rh-support/components';
15
+ import { GlobalMetadataStateContext } from '@rh-support/react-context';
15
16
  import isEqual from 'lodash/isEqual';
16
- import React, { useEffect, useState } from 'react';
17
+ import React, { useContext, useEffect, useState } from 'react';
17
18
  import { useTranslation } from 'react-i18next';
18
19
  import { useCaseSelector } from '../../../../context/CaseContext';
19
20
  const columnNames = {
@@ -23,6 +24,7 @@ const columnNames = {
23
24
  title: 'Summary',
24
25
  };
25
26
  const RelatedTickets = () => {
27
+ const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
26
28
  const [activeToggleKey, setActiveToggleKey] = useState('all');
27
29
  const [currentPage, setCurrentPage] = useState(1);
28
30
  const [itemsPerPage, setItemsPerPage] = useState(10);
@@ -37,7 +39,6 @@ const RelatedTickets = () => {
37
39
  const [bugzillaData, setBugzillaData] = useState([]);
38
40
  const [jiraData, setJiraData] = useState([]);
39
41
  const { t } = useTranslation();
40
- // reset pagination when searching for edge case
41
42
  useEffect(() => {
42
43
  setCurrentPage(1);
43
44
  }, [searchQuery, activeToggleKey]);
@@ -53,16 +54,18 @@ const RelatedTickets = () => {
53
54
  date: new Date(bugzilla.linkedAt),
54
55
  }));
55
56
  setBugzillaData(bugzillaTransformed);
56
- const jiraResults = yield getCaseJiras(caseNumber);
57
- const jiraTransformed = jiraResults.map((jira) => ({
58
- id: jira.resourceKey,
59
- type: 'Jira',
60
- link: jira.resourceURL || '',
61
- status: jira.status || 'N/A',
62
- title: jira.title || 'N/A',
63
- date: new Date(jira.createdDate),
64
- }));
65
- setJiraData(jiraTransformed);
57
+ if (loggedInUserRights.data.isInternal()) {
58
+ const jiraResults = yield getCaseJiras(caseNumber);
59
+ const jiraTransformed = jiraResults.map((jira) => ({
60
+ id: jira.resourceKey,
61
+ type: 'Jira',
62
+ link: jira.resourceURL || '',
63
+ status: jira.status || 'N/A',
64
+ title: jira.title || 'N/A',
65
+ date: new Date(jira.createdDate),
66
+ }));
67
+ setJiraData(jiraTransformed);
68
+ }
66
69
  }
67
70
  catch (error) {
68
71
  console.log(error);
@@ -70,8 +73,9 @@ const RelatedTickets = () => {
70
73
  });
71
74
  fetchData();
72
75
  // eslint-disable-next-line react-hooks/exhaustive-deps
73
- }, [bugzillaFetch, caseNumber]);
74
- const combinedData = [...bugzillaData, ...jiraData].sort((a, b) => b.date.getTime() - a.date.getTime());
76
+ }, [bugzillaFetch, caseNumber, loggedInUserRights.data]);
77
+ // don't add the jiradata into the combination if not internal
78
+ const combinedData = [...bugzillaData, ...(loggedInUserRights.data.isInternal() ? jiraData : [])].sort((a, b) => b.date.getTime() - a.date.getTime());
75
79
  const filteredData = combinedData.filter((item) => {
76
80
  const lowercasedQuery = searchQuery.toLowerCase();
77
81
  if (searchQuery &&
@@ -84,16 +88,18 @@ const RelatedTickets = () => {
84
88
  if (activeToggleKey === 'bugzilla')
85
89
  return item.type === 'Bugzilla';
86
90
  if (activeToggleKey === 'jira')
87
- return item.type === 'Jira';
91
+ return item.type === 'Jira' && loggedInUserRights.data.isInternal();
88
92
  return true;
89
93
  });
94
+ //pagination
90
95
  const startIdx = (currentPage - 1) * itemsPerPage;
91
96
  const endIdx = startIdx + itemsPerPage;
92
97
  const displayData = filteredData.slice(startIdx, endIdx);
93
98
  return (React.createElement("section", { className: "card card-white" },
94
- (activeToggleKey === 'all' && (bugzillaData.length > 0 || jiraData.length > 0)) ||
99
+ (activeToggleKey === 'all' &&
100
+ (bugzillaData.length > 0 || (jiraData.length > 0 && loggedInUserRights.data.isInternal()))) ||
95
101
  (activeToggleKey === 'bugzilla' && bugzillaData.length > 0) ||
96
- (activeToggleKey === 'jira' && jiraData.length > 0) ? (React.createElement("div", { className: "related-ticket-search-input-container", id: "related-ticket-search-container" },
102
+ (activeToggleKey === 'jira' && jiraData.length > 0 && loggedInUserRights.data.isInternal()) ? (React.createElement("div", { className: "related-ticket-search-input-container", id: "related-ticket-search-container" },
97
103
  React.createElement(SearchInput, { className: "related-ticket-search-input", placeholder: t('Search by Task ID or Summary'), value: searchQuery, onChange: (event) => setSearchQuery(event.currentTarget.value), onClear: () => setSearchQuery('') }))) : null,
98
104
  React.createElement(ToggleGroup, { "aria-label": "Toggle Group" },
99
105
  React.createElement(ToggleGroupItem, { text: t('All'), isSelected: activeToggleKey === 'all', onChange: () => setActiveToggleKey('all'), "data-tracking-id": 'related-ticket-all' }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "2.2.47",
3
+ "version": "2.2.48",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -132,5 +132,5 @@
132
132
  "defaults and supports es6-module",
133
133
  "maintained node versions"
134
134
  ],
135
- "gitHead": "b0978cf9cff4fa1b1355983b294a010e92b45938"
135
+ "gitHead": "8e4f76b9f341bc33c3cc44b081efb0ffe45f270a"
136
136
  }