Skip to content

Commit

Permalink
[MNT-24575] Added return type to function. Consolidated different pro…
Browse files Browse the repository at this point in the history
…perties into a single type
  • Loading branch information
swapnil-verma-gl committed Dec 6, 2024
1 parent 8877fad commit 40d3eee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<div class="aca-folder-info-container">
<div class="aca-folder-info-header">
<div class="aca-folder-icon">
<img alt="{{ 'APP.FOLDER_INFO.ICON' | translate }}" src="{{ icon }}">
<img alt="{{ 'APP.FOLDER_INFO.ICON' | translate }}" src="{{ folderDetails.icon }}">
</div>
<div class="aca-folder-title" data-automation-id="folder-info-name">{{ name }}</div>
<div class="aca-folder-title" data-automation-id="folder-info-name">{{ folderDetails.name }}</div>
</div>
<mat-divider></mat-divider>
<mat-divider/>
<div class="aca-folder-info-body">
<div class="aca-folder-info-item">
<div class="aca-folder-info-item-label">{{ 'APP.FOLDER_INFO.SIZE' | translate }}</div>
<div class="aca-folder-info-item-value"
data-automation-id="folder-info-size">{{ size }}</div>
data-automation-id="folder-info-size">{{ folderDetails.size }}</div>
</div>
<mat-divider></mat-divider>
<mat-divider/>
<div class="aca-folder-info-item">
<div class="aca-folder-info-item-label">{{ 'APP.FOLDER_INFO.LOCATION' | translate }}</div>
<div class="aca-folder-info-item-value"
data-automation-id="folder-info-location">{{ location }}</div>
data-automation-id="folder-info-location">{{ folderDetails.location }}</div>
</div>
<mat-divider></mat-divider>
<mat-divider/>
<div class="aca-folder-info-item">
<div class="aca-folder-info-item-label">{{ 'APP.FOLDER_INFO.CREATED' | translate }}</div>
<div class="aca-folder-info-item-value"
data-automation-id="folder-info-creation-date"
[title]="created | adfLocalizedDate">{{ created | adfTimeAgo }}</div>
[title]="folderDetails.created | adfLocalizedDate">{{ folderDetails.created | adfTimeAgo }}</div>
</div>
<mat-divider></mat-divider>
<mat-divider/>
<div class="aca-folder-info-item">
<div class="aca-folder-info-item-label">{{ 'APP.FOLDER_INFO.MODIFIED' | translate }}</div>
<div class="aca-folder-info-item-value"
data-automation-id="folder-info-modify-date"
[title]="modified | adfLocalizedDate">{{ modified | adfTimeAgo }}</div>
[title]="folderDetails.modified | adfLocalizedDate">{{ folderDetails.modified | adfTimeAgo }}</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('FolderInformationComponent', () => {
modifiedAt: new Date(2024, 2, 2, 22, 22)
};

const getValueFromElement = (id: string) => fixture.debugElement.query(By.css(`[data-automation-id="${id}"]`)).nativeElement.textContent;
const getValueFromElement = (id: string): string => fixture.debugElement.query(By.css(`[data-automation-id="${id}"]`)).nativeElement.textContent;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [FolderInformationComponent, LibTestingModule],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ import { EMPTY, timer } from 'rxjs';

const MEMORY_UNIT_LIST = ['bytes', 'KB', 'MB', 'GB', 'TB'];

interface FolderDetails {
name: string;
size: string;
location: string;
created: Date;
modified: Date;
icon: string;
}

@Component({
selector: 'app-folder-info',
standalone: true,
Expand All @@ -52,20 +61,15 @@ export class FolderInformationComponent implements OnInit {
private readonly destroyRef = inject(DestroyRef);

data: Node = inject(DIALOG_COMPONENT_DATA);
name: string;
size: string;
location: string;
created: Date;
modified: Date;
icon: string;
folderDetails: FolderDetails;

ngOnInit() {
this.name = this.data.name;
this.location = this.data.path.name;
this.created = this.data.createdAt;
this.modified = this.data.modifiedAt;
this.icon = this.contentService.getNodeIcon(this.data);
this.size = this.translateService.instant('APP.FOLDER_INFO.CALCULATING');
this.folderDetails.name = this.data.name;
this.folderDetails.location = this.data.path.name;
this.folderDetails.created = this.data.createdAt;
this.folderDetails.modified = this.data.modifiedAt;
this.folderDetails.icon = this.contentService.getNodeIcon(this.data);
this.folderDetails.size = this.translateService.instant('APP.FOLDER_INFO.CALCULATING');

this.nodesService
.initiateFolderSizeCalculation(this.data.id)
Expand All @@ -74,7 +78,7 @@ export class FolderInformationComponent implements OnInit {
this.nodesService
.getFolderSizeInfo(this.data.id, jobIdEntry.entry.jobId)
.pipe(
expand((result: any) =>
expand((result: SizeDetailsEntry) =>
result.entry.status === 'IN_PROGRESS'
? timer(5000).pipe(concatMap(() => this.nodesService.getFolderSizeInfo(this.data.id, jobIdEntry.entry.jobId)))
: EMPTY
Expand All @@ -96,7 +100,7 @@ export class FolderInformationComponent implements OnInit {
unit: MEMORY_UNIT_LIST[unitIndex],
count: folderInfo.entry.numberOfFiles
};
this.size = this.translateService.instant(
this.folderDetails.size = this.translateService.instant(
isMoreThanBytes ? 'APP.FOLDER_INFO.CALCULATED_SIZE_LARGE' : 'APP.FOLDER_INFO.CALCULATED_SIZE_NORMAL',
params
);
Expand Down

0 comments on commit 40d3eee

Please sign in to comment.