kunwp1 commented on code in PR #8935:
URL: https://github.com/apache/texera/pull/8935#discussion_r4371612363
##########
frontend/src/app/workspace/component/power-button/computing-unit-selection.component.ts:
##########
@@ -431,6 +430,30 @@ export class ComputingUnitSelectionComponent implements
OnInit {
});
}
+ /**
+ * Selects `preferred` once the unit list has loaded and still holds it,
else the first running
+ * unit, else nothing.
+ */
+ private selectFromLoadedUnits(wid: number, preferred?: number): void {
+ this.computingUnitStatusService
+ .getAllComputingUnits()
+ .pipe(
+ filter(units => units.length > 0),
+ take(1),
+ untilDestroyed(this)
+ )
+ .subscribe(units => {
+ // Skip if the workflow changed while the list was loading.
+ if (wid !== this.workflowId) {
+ return;
+ }
+ const unit = units.find(u => u.computingUnit.cuid === preferred) ??
units.find(u => u.status === "Running");
Review Comment:
The fallback picks the first Running unit regardless of access, and the list
includes units shared with the user. When the user owns no Running unit but a
colleague shared one with READ access, that unit gets selected, and the menu
then disables Run because it requires WRITE. Can the fallback skip units the
user can't run on and select nothing otherwise?
##########
frontend/src/app/workspace/component/power-button/computing-unit-selection.component.ts:
##########
@@ -431,6 +430,30 @@ export class ComputingUnitSelectionComponent implements
OnInit {
});
}
+ /**
+ * Selects `preferred` once the unit list has loaded and still holds it,
else the first running
+ * unit, else nothing.
+ */
+ private selectFromLoadedUnits(wid: number, preferred?: number): void {
+ this.computingUnitStatusService
+ .getAllComputingUnits()
+ .pipe(
+ filter(units => units.length > 0),
+ take(1),
+ untilDestroyed(this)
+ )
+ .subscribe(units => {
+ // Skip if the workflow changed while the list was loading.
+ if (wid !== this.workflowId) {
+ return;
+ }
Review Comment:
This block is the same as the branch in `selectInitialUnit`. Can you add a
small shared helper?
--
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]