Skip to content

Commit

Permalink
swap PublishedRunVisibility.choices_for_workspace for PublishedRunVis…
Browse files Browse the repository at this point in the history
…ibility.choices_for_pr
  • Loading branch information
nikochiko committed Jan 10, 2025
1 parent 88739d3 commit 60ad815
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
14 changes: 8 additions & 6 deletions bots/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import datetime
import typing
from multiprocessing.pool import ThreadPool
Expand Down Expand Up @@ -40,14 +42,14 @@ class PublishedRunVisibility(models.IntegerChoices):
INTERNAL = 3

@classmethod
def choices_for_workspace(
cls, workspace: typing.Optional["Workspace"]
) -> typing.Iterable["PublishedRunVisibility"]:
if not workspace or workspace.is_personal:
return [cls.UNLISTED, cls.PUBLIC]
def choices_for_pr(
cls, pr: PublishedRun
) -> typing.Iterable[PublishedRunVisibility]:
if not pr.workspace or pr.workspace.is_personal:
return {cls.UNLISTED, cls.PUBLIC, PublishedRunVisibility(pr.visibility)}
else:
# TODO: Add cls.PUBLIC when team-handles are added
return [cls.UNLISTED, cls.INTERNAL]
return {cls.UNLISTED, cls.INTERNAL, PublishedRunVisibility(pr.visibility)}

@classmethod
def get_default_for_workspace(cls, workspace: typing.Optional["Workspace"]):
Expand Down
7 changes: 1 addition & 6 deletions daras_ai_v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,12 +557,7 @@ def _render_share_modal(self, dialog: gui.AlertDialogRef):

options = {
str(enum.value): enum.help_text(self.current_pr.workspace)
for enum in [
*PublishedRunVisibility.choices_for_workspace(
self.current_pr.workspace
),
PublishedRunVisibility(self.current_pr.visibility),
]
for enum in PublishedRunVisibility.choices_for_pr(self.current_pr)
}
published_run_visibility = PublishedRunVisibility(
int(
Expand Down

0 comments on commit 60ad815

Please sign in to comment.