[ACS-9249] Add number of files to Folder Information (#4626)

* [ACS-9249] Add number of files to Folder Information

* [ACS-9249] cr fix

* [ACS-9249] fix e2e's
This commit is contained in:
Mykyta Maliarchuk
2025-06-26 14:32:52 +02:00
committed by GitHub
parent e110b73613
commit 29212b3cb3
6 changed files with 44 additions and 11 deletions

View File

@@ -467,9 +467,10 @@
"ICON": "Folder Icon",
"TITLE": "Folder Information",
"SIZE" : "Size",
"NUMBER_OF_FILES": "Number of files",
"CALCULATING": "Calculating...",
"CALCULATED_SIZE_LARGE": "{{sizeInBytes}} bytes ({{sizeInLargeUnit}} {{unit}} on disk) for {{count}} files",
"CALCULATED_SIZE_NORMAL": "{{sizeInBytes}} bytes for {{count}} files",
"CALCULATED_SIZE_LARGE": "{{sizeInBytes}} bytes ({{sizeInLargeUnit}} {{unit}} on disk)",
"CALCULATED_SIZE_NORMAL": "{{sizeInBytes}} bytes",
"LOCATION": "Location",
"CREATED": "Created",
"MODIFIED": "Modified",

View File

@@ -4,6 +4,12 @@
</div>
<mat-divider/>
<div class="aca-folder-info-body">
<div class="aca-folder-info-item">
<div class="aca-folder-info-item-label">{{ 'APP.FOLDER_INFO.NUMBER_OF_FILES' | translate }}</div>
<div class="aca-folder-info-item-value"
data-automation-id="folder-info-number-of-files">{{ folderDetails.numberOfFiles }}</div>
</div>
<mat-divider/>
<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"

View File

@@ -37,6 +37,8 @@ describe('FolderInformationComponent', () => {
let initiateFolderSizeCalculationSpy: jasmine.Spy<(nodeId: string) => Observable<JobIdBodyEntry>>;
let getFolderSizeInfoSpy: jasmine.Spy<(nodeId: string, jobId: string) => Observable<SizeDetailsEntry>>;
const getNumberOfFiles = (): string => unitTestingUtils.getInnerTextByDataAutomationId('folder-info-number-of-files');
const mockSub = new Subject<JobIdBodyEntry>();
const dialogData = {
name: 'mock-folder',
@@ -77,6 +79,7 @@ describe('FolderInformationComponent', () => {
it('should render all information in init', () => {
fixture.detectChanges();
expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-name')).toBe('mock-folder');
expect(getNumberOfFiles()).toBe('APP.FOLDER_INFO.CALCULATING');
expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-size')).toBe('APP.FOLDER_INFO.CALCULATING');
expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-location')).toBe('mock-folder-path');
expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-creation-date')).toBe('01/02/2024 11:11');
@@ -115,6 +118,7 @@ describe('FolderInformationComponent', () => {
expect(getFolderSizeInfoSpy).toHaveBeenCalledTimes(4);
tick(5000);
expect(getFolderSizeInfoSpy).not.toHaveBeenCalledTimes(5);
expect(fixture.componentInstance.folderDetails.numberOfFiles).toBe(1);
}));
it('should not make new API request, and display error message if response returned from API is neither COMPLETE, nor IN_PROGRESS', fakeAsync(() => {
@@ -125,6 +129,8 @@ describe('FolderInformationComponent', () => {
tick(1000);
fixture.detectChanges();
expect(getFolderSizeInfoSpy).toHaveBeenCalledTimes(1);
fixture.detectChanges();
expect(getNumberOfFiles()).toBe('APP.FOLDER_INFO.ERROR');
expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-size')).toBe('APP.FOLDER_INFO.ERROR');
tick(5000);
expect(getFolderSizeInfoSpy).not.toHaveBeenCalledTimes(2);

View File

@@ -42,6 +42,7 @@ class FolderDetails {
created: Date;
modified: Date;
icon: string;
numberOfFiles: string | number;
}
@Component({
@@ -70,6 +71,7 @@ export class FolderInformationComponent implements OnInit {
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.folderDetails.numberOfFiles = this.translateService.instant('APP.FOLDER_INFO.CALCULATING');
this.nodesService
.initiateFolderSizeCalculation(this.data.id)
@@ -91,6 +93,7 @@ export class FolderInformationComponent implements OnInit {
}),
takeUntilDestroyed(this.destroyRef),
catchError(() => {
this.folderDetails.numberOfFiles = this.translateService.instant('APP.FOLDER_INFO.ERROR');
this.folderDetails.size = this.translateService.instant('APP.FOLDER_INFO.ERROR');
return of(null);
})
@@ -108,15 +111,16 @@ export class FolderInformationComponent implements OnInit {
const params = {
sizeInBytes: parseFloat(folderInfo.entry.sizeInBytes).toLocaleString('en'),
sizeInLargeUnit: size.toFixed(2),
unit: MEMORY_UNIT_LIST[unitIndex],
count: folderInfo.entry.numberOfFiles
unit: MEMORY_UNIT_LIST[unitIndex]
};
this.folderDetails.size = this.translateService.instant(
isMoreThanBytes ? 'APP.FOLDER_INFO.CALCULATED_SIZE_LARGE' : 'APP.FOLDER_INFO.CALCULATED_SIZE_NORMAL',
params
);
this.folderDetails.numberOfFiles = folderInfo.entry.numberOfFiles;
} else if (folderInfo?.entry?.status !== SizeDetails.StatusEnum.IN_PROGRESS) {
this.folderDetails.size = this.translateService.instant('APP.FOLDER_INFO.ERROR');
this.folderDetails.numberOfFiles = this.translateService.instant('APP.FOLDER_INFO.ERROR');
}
});
}

View File

@@ -34,6 +34,7 @@ export class FolderInformationDialogComponent extends BaseComponent {
folderName = this.getChild('.aca-folder-info-header');
doneButton = this.getChild('[data-automation-id="adf-dialog-actions-confirm"]');
folderNumberOfFiles = this.getChild('[data-automation-id="folder-info-number-of-files"]');
folderSize = this.getChild('[data-automation-id="folder-info-size"]');
folderLocation = this.getChild('[data-automation-id="folder-info-location"]');
folderCreationDate = this.getChild('[data-automation-id="folder-info-creation-date"]');