Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workspace functionality #468

Open
wants to merge 88 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
664b9de
Add validations to disallow inviting members to a personal workspace
nikochiko Sep 18, 2024
d467bea
Fix view for validation errors
nikochiko Sep 18, 2024
f14d1b5
Disallow teams tab for personal workspaces
nikochiko Sep 18, 2024
8cf22d3
change billing tab URL to /account/billing and tab order in account page
nikochiko Sep 19, 2024
b53d1a6
update meta title for Members tab
nikochiko Sep 19, 2024
c725ce0
only owners and admins should see the billing tab
nikochiko Sep 19, 2024
26e4ac5
Revert "change billing tab URL to /account/billing and tab order in a…
nikochiko Sep 19, 2024
4203b03
enforce access control on workspace billing
nikochiko Sep 20, 2024
fa38031
Revert "Revert "change billing tab URL to /account/billing and tab or…
nikochiko Sep 20, 2024
b320cfe
fix accidental bug from conflict resolution
nikochiko Sep 20, 2024
ac75f6e
Add workspace to published run
nikochiko Sep 20, 2024
82e1787
fix can_edit_published_run access control for workspaces
nikochiko Sep 20, 2024
80c80a8
feat: show history belonging to uid ✖️ current workspace
nikochiko Sep 20, 2024
8672239
feat: show (and create) API keys belonging to workspace
nikochiko Sep 20, 2024
4bf5570
feat: fix view for saved tab to filter by workspace
nikochiko Sep 20, 2024
02740e8
feat: add current balance & plan to members tab
nikochiko Sep 20, 2024
18c0b84
feat: fix URLs for team & personal workspaces in account settings
nikochiko Sep 20, 2024
396e541
feat: allow published runs to be created with workspace
nikochiko Sep 20, 2024
b3e4563
fix routes in account
nikochiko Sep 21, 2024
2f997d1
fix: register workspace when duplicating published run
nikochiko Sep 21, 2024
05d09de
render workspace as the owner on published runs
nikochiko Sep 21, 2024
12d858a
fix rendering of validationerror messages
nikochiko Sep 21, 2024
6c3d845
Refactor workspace_selector with current_tab for clarity
nikochiko Sep 23, 2024
e2834e4
Add workspace selector to 'Save'/'Update' menu
nikochiko Sep 25, 2024
d8caf28
Add workspace API keys, bot integrations (#476)
nikochiko Sep 25, 2024
26692c8
fix black formatting
nikochiko Sep 25, 2024
95efc50
Add migration for ApiKey related_name for workspaces
nikochiko Sep 25, 2024
06ff80a
Add change notes to published run version & UI
nikochiko Sep 25, 2024
474ce99
Remove change_notes from _has_published_run_changed
nikochiko Sep 25, 2024
0275214
Redo rendering of version history with change notes
nikochiko Sep 25, 2024
f7f50d7
Add change notes in publish menu
nikochiko Sep 25, 2024
76658a5
fix api keys widget to not perform key migration from firebase
nikochiko Oct 3, 2024
9817033
revert API key migration from firebase->DB in API calls
nikochiko Oct 3, 2024
fa803d1
Merge branch 'master' into workspace-usability
nikochiko Oct 7, 2024
4ca7269
fix badly resolved conflicts
nikochiko Oct 7, 2024
0c66422
make change notes icon fs-3 in publish form
nikochiko Oct 7, 2024
32315c7
saved options menu: show duplicate and delete buttons on the same line
nikochiko Oct 7, 2024
5ed9c59
only show one of FIRST VERSION tag, change notes, or Renamed: ... tex…
nikochiko Oct 7, 2024
208ea2d
fix: use user.full_name() instead of user.display_name for version hi…
nikochiko Oct 7, 2024
95ac836
only show pending list to admins
nikochiko Oct 8, 2024
15169ed
fix: recipe page breaks for anon users
nikochiko Oct 10, 2024
01a4494
Merge branch 'master' into workspace-usability
nikochiko Oct 10, 2024
cab2a19
rename: published_run_notes -> published_run_description
nikochiko Oct 10, 2024
95c7fc7
fix: visibility for duplicate runs should be UNLISTED
nikochiko Oct 10, 2024
9b8a0e5
fix padding in publish dialog
nikochiko Oct 10, 2024
563e081
fix s/workspace.logo/workspace.photo_url
nikochiko Oct 10, 2024
68a9bd4
rename personal->Personal
nikochiko Oct 14, 2024
c0277e7
commit everything
nikochiko Oct 16, 2024
10f02ca
Merge branch 'master' into workspace-usability
nikochiko Oct 17, 2024
a3f0c4a
fix failing test with validate_constraints=False in create_with_owner
nikochiko Oct 21, 2024
1a2a469
don't show author as a link in version history
nikochiko Oct 21, 2024
51e3336
Merge branch 'master' into workspace-usability
nikochiko Nov 4, 2024
d0a11e3
remove stale migration file
nikochiko Nov 4, 2024
01e2769
fix route name: billing_route -> account_route
nikochiko Nov 4, 2024
0ad10b1
Merge branch 'master' into workspace-usability
nikochiko Nov 4, 2024
1f9467b
Merge branch 'master' into workspace-usability
nikochiko Nov 4, 2024
363933a
nicely resolve merge conflict
nikochiko Nov 4, 2024
4f56441
remove superseded migrations
nikochiko Nov 4, 2024
c25283c
fix duplicated workspace attribute in BotIntegration model
nikochiko Nov 4, 2024
20b2e99
Add migration for published run version change notes
nikochiko Nov 4, 2024
716f589
remove accidental changes when resolving conflicts
nikochiko Nov 4, 2024
3bcf906
remove unused import
nikochiko Nov 4, 2024
6aead4d
possessive -> possesive
nikochiko Nov 4, 2024
0473dcb
remove unused code
nikochiko Nov 4, 2024
215b93d
remove more unused code
nikochiko Nov 4, 2024
63d73b4
fix: get_url_path is not defined
nikochiko Nov 4, 2024
ced5288
remove unrelated formatter changes
nikochiko Nov 4, 2024
dcecd51
fix selected workspace bug in publish form
nikochiko Nov 4, 2024
eb53449
rearrange functions to make render_publish_form and clear_publish_for…
nikochiko Nov 4, 2024
6c4c19e
add placeholder for published_run_description, remove change notes fo…
nikochiko Nov 4, 2024
de8ec40
show workspace name after the breadcrumbs
nikochiko Nov 5, 2024
27f0bfc
remove stale uid and workspace_id variable assignment in history tab
nikochiko Nov 6, 2024
91974e3
fix: ui - don't wrap icons on members page
nikochiko Nov 7, 2024
5898361
use fontawesome icons for workspace roles
nikochiko Nov 7, 2024
faa7f14
Add link icon to share dialog
nikochiko Nov 7, 2024
edc80c7
fix: rewrite texts for saved tab under accounts
nikochiko Nov 7, 2024
be8c38d
Add workspace indicator on billing tab in accounts
nikochiko Nov 7, 2024
5e42349
fix: show workspace indicator on billing only when user has >1 worksp…
nikochiko Nov 7, 2024
e473991
feat: default name for new workspace should use `{company} name` if a…
nikochiko Nov 7, 2024
37eee92
set nowrap on column header `{logo} Invite Sent`
nikochiko Nov 7, 2024
7f12c41
add migration adding PublishedRunVisibility.INTERNAL
nikochiko Nov 7, 2024
550033c
Add change notes and add support for INTERNAL visibility for teams
nikochiko Nov 7, 2024
65470a7
Add author full name in breadcrumbs for team workspaces
nikochiko Nov 7, 2024
77073dc
move workspace creation dialog to workspaces/widgets.py
nikochiko Nov 7, 2024
a5df56e
small edits to workspace invitation form
nikochiko Nov 8, 2024
1bc02cc
Merge branch 'master' into workspace-usability
nikochiko Nov 12, 2024
0a27f1a
no api_hashids for workspace
nikochiko Nov 12, 2024
5bc3c42
remove unused funcs
nikochiko Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app_users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ def get_or_create_personal_workspace(self) -> tuple["Workspace", bool]:

return Workspace.objects.get_or_create_from_user(self)

def get_workspaces(self) -> models.QuerySet["Workspace"]:
from workspaces.models import Workspace

return Workspace.objects.filter(
memberships__user=self, memberships__deleted__isnull=True
)

def get_anonymous_token(self):
return auth.create_custom_token(self.uid).decode()

Expand Down
23 changes: 23 additions & 0 deletions bots/migrations/0087_alter_publishedrun_visibility_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.1.2 on 2024-11-07 16:31

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('bots', '0086_publishedrunversion_change_notes'),
]

