@@ -31,7 +31,8 @@ defmodule AlgoraWeb.Org.PreviewNav do
31
31
|> assign ( :current_user_role , :admin )
32
32
|> assign ( :nav , nav_items ( repo_owner , repo_name ) )
33
33
|> assign ( :contacts , [ ] )
34
- |> attach_hook ( :active_tab , :handle_params , & handle_active_tab_params / 3 ) }
34
+ |> attach_hook ( :active_tab , :handle_params , & handle_active_tab_params / 3 )
35
+ |> attach_hook ( :handle_event , :handle_event , & handle_event / 3 ) }
35
36
36
37
{ :error , reason } ->
37
38
Logger . error ( "Failed to restore preview state for #{ repo_owner } /#{ repo_name } : #{ inspect ( reason ) } " )
@@ -53,6 +54,7 @@ defmodule AlgoraWeb.Org.PreviewNav do
53
54
|> assign ( :nav , nav_items ( repo_owner , repo_name ) )
54
55
|> assign ( :contacts , [ ] )
55
56
|> attach_hook ( :active_tab , :handle_params , & handle_active_tab_params / 3 )
57
+ |> attach_hook ( :handle_event , :handle_event , & handle_event / 3 )
56
58
57
59
# checking if the socket is connected to avoid redirect loop that prevents og image from being fetched
58
60
if ( current_context && current_context . last_context == "repo/#{ repo_owner } /#{ repo_name } " ) ||
@@ -97,6 +99,34 @@ defmodule AlgoraWeb.Org.PreviewNav do
97
99
end
98
100
end
99
101
102
+ defp handle_event ( "create_contract_main" , % { "contract_form" => _params } , socket ) do
103
+ { :cont , put_flash ( socket , :warning , "Please sign in to create your contract" ) }
104
+ end
105
+
106
+ defp handle_event ( "create_bounty_main" , % { "bounty_form" => _params } , socket ) do
107
+ { :cont , put_flash ( socket , :warning , "Please sign in to create your bounty" ) }
108
+ end
109
+
110
+ defp handle_event ( "open_main_bounty_form" , _params , socket ) do
111
+ { :cont , assign ( socket , :main_bounty_form_open? , true ) }
112
+ end
113
+
114
+ defp handle_event ( "close_main_bounty_form" , _params , socket ) do
115
+ { :cont , assign ( socket , :main_bounty_form_open? , false ) }
116
+ end
117
+
118
+ defp handle_event ( "open_main_contract_form" , _params , socket ) do
119
+ { :cont , assign ( socket , :main_contract_form_open? , true ) }
120
+ end
121
+
122
+ defp handle_event ( "close_main_contract_form" , _params , socket ) do
123
+ { :cont , assign ( socket , :main_contract_form_open? , false ) }
124
+ end
125
+
126
+ defp handle_event ( _event , _params , socket ) do
127
+ { :cont , socket }
128
+ end
129
+
100
130
defp handle_active_tab_params ( _params , _url , socket ) do
101
131
active_tab =
102
132
case { socket . view , socket . assigns . live_action } do
0 commit comments