Skip to content

Commit

Permalink
chore(isct-63): add attribution to table, table row, search, modal
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyKIron committed Oct 16, 2023
1 parent 68c9844 commit e217068
Show file tree
Hide file tree
Showing 22 changed files with 131 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {TestIdsService} from '@ironsource/fusion-ui/services/test-ids';

@Directive()
export abstract class ChipFilterBaseComponent implements OnInit, AfterViewInit, OnDestroy, AfterContentInit {
/** @internal */
@Input() testId: string;
/** @internal */
@ContentChild(ApiBase, {static: true}) apiBase: ApiBase;
Expand All @@ -52,7 +53,9 @@ export abstract class ChipFilterBaseComponent implements OnInit, AfterViewInit,
/** @internal */
rightIcon: ChipIcon;

/** @internal */
testIdChipFilterModifiers: typeof ChipFilterTestIdModifiers = ChipFilterTestIdModifiers;
/** @internal */
testIdsService: TestIdsService = this.injector.get(TestIdsService);

private onDestroy$ = new Subject<void>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export abstract class DropdownDualMultiSelectBaseComponent extends ApiBase imple
/** @internal */
@Input() autoComplete: boolean = true;
@Input() title: string;
/** @internal */
@Input() testId: string;
/** @internal */
@Input() pendingItems: boolean = false;
Expand All @@ -59,7 +60,9 @@ export abstract class DropdownDualMultiSelectBaseComponent extends ApiBase imple
return this._hasSelectAll;
}

/** @internal */
testIdIncludeExcludeModifiers: typeof IncludeExcludeTestIdModifiers = IncludeExcludeTestIdModifiers;
/** @internal */
testIdsService: TestIdsService = this.injector.get(TestIdsService);

