@@ -2,9 +2,10 @@ use editor::Editor;
22use futures:: channel:: oneshot;
33use gpui:: { AppContext , DismissEvent , Entity , EventEmitter , Focusable , Styled } ;
44use ui:: {
5- ActiveTheme , App , Context , DynamicSpacing , Headline , HeadlineSize , Icon , IconName , IconSize ,
6- InteractiveElement , IntoElement , ParentElement , Render , SharedString , StyledExt ,
7- StyledTypography , Window , div, h_flex, v_flex,
5+ ActiveTheme , AnyElement , App , Button , Clickable , Color , Context , DynamicSpacing , Headline ,
6+ HeadlineSize , Icon , IconName , IconSize , InteractiveElement , IntoElement , Label , LabelCommon ,
7+ LabelSize , ParentElement , Render , SharedString , StyledExt , StyledTypography , Window , div,
8+ h_flex, v_flex,
89} ;
910use workspace:: ModalView ;
1011
@@ -33,7 +34,7 @@ impl AskPassModal {
3334 ) -> Self {
3435 let editor = cx. new ( |cx| {
3536 let mut editor = Editor :: single_line ( window, cx) ;
36- if prompt. contains ( "yes/no" ) {
37+ if prompt. contains ( "yes/no" ) || prompt . contains ( "Username" ) {
3738 editor. set_masked ( false , cx) ;
3839 } else {
3940 editor. set_masked ( true , cx) ;
@@ -58,6 +59,36 @@ impl AskPassModal {
5859 }
5960 cx. emit ( DismissEvent ) ;
6061 }
62+
63+ fn render_hint ( & mut self , cx : & mut Context < Self > ) -> Option < AnyElement > {
64+ let color = cx. theme ( ) . status ( ) . info_background ;
65+ if ( self . prompt . contains ( "Password" ) || self . prompt . contains ( "Username" ) )
66+ && self . prompt . contains ( "github.com" )
67+ {
68+ return Some (
69+ div ( )
70+ . p_2 ( )
71+ . bg ( color)
72+ . border_t_1 ( )
73+ . border_color ( cx. theme ( ) . status ( ) . info_border )
74+ . child (
75+ h_flex ( ) . gap_2 ( )
76+ . child (
77+ Icon :: new ( IconName :: Github ) . size ( IconSize :: Small )
78+ )
79+ . child (
80+ Label :: new ( "You may need to configure git for Github." )
81+ . size ( LabelSize :: Small ) ,
82+ )
83+ . child ( Button :: new ( "learn-more" , "Learn more" ) . color ( Color :: Accent ) . label_size ( LabelSize :: Small ) . on_click ( |_, _, cx| {
84+ cx. open_url ( "https://docs.github.com/en/get-started/git-basics/set-up-git#authenticating-with-github-from-git" )
85+ } ) ) ,
86+ )
87+ . into_any_element ( ) ,
88+ ) ;
89+ }
90+ None
91+ }
6192}
6293
6394impl Render for AskPassModal {
@@ -68,9 +99,9 @@ impl Render for AskPassModal {
6899 . on_action ( cx. listener ( Self :: confirm) )
69100 . elevation_2 ( cx)
70101 . size_full ( )
71- . font_buffer ( cx)
72102 . child (
73103 h_flex ( )
104+ . font_buffer ( cx)
74105 . px ( DynamicSpacing :: Base12 . rems ( cx) )
75106 . pt ( DynamicSpacing :: Base08 . rems ( cx) )
76107 . pb ( DynamicSpacing :: Base04 . rems ( cx) )
@@ -86,6 +117,7 @@ impl Render for AskPassModal {
86117 )
87118 . child (
88119 div ( )
120+ . font_buffer ( cx)
89121 . text_buffer ( cx)
90122 . py_2 ( )
91123 . px_3 ( )
@@ -97,5 +129,6 @@ impl Render for AskPassModal {
97129 . child ( self . prompt . clone ( ) )
98130 . child ( self . editor . clone ( ) ) ,
99131 )
132+ . children ( self . render_hint ( cx) )
100133 }
101134}
0 commit comments