diff --git a/src/app/components/stix/stix-list/stix-list.component.ts b/src/app/components/stix/stix-list/stix-list.component.ts index a0d6ce54..3c468541 100644 --- a/src/app/components/stix/stix-list/stix-list.component.ts +++ b/src/app/components/stix/stix-list/stix-list.component.ts @@ -916,7 +916,7 @@ export class StixListComponent implements OnInit, AfterViewInit, OnDestroy { this.data$ = of({ data: paged, pagination: { - total: this.config.stixObjects.length, + total: filtered.length, offset: startIndex, limit: this.paginator ? this.paginator.pageSize : 0, }, @@ -999,6 +999,7 @@ export class StixListComponent implements OnInit, AfterViewInit, OnDestroy { this.data$ = this.restAPIConnectorService.getAllObjects({ limit, offset, + excludeIDs: this.config.excludeIDs, state: filterStates.state, revoked: filterStates.revoked, deprecated: filterStates.deprecated, diff --git a/src/app/services/connectors/rest-api/rest-api-connector.service.ts b/src/app/services/connectors/rest-api/rest-api-connector.service.ts index c7545f96..476c2dbe 100644 --- a/src/app/services/connectors/rest-api/rest-api-connector.service.ts +++ b/src/app/services/connectors/rest-api/rest-api-connector.service.ts @@ -533,6 +533,7 @@ export class RestApiConnectorService extends ApiConnector { deprecated?: boolean; deserialize?: boolean; versions?: 'all' | 'latest'; + excludeIDs?: string[]; lastUpdatedBy?: string[]; search?: string; }) { @@ -557,6 +558,8 @@ export class RestApiConnectorService extends ApiConnector { options.deprecated ? 'true' : 'false' ); if (options?.versions) query = query.set('versions', options.versions); + if (options?.excludeIDs) + options.excludeIDs.forEach(id => (query = query.append('excludeID', id))); // searching if (options?.search) query = query.set('search', options.search); // lastUpdatedBy diff --git a/src/app/views/dashboard-page/release-management/release-track-page/release-track-page.component.spec.ts b/src/app/views/dashboard-page/release-management/release-track-page/release-track-page.component.spec.ts index 0f958c2e..15f9e0b2 100644 --- a/src/app/views/dashboard-page/release-management/release-track-page/release-track-page.component.spec.ts +++ b/src/app/views/dashboard-page/release-management/release-track-page/release-track-page.component.spec.ts @@ -1403,7 +1403,9 @@ describe('ReleaseTrackPageComponent', () => { ).not.toHaveBeenCalled(); }); - it('should open the all objects table to add candidates', () => { + it('should exclude current candidates from the all objects table', () => { + const candidateId = 'attack-pattern--candidate'; + const stagedId = 'attack-pattern--staged'; mockDialog.open.mockImplementation((_component: any, config: any) => { config.data.select.select('attack-pattern--1234'); return { @@ -1412,7 +1414,11 @@ describe('ReleaseTrackPageComponent', () => { }); mockReleaseTrackApiConnector.addCandidates.mockReturnValue(of({})); component.id = 'release-track--123'; - component.releaseTrack = { id: 'release-track--123' } as any; + component.releaseTrack = { + id: 'release-track--123', + candidates: [{ object_ref: candidateId }], + staged: [{ object_ref: stagedId }], + } as any; component.onAddCandidate(); @@ -1425,6 +1431,7 @@ describe('ReleaseTrackPageComponent', () => { stixListConfig: expect.objectContaining({ showUserSearch: true, excludeAttackTypes: ['relationship', 'note', 'collection'], + excludeIDs: [candidateId], select: 'many', }), }), diff --git a/src/app/views/dashboard-page/release-management/release-track-page/release-track-page.component.ts b/src/app/views/dashboard-page/release-management/release-track-page/release-track-page.component.ts index d94af7ea..06f1351a 100644 --- a/src/app/views/dashboard-page/release-management/release-track-page/release-track-page.component.ts +++ b/src/app/views/dashboard-page/release-management/release-track-page/release-track-page.component.ts @@ -790,7 +790,6 @@ export class ReleaseTrackPageComponent implements OnInit { public onAddCandidate(): void { if (!this.releaseTrack) return; - const selection = new SelectionModel(true); const selectedObjectRefs = new Map< string, @@ -809,6 +808,9 @@ export class ReleaseTrackPageComponent implements OnInit { clearSelection: true, stixListConfig: { ...ALL_OBJECTS_STIX_LIST_CONFIG, + excludeIDs: this.candidates + .map(candidate => candidate.object_ref) + .filter((objectRef): objectRef is string => !!objectRef), select: 'many', selectionModel: selection, selectedObjectRefs,