Skip to content

Commit

Permalink
Add private/public pills for visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Dec 14, 2023
1 parent a702775 commit c3d8d6e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
28 changes: 28 additions & 0 deletions bots/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import typing
from multiprocessing.pool import ThreadPool
from textwrap import dedent

import pytz
from django.conf import settings
Expand Down Expand Up @@ -44,6 +45,33 @@ def help_text(self):
case _:
return self.label

def get_badge_html(self):
badge_container_class = (
"text-sm bg-light border border-dark rounded-pill px-2 py-1"
)

match self:
case PublishedRunVisibility.UNLISTED:
return dedent(
f"""\
<span class="{badge_container_class}">
<i class="fa-regular fa-lock"></i>
Private
</span>
"""
)
case PublishedRunVisibility.PUBLIC:
return dedent(
f"""\
<span class="{badge_container_class}">
<i class="fa-regular fa-globe"></i>
Public
</span>
"""
)
case _:
raise NotImplementedError(self)


class Platform(models.IntegerChoices):
FACEBOOK = 1
Expand Down
12 changes: 6 additions & 6 deletions daras_ai_v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,12 +1633,12 @@ def _render_run_preview(self, saved_run: SavedRun):
)

with st.link(to=saved_run.get_app_url(), className="text-decoration-none"):
with st.tag("span", className="badge bg-secondary px-4 py-2 mb-2 lead"):
with st.div(className="mb-1", style={"font-size": "0.9rem"}):
if is_latest_version:
st.html(
PublishedRunVisibility(published_run.visibility)
.help_text()
.upper()
PublishedRunVisibility(
published_run.visibility
).get_badge_html()
)

st.write(f"#### {title}")
Expand All @@ -1661,9 +1661,9 @@ def _render_published_run_preview(self, published_run: PublishedRun):
)

with st.link(to=published_run.get_app_url(), className="text-decoration-none"):
with st.tag("span", className="badge bg-secondary px-4 py-2 mb-2"):
with st.div(className="mb-1", style={"font-size": "0.9rem"}):
st.html(
PublishedRunVisibility(published_run.visibility).help_text().upper()
PublishedRunVisibility(published_run.visibility).get_badge_html()
)

st.write(f"#### {title}")
Expand Down

0 comments on commit c3d8d6e

Please sign in to comment.