From cd2e2f9a75256c330d76781a5a017cac42df9f72 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 11:33:18 +0700 Subject: [PATCH 01/42] [#16] Add UI for Sign In view --- app/views/devise/sessions/new.html.erb | 56 +++++++++++++++----------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 5ede9648..686b665a 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,26 +1,34 @@ -

Log in

- -<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> -
- -
- <%= f.label :password %>
- <%= f.password_field :password, autocomplete: "current-password" %> -
- - <% if devise_mapping.rememberable? %> -
- <%= f.check_box :remember_me %> - <%= f.label :remember_me %> +
+
+
+
+
+ <%= link_to 'Sign up', new_registration_path(resource_name), class: 'float-right btn btn-outline-primary' %> +

Sign in

+ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %> +
+
+ <%= link_to 'Forgot your password?', new_password_path(resource_name), class:'float-right' %>
+ <%= f.label :password %>
+ <%= f.password_field :password, autocomplete: 'current-password', class: 'form-control' %> +
+
+ <% if devise_mapping.rememberable? %> +
+ <%= f.check_box :remember_me %> + <%= f.label :remember_me %> +
+
+ <% end %> +
+ <%= f.submit 'Sign in', class: 'btn btn-primary btn-block' %> +
+ <% end %> +
+
- <% end %> - -
- <%= f.submit "Log in" %>
-<% end %> - -<%= render "devise/shared/links" %> +
From e12fbed6c235bb121787adecadf95b4faa3f3409 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 11:33:41 +0700 Subject: [PATCH 02/42] [#16] Add basic navbar for unauthenticated user --- app/assets/images/logo.svg | 1 + app/views/layouts/application.html.erb | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 app/assets/images/logo.svg diff --git a/app/assets/images/logo.svg b/app/assets/images/logo.svg new file mode 100644 index 00000000..432084d1 --- /dev/null +++ b/app/assets/images/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c9e413bb..c9eec24c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ - GoogleSearchRuby + Google Search Ruby <%= csrf_meta_tags %> <%= csp_meta_tag %> @@ -13,6 +13,13 @@ <% if user_signed_in? %> <%= button_to t('logout'), destroy_user_session_path, method: :delete %> + <% else %> + <% end %>

<%= notice %>

<%= alert %>

From f2b09d57afc0184517f3ae2db7630d8654528dbe Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 11:45:16 +0700 Subject: [PATCH 03/42] [#16] Add UI for alert and notice messages --- app/views/layouts/application.html.erb | 40 +++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c9eec24c..2866c68c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,5 +1,29 @@ + + <% if user_signed_in? %> + <%= button_to t('logout'), destroy_user_session_path, method: :delete %> + <% else %> + + <% end %> +
+
+ <% if notice %> +

<%= notice %>

+ <% end %> + <% if alert %> +

<%= alert %>

+ <% end %> +
+
+ <%= yield %> + + Google Search Ruby @@ -9,20 +33,4 @@ <%= stylesheet_link_tag 'application', media: 'all' %> <%= javascript_pack_tag 'application' %> - - - <% if user_signed_in? %> - <%= button_to t('logout'), destroy_user_session_path, method: :delete %> - <% else %> - - <% end %> -

<%= notice %>

-

<%= alert %>

- <%= yield %> - From 57ddc5d06bee0a9486966010f78d1d3ea03e6b94 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 11:54:51 +0700 Subject: [PATCH 04/42] [#16] Fix semantic issue in sign in view --- app/views/devise/sessions/new.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 686b665a..35e88d9d 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -2,7 +2,7 @@
-
+
<%= link_to 'Sign up', new_registration_path(resource_name), class: 'float-right btn btn-outline-primary' %>

Sign in

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> @@ -21,13 +21,13 @@ <%= f.check_box :remember_me %> <%= f.label :remember_me %>
-
<% end %> -
- <%= f.submit 'Sign in', class: 'btn btn-primary btn-block' %> +
+
+ <%= f.submit 'Sign in', class: 'btn btn-primary btn-block' %>
<% end %> - +
From 8150621a21c5908b833084e155155e390bd1fb15 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 11:58:03 +0700 Subject: [PATCH 05/42] [#16] Add UI for Sign Up view --- app/views/devise/registrations/new.html.erb | 80 +++++++++++---------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 2a4fe044..2c62e4da 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,39 +1,43 @@ -

Sign up

- -<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= render "devise/shared/error_messages", resource: resource %> - -
- <%= f.label :first_name %>
- <%= f.text_field :first_name, autofocus: true %> -
- -
- <%= f.label :last_name %>
- <%= f.text_field :last_name %> +
+
+
+
+
+ <%= link_to 'Sign in', new_session_path(resource_name), class: 'float-right btn btn-outline-primary' %> +

Sign up

+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> + + <%= render "devise/shared/error_messages", resource: resource %> + +
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name, autofocus: true, class: 'form-control' %> +
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name, class: 'form-control' %> +
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autocomplete: 'email', class: 'form-control' %> +
+
+ <%= f.label :password %>
+ <% if @minimum_password_length %> + (<%= @minimum_password_length %> characters minimum) + <% end %>
+ <%= f.password_field :password, autocomplete: 'new-password', class: 'form-control' %> +
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %> +
+
+ <%= f.submit 'Sign up', class: 'btn btn-primary btn-block' %> +
+ <% end %> +
+
+
- -
- <%= f.label :email %>
- <%= f.email_field :email, autocomplete: "email" %> -
- -
- <%= f.label :password %> - <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum) - <% end %>
- <%= f.password_field :password, autocomplete: "new-password" %> -
- -
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %> -
- -
- <%= f.submit "Sign up" %> -
-<% end %> - -<%= render "devise/shared/links" %> +
From b14e8c0ce2dbd3dda99e712455fee66a65298935 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 13:19:43 +0700 Subject: [PATCH 06/42] [#16] Add nav bar for authenticated users --- app/views/layouts/application.html.erb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2866c68c..4897f6ba 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,16 +1,15 @@ - <% if user_signed_in? %> - <%= button_to t('logout'), destroy_user_session_path, method: :delete %> - <% else %> - - <% end %> +
<% if notice %> From 63e742bc8ec06a5d1a5054d6535588ebd6e50809 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 13:20:05 +0700 Subject: [PATCH 07/42] [#16] Add UI to Users/edit view --- app/views/devise/registrations/edit.html.erb | 105 +++++++++++-------- 1 file changed, 62 insertions(+), 43 deletions(-) diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3bfea996..803638c8 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,53 +1,72 @@ -

Edit <%= resource_name.to_s.humanize %>

+
+
+
+
+
+

Edit <%= resource_name.to_s.humanize %>

-<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> - <%= render "devise/shared/error_messages", resource: resource %> + <%= form_for(resource, as: resource_name, + url: registration_path(resource_name), html: { method: :put }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> -
- <%= f.label :first_name %>
- <%= f.text_field :first_name, autofocus: true %> -
+
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name, autofocus: true, class: 'form-control' %> +
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name, class: 'form-control' %> +
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autocomplete: 'email', class: 'form-control' %> +
-
- <%= f.label :last_name %>
- <%= f.text_field :last_name %> -
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> +
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+ <% end %> -
- <%= f.label :email %>
- <%= f.email_field :email, autocomplete: "email" %> -
+
+ <%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, autocomplete: "new-password", class: 'form-control' %> + <% if @minimum_password_length %> +
+ <%= @minimum_password_length %> characters minimum + <% end %> +
- <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> -
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
- <% end %> - -
- <%= f.label :password %> (leave blank if you don't want to change it)
- <%= f.password_field :password, autocomplete: "new-password" %> - <% if @minimum_password_length %> -
- <%= @minimum_password_length %> characters minimum - <% end %> -
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %> +
-
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %> -
+
+ <%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control' %> +
-
- <%= f.label :current_password %> (we need your current password to confirm your changes)
- <%= f.password_field :current_password, autocomplete: "current-password" %> +
+ <%= f.submit 'Update', class:'btn btn-primary btn-block' %> +
+ <% end %> +
+
+
+
+
+
+
+

Cancel my account

-
- <%= f.submit "Update" %> +

Unhappy? 🥺

+ <%= button_to "Cancel my account", + registration_path(resource_name), + data: { confirm: "Are you sure?" }, + method: :delete, + class:'btn btn-danger btn-block' %> +
+
+
-<% end %> - -

Cancel my account

- -

Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>

- -<%= link_to "Back", :back %> +
From 257b239b68de35560f992244db2fc0decb24fb10 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 14:01:01 +0700 Subject: [PATCH 08/42] [#16] Add responsiveness to user edit view --- app/views/devise/registrations/edit.html.erb | 89 +++++++++++++------- 1 file changed, 57 insertions(+), 32 deletions(-) diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 803638c8..9149debd 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,6 +1,6 @@
-
+

Edit <%= resource_name.to_s.humanize %>

@@ -8,45 +8,70 @@ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> <%= render "devise/shared/error_messages", resource: resource %> - -
- <%= f.label :first_name %>
- <%= f.text_field :first_name, autofocus: true, class: 'form-control' %> +
+
+
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name, autofocus: true, class: 'form-control' %> +
+
+
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name, class: 'form-control' %> +
+
-
- <%= f.label :last_name %>
- <%= f.text_field :last_name, class: 'form-control' %> +
+
+ <%= f.label :email %> +
+ <%= f.email_field :email, autocomplete: 'email', class: 'form-control' %> +
+ + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> +
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+ <% end %> +
+
+
+ <%= f.label :current_password %> + <%= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control' %> +
+
-
- <%= f.label :email %>
- <%= f.email_field :email, autocomplete: 'email', class: 'form-control' %> + - - <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> -
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
- <% end %> - -
- <%= f.label :password %> (leave blank if you don't want to change it)
- <%= f.password_field :password, autocomplete: "new-password", class: 'form-control' %> +
<% if @minimum_password_length %> -
<%= @minimum_password_length %> characters minimum <% end %> -
- -
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %> -
- -
- <%= f.label :current_password %> (we need your current password to confirm your changes)
- <%= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control' %> +
+
+
+ <%= f.label :password %>
+ <%= f.password_field :password, autocomplete: "new-password", class: 'form-control' %> +
+
+
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %> +
+
+
- <%= f.submit 'Update', class:'btn btn-primary btn-block' %> + <%= f.submit 'Update', class: 'btn btn-primary btn-block' %>
<% end %>
@@ -64,7 +89,7 @@ registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete, - class:'btn btn-danger btn-block' %> + class: 'btn btn-danger btn-block' %>
From 40b078d011cc3eddc709f523f8e0fc510bd5f279 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 14:18:02 +0700 Subject: [PATCH 09/42] [#16] Use translation locales --- app/views/devise/registrations/edit.html.erb | 12 ++++++------ app/views/devise/registrations/new.html.erb | 6 +++--- app/views/devise/sessions/new.html.erb | 7 ++++--- app/views/layouts/application.html.erb | 2 +- config/locales/en.yml | 12 +++++++++++- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 9149debd..15ce32e2 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -30,7 +30,7 @@
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> -
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+
<%= t('waiting_confirmation_for') %>: <%= resource.unconfirmed_email %>
<% end %>
@@ -52,7 +52,7 @@
<% if @minimum_password_length %> - <%= @minimum_password_length %> characters minimum + (<%= "#{@minimum_password_length} #{t('min_char')}" %>) <% end %>
@@ -71,7 +71,7 @@
- <%= f.submit 'Update', class: 'btn btn-primary btn-block' %> + <%= f.submit t('update'), class: 'btn btn-primary btn-block' %>
<% end %> @@ -84,10 +84,10 @@

Cancel my account

-

Unhappy? 🥺

- <%= button_to "Cancel my account", +

<%= t('unhappy') %>? 🥺

+ <%= button_to t('auth.cancel_my_account'), registration_path(resource_name), - data: { confirm: "Are you sure?" }, + data: { confirm: t('confirm') }, method: :delete, class: 'btn btn-danger btn-block' %>
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 2c62e4da..0b71708a 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -3,7 +3,7 @@
- <%= link_to 'Sign in', new_session_path(resource_name), class: 'float-right btn btn-outline-primary' %> + <%= link_to t('auth.sign_in'), new_session_path(resource_name), class: 'float-right btn btn-outline-primary' %>

Sign up

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> @@ -24,7 +24,7 @@
<%= f.label :password %>
<% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum) + (<%= "#{@minimum_password_length} #{t('min_char')}" %>) <% end %>
<%= f.password_field :password, autocomplete: 'new-password', class: 'form-control' %>
@@ -33,7 +33,7 @@ <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %>
- <%= f.submit 'Sign up', class: 'btn btn-primary btn-block' %> + <%= f.submit t('auth.sign_up'), class: 'btn btn-primary btn-block' %>
<% end %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 35e88d9d..f59a2ec7 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -3,7 +3,8 @@
- <%= link_to 'Sign up', new_registration_path(resource_name), class: 'float-right btn btn-outline-primary' %> + <%= link_to t('auth.sign_up'), new_registration_path(resource_name), + class: 'float-right btn btn-outline-primary' %>

Sign in

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
@@ -11,7 +12,7 @@ <%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
- <%= link_to 'Forgot your password?', new_password_path(resource_name), class:'float-right' %>
+ <%= link_to t('forgot_password'), new_password_path(resource_name), class:'float-right' %>
<%= f.label :password %>
<%= f.password_field :password, autocomplete: 'current-password', class: 'form-control' %>
@@ -24,7 +25,7 @@ <% end %>
- <%= f.submit 'Sign in', class: 'btn btn-primary btn-block' %> + <%= f.submit t('auth.sign_in'), class: 'btn btn-primary btn-block' %>
<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 4897f6ba..98ac5c89 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,7 +7,7 @@ Google Search Ruby <% if user_signed_in? %> - <%= button_to t('logout'), destroy_user_session_path, method: :delete, class:'btn btn-link' %> + <%= button_to t('auth.logout'), destroy_user_session_path, method: :delete, class:'btn btn-link' %> <% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 14ffadfb..2d6245a8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,4 +30,14 @@ # available at https://guides.rubyonrails.org/i18n.html. en: - logout: "Sign out" + auth: + logout: 'Sign out' + sign_up: 'Sign up' + sign_in: 'Sign in' + cancel_my_account: 'Cancel my account' + min_char: 'characters minimum' + confirm: 'Are you sure?' + update: 'Update' + unhappy: 'Unhappy' + waiting_confirmation_for: 'Currently waiting confirmation for' + forgot_password: 'Forgot your password?' From b3360eeef5d78253b8c8362627476f4562fe91c1 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 14:37:03 +0700 Subject: [PATCH 10/42] [#16] Remove rspec exceptions when asset is missing in test pipeline --- config/environments/test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/environments/test.rb b/config/environments/test.rb index b21e485d..3c34aede 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -78,4 +78,5 @@ # Do not fallback to assets pipeline if a precompiled asset is missing. config.assets.compile = false + config.assets.unknown_asset_fallback = false end From ca268d6fd1b917e1cd1603488bdc5998ec3a272f Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 14:40:15 +0700 Subject: [PATCH 11/42] [#16] Fix tests due to Log In button renamed in Sign In --- spec/support/authentication_helper.rb | 2 +- spec/systems/signup_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/support/authentication_helper.rb b/spec/support/authentication_helper.rb index 7a9ffded..39b44b89 100644 --- a/spec/support/authentication_helper.rb +++ b/spec/support/authentication_helper.rb @@ -16,7 +16,7 @@ def sign_in_ui(user = nil) fill_in 'user_email', with: user.email fill_in 'user_password', with: user.password - click_button 'Log in' + click_button 'Sign in' end def sign_in(user) diff --git a/spec/systems/signup_spec.rb b/spec/systems/signup_spec.rb index 8cb5e2f9..1db60d48 100644 --- a/spec/systems/signup_spec.rb +++ b/spec/systems/signup_spec.rb @@ -57,7 +57,7 @@ context 'when an authenticated user reaches the sign up page' do it 'redirects him to the root_page' do - sign_in_ui + sign_in(Fabricate(:user)) visit new_user_registration_path expect(page).to have_current_path(root_path) From 72e98d3ca1e25295ce82d0aa0860e455e48a3a30 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 15:16:33 +0700 Subject: [PATCH 12/42] [#16] Add My Profile link to navbar --- app/views/layouts/application.html.erb | 71 ++++++++++++++++---------- config/locales/en.yml | 2 + 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 98ac5c89..d6db64bd 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,35 +1,54 @@ - -
-
- <% if notice %> -

<%= notice %>

- <% end %> - <% if alert %> -

<%= alert %>

- <% end %> + +
+
+ <% if notice %> +

<%= notice %>

+ <% end %> + <% if alert %> +

<%= alert %>

+ <% end %>
- <%= yield %> +
+<%= yield %> - - Google Search Ruby - - <%= csrf_meta_tags %> - <%= csp_meta_tag %> + + Google Search Ruby + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> - <%= stylesheet_link_tag 'application', media: 'all' %> - <%= javascript_pack_tag 'application' %> - + <%= stylesheet_link_tag 'application', media: 'all' %> + <%= javascript_pack_tag 'application' %> + diff --git a/config/locales/en.yml b/config/locales/en.yml index 2d6245a8..50e76d0c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,6 +30,7 @@ # available at https://guides.rubyonrails.org/i18n.html. en: + app_name: 'Google Search Ruby' auth: logout: 'Sign out' sign_up: 'Sign up' @@ -41,3 +42,4 @@ en: unhappy: 'Unhappy' waiting_confirmation_for: 'Currently waiting confirmation for' forgot_password: 'Forgot your password?' + my_profile: 'My Profile' From 4785ee4476c93c95dca3149d332db50f27b2e655 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 15:38:32 +0700 Subject: [PATCH 13/42] [#16] Add Footer UI --- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/components/.keep | 0 app/assets/stylesheets/components/footer.scss | 8 ++ app/views/layouts/application.html.erb | 97 +++++++++++-------- 4 files changed, 63 insertions(+), 43 deletions(-) delete mode 100644 app/assets/stylesheets/components/.keep create mode 100644 app/assets/stylesheets/components/footer.scss diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 44acc398..fa0921c1 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -14,5 +14,6 @@ // Layouts // Components +@import 'components/footer'; // Screens diff --git a/app/assets/stylesheets/components/.keep b/app/assets/stylesheets/components/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/assets/stylesheets/components/footer.scss b/app/assets/stylesheets/components/footer.scss new file mode 100644 index 00000000..0d522d98 --- /dev/null +++ b/app/assets/stylesheets/components/footer.scss @@ -0,0 +1,8 @@ +footer { + position: absolute; + bottom: 0; + width: 100%; + height: 60px; + line-height: 60px; + background-color: #f5f5f5; +} diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d6db64bd..dbe0a6ee 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,49 +1,7 @@ - - -
-
- <% if notice %> -

<%= notice %>

- <% end %> - <% if alert %> -

<%= alert %>

- <% end %> -
-
-<%= yield %> - - - Google Search Ruby + <%= t('app_name') %> <%= csrf_meta_tags %> <%= csp_meta_tag %> @@ -51,4 +9,57 @@ <%= stylesheet_link_tag 'application', media: 'all' %> <%= javascript_pack_tag 'application' %> + +
+ +
+
+
+
+ <% if notice %> +

<%= notice %>

+ <% end %> + <% if alert %> +

<%= alert %>

+ <% end %> +
+
+ <%= yield %> +
+
+
+ + This project is a Ruby/Rails Internal Certification for + <%= link_to 'Nimble', "https://nimblehq.co/", target: "_blank" %>. + +
+
+ From decca3e09b449acddc286ec4ec7d31d35fce778c Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 15:44:35 +0700 Subject: [PATCH 14/42] [#16] Extract header and footer in partial views --- app/views/layouts/_footer.html.erb | 8 ++++++ app/views/layouts/_header.html.erb | 30 +++++++++++++++++++ app/views/layouts/application.html.erb | 40 ++------------------------ 3 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 app/views/layouts/_footer.html.erb create mode 100644 app/views/layouts/_header.html.erb diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb new file mode 100644 index 00000000..031347af --- /dev/null +++ b/app/views/layouts/_footer.html.erb @@ -0,0 +1,8 @@ +
+
+ + This project is a Ruby/Rails Internal Certification for + <%= link_to 'Nimble', "https://nimblehq.co/", target: "_blank" %>. + +
+
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb new file mode 100644 index 00000000..761412eb --- /dev/null +++ b/app/views/layouts/_header.html.erb @@ -0,0 +1,30 @@ +
+ +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index dbe0a6ee..5cccb9b9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,36 +10,7 @@ <%= javascript_pack_tag 'application' %> -
- -
+<%= render 'layouts/header' %>
@@ -53,13 +24,6 @@
<%= yield %>
-
-
- - This project is a Ruby/Rails Internal Certification for - <%= link_to 'Nimble', "https://nimblehq.co/", target: "_blank" %>. - -
-
+<%= render 'layouts/footer' %> From 0a2bd62c097a052d2ecb4d2de40a9f30c2934999 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 15:56:38 +0700 Subject: [PATCH 15/42] [#16] Update footer to use flex --- app/assets/stylesheets/components/footer.scss | 2 -- app/views/layouts/application.html.erb | 30 ++++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/components/footer.scss b/app/assets/stylesheets/components/footer.scss index 0d522d98..af31247f 100644 --- a/app/assets/stylesheets/components/footer.scss +++ b/app/assets/stylesheets/components/footer.scss @@ -1,6 +1,4 @@ footer { - position: absolute; - bottom: 0; width: 100%; height: 60px; line-height: 60px; diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5cccb9b9..959eccc2 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,20 +10,22 @@ <%= javascript_pack_tag 'application' %> -<%= render 'layouts/header' %> -
-
-
- <% if notice %> -

<%= notice %>

- <% end %> - <% if alert %> -

<%= alert %>

- <% end %> + - <%= yield %> -
-<%= render 'layouts/footer' %> + <%= yield %> + + <%= render 'layouts/footer' %> +
From 11594a6dd5e97c871e64bcfbb010ce36cdd48a4e Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 16:09:10 +0700 Subject: [PATCH 16/42] [#16] Add UI for error messages --- app/views/devise/shared/_error_messages.html.erb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/app/views/devise/shared/_error_messages.html.erb b/app/views/devise/shared/_error_messages.html.erb index bb5b70b0..a01e694a 100644 --- a/app/views/devise/shared/_error_messages.html.erb +++ b/app/views/devise/shared/_error_messages.html.erb @@ -1,15 +1,7 @@ <% if resource.errors.any? %> -
-

- <%= t("errors.messages.not_saved", - count: resource.errors.count, - resource: resource.class.model_name.human.downcase) - %> -

-
    - <% resource.errors.full_messages.each do |message| %> -
  • <%= message %>
  • - <% end %> -
+
+ <% resource.errors.full_messages.each do |message| %> +

<%= message %>

+ <% end %>
<% end %> From 827add80d40a1b059f609102f9011d860040b2e6 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 16:10:15 +0700 Subject: [PATCH 17/42] [#16] Add margin top to footer --- app/assets/stylesheets/components/footer.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/components/footer.scss b/app/assets/stylesheets/components/footer.scss index af31247f..7fe32819 100644 --- a/app/assets/stylesheets/components/footer.scss +++ b/app/assets/stylesheets/components/footer.scss @@ -3,4 +3,5 @@ footer { height: 60px; line-height: 60px; background-color: #f5f5f5; + margin-top: 2rem; } From 8415fe6d0f5da646eb946fce2b77a700452d2687 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 15 Jun 2021 16:53:23 +0700 Subject: [PATCH 18/42] [#16] Update system tests to map error message --- spec/systems/signup_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/systems/signup_spec.rb b/spec/systems/signup_spec.rb index 1db60d48..fdba0c24 100644 --- a/spec/systems/signup_spec.rb +++ b/spec/systems/signup_spec.rb @@ -43,7 +43,7 @@ it 'displays an error message' do sign_up_ui 'good@email.com', '123' - expect(page).to have_selector('#error_explanation li') + expect(page).to have_selector('#error_explanation') end end @@ -51,7 +51,7 @@ it 'displays an error message' do sign_up_ui 'good@email.com', 'complex123password', 'differentPassword123' - expect(page).to have_selector('#error_explanation li') + expect(page).to have_selector('#error_explanation') end end From 67e64b0e075d4e86d6ff3eaac4b6e86f1d573f86 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Wed, 16 Jun 2021 10:54:55 +0700 Subject: [PATCH 19/42] [#16] Move footer into layout scss and shared html --- app/assets/stylesheets/application.scss | 2 +- app/assets/stylesheets/components/footer.scss | 7 ------- app/assets/stylesheets/layouts/_default.scss | 9 +++++++++ app/views/layouts/application.html.erb | 6 +++--- app/views/{layouts => shared}/_footer.html.erb | 0 app/views/{layouts => shared}/_header.html.erb | 0 6 files changed, 13 insertions(+), 11 deletions(-) delete mode 100644 app/assets/stylesheets/components/footer.scss create mode 100644 app/assets/stylesheets/layouts/_default.scss rename app/views/{layouts => shared}/_footer.html.erb (100%) rename app/views/{layouts => shared}/_header.html.erb (100%) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index fa0921c1..e3e801c8 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -12,8 +12,8 @@ // Base // Layouts +@import 'layouts/default'; // Components -@import 'components/footer'; // Screens diff --git a/app/assets/stylesheets/components/footer.scss b/app/assets/stylesheets/components/footer.scss deleted file mode 100644 index 7fe32819..00000000 --- a/app/assets/stylesheets/components/footer.scss +++ /dev/null @@ -1,7 +0,0 @@ -footer { - width: 100%; - height: 60px; - line-height: 60px; - background-color: #f5f5f5; - margin-top: 2rem; -} diff --git a/app/assets/stylesheets/layouts/_default.scss b/app/assets/stylesheets/layouts/_default.scss new file mode 100644 index 00000000..cb91c642 --- /dev/null +++ b/app/assets/stylesheets/layouts/_default.scss @@ -0,0 +1,9 @@ +.layout-default{ + .app-footer{ + width: 100%; + height: 60px; + line-height: 60px; + background-color: #f5f5f5; + margin-top: 2rem; + } +} diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 959eccc2..d8006bf0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,5 +1,5 @@ - + <%= t('app_name') %> @@ -11,7 +11,7 @@ diff --git a/app/views/layouts/_footer.html.erb b/app/views/shared/_footer.html.erb similarity index 100% rename from app/views/layouts/_footer.html.erb rename to app/views/shared/_footer.html.erb diff --git a/app/views/layouts/_header.html.erb b/app/views/shared/_header.html.erb similarity index 100% rename from app/views/layouts/_header.html.erb rename to app/views/shared/_header.html.erb From 78d07ecc9a8746c105b17fe0d9108a3b4146a0d4 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Wed, 16 Jun 2021 10:55:15 +0700 Subject: [PATCH 20/42] [#16] Add empty line to logo.svg --- app/assets/images/logo.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/images/logo.svg b/app/assets/images/logo.svg index 432084d1..9835d3e8 100644 --- a/app/assets/images/logo.svg +++ b/app/assets/images/logo.svg @@ -1 +1 @@ - \ No newline at end of file + From f3befbd076bf8e72d5b185cfa4f149b30ddaaf1d Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Wed, 16 Jun 2021 11:08:34 +0700 Subject: [PATCH 21/42] [#16] Move edit/new forms into partial views --- .../devise/registrations/_edit_form.html.erb | 69 ++++++++++++++++++ .../devise/registrations/_new_form.html.erb | 31 ++++++++ app/views/devise/registrations/edit.html.erb | 70 +------------------ app/views/devise/registrations/new.html.erb | 31 +------- 4 files changed, 102 insertions(+), 99 deletions(-) create mode 100644 app/views/devise/registrations/_edit_form.html.erb create mode 100644 app/views/devise/registrations/_new_form.html.erb diff --git a/app/views/devise/registrations/_edit_form.html.erb b/app/views/devise/registrations/_edit_form.html.erb new file mode 100644 index 00000000..43aa800c --- /dev/null +++ b/app/views/devise/registrations/_edit_form.html.erb @@ -0,0 +1,69 @@ +<%= form_for(resource, as: resource_name, + url: registration_path(resource_name), html: { method: :put }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> +
+
+
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name, autofocus: true, class: 'form-control' %> +
+
+
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name, class: 'form-control' %> +
+
+
+
+
+ <%= f.label :email %> +
+ <%= f.email_field :email, autocomplete: 'email', class: 'form-control' %> +
+ + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> +
<%= t('waiting_confirmation_for') %>: <%= resource.unconfirmed_email %>
+ <% end %> +
+
+
+ <%= f.label :current_password %> + <%= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control' %> +
+
+
+ +
+ <% if @minimum_password_length %> + (<%= "#{@minimum_password_length} #{t('min_char')}" %>) + <% end %> +
+
+
+ <%= f.label :password %>
+ <%= f.password_field :password, autocomplete: "new-password", class: 'form-control' %> +
+
+
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %> +
+
+
+
+ +
+ <%= f.submit t('update'), class: 'btn btn-primary btn-block' %> +
+<% end %> diff --git a/app/views/devise/registrations/_new_form.html.erb b/app/views/devise/registrations/_new_form.html.erb new file mode 100644 index 00000000..34d4bc85 --- /dev/null +++ b/app/views/devise/registrations/_new_form.html.erb @@ -0,0 +1,31 @@ +<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> + + <%= render "devise/shared/error_messages", resource: resource %> + +
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name, autofocus: true, class: 'form-control' %> +
+
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name, class: 'form-control' %> +
+
+ <%= f.label :email %>
+ <%= f.email_field :email, autocomplete: 'email', class: 'form-control' %> +
+
+ <%= f.label :password %>
+ <% if @minimum_password_length %> + (<%= "#{@minimum_password_length} #{t('min_char')}" %>) + <% end %>
+ <%= f.password_field :password, autocomplete: 'new-password', class: 'form-control' %> +
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %> +
+
+ <%= f.submit t('auth.sign_up'), class: 'btn btn-primary btn-block' %> +
+<% end %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 15ce32e2..bd41fae2 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -5,75 +5,7 @@

Edit <%= resource_name.to_s.humanize %>

- <%= form_for(resource, as: resource_name, - url: registration_path(resource_name), html: { method: :put }) do |f| %> - <%= render "devise/shared/error_messages", resource: resource %> -
-
-
- <%= f.label :first_name %>
- <%= f.text_field :first_name, autofocus: true, class: 'form-control' %> -
-
-
-
- <%= f.label :last_name %>
- <%= f.text_field :last_name, class: 'form-control' %> -
-
-
-
-
- <%= f.label :email %> -
- <%= f.email_field :email, autocomplete: 'email', class: 'form-control' %> -
- - <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> -
<%= t('waiting_confirmation_for') %>: <%= resource.unconfirmed_email %>
- <% end %> -
-
-
- <%= f.label :current_password %> - <%= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control' %> -
-
-
- -
- <% if @minimum_password_length %> - (<%= "#{@minimum_password_length} #{t('min_char')}" %>) - <% end %> -
-
-
- <%= f.label :password %>
- <%= f.password_field :password, autocomplete: "new-password", class: 'form-control' %> -
-
-
-
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %> -
-
-
-
- -
- <%= f.submit t('update'), class: 'btn btn-primary btn-block' %> -
- <% end %> + <%= render 'edit_form' %>
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 0b71708a..ff1f46d9 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -5,37 +5,8 @@
<%= link_to t('auth.sign_in'), new_session_path(resource_name), class: 'float-right btn btn-outline-primary' %>

Sign up

- <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= render "devise/shared/error_messages", resource: resource %> - -
- <%= f.label :first_name %>
- <%= f.text_field :first_name, autofocus: true, class: 'form-control' %> -
-
- <%= f.label :last_name %>
- <%= f.text_field :last_name, class: 'form-control' %> -
-
- <%= f.label :email %>
- <%= f.email_field :email, autocomplete: 'email', class: 'form-control' %> -
-
- <%= f.label :password %>
- <% if @minimum_password_length %> - (<%= "#{@minimum_password_length} #{t('min_char')}" %>) - <% end %>
- <%= f.password_field :password, autocomplete: 'new-password', class: 'form-control' %> -
-
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %> -
-
- <%= f.submit t('auth.sign_up'), class: 'btn btn-primary btn-block' %> -
- <% end %> + <%= render 'devise/registrations/new_form' %>
From aa9837aefea633521c354002de5016173bad5a39 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Wed, 16 Jun 2021 11:11:28 +0700 Subject: [PATCH 22/42] [#16] Add missing class to html footer --- app/views/shared/_footer.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_footer.html.erb b/app/views/shared/_footer.html.erb index 031347af..e286c240 100644 --- a/app/views/shared/_footer.html.erb +++ b/app/views/shared/_footer.html.erb @@ -1,4 +1,4 @@ -