@@ -45,17 +45,17 @@ defmodule AlgoraWeb.Org.DashboardLive do
45
45
46
46
defp list_contributors ( _current_org ) , do: [ ]
47
47
48
- defp get_previewed_user ( % { last_context: "repo/" <> repo } = _current_org ) do
48
+ defp get_previewed_user ( % { last_context: "repo/" <> repo } = current_org ) do
49
49
case String . split ( repo , "/" ) do
50
50
[ repo_owner , _repo_name ] ->
51
51
Repo . one ( from u in User , where: u . provider_login == ^ repo_owner and not is_nil ( u . handle ) )
52
52
53
53
_ ->
54
- nil
54
+ current_org
55
55
end
56
56
end
57
57
58
- defp get_previewed_user ( _current_org ) , do: nil
58
+ defp get_previewed_user ( current_org ) , do: current_org
59
59
60
60
@ impl true
61
61
def mount ( _params , _session , % { assigns: % { live_action: :preview , current_org: nil } } = socket ) do
@@ -76,11 +76,11 @@ defmodule AlgoraWeb.Org.DashboardLive do
76
76
_experts = Accounts . list_developers ( org_id: current_org . id , earnings_gt: Money . zero ( :USD ) )
77
77
experts = [ ]
78
78
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" )
80
80
81
81
contributors = list_contributors ( current_org )
82
82
83
- matches = Algora.Settings . get_org_matches ( previewed_user || current_org )
83
+ matches = Algora.Settings . get_org_matches ( previewed_user )
84
84
85
85
admins_last_active = Algora.Admin . admins_last_active ( )
86
86
@@ -1094,32 +1094,35 @@ defmodule AlgoraWeb.Org.DashboardLive do
1094
1094
end
1095
1095
1096
1096
defp assign_achievements ( socket ) do
1097
+ previewed_user = socket . assigns . previewed_user
1097
1098
current_org = socket . assigns . current_org
1098
1099
1099
1100
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
+ ]
1123
1126
end
1124
1127
1125
1128
{ achievements , _ } =
@@ -1175,14 +1178,14 @@ defmodule AlgoraWeb.Org.DashboardLive do
1175
1178
end
1176
1179
1177
1180
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
1179
1182
[ ] -> :upcoming
1180
1183
_ -> :completed
1181
1184
end
1182
1185
end
1183
1186
1184
1187
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
1186
1189
[ ] -> :upcoming
1187
1190
_ -> :completed
1188
1191
end
@@ -1559,7 +1562,7 @@ defmodule AlgoraWeb.Org.DashboardLive do
1559
1562
< 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 " >
1560
1563
< div :if = { length ( @ achievements ) > 1 } class = "pb-12 " >
1561
1564
< h2 class = "text-xl font-semibold leading-none tracking-tight " >
1562
- <%= if @ previewed_user do %>
1565
+ <%= if @ previewed_user != @ current_org do %>
1563
1566
Get back in
1564
1567
<% else %>
1565
1568
Getting started
0 commit comments