operations = [
migrations.AlterField(
model_name='publishedrun',
name='visibility',
field=models.IntegerField(choices=[(1, 'Unlisted'), (2, 'Public'), (3, 'Internal')], default=1),
),
migrations.AlterField(
model_name='publishedrunversion',
name='visibility',
field=models.IntegerField(choices=[(1, 'Unlisted'), (2, 'Public'), (3, 'Internal')], default=1),
),
]
39 changes: 36 additions & 3 deletions bots/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
from app_users.models import AppUser
from bots.admin_links import open_in_new_tab
from bots.custom_fields import PostgresJSONEncoder, CustomURLField
from daras_ai_v2 import icons
from daras_ai_v2 import icons, urls
from daras_ai_v2.crypto import get_random_doc_id
from daras_ai_v2.fastapi_tricks import get_route_path
from daras_ai_v2.language_model import format_chat_entry
from functions.models import CalledFunctionResponse
from gooeysite.bg_db_conn import get_celery_result_db_safe
Expand All @@ -36,27 +37,58 @@
class PublishedRunVisibility(models.IntegerChoices):
UNLISTED = 1
PUBLIC = 2
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]
else:
# TODO: Add cls.PUBLIC when team-handles are added
return [cls.UNLISTED, cls.INTERNAL]

def help_text(self, workspace: typing.Optional["Workspace"] = None):
from routers.account import profile_route, saved_route

