Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/app/components/stix/stix-list/stix-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ export class RestApiConnectorService extends ApiConnector {
deprecated?: boolean;
deserialize?: boolean;
versions?: 'all' | 'latest';
excludeIDs?: string[];
lastUpdatedBy?: string[];
search?: string;
}) {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();

Expand All @@ -1425,6 +1431,7 @@ describe('ReleaseTrackPageComponent', () => {
stixListConfig: expect.objectContaining({
showUserSearch: true,
excludeAttackTypes: ['relationship', 'note', 'collection'],
excludeIDs: [candidateId],
select: 'many',
}),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,6 @@ export class ReleaseTrackPageComponent implements OnInit {

public onAddCandidate(): void {
if (!this.releaseTrack) return;

const selection = new SelectionModel<string>(true);
const selectedObjectRefs = new Map<
string,
Expand All @@ -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,
Expand Down
Loading