docbrown/app/views/users/show.html.erb
Molly Struve e87dead7ad
Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121)
* schema file undelete description

* feat: v1 of the script

* Flesh out remaining enums under their categories

* complete UsersSettings data update script

* complete DUS for relevant attributes in users and profiles tables

* complete DUS for users_notification_settings

* alphabetize user_settings sql file

* safeguard against null values for "null: false" settings

* Set up actual UsersSettings DUS and specs files

* fix broken DUS script

* complete specs for UsersSetting DUS

* Address QA of specs

* complete specs for users_notification_settings DUS

* fix the typos (thanks Julianna!)

* begin implementation

* still building

* add missing attribute "email_membership_newsletter"

* complete sync code (except race condition for user profile)

* complete implementation, remains tests

* Address PR review and fix Travis fails

* remove superfluous Profile.new

* fix travis fails

* feat: update the users_notification_setting attributes from the user model

* feat: use the config fonts enums to display the fonts

* feat: loop through the keys

* fix profile = nil blowing up; add specs for notification_setting model

* remove unneeded spec

* remove feed validation until after sync code removed; fixes feed_import spec failures

* remove spec associated with feed_url validation in user_setting model

* fix failing spec 😅

* add TODO

* feat: set the user settings in the user controller  and use it in the customization form

* feat: move some update logic to the users settings controller thats being used from customization

* feat: show the updated values form the users_settingd and not the user instance

* Generalize redirect back to current tab

* still trying to reflect changed theme upon refresh

* customizations take effect on refresh

* remove 'with_feed' scope from user model

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* start with takeover for fields previously in profiles table