def help_text(self):
match self:
case PublishedRunVisibility.UNLISTED:
return f"{self.get_icon()} Only me + people with a link"
case PublishedRunVisibility.PUBLIC if workspace and workspace.is_personal:
user = workspace.created_by
if user.handle:
profile_url = user.handle.get_app_url()
pretty_profile_url = urls.remove_scheme(profile_url).rstrip("/")
return f'{self.get_icon()} Public on <a href="{pretty_profile_url}" target="_blank">{profile_url}</a>'
else:
edit_profile_url = get_route_path(profile_route)
return f'{self.get_icon()} Public on <a href="{edit_profile_url}" target="_blank">my profile page</a>'
case PublishedRunVisibility.PUBLIC:
return f"{self.get_icon()} Public"
case PublishedRunVisibility.INTERNAL if workspace:
saved_route_url = get_route_path(saved_route)
return f'{self.get_icon()} Members <a href="{saved_route_url}" target="_blank">can find</a> and edit'
case PublishedRunVisibility.INTERNAL:
return f"{self.get_icon()} Members can find and edit"

def get_icon(self):
match self:
case PublishedRunVisibility.UNLISTED:
return icons.lock
case PublishedRunVisibility.PUBLIC:
return icons.globe
case PublishedRunVisibility.INTERNAL:
return icons.company_solid

def get_badge_html(self):
def get_badge_html(self) -> str:
match self:
case PublishedRunVisibility.UNLISTED:
return f"{self.get_icon()} Private"
case PublishedRunVisibility.PUBLIC:
return f"{self.get_icon()} Public"
case PublishedRunVisibility.INTERNAL:
return f"{self.get_icon()} Internal"


class Platform(models.IntegerChoices):
Expand Down Expand Up @@ -1686,6 +1718,7 @@ def create_with_version(
title=title,
visibility=visibility,
notes=notes,
change_notes="First Version",
)
return pr

Expand Down
Loading
Loading