Skip to content

Commit

Permalink
Add org support with role and UI view
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Jul 15, 2024
1 parent eb6d1c3 commit b39f3f6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions daras_ai_v2/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
company = '<i class="fa-regular fa-buildings"></i>'
copy = '<i class="fa-solid fa-copy"></i>'
preview = '<i class="fa-solid fa-eye"></i>'
time = '<i class="fa-regular fa-clock"></i>'

code = '<i class="fa-regular fa-code"></i>'
chat = '<i class="fa-regular fa-messages"></i>'
admin = '<i class="fa-solid fa-shield-halved"></i>'
remove_user = '<i class="fa-solid fa-user-minus"></i>'
add_user = '<i class="fa-solid fa-user-plus"></i>'
transfer_ownership = '<i class="fa-solid fa-right-left"></i>'

# brands
github = '<i class="fa-brands fa-github"></i>'
Expand Down
1 change: 1 addition & 0 deletions daras_ai_v2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"handles",
"payments",
"functions",
"orgs",
]

MIDDLEWARE = [
Expand Down
21 changes: 21 additions & 0 deletions gooey_ui/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,27 @@ def table(df: "pd.DataFrame"):
html(dedent(str(value)))


def raw_table(header: list[str], className: str = "", **props) -> state.NestingCtx:
className = "table " + className
with tag("table", className=className, **props):
if header:
with tag("thead"), tag("tr"):
for col in header:
with tag("th", scope="col"):
html(dedent(col))

return tag("tbody")


def table_row(values: list[str], **props):
row = tag("tr", **props)
with row:
for v in values:
with tag("td"):
html(html_lib.escape(v))
return row


def horizontal_radio(
label: str,
options: typing.Sequence[T],
Expand Down
24 changes: 24 additions & 0 deletions routers/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from gooey_ui.components.pills import pill
from payments.webhooks import PaypalWebhookHandler
from routers.root import page_wrapper, get_og_url_path
from orgs.views import orgs_page

app = APIRouter()

Expand Down Expand Up @@ -144,6 +145,24 @@ def api_keys_route(request: Request):
)


@app.post("/orgs/")
@st.route
def orgs_route(request: Request):
with account_page_wrapper(request, AccountTabs.orgs):
orgs_tab(request)

url = get_og_url_path(request)
return dict(
meta=raw_build_meta_tags(
url=url,
canonical_url=url,
title="Teams • Gooey.AI",
description="Your teams.",
robots="noindex,nofollow",
)
)


class TabData(typing.NamedTuple):
title: str
route: typing.Callable
Expand All @@ -154,6 +173,7 @@ class AccountTabs(TabData, Enum):
profile = TabData(title=f"{icons.profile} Profile", route=profile_route)
saved = TabData(title=f"{icons.save} Saved", route=saved_route)
api_keys = TabData(title=f"{icons.api} API Keys", route=api_keys_route)
orgs = TabData(title=f"{icons.company} Teams", route=orgs_route)

@property
def url_path(self) -> str:
Expand Down Expand Up @@ -213,6 +233,10 @@ def api_keys_tab(request: Request):
manage_api_keys(request.user)


def orgs_tab(request: Request):
orgs_page(request.user)


@contextmanager
def account_page_wrapper(request: Request, current_tab: TabData):
if not request.user or request.user.is_anonymous:
Expand Down

0 comments on commit b39f3f6

Please sign in to comment.