* Takeover code for `publishing_from_rss` section in Settings (#13914)

* implement takeover code part 1

* implement takeover code

* fix feed fetch

* need rhymes help

* complete implementation; specs pending

* fix STUPID omission that caused so many headaches 😫

* implement profile fields pointing to users_settings 🎉

* run migrations

* implement inbox type & guidelines takeover code; specs pending (#13911)

* Point changes in notification settings to `users_notification_settings` table (#13910)

* implement takeover code; remains specs

* address PR feedback; remove related sync code

* address PR review feedback

* need help with routing and specs

* address pr review

* addressing pr review

* Treat implementation edge cases and omissions 😅

* fix uncommented comment

* fixing implementation cases

* address more PR review feedback

* fixing notifications use-cases

* refactor settings controller

* more pr review changes

* solving bugs

* fix broken onboarding

* handle eperience_level calls

* more fixes

* remove unneeded mappings

* add To-dos for quety updates

* remove done TODO

* purge done TODOs

* update notification_settings-related queries

* start fixing specs

* fixing specs

* fix notification and lrg_forem specs

* fixing broken specs

* still fixing

* fix line dif and remove reloads from user.rb

* run specs

* silence bullet and other fixes

* remove setting migration scripts and specs, fix more settings for specs

* handle missing user for article builder and fix notification specs

* fix some final controller specs and re-add incorrectly removed specs

* remove deprecated data update scripts and related workers, put travis back

* refactor admin tags mods controller, write/move specs for users notifications settings controller

* schema cleanup and other small refactors for consistency

* set field we can invalidate in spec via active record instead of at the db level

* remove I think an uneccessary hook call from subscribe_to_mailchimp_newsletter

* use bnefore_create to setup settings, please dont blow up the test suite

* mailchimp bot fix

* remove decorator in favor of single model method

Co-authored-by: Arit Amana <msarit@gmail.com>
Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
Co-authored-by: Arit Amana <32520970+msarit@users.noreply.github.com>
Co-authored-by: Jamie Gaskins <jamie@forem.com>
2021-07-08 09:31:34 -05:00

161 lines
8.1 KiB
Text

<% title @user.name %>
<%= render "shared/payment_pointer", user: @user %>
<%= content_for :page_meta do %>
<%= render "users/meta" %>
<% end %>
<% unless internal_navigation? || user_signed_in? %>
<script type="application/ld+json">
<%= @user_json_ld.to_json.html_safe %>
</script>
<% end %>
<% cache "user-profile-header-area-#{@user.id}-#{@user.profile_updated_at}-#{user_signed_in?}", expires_in: 10.days do %>
<style>
:root {
--profile-brand-color: <%= Color::CompareHex.new([user_colors(@user)[:bg], user_colors(@user)[:text]]).brightness(0.88) %>;
}
</style>
<div class="brand-bg">
<div class="crayons-layout crayons-layout--limited-l pt-7 m:pt-9">
<header class="profile-header crayons-card mt-2">
<div class="relative profile-header__top">
<span class="crayons-avatar crayons-avatar--3xl">
<img src="<%= Images::Profile.call(@user.profile_image_url, length: 320) %>" width="128" height="128" alt="<%= @user.name %> profile picture" class="crayons-avatar__image">
</span>
<div class="profile-header__actions">
<div class="profile-dropdown mr-2 relative hidden" data-username="<%= @user.username %>">
<button id="user-profile-dropdown" aria-expanded="false" aria-controls="user-profile-dropdownmenu" aria-haspopup="true" class="crayons-btn crayons-btn--ghost-dimmed crayons-btn--icon">
<%= inline_svg_tag("overflow-horizontal.svg", class: "dropdown-icon crayons-icon", aria: true, title: "User actions") %>
</button>
<div id="user-profile-dropdownmenu" class="crayons-dropdown top-100 right-0 p-1">
<%= javascript_packs_with_chunks_tag "profileDropdown", defer: true %>
<% if user_signed_in? %>
<a href="javascript:void(0);" id="user-profile-dropdownmenu-block-button" data-profile-user-id="<%= @user.id %>" class="border-none crayons-link crayons-link--block">Block @<%= @user.username %></a>
<a
href="javascript:void(0);"
id="user-profile-dropdownmenu-flag-button"
data-profile-user-id="<%= @user.id %>"
data-profile-user-name="@<%= @user.username %>"
data-is-user-flagged="<%= @is_user_flagged %>"
class="border-none crayons-link crayons-link--block">
<%= @flag_status ? "Unflag" : "Flag" %> @<%= @user.username %>
</a>
<% end %>
<span class="report-abuse-link-wrapper" data-path="/report-abuse?url=<%= user_url(@user) %>"></span>
</div>
</div>
<% if user_signed_in? %>
<a href="/connect/@<%= @user.username %>" class="hidden mr-2" id="user-connect-redirect">
<button class="chat-action-button crayons-btn crayons-btn--outlined hidden" id="modal-opener">Chat</button>
</a>
<% end %>
<button id="user-follow-butt" class="crayons-btn whitespace-nowrap follow-action-button user-profile-follow-button" data-info='{"id":<%= @user.id %>,"className":"<%= @user.class.name %>"}'>Follow</button>
</div>
</div>
<div class="profile-header__details">
<h1 class="crayons-title fw-heavy mb-2"><%= @user.name %></h1>
<p class="fs-base m:fs-l color-base-90 mb-4 mx-auto max-w-100 m:max-w-75"><%= @user.summary.presence || ["404 bio not found"].sample %></p>
<div class="profile-header__meta">
<% if @user.location.present? %>
<span class="profile-header__meta__item">
<%= inline_svg_tag("location.svg", aria: true, class: "crayons-icon mr-2 shrink-0", title: "Location") %>
<%= @user.location %>
</span>
<% end %>
<span class="profile-header__meta__item">
<%= inline_svg_tag("cake.svg", aria: true, class: "crayons-icon mr-2 shrink-0", title: "Joined") %>
Joined on&nbsp;
<%= local_date(@user.created_at) %>
</span>
<% if @user.setting.display_email_on_profile %>
<a href="mailto:<%= @user.email %>" class="profile-header__meta__item">
<%= inline_svg_tag("email.svg", class: "crayons-icon mr-2 shrink-0", aria: true, title: "Email address") %>
<%= @user.email %>
</a>
<% end %>
<% if @user.website_url.present? %>
<a href="<%= @user.website_url %>" target="_blank" rel="noopener me" class="profile-header__meta__item">
<%= inline_svg_tag("link-external.svg", class: "crayons-icon mr-2 shrink-0", aria: true, title: "Personal website") %>
<%= @user.website_url %>
</a>
<% end %>
<% social_authentication_links_for(@user).each do |provider_name, url| %>
<a href="<%= url %>" target="_blank" rel="noopener me" class="profile-header__meta__item p-1">
<%= inline_svg_tag("#{provider_name}.svg", class: "crayons-icon shrink-0", aria: true, title: "#{provider_name} website") %>
</a>
<% end %>
</div>
</div>
<%= render "users/metadata" %>
<div class="p-3 pt-0 block m:hidden js-user-info-trigger-wrapper">
<button type="button" class="crayons-btn crayons-btn--outlined w-100 js-user-info-trigger">More info about @<%= @user.username %></button>
</div>
<div class="crayons-modal align-left hidden">
<div class="crayons-modal__box">
<div class="crayons-modal__box__header">
<h2 class="crayons-modal__box__header__title">Chat with <%= @user.name %></h2>
<button title="Close" class="crayons-btn crayons-btn--ghost-dimmed crayons-btn--icon close-modal">
<%= inline_svg_tag("x.svg", class: "crayons-icon", aria: true, title: "Close modal") %>
</button>
</div>
<div class="crayons-modal__box__body">
<% if @user.setting.inbox_guidelines.present? %>
<p class="fw-bold mb-2">@<%= @user.username %>'s guidelines:</p>
<p class="mb-6"><%= @user.setting.inbox_guidelines %></p>
<% end %>
<form id="new-message-form" class="message-form mb-4" data-info='{"id":<%= @user.id %>,"className":"<%= @user.class.name %>","username":"<%= @user.username %>", "showChat":"<%= @user.setting.inbox_type %>"}'>
<textarea id="new-message" rows="4" cols="70" placeholder="Enter your message here..." class="crayons-textfield"></textarea>
<button type="submit" class="submit-message crayons-btn">Send</button>
</form>
<p class="fs-s color-base-60">All private interactions <b>must</b> abide by the <a href="/code-of-conduct">code of conduct</a>.</p>
</div>
</div>
<div class="crayons-modal__overlay"></div>
</div>
</header>
</div>
</div>
<% end %>
<div
class="crayons-layout crayons-layout--limited-l crayons-layout--2-cols crayons-layout--2-cols--1-2 pt-4 m:pt-0"
id="index-container"
data-params="<%= params.merge(user_id: @user.id, class_name: "Article", sort_by: "published_at", sort_direction: "desc").to_json(only: %i[tag user_id q class_name sort_by sort_direction]) %>" data-which="<%= @list_of %>"
data-tag=""
data-feed="<%= params[:timeframe] || "base-feed" %>"
data-articles-since="0">
<div class="crayons-layout__sidebar-left">
<%= render partial: "users/sidebar", locals: { repositories: @github_repositories } %>
</div>
<main class="crayons-layout__content articles-list" id="articles-list">
<div class="substories" id="substories">
<% if params[:view] == "comments" %>
<%= render "users/comments_section" %>
<% elsif @stories.any? || @comments.any? || @pinned_stories.any? %>
<%= render "users/main_feed" %>
<% end %>
</div>
<div class="loading-articles" id="loading-articles">
loading...
</div>
</main>
</div>
<%= javascript_packs_with_chunks_tag "storiesList", defer: true %>