From bbc28b46599b90e9ef669bfaeeb96c44d8198042 Mon Sep 17 00:00:00 2001 From: RehanY147 Date: Mon, 6 Jan 2025 05:22:33 +0500 Subject: [PATCH] NAS-133308: Add bucket value if readonly user --- .../cloudsync-form/cloudsync-form.component.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/app/pages/data-protection/cloudsync/cloudsync-form/cloudsync-form.component.ts b/src/app/pages/data-protection/cloudsync/cloudsync-form/cloudsync-form.component.ts index 79eb1e65b4e..0174315dce6 100644 --- a/src/app/pages/data-protection/cloudsync/cloudsync-form/cloudsync-form.component.ts +++ b/src/app/pages/data-protection/cloudsync/cloudsync-form/cloudsync-form.component.ts @@ -1,6 +1,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, } from '@angular/core'; +import { toSignal } from '@angular/core/rxjs-interop'; import { FormControl, Validators, ReactiveFormsModule } from '@angular/forms'; import { MatButton } from '@angular/material/button'; import { MatCard, MatCardContent } from '@angular/material/card'; @@ -35,6 +36,7 @@ import { CloudSyncCredential } from 'app/interfaces/cloudsync-credential.interfa import { CloudSyncProvider } from 'app/interfaces/cloudsync-provider.interface'; import { newOption, SelectOption } from 'app/interfaces/option.interface'; import { ExplorerNodeData, TreeNode } from 'app/interfaces/tree-node.interface'; +import { AuthService } from 'app/modules/auth/auth.service'; import { DialogService } from 'app/modules/dialog/dialog.service'; import { CloudCredentialsSelectComponent } from 'app/modules/forms/custom-selects/cloud-credentials-select/cloud-credentials-select.component'; import { IxCheckboxComponent } from 'app/modules/forms/ix-forms/components/ix-checkbox/ix-checkbox.component'; @@ -210,6 +212,8 @@ export class CloudSyncFormComponent implements OnInit { bucketOptions$ = of([]); + private hasRequiredRoles = toSignal(this.authService.hasRole(this.requiredRoles)); + fileNodeProvider: TreeNodeProvider; bucketNodeProvider: TreeNodeProvider; @@ -229,6 +233,7 @@ export class CloudSyncFormComponent implements OnInit { private filesystemService: FilesystemService, protected cloudCredentialService: CloudCredentialService, public slideInRef: SlideInRef, + private authService: AuthService, ) { this.slideInRef.requireConfirmationWhen(() => { return of(this.form.dirty); @@ -388,6 +393,17 @@ export class CloudSyncFormComponent implements OnInit { } loadBucketOptions(): void { + if (!this.hasRequiredRoles()) { + this.isLoading = false; + const bucket = this.editingTask.attributes.bucket as string; + if (bucket) { + this.form.controls.bucket.enable(); + this.bucketOptions$ = of([{ label: bucket, value: bucket }]); + this.form.controls.bucket.setValue(bucket); + } + this.cdr.markForCheck(); + return; + } const targetCredentials = find(this.credentialsList, { id: this.form.controls.credentials.value }); this.cloudCredentialService.getBuckets(targetCredentials.id)