@Input() set placeholder(data: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class DropdownDualMultiSelectBodyComponent implements OnInit, OnDestroy,
@Input() totalItems: number;
@Input() isPendingItems: boolean;
@Input() hasSelectAll: boolean = true;
/** @internal */
@Input() testId: string;

@Input() set items(data: DropdownOption[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {ChangeDetectionStrategy, Component, EventEmitter, Input, Output} from '@
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DropdownDualMultiSelectFooterComponent {
/** @internal */
@Input() testId: string;
@Output() applySelect = new EventEmitter<boolean>();
@Output() closeSelect = new EventEmitter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {Subject} from 'rxjs';
})
export class DropdownDualMultiSelectHeaderComponent implements OnDestroy, ControlValueAccessor {
@Input() title: string;
/** @internal */
@Input() testId: string;

inputSize = InputSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ export class DropdownDualMultiSelectBodyItemComponent {
@Input() item: DropdownOption;
@Input() isDisabled: boolean;
@Input() isSelectedItem: boolean;
/** @internal */
@Input() testId: string;

@Output() changeSelected = new EventEmitter();
@Output() clearSelect = new EventEmitter();

/** @internal */
testIdIncludeExcludeModifiers: typeof IncludeExcludeTestIdModifiers = IncludeExcludeTestIdModifiers;
/** @internal */
testIdsService: TestIdsService = this.injector.get(TestIdsService);

constructor(private injector: Injector) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class DropdownDualMultiSelectBodyComponent implements OnInit, OnDestroy,
@Input() totalItems: number;
@Input() isPendingItems: boolean;
@Input() hasSelectAll: boolean = true;
/** @internal */
@Input() testId: string;

@Input() set items(data: DropdownOption[]) {
Expand All @@ -75,7 +76,9 @@ export class DropdownDualMultiSelectBodyComponent implements OnInit, OnDestroy,

@Output() scrollDown = new EventEmitter();

/** @internal */
testIdIncludeExcludeModifiers: typeof IncludeExcludeTestIdModifiers = IncludeExcludeTestIdModifiers;
/** @internal */
testIdsService: TestIdsService = this.injector.get(TestIdsService);

isSelectAllDisabled$ = new BehaviorSubject<boolean>(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import {TestIdsService} from '@ironsource/fusion-ui/services/test-ids';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DropdownDualMultiSelectFooterComponent {
/** @internal */
@Input() testId: string;
@Output() applySelect = new EventEmitter<boolean>();
@Output() closeSelect = new EventEmitter();

/** @internal */
testIdIncludeExcludeModifiers: typeof IncludeExcludeTestIdModifiers = IncludeExcludeTestIdModifiers;
/** @internal */
testIdsService: TestIdsService = this.injector.get(TestIdsService);

constructor(private injector: Injector) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ export class DropdownDualMultiSelectHeaderComponent implements OnDestroy, AfterV
@ViewChild('input') input?: ElementRef;

@Input() title: string;
/** @internal */
@Input() testId: string;

/** @internal */
testIdIncludeExcludeModifiers: typeof IncludeExcludeTestIdModifiers = IncludeExcludeTestIdModifiers;
/** @internal */
testIdsService: TestIdsService = this.injector.get(TestIdsService);

searchIcon?: IconData = {iconName: 'search-bold', iconVersion: 'v3'};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Component, EventEmitter, Injector, Input, Output} from '@angular/core';
import {ModalTestIdModifiers, TestIdsService} from '@ironsource/fusion-ui';
import {ModalTestIdModifiers} from '@ironsource/fusion-ui/entities';
import {TestIdsService} from '@ironsource/fusion-ui/services/test-ids';

@Component({
selector: 'fusion-modal-footer',
Expand All @@ -19,6 +20,7 @@ export class ModalFooterComponent {
this.submitButtonDisabled = config?.submitButtonDisabled;
}
@Input() error;
/** @internal */
@Input() testId: string;

@Output() onSubmit = new EventEmitter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, EventEmitter, Injector, Input, Output} from '@angular/core';
import {BehaviorSubject} from 'rxjs';
import {ModalTestIdModifiers, TestIdsService} from '@ironsource/fusion-ui';
import {ModalTestIdModifiers} from '@ironsource/fusion-ui/entities';
import {TestIdsService} from '@ironsource/fusion-ui/services/test-ids';

@Component({
selector: 'fusion-modal-header',
Expand All @@ -10,6 +10,7 @@ import {ModalTestIdModifiers, TestIdsService} from '@ironsource/fusion-ui';
export class ModalHeaderComponent {
@Input() headerText: string;
@Input() showCloseButton = true;
/** @internal */
@Input() testId: string;

private _infoText: string;
Expand Down
4 changes: 3 additions & 1 deletion projects/fusion-ui/components/modal/v3/modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ModalComponent implements OnDestroy, OnInit {
get configuration(): ModalConfiguration {
return this._configuration.getValue();
}

/** @internal */
@Input() testId: string;

@Output() open = new EventEmitter();
Expand All @@ -69,7 +69,9 @@ export class ModalComponent implements OnDestroy, OnInit {
/** @internal */
@ViewChild('modalHolder', {static: true}) modalHolder: ElementRef;

/** @internal */
modalTestIdModifiers: typeof ModalTestIdModifiers = ModalTestIdModifiers;
/** @internal */
testIdsService: TestIdsService = this.injector.get(TestIdsService);

private uid: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
[placeholder]="placeholder"
[formControl]="searchFormControl"
[class.fu-has-clear-icon]="showClearIcon"
[attr.data-testid]="testIdsService.getTestAttribute.bind(this) | generic:testId:searchTestIdModifiers.INPUT"
/>
<fusion-icon class="fu-clear" *ngIf="showClearIcon && (searchFormControl.valueChanges | async)" [name]="clearIcon" (click)="clearInput(true)"></fusion-icon>
<fusion-icon class="fu-clear"
*ngIf="showClearIcon && (searchFormControl.valueChanges | async)"
[name]="clearIcon"
[attr.data-testid]="testIdsService.getTestAttribute.bind(this) | generic:testId:searchTestIdModifiers.CLEAR_BUTTON"
(click)="clearInput(true)"
></fusion-icon>
17 changes: 15 additions & 2 deletions projects/fusion-ui/components/search/v3/search.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import {ChangeDetectionStrategy, Component, ElementRef, forwardRef, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {ChangeDetectionStrategy, Component, ElementRef, forwardRef, Injector, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormControl, FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule} from '@angular/forms';
import {Subject} from 'rxjs';
import {takeUntil} from 'rxjs/operators';
import {isNullOrUndefined} from '@ironsource/fusion-ui/utils';
import {IconData, IconModule} from '@ironsource/fusion-ui/components/icon/v1';
import {GenericPipe} from '@ironsource/fusion-ui/pipes/generic';
import {SearchTestIdModifiers} from '@ironsource/fusion-ui/entities';
import {TestIdsService} from '@ironsource/fusion-ui/services/test-ids';

@Component({
selector: 'fusion-search',
templateUrl: './search.component.html',
styleUrls: ['./search.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [CommonModule, FormsModule, ReactiveFormsModule, IconModule],
imports: [CommonModule, FormsModule, ReactiveFormsModule, IconModule, GenericPipe],
providers: [
{
provide: NG_VALUE_ACCESSOR,
Expand Down Expand Up @@ -45,6 +48,9 @@ export class SearchComponent implements OnInit, OnDestroy {
return this._showClearIcon;
}

/** @internal */
@Input() testId: string;

/** @internal */
searchFormControl = new FormControl();
/** @internal */
Expand All @@ -54,6 +60,13 @@ export class SearchComponent implements OnInit, OnDestroy {
/** @internal */
clearIcon: IconData = {iconName: 'cancel', iconVersion: 'v3'};

/** @internal */
searchTestIdModifiers: typeof SearchTestIdModifiers = SearchTestIdModifiers;
/** @internal */
testIdsService: TestIdsService = this.injector.get(TestIdsService);

constructor(private injector: Injector) {}

ngOnInit() {
this.searchFormControl.valueChanges.pipe(takeUntil(this.onDestroy$)).subscribe(value => {
this.propagateTouched();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[isExpanded]="isExpanded(rowIndex)"
[isInnerRow]="false"
[class.is-row-in-request]="tableService.rowsMetadata[row['_rowId']]?.inRequest"
[testId]="testId"
(rowRemoved)="tableService.removeRow({rows: rows, rowIndex: rowIndex, row: row, options: options})"
(selectedChange)="tableService.onRowSelectChanged($event, row)"
(expandRow)="onExpandRow($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Component,
ElementRef,
EventEmitter,
Injector,
Input,
OnDestroy,
OnInit,
Expand All @@ -21,6 +22,8 @@ import {
import {TableService} from '@ironsource/fusion-ui/components/table/common/services';
import {fromEvent, Subject, from} from 'rxjs';
import {filter, mergeMap, takeUntil} from 'rxjs/operators';
import {TableTestIdModifiers} from '@ironsource/fusion-ui/entities';
import {TestIdsService} from '@ironsource/fusion-ui/services/test-ids';

@Component({
// eslint-disable-next-line
Expand All @@ -44,6 +47,9 @@ export class TableBasicComponent implements OnInit, OnDestroy, AfterViewInit {
this._halfTableClientWidth = value ? value / 2 : 0;
}

/** @internal */
@Input() testId: string;

@Output() rowSelected = new EventEmitter();
@Output() expandRow = new EventEmitter<TableRowExpandEmitter>();

Expand Down Expand Up @@ -71,6 +77,11 @@ export class TableBasicComponent implements OnInit, OnDestroy, AfterViewInit {
rowClass = this.getRowClass.bind(this);
rowRowspanIndexes = this.getRowspanIndexes.bind(this);

/** @internal */
tableTestIdModifiers: typeof TableTestIdModifiers = TableTestIdModifiers;
/** @internal */
testIdsService: TestIdsService = this.injector.get(TestIdsService);

private _halfTableClientWidth = 0;
private tableOptions;
private onDestroy$ = new Subject();
Expand All @@ -79,7 +90,8 @@ export class TableBasicComponent implements OnInit, OnDestroy, AfterViewInit {
public tableService: TableService,
private cdr: ChangeDetectorRef,
private elementRef: ElementRef,
private renderer: Renderer2
private renderer: Renderer2,
private injector: Injector
) {}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<ng-container *ngFor="let expandCell of expandCellCount | async; let isLast = last">
<ng-container *ngFor="let expandCell of expandCellCount | async; let isLast = last; let idx=index">
<td *ngIf="cellShown | generic:'cell-expand'"
class="expand-cell"
[class.total-row]="isRowTotal"
[class.expanded]="isExpanded"
[class.inner-row]="isInnerRow"
[class.sticky-left]="options?.rowsExpandableOptions?.sticky"
[attr.rowspan]="attrRowspan | generic:'cell-expand'"
[attr.data-testid]="testIdsService.getTestAttribute.bind(this) | generic:testId:(tableTestIdModifiers.CELL+'-r'+rowIndex+'-c'+idx)"
>
<fusion-icon
*ngIf="isLast && showExpandIcon()"
Expand All @@ -16,7 +17,7 @@
</fusion-icon>
</td>
</ng-container>
<ng-container *ngFor="let column of columns; trackBy: trackByFn; let columnIndex = index; let isLast = last;">
<ng-container *ngFor="let column of columns; trackBy: trackByFn; let columnIndex = index; let isLast = last; let idx=index">
<td *ngIf="cellShown | generic:column.key"
fusionTableCell
[fusionTooltip]="columnsData[columnIndex]?.tooltip"
Expand All @@ -41,6 +42,7 @@
[style.width]="columnsData[columnIndex]?.width"
[attr.colspan]="columnsData[columnIndex]?.colspan"
[attr.rowspan]="attrRowspan | generic:column.key"
[attr.data-testid]="testIdsService.getTestAttribute.bind(this) | generic:testId:(tableTestIdModifiers.CELL+'-r'+rowIndex+'-c'+idx)"
(remove)="rowRemoved.emit()"
(selectedChange)="selectedChange.emit($event)"
(dataChange)="onDataChange($event, column.key)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Component,
EventEmitter,
HostBinding,
Injector,
Input,
OnChanges,
OnInit,
Expand All @@ -17,6 +18,8 @@ import {Observable, of} from 'rxjs';
import {ColumnData} from './column-data';
import {TableRow} from '@ironsource/fusion-ui/components/table/common/entities';
import {IconData} from '@ironsource/fusion-ui/components/icon/v1';
import {TableTestIdModifiers} from '@ironsource/fusion-ui/entities';
import {TestIdsService} from '@ironsource/fusion-ui/services/test-ids';

@Component({
// eslint-disable-next-line
Expand All @@ -36,6 +39,10 @@ export class TableRowComponent implements OnInit, OnChanges {
@Input() isExpanded: boolean;
@Input() isInnerRow: boolean;
@Input() hasAfterSticky: boolean;

/** @internal */
@Input() testId: string;

@Output() rowRemoved = new EventEmitter();
@Output() selectedChange = new EventEmitter();
@Output() expandRow = new EventEmitter<TableRowExpandEmitter>();
Expand Down Expand Up @@ -69,6 +76,11 @@ export class TableRowComponent implements OnInit, OnChanges {
cellShown = this.showCell.bind(this);
attrRowspan = this.getAttrRowspan.bind(this);

/** @internal */
tableTestIdModifiers: typeof TableTestIdModifiers = TableTestIdModifiers;
/** @internal */
testIdsService: TestIdsService = this.injector.get(TestIdsService);

get expandCellCount(): Observable<number[]> {
if (!!this.options && !!this.options.rowsExpandableOptions && !!this.tableService.expandLevels) {
const expandLevelsByIndex = this.tableService.getExpandLevelByRowIndex(this.rowIndex);
Expand Down Expand Up @@ -100,7 +112,7 @@ export class TableRowComponent implements OnInit, OnChanges {
};
}

constructor(public tableService: TableService, private cdRef: ChangeDetectorRef) {}
constructor(public tableService: TableService, private cdRef: ChangeDetectorRef, private injector: Injector) {}

ngOnInit(): void {
this.dataRowIndex = this.rowIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export default {
args: {
options: TABLE_DEFAULT_OPTIONS,
columns: TABLE_DEFAULT_COLUMNS_CONFIG,
rows: ROWS_DEFAULT_DATA
rows: ROWS_DEFAULT_DATA,
testId: 'test-id'
}
} as Meta<TableComponent>;

Expand All @@ -76,6 +77,7 @@ const TableTemplate: StoryFn<TableComponent> = (args: TableComponent) => ({
[columns]="columns"
[rows]="rows"
[loading]="loading"
[testId]="testId"
></fusion-table>`
});

Expand All @@ -85,6 +87,7 @@ const TableWithHostTemplate: StoryFn<TableComponent> = (args: TableComponent) =>
[options]="options"
[columns]="columns"
[rows]="rows"
[testId]="testId"
></fusion-table-story-holder>`
});

Expand Down
Loading

0 comments on commit e217068

Please sign in to comment.