@rh-support/cases 2.7.36 → 2.7.37
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.
- package/lib/esm/enums/case.js +1 -1
- package/lib/esm/utils/caseListGraphQLUtils.d.ts.map +1 -1
- package/lib/esm/utils/caseListGraphQLUtils.js +65 -11
- package/lib/esm/utils/caseListVariablesBuilder.d.ts +1 -1
- package/lib/esm/utils/caseListVariablesBuilder.d.ts.map +1 -1
- package/lib/esm/utils/caseListVariablesBuilder.js +19 -5
- package/lib/esm/utils/displayLabelSort.d.ts +33 -0
- package/lib/esm/utils/displayLabelSort.d.ts.map +1 -0
- package/lib/esm/utils/displayLabelSort.js +204 -0
- package/package.json +6 -6
package/lib/esm/enums/case.js
CHANGED
|
@@ -70,11 +70,11 @@ export const caseListSortColumnIdsToGraphQLMap = {
|
|
|
70
70
|
[CaseListColumnIds.caseId]: 'CaseNumber__c',
|
|
71
71
|
[CaseListColumnIds.summary]: 'Subject',
|
|
72
72
|
[CaseListColumnIds.severity]: 'Priority',
|
|
73
|
-
[CaseListColumnIds.owner]: 'OwnerId',
|
|
74
73
|
[CaseListColumnIds.created]: 'CreatedDate',
|
|
75
74
|
[CaseListColumnIds.status]: 'Status',
|
|
76
75
|
[CaseListColumnIds.modified]: 'LastModifiedDate',
|
|
77
76
|
[CaseListColumnIds.accountNumber]: 'Account_Number__c',
|
|
77
|
+
[CaseListColumnIds.alternateCaseId]: 'AlternateCaseId__c',
|
|
78
78
|
[CaseListColumnIds.type]: 'Type',
|
|
79
79
|
[CaseListColumnIds.caseClosedDate]: 'ClosedDate',
|
|
80
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caseListGraphQLUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseListGraphQLUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAKH,aAAa,EAEhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,oBAAoB,EAAkB,MAAM,+CAA+C,CAAC;AAGrG,OAAO,EAGH,qBAAqB,EAExB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"caseListGraphQLUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseListGraphQLUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAKH,aAAa,EAEhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,oBAAoB,EAAkB,MAAM,+CAA+C,CAAC;AAGrG,OAAO,EAGH,qBAAqB,EAExB,MAAM,4BAA4B,CAAC;AAGpC,MAAM,WAAW,wBAAwB;IACrC,gBAAgB,EAAE;QACd,QAAQ,EAAE;YACN,IAAI,EAAE,aAAa,EAAE,CAAC;YACtB,QAAQ,EAAE,MAAM,CAAC;YACjB,KAAK,EAAE,MAAM,CAAC;SACjB,CAAC;KACL,CAAC;IACF,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAwDD,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAkFD,wBAAsB,sBAAsB,CACxC,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,YAAY,EAC1B,aAAa,CAAC,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,mBAAmB,CAAC,EAAE,MAAM,EAAE,EAC9B,yBAAyB,UAAQ,EACjC,YAAY,CAAC,EAAE,qBAAqB,GACrC,OAAO,CAAC,wBAAwB,CAAC,CA0InC;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAC/B,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,EACpB,yBAAyB,UAAQ,EACjC,YAAY,CAAC,EAAE,qBAAqB,GACrC,OAAO,CAAC,eAAe,CAAC,CAiF1B"}
|
|
@@ -22,6 +22,7 @@ import { GET_CASES_BY_FILTERS, GET_GROUP_IDS_BY_NAME, GET_PRODUCTS, GET_USER_IDS
|
|
|
22
22
|
import { SolrKeys, SolrPivotKeys } from '../enums/filters';
|
|
23
23
|
import { mapGraphQLResponseToCaseList } from './caseListMapper';
|
|
24
24
|
import { createGraphQLVariablesFromFilterState, getOwnerFederationIdsToResolve, } from './caseListVariablesBuilder';
|
|
25
|
+
import { fetchCasesInDisplayLabelOrder, isDisplayLabelColumnSort } from './displayLabelSort';
|
|
25
26
|
const pageCursors = new Map();
|
|
26
27
|
/**
|
|
27
28
|
* Workaround step 1 for Assigned To (case OwnerId): lookup RedHatSupportUser and
|
|
@@ -161,7 +162,7 @@ function resolveVersionProductIds(filterState, apolloClient) {
|
|
|
161
162
|
}
|
|
162
163
|
export function getCaseListFromGraphQL(filterState_1, apolloClient_1, limitOverride_1, signal_1, selectedCaseNumbers_1) {
|
|
163
164
|
return __awaiter(this, arguments, void 0, function* (filterState, apolloClient, limitOverride, signal, selectedCaseNumbers, includeSecureSupportCases = false, accountScope) {
|
|
164
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
165
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
165
166
|
try {
|
|
166
167
|
yield resolveVersionProductIds(filterState, apolloClient);
|
|
167
168
|
// Pre-resolve Assigned To owner IDs — users and groups (see resolveOwnerIds / caseListVariablesBuilder comments).
|
|
@@ -202,13 +203,44 @@ export function getCaseListFromGraphQL(filterState_1, apolloClient_1, limitOverr
|
|
|
202
203
|
else {
|
|
203
204
|
caseQueryVariables.after = getCursorForPage(currentPage);
|
|
204
205
|
}
|
|
206
|
+
const sortColumn = (_c = filterState.sortInfo) === null || _c === void 0 ? void 0 : _c.column;
|
|
207
|
+
if (isDisplayLabelColumnSort(sortColumn)) {
|
|
208
|
+
const page = yield fetchCasesInDisplayLabelOrder({
|
|
209
|
+
apolloClient,
|
|
210
|
+
where: caseQueryVariables.where,
|
|
211
|
+
first: caseQueryVariables.first,
|
|
212
|
+
afterCursor: caseQueryVariables.after,
|
|
213
|
+
column: sortColumn,
|
|
214
|
+
direction: (_d = filterState.sortInfo) === null || _d === void 0 ? void 0 : _d.direction,
|
|
215
|
+
types: (_e = filterState.filterInfo) === null || _e === void 0 ? void 0 : _e[SolrKeys.type],
|
|
216
|
+
statuses: (_f = filterState.filterInfo) === null || _f === void 0 ? void 0 : _f[SolrKeys.status],
|
|
217
|
+
signal,
|
|
218
|
+
fetchPolicy: 'network-only',
|
|
219
|
+
includeTotalCount: true,
|
|
220
|
+
});
|
|
221
|
+
if (page.endCursor) {
|
|
222
|
+
storeEndCursor(currentPage, page.endCursor);
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
caseListResponse: {
|
|
226
|
+
response: {
|
|
227
|
+
docs: mapGraphQLResponseToCaseList(page.edges || []),
|
|
228
|
+
numFound: page.totalCount || 0,
|
|
229
|
+
start: 0,
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
showErrorMessage: false,
|
|
233
|
+
hasNextPage: page.hasNextPage,
|
|
234
|
+
endCursor: page.endCursor,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
205
237
|
const { data, error } = yield apolloClient.query({
|
|
206
238
|
query: GET_CASES_BY_FILTERS,
|
|
207
239
|
variables: caseQueryVariables,
|
|
208
240
|
fetchPolicy: 'network-only',
|
|
209
241
|
context: signal ? { fetchOptions: { signal } } : undefined,
|
|
210
242
|
});
|
|
211
|
-
const connection = (
|
|
243
|
+
const connection = (_h = (_g = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _g === void 0 ? void 0 : _g.query) === null || _h === void 0 ? void 0 : _h.RedHatSupportCase;
|
|
212
244
|
if (!connection) {
|
|
213
245
|
return {
|
|
214
246
|
caseListResponse: { response: { docs: [], numFound: 0, start: 0 } },
|
|
@@ -217,7 +249,7 @@ export function getCaseListFromGraphQL(filterState_1, apolloClient_1, limitOverr
|
|
|
217
249
|
endCursor: undefined,
|
|
218
250
|
};
|
|
219
251
|
}
|
|
220
|
-
if ((
|
|
252
|
+
if ((_j = connection.pageInfo) === null || _j === void 0 ? void 0 : _j.endCursor) {
|
|
221
253
|
storeEndCursor(currentPage, connection.pageInfo.endCursor);
|
|
222
254
|
}
|
|
223
255
|
const docs = mapGraphQLResponseToCaseList(connection.edges || []);
|
|
@@ -230,12 +262,12 @@ export function getCaseListFromGraphQL(filterState_1, apolloClient_1, limitOverr
|
|
|
230
262
|
},
|
|
231
263
|
},
|
|
232
264
|
showErrorMessage: false,
|
|
233
|
-
hasNextPage: (
|
|
234
|
-
endCursor: (
|
|
265
|
+
hasNextPage: (_l = (_k = connection.pageInfo) === null || _k === void 0 ? void 0 : _k.hasNextPage) !== null && _l !== void 0 ? _l : false,
|
|
266
|
+
endCursor: (_o = (_m = connection.pageInfo) === null || _m === void 0 ? void 0 : _m.endCursor) !== null && _o !== void 0 ? _o : undefined,
|
|
235
267
|
};
|
|
236
268
|
}
|
|
237
269
|
catch (error) {
|
|
238
|
-
if ((error === null || error === void 0 ? void 0 : error.name) === 'AbortError' || ((
|
|
270
|
+
if ((error === null || error === void 0 ? void 0 : error.name) === 'AbortError' || ((_p = error === null || error === void 0 ? void 0 : error.message) === null || _p === void 0 ? void 0 : _p.includes('aborted')) || (signal === null || signal === void 0 ? void 0 : signal.aborted)) {
|
|
239
271
|
return {
|
|
240
272
|
caseListResponse: { response: { docs: [], numFound: 0, start: 0 } },
|
|
241
273
|
showErrorMessage: false,
|
|
@@ -259,7 +291,7 @@ export function getCaseListFromGraphQL(filterState_1, apolloClient_1, limitOverr
|
|
|
259
291
|
*/
|
|
260
292
|
export function loadMoreCases(filterState_1, apolloClient_1, afterCursor_1, signal_1) {
|
|
261
293
|
return __awaiter(this, arguments, void 0, function* (filterState, apolloClient, afterCursor, signal, includeSecureSupportCases = false, accountScope) {
|
|
262
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
294
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
263
295
|
try {
|
|
264
296
|
yield resolveVersionProductIds(filterState, apolloClient);
|
|
265
297
|
// Pre-resolve Assigned To owner IDs — users and groups (see resolveOwnerIds / caseListVariablesBuilder comments).
|
|
@@ -276,25 +308,47 @@ export function loadMoreCases(filterState_1, apolloClient_1, afterCursor_1, sign
|
|
|
276
308
|
}
|
|
277
309
|
caseQueryVariables.first = 20;
|
|
278
310
|
caseQueryVariables.after = afterCursor;
|
|
311
|
+
const sortColumn = (_a = filterState.sortInfo) === null || _a === void 0 ? void 0 : _a.column;
|
|
312
|
+
if (isDisplayLabelColumnSort(sortColumn)) {
|
|
313
|
+
const page = yield fetchCasesInDisplayLabelOrder({
|
|
314
|
+
apolloClient,
|
|
315
|
+
where: caseQueryVariables.where,
|
|
316
|
+
first: caseQueryVariables.first,
|
|
317
|
+
afterCursor,
|
|
318
|
+
column: sortColumn,
|
|
319
|
+
direction: (_b = filterState.sortInfo) === null || _b === void 0 ? void 0 : _b.direction,
|
|
320
|
+
types: (_c = filterState.filterInfo) === null || _c === void 0 ? void 0 : _c[SolrKeys.type],
|
|
321
|
+
statuses: (_d = filterState.filterInfo) === null || _d === void 0 ? void 0 : _d[SolrKeys.status],
|
|
322
|
+
signal,
|
|
323
|
+
fetchPolicy: 'no-cache',
|
|
324
|
+
queryDeduplication: false,
|
|
325
|
+
includeTotalCount: false,
|
|
326
|
+
});
|
|
327
|
+
return {
|
|
328
|
+
docs: mapGraphQLResponseToCaseList(page.edges || []),
|
|
329
|
+
hasNextPage: page.hasNextPage,
|
|
330
|
+
endCursor: page.endCursor,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
279
333
|
const { data } = yield apolloClient.query({
|
|
280
334
|
query: GET_CASES_BY_FILTERS,
|
|
281
335
|
variables: caseQueryVariables,
|
|
282
336
|
fetchPolicy: 'no-cache',
|
|
283
337
|
context: Object.assign({ queryDeduplication: false }, (signal ? { fetchOptions: { signal } } : undefined)),
|
|
284
338
|
});
|
|
285
|
-
const connection = (
|
|
339
|
+
const connection = (_f = (_e = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _e === void 0 ? void 0 : _e.query) === null || _f === void 0 ? void 0 : _f.RedHatSupportCase;
|
|
286
340
|
if (!connection) {
|
|
287
341
|
return { docs: [], hasNextPage: false, endCursor: undefined };
|
|
288
342
|
}
|
|
289
343
|
const docs = mapGraphQLResponseToCaseList(connection.edges || []);
|
|
290
344
|
return {
|
|
291
345
|
docs,
|
|
292
|
-
hasNextPage: (
|
|
293
|
-
endCursor: (
|
|
346
|
+
hasNextPage: (_h = (_g = connection.pageInfo) === null || _g === void 0 ? void 0 : _g.hasNextPage) !== null && _h !== void 0 ? _h : false,
|
|
347
|
+
endCursor: (_k = (_j = connection.pageInfo) === null || _j === void 0 ? void 0 : _j.endCursor) !== null && _k !== void 0 ? _k : undefined,
|
|
294
348
|
};
|
|
295
349
|
}
|
|
296
350
|
catch (error) {
|
|
297
|
-
if ((error === null || error === void 0 ? void 0 : error.name) === 'AbortError' || ((
|
|
351
|
+
if ((error === null || error === void 0 ? void 0 : error.name) === 'AbortError' || ((_l = error === null || error === void 0 ? void 0 : error.message) === null || _l === void 0 ? void 0 : _l.includes('aborted')) || (signal === null || signal === void 0 ? void 0 : signal.aborted)) {
|
|
298
352
|
throw error;
|
|
299
353
|
}
|
|
300
354
|
console.error('[GraphQL] loadMoreCases error:', error);
|
|
@@ -14,7 +14,7 @@ export interface ICaseListAccountScope {
|
|
|
14
14
|
isInternal?: boolean;
|
|
15
15
|
/** Salesforce Account Id — used for external users (and when an account filter resolves to Ids). */
|
|
16
16
|
salesforceAccountId?: string;
|
|
17
|
-
/** Account number — used for internal users when no account filter and no keyword search is applied. */
|
|
17
|
+
/** Account number — used for internal users when no account filter and no keyword/username search is applied. */
|
|
18
18
|
accountNumber?: string;
|
|
19
19
|
}
|
|
20
20
|
export interface IResolvedUserIds {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caseListVariablesBuilder.d.ts","sourceRoot":"","sources":["../../../src/utils/caseListVariablesBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAenD,OAAO,EAEH,oBAAoB,EAEvB,MAAM,+CAA+C,CAAC;AAMvD,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAM1F;AAED,MAAM,WAAW,yBAAyB;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,yGAAyG;IACzG,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,iEAAiE;AACjE,MAAM,WAAW,qBAAqB;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oGAAoG;IACpG,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,
|
|
1
|
+
{"version":3,"file":"caseListVariablesBuilder.d.ts","sourceRoot":"","sources":["../../../src/utils/caseListVariablesBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAenD,OAAO,EAEH,oBAAoB,EAEvB,MAAM,+CAA+C,CAAC;AAMvD,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAM1F;AAED,MAAM,WAAW,yBAAyB;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,yGAAyG;IACzG,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,iEAAiE;AACjE,MAAM,WAAW,qBAAqB;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oGAAoG;IACpG,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iHAAiH;IACjH,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC7B,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAqfD,wBAAsB,qCAAqC,CACvD,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,YAAY,EAC1B,eAAe,CAAC,EAAE,gBAAgB,EAClC,yBAAyB,UAAQ,EACjC,YAAY,CAAC,EAAE,qBAAqB,GACrC,OAAO,CAAC,yBAAyB,CAAC,CA6JpC"}
|
|
@@ -27,6 +27,9 @@ function buildOrderByFromSortInfo(sortInfo) {
|
|
|
27
27
|
if (sortInfo.column === CaseListColumnIds.group) {
|
|
28
28
|
return { Group__r: { Name: { order } } };
|
|
29
29
|
}
|
|
30
|
+
if (sortInfo.column === CaseListColumnIds.owner) {
|
|
31
|
+
return { RedHatSupportContact: { Name: { order } } };
|
|
32
|
+
}
|
|
30
33
|
const gqlField = caseListSortColumnIdsToGraphQLMap[sortInfo.column];
|
|
31
34
|
if (!gqlField)
|
|
32
35
|
return { LastModifiedDate: { order: 'DESC' } };
|
|
@@ -301,6 +304,17 @@ function getSearchKeyword(queryString) {
|
|
|
301
304
|
var _a;
|
|
302
305
|
return (_a = queryString === null || queryString === void 0 ? void 0 : queryString.replace(/\*$/g, '').trim()) !== null && _a !== void 0 ? _a : '';
|
|
303
306
|
}
|
|
307
|
+
function hasNonEmptyFilterValues(values) {
|
|
308
|
+
return Boolean(values === null || values === void 0 ? void 0 : values.some((value) => Boolean(value)));
|
|
309
|
+
}
|
|
310
|
+
/** Username filters search across accounts; default logged-in account scope would hide those cases. */
|
|
311
|
+
function hasUsernameFilter(filterInfo) {
|
|
312
|
+
if (!filterInfo)
|
|
313
|
+
return false;
|
|
314
|
+
return (hasNonEmptyFilterValues(filterInfo[SolrKeys.createdBySsoUsername]) ||
|
|
315
|
+
hasNonEmptyFilterValues(filterInfo[SolrKeys.caseContactSSO]) ||
|
|
316
|
+
hasNonEmptyFilterValues(filterInfo[SolrKeys.caseOwner]));
|
|
317
|
+
}
|
|
304
318
|
function buildKeywordSearchFilter(queryString) {
|
|
305
319
|
const keyword = getSearchKeyword(queryString);
|
|
306
320
|
if (!keyword)
|
|
@@ -453,13 +467,13 @@ export function createGraphQLVariablesFromFilterState(filterState_1, apolloClien
|
|
|
453
467
|
// Account scoping:
|
|
454
468
|
// - Account filter applied → AccountId(s) from selected accounts (both user types)
|
|
455
469
|
// - Filter cleared / default:
|
|
456
|
-
// - internal + keyword search → no account scope (search across accounts)
|
|
457
|
-
// - internal, no keyword → Account_Number__c (logged-in account number)
|
|
458
|
-
// - external → AccountId (logged-in salesforceAccountId), with or without keyword search
|
|
470
|
+
// - internal + keyword or username search → no account scope (search across accounts)
|
|
471
|
+
// - internal, no keyword/username → Account_Number__c (logged-in account number)
|
|
472
|
+
// - external → AccountId (logged-in salesforceAccountId), with or without keyword/username search
|
|
459
473
|
const filteredAccountNumbers = ((_a = filterInfo === null || filterInfo === void 0 ? void 0 : filterInfo[SolrKeys.accountNumber]) === null || _a === void 0 ? void 0 : _a.length)
|
|
460
474
|
? flattenAccountNumbers(filterInfo[SolrKeys.accountNumber])
|
|
461
475
|
: [];
|
|
462
|
-
const
|
|
476
|
+
const omitInternalDefaultAccountScope = Boolean(getSearchKeyword(filterQueryInfo === null || filterQueryInfo === void 0 ? void 0 : filterQueryInfo.queryString)) || hasUsernameFilter(filterInfo);
|
|
463
477
|
if (filteredAccountNumbers.length) {
|
|
464
478
|
const accountIds = yield resolveAccountIdsByAccountNumbers(filteredAccountNumbers, apolloClient);
|
|
465
479
|
if (!accountIds.length) {
|
|
@@ -470,7 +484,7 @@ export function createGraphQLVariablesFromFilterState(filterState_1, apolloClien
|
|
|
470
484
|
andConditions.push(accountIdFilter);
|
|
471
485
|
}
|
|
472
486
|
else if (accountScope === null || accountScope === void 0 ? void 0 : accountScope.isInternal) {
|
|
473
|
-
if (accountScope.accountNumber && !
|
|
487
|
+
if (accountScope.accountNumber && !omitInternalDefaultAccountScope) {
|
|
474
488
|
andConditions.push({ Account_Number__c: { eq: accountScope.accountNumber } });
|
|
475
489
|
}
|
|
476
490
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ApolloClient } from '@apollo/client';
|
|
2
|
+
import { type IGqlCaseConnection } from '@rh-support/utils';
|
|
3
|
+
type CaseEdge = IGqlCaseConnection['edges'][number];
|
|
4
|
+
export type DisplaySortBucket = {
|
|
5
|
+
where: Record<string, unknown>;
|
|
6
|
+
orderBy: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
export declare function isDisplayLabelColumnSort(column?: string): column is string;
|
|
9
|
+
export declare function buildDisplayLabelSortBuckets(column: string, direction: string | undefined, filters?: {
|
|
10
|
+
types?: string[];
|
|
11
|
+
statuses?: string[];
|
|
12
|
+
}): DisplaySortBucket[];
|
|
13
|
+
export declare function fetchCasesInDisplayLabelOrder(options: {
|
|
14
|
+
apolloClient: ApolloClient;
|
|
15
|
+
where?: Record<string, unknown>;
|
|
16
|
+
first: number;
|
|
17
|
+
afterCursor?: string;
|
|
18
|
+
column: string;
|
|
19
|
+
direction?: string;
|
|
20
|
+
types?: string[];
|
|
21
|
+
statuses?: string[];
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
fetchPolicy: 'network-only' | 'no-cache';
|
|
24
|
+
queryDeduplication?: boolean;
|
|
25
|
+
includeTotalCount: boolean;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
edges: CaseEdge[];
|
|
28
|
+
hasNextPage: boolean;
|
|
29
|
+
endCursor?: string;
|
|
30
|
+
totalCount: number;
|
|
31
|
+
}>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=displayLabelSort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"displayLabelSort.d.ts","sourceRoot":"","sources":["../../../src/utils/displayLabelSort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAEH,KAAK,kBAAkB,EAM1B,MAAM,mBAAmB,CAAC;AAI3B,KAAK,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAMpD,MAAM,MAAM,iBAAiB,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAQF,wBAAgB,wBAAwB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,IAAI,MAAM,CAE1E;AA0ED,wBAAgB,4BAA4B,CACxC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GACpD,iBAAiB,EAAE,CASrB;AA8DD,wBAAsB,6BAA6B,CAAC,OAAO,EAAE;IACzD,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,cAAc,GAAG,UAAU,CAAC;IACzC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,OAAO,CAAC;CAC9B,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAuF/F"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { GET_CASES_BY_FILTERS, mapSfdcStatusToPortalStatus, PORTAL_STATUS_GROUPS, PreviousCaseTypes, toNewCaseTypeSwitcher, } from '@rh-support/utils';
|
|
11
|
+
import { CaseListColumnIds } from '../enums/case';
|
|
12
|
+
const CURSOR_PREFIX = 'pcm-display-sort:';
|
|
13
|
+
export function isDisplayLabelColumnSort(column) {
|
|
14
|
+
return column === CaseListColumnIds.type || column === CaseListColumnIds.status;
|
|
15
|
+
}
|
|
16
|
+
function normalizeDirection(direction) {
|
|
17
|
+
return (direction === null || direction === void 0 ? void 0 : direction.toLowerCase()) === 'asc' ? 'asc' : 'desc';
|
|
18
|
+
}
|
|
19
|
+
function compareLabels(left, right) {
|
|
20
|
+
return left.localeCompare(right, undefined, { sensitivity: 'base' });
|
|
21
|
+
}
|
|
22
|
+
function sortByLabel(items, labelOf, direction) {
|
|
23
|
+
const sorted = [...items].sort((left, right) => compareLabels(labelOf(left), labelOf(right)));
|
|
24
|
+
return direction === 'desc' ? sorted.reverse() : sorted;
|
|
25
|
+
}
|
|
26
|
+
function supportTypeBuckets(direction, selectedTypes) {
|
|
27
|
+
const knownTypes = Object.values(PreviousCaseTypes);
|
|
28
|
+
const pool = (selectedTypes === null || selectedTypes === void 0 ? void 0 : selectedTypes.length) ? [...new Set(selectedTypes.filter(Boolean))] : [...knownTypes];
|
|
29
|
+
const ordered = sortByLabel(pool, (type) => toNewCaseTypeSwitcher(type), direction);
|
|
30
|
+
const buckets = ordered.map((type) => ({
|
|
31
|
+
where: { Type: { eq: type } },
|
|
32
|
+
orderBy: { LastModifiedDate: { order: 'DESC' } },
|
|
33
|
+
}));
|
|
34
|
+
if (!(selectedTypes === null || selectedTypes === void 0 ? void 0 : selectedTypes.length)) {
|
|
35
|
+
buckets.push({
|
|
36
|
+
where: { Type: { nin: knownTypes } },
|
|
37
|
+
orderBy: { Type: { order: direction === 'asc' ? 'ASC' : 'DESC' } },
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return buckets;
|
|
41
|
+
}
|
|
42
|
+
function statusValuesForLabel(status) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (PORTAL_STATUS_GROUPS[status]) {
|
|
45
|
+
return { label: status, values: PORTAL_STATUS_GROUPS[status] };
|
|
46
|
+
}
|
|
47
|
+
const label = mapSfdcStatusToPortalStatus(status);
|
|
48
|
+
return { label, values: (_a = PORTAL_STATUS_GROUPS[label]) !== null && _a !== void 0 ? _a : [status] };
|
|
49
|
+
}
|
|
50
|
+
function statusBuckets(direction, selectedStatuses) {
|
|
51
|
+
const groups = new Map();
|
|
52
|
+
if (selectedStatuses === null || selectedStatuses === void 0 ? void 0 : selectedStatuses.length) {
|
|
53
|
+
selectedStatuses.filter(Boolean).forEach((status) => {
|
|
54
|
+
const group = statusValuesForLabel(status);
|
|
55
|
+
groups.set(group.label, group.values);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
Object.entries(PORTAL_STATUS_GROUPS).forEach(([label, values]) => {
|
|
60
|
+
groups.set(label, values);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const ordered = sortByLabel([...groups.entries()], ([label]) => label, direction);
|
|
64
|
+
const buckets = ordered.map(([, values]) => ({
|
|
65
|
+
where: { Status: { in: values } },
|
|
66
|
+
orderBy: { LastModifiedDate: { order: 'DESC' } },
|
|
67
|
+
}));
|
|
68
|
+
if (!(selectedStatuses === null || selectedStatuses === void 0 ? void 0 : selectedStatuses.length)) {
|
|
69
|
+
const knownStatuses = [...new Set(Object.values(PORTAL_STATUS_GROUPS).flat())];
|
|
70
|
+
buckets.push({
|
|
71
|
+
where: { Status: { nin: knownStatuses } },
|
|
72
|
+
orderBy: { Status: { order: direction === 'asc' ? 'ASC' : 'DESC' } },
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return buckets;
|
|
76
|
+
}
|
|
77
|
+
export function buildDisplayLabelSortBuckets(column, direction, filters) {
|
|
78
|
+
const normalizedDirection = normalizeDirection(direction);
|
|
79
|
+
if (column === CaseListColumnIds.type) {
|
|
80
|
+
return supportTypeBuckets(normalizedDirection, filters === null || filters === void 0 ? void 0 : filters.types);
|
|
81
|
+
}
|
|
82
|
+
if (column === CaseListColumnIds.status) {
|
|
83
|
+
return statusBuckets(normalizedDirection, filters === null || filters === void 0 ? void 0 : filters.statuses);
|
|
84
|
+
}
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
function withBucketWhere(baseWhere, bucketWhere) {
|
|
88
|
+
if (!baseWhere)
|
|
89
|
+
return bucketWhere;
|
|
90
|
+
if (Array.isArray(baseWhere.and)) {
|
|
91
|
+
return Object.assign(Object.assign({}, baseWhere), { and: [...baseWhere.and, bucketWhere] });
|
|
92
|
+
}
|
|
93
|
+
return { and: [baseWhere, bucketWhere] };
|
|
94
|
+
}
|
|
95
|
+
function encodeCursor(state) {
|
|
96
|
+
return CURSOR_PREFIX + btoa(JSON.stringify(state));
|
|
97
|
+
}
|
|
98
|
+
function decodeCursor(cursor, column) {
|
|
99
|
+
if (!(cursor === null || cursor === void 0 ? void 0 : cursor.startsWith(CURSOR_PREFIX))) {
|
|
100
|
+
return { bucketIndex: 0 };
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const parsed = JSON.parse(atob(cursor.slice(CURSOR_PREFIX.length)));
|
|
104
|
+
if (parsed.column !== column || typeof parsed.bucketIndex !== 'number' || parsed.bucketIndex < 0) {
|
|
105
|
+
return { bucketIndex: 0 };
|
|
106
|
+
}
|
|
107
|
+
return { bucketIndex: parsed.bucketIndex, after: parsed.after || undefined };
|
|
108
|
+
}
|
|
109
|
+
catch (_a) {
|
|
110
|
+
return { bucketIndex: 0 };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function queryCaseConnection(apolloClient, variables, fetchPolicy, signal, queryDeduplication) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
const context = {};
|
|
117
|
+
if (queryDeduplication === false) {
|
|
118
|
+
context.queryDeduplication = false;
|
|
119
|
+
}
|
|
120
|
+
if (signal) {
|
|
121
|
+
context.fetchOptions = { signal };
|
|
122
|
+
}
|
|
123
|
+
const { data } = yield apolloClient.query({
|
|
124
|
+
query: GET_CASES_BY_FILTERS,
|
|
125
|
+
variables,
|
|
126
|
+
fetchPolicy,
|
|
127
|
+
context: Object.keys(context).length ? context : undefined,
|
|
128
|
+
});
|
|
129
|
+
const connection = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportCase;
|
|
130
|
+
if (!connection) {
|
|
131
|
+
throw new Error('Case list display sort query returned no data');
|
|
132
|
+
}
|
|
133
|
+
return connection;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
export function fetchCasesInDisplayLabelOrder(options) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
var _a, _b, _c, _d;
|
|
139
|
+
const buckets = buildDisplayLabelSortBuckets(options.column, options.direction, {
|
|
140
|
+
types: options.types,
|
|
141
|
+
statuses: options.statuses,
|
|
142
|
+
});
|
|
143
|
+
const cursor = decodeCursor(options.afterCursor, options.column);
|
|
144
|
+
let bucketIndex = cursor.bucketIndex;
|
|
145
|
+
let after = cursor.after;
|
|
146
|
+
const collected = [];
|
|
147
|
+
const pageSize = options.first;
|
|
148
|
+
const countPromise = options.includeTotalCount
|
|
149
|
+
? queryCaseConnection(options.apolloClient, {
|
|
150
|
+
where: options.where,
|
|
151
|
+
first: 1,
|
|
152
|
+
orderBy: { LastModifiedDate: { order: 'DESC' } },
|
|
153
|
+
}, options.fetchPolicy, options.signal, options.queryDeduplication).then((connection) => connection.totalCount || 0)
|
|
154
|
+
: Promise.resolve(0);
|
|
155
|
+
try {
|
|
156
|
+
while (collected.length < pageSize && bucketIndex < buckets.length) {
|
|
157
|
+
const bucket = buckets[bucketIndex];
|
|
158
|
+
const connection = yield queryCaseConnection(options.apolloClient, Object.assign({ where: withBucketWhere(options.where, bucket.where), first: pageSize - collected.length, orderBy: bucket.orderBy }, (after ? { after } : {})), options.fetchPolicy, options.signal, options.queryDeduplication);
|
|
159
|
+
const edges = connection.edges || [];
|
|
160
|
+
if (!edges.length) {
|
|
161
|
+
bucketIndex += 1;
|
|
162
|
+
after = undefined;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const room = pageSize - collected.length;
|
|
166
|
+
const pageEdges = edges.slice(0, room);
|
|
167
|
+
collected.push(...pageEdges);
|
|
168
|
+
const consumedEntireResponse = pageEdges.length === edges.length;
|
|
169
|
+
if (!consumedEntireResponse || ((_a = connection.pageInfo) === null || _a === void 0 ? void 0 : _a.hasNextPage)) {
|
|
170
|
+
const resumeAfter = consumedEntireResponse
|
|
171
|
+
? (_b = connection.pageInfo) === null || _b === void 0 ? void 0 : _b.endCursor
|
|
172
|
+
: ((_c = pageEdges[pageEdges.length - 1]) === null || _c === void 0 ? void 0 : _c.cursor) || ((_d = connection.pageInfo) === null || _d === void 0 ? void 0 : _d.endCursor);
|
|
173
|
+
if (resumeAfter) {
|
|
174
|
+
const totalCount = yield countPromise;
|
|
175
|
+
return {
|
|
176
|
+
edges: collected,
|
|
177
|
+
hasNextPage: true,
|
|
178
|
+
endCursor: encodeCursor({
|
|
179
|
+
column: options.column,
|
|
180
|
+
bucketIndex,
|
|
181
|
+
after: resumeAfter,
|
|
182
|
+
}),
|
|
183
|
+
totalCount,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
bucketIndex += 1;
|
|
188
|
+
after = undefined;
|
|
189
|
+
}
|
|
190
|
+
const hasNextPage = bucketIndex < buckets.length;
|
|
191
|
+
const totalCount = yield countPromise;
|
|
192
|
+
return {
|
|
193
|
+
edges: collected,
|
|
194
|
+
hasNextPage,
|
|
195
|
+
endCursor: hasNextPage ? encodeCursor({ column: options.column, bucketIndex }) : undefined,
|
|
196
|
+
totalCount,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
yield countPromise.catch(() => undefined);
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/cases",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.37",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@patternfly/patternfly": "6.2.1",
|
|
39
39
|
"@patternfly/react-core": "6.2.1",
|
|
40
40
|
"@patternfly/react-table": "6.2.1",
|
|
41
|
-
"@rh-support/components": "2.6.
|
|
42
|
-
"@rh-support/react-context": "2.6.
|
|
41
|
+
"@rh-support/components": "2.6.33",
|
|
42
|
+
"@rh-support/react-context": "2.6.35",
|
|
43
43
|
"@rh-support/types": "2.0.31",
|
|
44
|
-
"@rh-support/user-permissions": "2.6.
|
|
45
|
-
"@rh-support/utils": "2.6.
|
|
44
|
+
"@rh-support/user-permissions": "2.6.30",
|
|
45
|
+
"@rh-support/utils": "2.6.29",
|
|
46
46
|
"localforage": "^1.10.0",
|
|
47
47
|
"lodash": "^4.17.21",
|
|
48
48
|
"pegjs": "^0.10.0",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"defaults and supports es6-module",
|
|
95
95
|
"maintained node versions"
|
|
96
96
|
],
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "f99f57bcf4460ad269285c718193ecadca625389"
|
|
98
98
|
}
|