Skip to content

Commit

Permalink
NAS-133308: Add bucket value if readonly user
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanY147 committed Jan 6, 2025
1 parent 464a06e commit bbc28b4
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -210,6 +212,8 @@ export class CloudSyncFormComponent implements OnInit {

bucketOptions$ = of<SelectOption[]>([]);

private hasRequiredRoles = toSignal(this.authService.hasRole(this.requiredRoles));

fileNodeProvider: TreeNodeProvider;
bucketNodeProvider: TreeNodeProvider;

Expand All @@ -229,6 +233,7 @@ export class CloudSyncFormComponent implements OnInit {
private filesystemService: FilesystemService,
protected cloudCredentialService: CloudCredentialService,
public slideInRef: SlideInRef<CloudSyncTaskUi | undefined, CloudSyncTask | false>,
private authService: AuthService,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bbc28b4

Please sign in to comment.