@@ -45,17 +45,17 @@ defmodule AlgoraWeb.Org.DashboardLive do
4545
4646 defp list_contributors ( _current_org ) , do: [ ]
4747
48- defp get_previewed_user ( % { last_context: "repo/" <> repo } = _current_org ) do
48+ defp get_previewed_user ( % { last_context: "repo/" <> repo } = current_org ) do
4949 case String . split ( repo , "/" ) do
5050 [ repo_owner , _repo_name ] ->
5151 Repo . one ( from u in User , where: u . provider_login == ^ repo_owner and not is_nil ( u . handle ) )
5252
5353 _ ->
54- nil
54+ current_org
5555 end
5656 end
5757
58- defp get_previewed_user ( _current_org ) , do: nil
58+ defp get_previewed_user ( current_org ) , do: current_org
5959
6060 @ impl true
6161 def mount ( _params , _session , % { assigns: % { live_action: :preview , current_org: nil } } = socket ) do
@@ -76,11 +76,11 @@ defmodule AlgoraWeb.Org.DashboardLive do
7676 _experts = Accounts . list_developers ( org_id: current_org . id , earnings_gt: Money . zero ( :USD ) )
7777 experts = [ ]
7878
79- installations = Workspace . list_installations_by ( connected_user_id: current_org . id , provider: "github" )
79+ installations = Workspace . list_installations_by ( connected_user_id: previewed_user . id , provider: "github" )
8080
8181 contributors = list_contributors ( current_org )
8282
83- matches = Algora.Settings . get_org_matches ( previewed_user || current_org )
83+ matches = Algora.Settings . get_org_matches ( previewed_user )
8484
8585 admins_last_active = Algora.Admin . admins_last_active ( )
8686
@@ -1094,32 +1094,35 @@ defmodule AlgoraWeb.Org.DashboardLive do
10941094 end
10951095
10961096 defp assign_achievements ( socket ) do
1097+ previewed_user = socket . assigns . previewed_user
10971098 current_org = socket . assigns . current_org
10981099
10991100 status_fns =
1100- case socket . assigns . previewed_user do
1101- nil ->
1102- [
1103- { & personalize_status / 1 , "Personalize Algora" , nil } ,
1104- { & complete_signup_status / 1 , "Complete signup" , nil } ,
1105- { & connect_github_status / 1 , "Connect GitHub" , nil } ,
1106- { & install_app_status / 1 , "Install Algora in #{ current_org . name } " , nil } ,
1107- { & create_bounty_status / 1 , "Create a bounty" , nil } ,
1108- { & reward_bounty_status / 1 , "Reward a bounty" , nil } ,
1109- { & create_contract_status / 1 , "Contract a developer" ,
1110- if ( current_org . handle , do: [ patch: ~p" /#{ current_org . handle } /dashboard?action=create_contract" ] ) } ,
1111- { & embed_algora_status / 1 , "Embed Algora" , "/docs/embed/sdk" } ,
1112- { & share_with_friend_status / 1 , "Share Algora with a friend" , nil }
1113- ]
1114-
1115- _ ->
1116- [
1117- { & complete_signin_status / 1 , "Sign in to your account" , nil } ,
1118- { & create_contract_status / 1 , "Contract a developer" ,
1119- if ( current_org . handle , do: [ patch: ~p" /#{ current_org . handle } /dashboard?action=create_contract" ] ) } ,
1120- { & embed_algora_status / 1 , "Embed Algora" , "/docs/embed/sdk" } ,
1121- { & share_with_friend_status / 1 , "Share Algora with a friend" , nil }
1122- ]
1101+ if previewed_user == current_org do
1102+ [
1103+ { & personalize_status / 1 , "Personalize Algora" , nil } ,
1104+ { & complete_signup_status / 1 , "Complete signup" , nil } ,
1105+ { & connect_github_status / 1 , "Connect GitHub" , nil } ,
1106+ { & install_app_status / 1 , "Install Algora in #{ previewed_user . name } " , nil } ,
1107+ { & create_bounty_status / 1 , "Create a bounty" , nil } ,
1108+ { & reward_bounty_status / 1 , "Reward a bounty" , nil } ,
1109+ { & create_contract_status / 1 , "Contract a developer" ,
1110+ if ( previewed_user . handle , do: [ patch: ~p" /#{ previewed_user . handle } /dashboard?action=create_contract" ] ) } ,
1111+ { & embed_algora_status / 1 , "Embed Algora" , "/docs/embed/sdk" } ,
1112+ { & share_with_friend_status / 1 , "Share Algora with a friend" , nil }
1113+ ]
1114+ else
1115+ [
1116+ { & complete_signin_status / 1 , "Sign in to your account" , nil } ,
1117+ { & connect_github_status / 1 , "Connect GitHub" , nil } ,
1118+ { & install_app_status / 1 , "Install Algora in #{ previewed_user . name } " , nil } ,
1119+ { & create_bounty_status / 1 , "Create a bounty" , nil } ,
1120+ { & reward_bounty_status / 1 , "Reward a bounty" , nil } ,
1121+ { & create_contract_status / 1 , "Contract a developer" ,
1122+ if ( previewed_user . handle , do: [ patch: ~p" /#{ previewed_user . handle } /dashboard?action=create_contract" ] ) } ,
1123+ { & embed_algora_status / 1 , "Embed Algora" , "/docs/embed/sdk" } ,
1124+ { & share_with_friend_status / 1 , "Share Algora with a friend" , nil }
1125+ ]
11231126 end
11241127
11251128 { achievements , _ } =
@@ -1175,14 +1178,14 @@ defmodule AlgoraWeb.Org.DashboardLive do
11751178 end
11761179
11771180 defp create_bounty_status ( socket ) do
1178- case Bounties . list_bounties ( owner_id: socket . assigns . current_org . id , limit: 1 ) do
1181+ case Bounties . list_bounties ( owner_id: socket . assigns . previewed_user . id , limit: 1 ) do
11791182 [ ] -> :upcoming
11801183 _ -> :completed
11811184 end
11821185 end
11831186
11841187 defp reward_bounty_status ( socket ) do
1185- case Bounties . list_bounties ( owner_id: socket . assigns . current_org . id , status: :paid , limit: 1 ) do
1188+ case Bounties . list_bounties ( owner_id: socket . assigns . previewed_user . id , status: :paid , limit: 1 ) do
11861189 [ ] -> :upcoming
11871190 _ -> :completed
11881191 end
@@ -1559,7 +1562,7 @@ defmodule AlgoraWeb.Org.DashboardLive do
15591562 < aside class = "scrollbar-thin fixed top-16 right-0 bottom-0 hidden w-96 h-full overflow-y-auto border-l border-border bg-background p-4 pt-6 sm:p-6 md:p-8 lg:flex lg:flex-col " >
15601563 < div :if = { length ( @ achievements ) > 1 } class = "pb-12 " >
15611564 < h2 class = "text-xl font-semibold leading-none tracking-tight " >
1562- <%= if @ previewed_user do %>
1565+ <%= if @ previewed_user != @ current_org do %>
15631566 Get back in
15641567 <% else %>
15651568 Getting started
0 commit comments