Skip to content

Conversation

aleDsz
Copy link
Member

@aleDsz aleDsz commented Aug 11, 2025

No description provided.

hugobarauna and others added 8 commits August 5, 2025 15:46
Implement UI for deployment group access control that shows
all deployment groups but disables unauthorized ones. Features include:

- Tooltip explaining authorization restrictions
- Block cursor and disabled click handling
- Mock authorization logic (production/staging disabled)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@aleDsz aleDsz self-assigned this Aug 11, 2025
Copy link
Contributor

@josevalim josevalim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just some nits!

Deploys the given app deployment to given deployment group using a deploy key.
"""
@spec authorized_user_to_deploy?(Team.t(), Teams.DeploymentGroup.t()) :: boolean()
def authorized_user_to_deploy?(%Team{} = team, %Teams.DeploymentGroup{} = deployment_group) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def authorized_user_to_deploy?(%Team{} = team, %Teams.DeploymentGroup{} = deployment_group) do
def user_can_deploy?(%Team{} = team, %Teams.DeploymentGroup{} = deployment_group) do

@@ -34,6 +34,7 @@ defmodule Livebook.Teams.Broadcasts do
* `{:deployment_group_created, DeploymentGroup.t()}`
* `{:deployment_group_updated, DeploymentGroup.t()}`
* `{:deployment_group_deleted, DeploymentGroup.t()}`
* `{:deployment_authorization_updated, DeploymentGroup.t()}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think authorisation here can be ambiguous. Perhaps one can think it is about the authorized users? What about:

Suggested change
* `{:deployment_authorization_updated, DeploymentGroup.t()}`
* `{:deployment_users_updated, DeploymentGroup.t()}`

if(@active,
do: "border-blue-600 bg-blue-50",
else: "border-gray-200"
)
),
!@authorized && "opacity-50 bg-gray-50"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind the order specified in "class" does not matter. Therefore, there is no guarantee bg-gray-50 will override the ones above. You need to replace the above into a cond instead:

cond do
  !@authorized -> "tooltip top select_deployment_group"
  @active -> "border-blue-600 bg-blue-50"
  true -> "border-gray-200"
end

Comment on lines 316 to 317
@selectable && @authorized && "cursor-pointer",
@selectable && !@authorized && "cursor-not-allowed",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@selectable && @authorized && "cursor-pointer",
@selectable && !@authorized && "cursor-not-allowed",
@selectable && if(@authorized, do: "cursor-pointer", else: "cursor-not-allowed"),

]}
phx-click={@selectable && "select_deployment_group"}
style={!@authorized && "display: block !important;"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to not use style=? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I forgot to change to class

Comment on lines 171 to 174
def authorized_user_to_deploy?(id, user_id, deployment_group_id) do
GenServer.call(
registry_name(id),
{:check_deployment_authorization, user_id, deployment_group_id}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, if you want another name, you could call it this:

Suggested change
def authorized_user_to_deploy?(id, user_id, deployment_group_id) do
GenServer.call(
registry_name(id),
{:check_deployment_authorization, user_id, deployment_group_id}
def user_can_deploy?(id, user_id, deployment_group_id) do
GenServer.call(
registry_name(id),
{:user_can_deploy?, user_id, deployment_group_id}

It is shorter and reads a bit nicer. :)

Comment on lines 750 to 761
state.deployment_group_id == deployment_group.id and
(current_deployment_group.authorization_groups !=
deployment_group.authorization_groups or
current_deployment_group.groups_auth != deployment_group.groups_auth or
current_deployment_group.teams_auth != deployment_group.teams_auth) ->
Teams.Broadcasts.server_authorization_updated(deployment_group)

state.deployment_group_id == nil and
(current_deployment_group.deployment_users !=
deployment_group.deployment_users or
current_deployment_group.deploy_auth != deployment_group.deploy_auth) ->
Teams.Broadcasts.deployment_authorization_updated(deployment_group)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically both clauses could be the case? The current UI may imply that only one of these is true at a time, but we could not make this assumption and have two separate ifs instead?

@aleDsz aleDsz requested a review from jonatanklosko August 12, 2025 16:21
@aleDsz aleDsz changed the title Implement authorization to deploy apps for Teams' users Implement authorization to deploy apps Aug 12, 2025
Copy link
Member

@jonatanklosko jonatanklosko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@aleDsz aleDsz merged commit 9043edb into main Aug 14, 2025
4 checks passed
@hugobarauna hugobarauna deleted the hb-deploy-authz-ui-prototype branch August 18, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants