mengw15 commented on code in PR #8005: URL: https://github.com/apache/texera/pull/8005#discussion_r3875819584
########## frontend/src/app/dashboard/component/user/user-warehouse/user-warehouse.component.ts: ########## @@ -0,0 +1,129 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Component, OnInit } from "@angular/core"; +import { NgIf } from "@angular/common"; +import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; + +import { ɵɵCdkVirtualScrollViewport, ɵɵCdkFixedSizeVirtualScroll, ɵɵCdkVirtualForOf } from "@angular/cdk/overlay"; +import { NzButtonComponent } from "ng-zorro-antd/button"; +import { NzCardComponent } from "ng-zorro-antd/card"; +import { ɵNzTransitionPatchDirective } from "ng-zorro-antd/core/transition-patch"; +import { NzWaveDirective } from "ng-zorro-antd/core/wave"; +import { NzIconDirective } from "ng-zorro-antd/icon"; +import { NzListComponent } from "ng-zorro-antd/list"; +import { NzSpaceCompactItemDirective } from "ng-zorro-antd/space"; + +import { WarehouseCreateModalComponent } from "../../../../common/component/warehouse-create-modal/warehouse-create-modal.component"; +import { NotificationService } from "../../../../common/service/notification/notification.service"; +import { WarehouseActionsService } from "../../../../common/service/warehouse/warehouse-actions.service"; +import { WarehouseService } from "../../../../common/service/warehouse/warehouse.service"; +import { DashboardWarehouse } from "../../../../common/type/warehouse"; +import { UserWarehouseListItemComponent } from "./user-warehouse-list-item/user-warehouse-list-item.component"; + +/** + * Dashboard page for per-user warehouses (#6933), mirroring + * UserComputingUnitComponent: list the caller's warehouses, create one (Local + * flavor), delete one. Reachable only while the deployment reports the feature + * enabled; the page re-checks and says so otherwise. + */ +@UntilDestroy() +@Component({ + selector: "texera-user-warehouse", + templateUrl: "./user-warehouse.component.html", + styleUrls: ["./user-warehouse.component.scss"], + imports: [ + NgIf, + NzCardComponent, + NzSpaceCompactItemDirective, + NzButtonComponent, + NzWaveDirective, + ɵNzTransitionPatchDirective, + NzIconDirective, + ɵɵCdkVirtualScrollViewport, + ɵɵCdkFixedSizeVirtualScroll, + NzListComponent, + ɵɵCdkVirtualForOf, + UserWarehouseListItemComponent, + WarehouseCreateModalComponent, + ], +}) +export class UserWarehouseComponent implements OnInit { + // Undefined until the status request settles: with a plain false, a pending or + // failed request renders the "disabled in this deployment" notice, which names + // the wrong cause. + warehouseEnabled?: boolean; + warehouses: DashboardWarehouse[] = []; + // The status request failed: without this the page renders neither the + // disabled notice nor the list, leaving a blank card and no way back. + loadFailed = false; + + // visibility of the shared create-warehouse modal + addWarehouseModalVisible = false; + + constructor( + private warehouseService: WarehouseService, + private notificationService: NotificationService, + private warehouseActionsService: WarehouseActionsService + ) {} + + ngOnInit(): void { + this.refresh(); + } + + retry(): void { + this.refresh(); + } + + private refresh(): void { + this.warehouseService + .getStatus() + .pipe(untilDestroyed(this)) + .subscribe({ Review Comment: Done — refreshes now flow through a single switchMap'd stream, so a new request cancels the in-flight one and a late response can no longer overwrite newer state. Covered by a regression test. ########## frontend/src/app/dashboard/component/user/user-warehouse/user-warehouse.component.html: ########## @@ -0,0 +1,83 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +<div class="section-container subsection-grid-container"> + <nz-card class="section-title"> + <h2 class="page-title">Warehouses</h2> + <div class="button-group"> + <button + nz-button + class="create-btn" + (click)="showAddWarehouseModalVisible()" + [disabled]="!warehouseEnabled" + title="Create Warehouse"> + <i + nz-icon + nzType="file-add" + nzTheme="outline"></i> + <span>Create Warehouse</span> + </button> + </div> + </nz-card> + + <nz-card + class="section-list-container" + [nzBodyStyle]="{ height: '100%'}"> + <div + *ngIf="loadFailed" + class="warehouse-page-empty"> + Could not load your warehouses. + <button + nz-button + nzType="link" + (click)="retry()"> + Retry + </button> + </div> + + <div + *ngIf="warehouseEnabled === false" + class="warehouse-page-empty"> + Per-user warehouses are disabled in this deployment. Review Comment: The notice is user-facing and the config key isn't something a user can act on, so the wording stays; reworded the PR description instead — it no longer claims the notice names the flag. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
