bobbai00 commented on code in PR #3772:
URL: https://github.com/apache/texera/pull/3772#discussion_r2407569518


##########
core/gui/src/app/workspace/service/workflow-result-export/workflow-result-export.service.ts:
##########
@@ -26,13 +26,21 @@ import { PaginatedResultEvent, ResultExportResponse } from 
"../../types/workflow
 import { NotificationService } from 
"../../../common/service/notification/notification.service";
 import { ExecuteWorkflowService } from 
"../execute-workflow/execute-workflow.service";
 import { ExecutionState, isNotInExecution } from 
"../../types/execute-workflow.interface";
-import { filter } from "rxjs/operators";
+import { catchError, filter, map, take, tap } from "rxjs/operators";
 import { OperatorResultService, WorkflowResultService } from 
"../workflow-result/workflow-result.service";
 import { DownloadService } from 
"../../../dashboard/service/user/download/download.service";
 import { HttpResponse } from "@angular/common/http";
 import { ExportWorkflowJsonResponse } from 
"../../../dashboard/service/user/download/download.service";
 import { DashboardWorkflowComputingUnit } from 
"../../types/workflow-computing-unit";
 import { GuiConfigService } from "../../../common/service/gui-config.service";
+import { DatasetService } from 
"../../../dashboard/service/user/dataset/dataset.service";
+import { parseFilePathToDatasetFile } from "../../../common/type/dataset-file";
+
+export interface RestrictionAnalysisResult {
+  restrictedOperatorMap: Map<string, Set<string>>;

Review Comment:
   Rename to `WorkflowResultDownloadability`. Add comment on each field to list 
the specification



##########
core/gui/src/app/workspace/service/workflow-result-export/workflow-result-export.service.ts:
##########
@@ -60,34 +69,284 @@ export class WorkflowResultExportService {
       
this.workflowActionService.getJointGraphWrapper().getJointOperatorHighlightStream(),
       
this.workflowActionService.getJointGraphWrapper().getJointOperatorUnhighlightStream()
     ).subscribe(() => {
-      // check if there are any results to export on highlighted operators 
(either paginated or snapshot)
-      this.hasResultToExportOnHighlightedOperators =
-        
isNotInExecution(this.executeWorkflowService.getExecutionState().state) &&
-        this.workflowActionService
-          .getJointGraphWrapper()
-          .getCurrentHighlightedOperatorIDs()
-          .filter(
-            operatorId =>
-              this.workflowResultService.hasAnyResult(operatorId) ||
-              
this.workflowResultService.getResultService(operatorId)?.getCurrentResultSnapshot()
 !== undefined
-          ).length > 0;
-
-      // check if there are any results to export on all operators (either 
paginated or snapshot)
-      let staticHasResultToExportOnAllOperators =
-        
isNotInExecution(this.executeWorkflowService.getExecutionState().state) &&
-        this.workflowActionService
-          .getTexeraGraph()
-          .getAllOperators()
-          .map(operator => operator.operatorID)
-          .filter(
-            operatorId =>
-              this.workflowResultService.hasAnyResult(operatorId) ||
-              
this.workflowResultService.getResultService(operatorId)?.getCurrentResultSnapshot()
 !== undefined
-          ).length > 0;
-
-      // Notify subscribers of changes
-      
this.hasResultToExportOnAllOperators.next(staticHasResultToExportOnAllOperators);
+      this.updateExportAvailabilityFlags();
+    });
+  }
+
+  /**
+   * Computes restriction analysis on-demand by fetching dataset metadata and 
analyzing workflow graph.
+   *
+   * Fetches all accessible datasets and their permissions, then:
+   * - Builds datasetDownloadableMap: tracks which datasets are downloadable
+   * - Builds datasetLabelMap: stores human-readable dataset labels
+   * - Performs restriction analysis to identify operators blocked by dataset 
access controls
+   *
+   * A dataset is considered downloadable if either:
+   * - The dataset's isDownloadable flag is true, OR
+   * - The current user is the dataset owner
+   *
+   * @returns Observable that emits the restriction analysis result
+   */
+  public computeRestrictionAnalysis(): Observable<RestrictionAnalysisResult> {

Review Comment:
   I saw on the backend you add an endpoint to calculate the same thing as 
here. Can you use that endpoint to replace the current frontend implementation?



##########
core/gui/src/app/workspace/service/workflow-result-export/workflow-result-export.service.ts:
##########
@@ -26,13 +26,21 @@ import { PaginatedResultEvent, ResultExportResponse } from 
"../../types/workflow
 import { NotificationService } from 
"../../../common/service/notification/notification.service";
 import { ExecuteWorkflowService } from 
"../execute-workflow/execute-workflow.service";
 import { ExecutionState, isNotInExecution } from 
"../../types/execute-workflow.interface";
-import { filter } from "rxjs/operators";
+import { catchError, filter, map, take, tap } from "rxjs/operators";
 import { OperatorResultService, WorkflowResultService } from 
"../workflow-result/workflow-result.service";
 import { DownloadService } from 
"../../../dashboard/service/user/download/download.service";
 import { HttpResponse } from "@angular/common/http";
 import { ExportWorkflowJsonResponse } from 
"../../../dashboard/service/user/download/download.service";
 import { DashboardWorkflowComputingUnit } from 
"../../types/workflow-computing-unit";
 import { GuiConfigService } from "../../../common/service/gui-config.service";
+import { DatasetService } from 
"../../../dashboard/service/user/dataset/dataset.service";
+import { parseFilePathToDatasetFile } from "../../../common/type/dataset-file";
+
+export interface RestrictionAnalysisResult {
+  restrictedOperatorMap: Map<string, Set<string>>;
+  datasetDownloadableMap: Map<string, boolean>;
+  datasetLabelMap: Map<string, string>;

Review Comment:
   Seems their keys are all dataset id, can these two map be merged into one?



-- 
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]

Reply via email to