From 7d6623d069af2e6fe4f37d5d48c71c29683fa109 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 7 Apr 2018 02:49:42 +0200 Subject: [PATCH] Remove contacts page on profiles closes #7769 --- Changelog.md | 1 + app/assets/javascripts/app/pages/profile.js | 4 --- app/assets/javascripts/app/router.js | 1 - .../app/views/profile_header_view.js | 7 ---- .../templates/profile_header_tpl.jst.hbs | 17 ---------- app/controllers/people_controller.rb | 25 -------------- app/controllers/photos_controller.rb | 1 - app/models/contact.rb | 11 ------ app/views/people/contacts.haml | 32 ----------------- config/locales/javascript/javascript.en.yml | 1 - config/routes.rb | 1 - features/desktop/contacts.feature | 17 ---------- spec/controllers/people_controller_spec.rb | 34 ------------------- 13 files changed, 1 insertion(+), 151 deletions(-) delete mode 100644 app/views/people/contacts.haml delete mode 100644 features/desktop/contacts.feature diff --git a/Changelog.md b/Changelog.md index e82800e7e..0f3e91f3c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ # 0.7.5.0 ## Refactor +* Remove the 'make contacts in this aspect visible to each other' option [#7769](https://github.com/diaspora/diaspora/pull/7769) ## Bug fixes * Prefill conversation form on contacts page only with mutual contacts [#7744](https://github.com/diaspora/diaspora/pull/7744) diff --git a/app/assets/javascripts/app/pages/profile.js b/app/assets/javascripts/app/pages/profile.js index f4eb21b4f..09e8db0d4 100644 --- a/app/assets/javascripts/app/pages/profile.js +++ b/app/assets/javascripts/app/pages/profile.js @@ -24,9 +24,6 @@ app.pages.Profile = app.views.Base.extend({ if (app.hasPreload("photos_count")) { this.photos = app.parsePreload("photos_count"); } - if (app.hasPreload("contacts_count")) { - this.contacts = app.parsePreload("contacts_count"); - } this.streamCollection = _.has(opts, "streamCollection") ? opts.streamCollection : null; this.streamViewClass = _.has(opts, "streamView") ? opts.streamView : null; @@ -70,7 +67,6 @@ app.pages.Profile = app.views.Base.extend({ return new app.views.ProfileHeader({ model: this.model, photos: this.photos, - contacts: this.contacts }); }, diff --git a/app/assets/javascripts/app/router.js b/app/assets/javascripts/app/router.js index 702edc903..265b3cd48 100644 --- a/app/assets/javascripts/app/router.js +++ b/app/assets/javascripts/app/router.js @@ -20,7 +20,6 @@ app.Router = Backbone.Router.extend({ "p/:id(/)": "singlePost", "people(/)": "peopleSearch", "people/:id(/)": "profile", - "people/:id/contacts(/)": "profile", "people/:id/photos(/)": "photos", "posts/:id(/)": "singlePost", "profile/edit(/)": "settings", diff --git a/app/assets/javascripts/app/views/profile_header_view.js b/app/assets/javascripts/app/views/profile_header_view.js index f23ffc680..4858f9719 100644 --- a/app/assets/javascripts/app/views/profile_header_view.js +++ b/app/assets/javascripts/app/views/profile_header_view.js @@ -14,7 +14,6 @@ app.views.ProfileHeader = app.views.Base.extend({ initialize: function(opts) { this.photos = _.has(opts, 'photos') ? opts.photos : null; - this.contacts = _.has(opts, 'contacts') ? opts.contacts : null; this.model.on("change", this.render, this); $("#mentionModal").on("modal:loaded", this.mentionModalLoaded.bind(this)); $("#mentionModal").on("hidden.bs.modal", this.mentionModalHidden); @@ -24,13 +23,11 @@ app.views.ProfileHeader = app.views.Base.extend({ return _.extend({}, this.defaultPresenter(), { show_profile_btns: this._shouldShowProfileBtns(), show_photos: this._shouldShowPhotos(), - show_contacts: this._shouldShowContacts(), is_blocked: this.model.isBlocked(), is_sharing: this.model.isSharing(), is_receiving: this.model.isReceiving(), is_mutual: this.model.isMutual(), has_tags: this._hasTags(), - contacts: this.contacts, photos: this.photos }); }, @@ -51,10 +48,6 @@ app.views.ProfileHeader = app.views.Base.extend({ return (this.photos && this.photos > 0); }, - _shouldShowContacts: function() { - return (this.contacts && this.contacts > 0); - }, - showMentionModal: function() { app.helpers.showModal("#mentionModal"); }, diff --git a/app/assets/templates/profile_header_tpl.jst.hbs b/app/assets/templates/profile_header_tpl.jst.hbs index e6f94881f..d24f37c3b 100644 --- a/app/assets/templates/profile_header_tpl.jst.hbs +++ b/app/assets/templates/profile_header_tpl.jst.hbs @@ -82,22 +82,5 @@ {{/if}} - {{#if show_contacts}} -
  • - {{#if is_own_profile}} - - - {{t 'profile.contacts'}} -
    {{contacts}}
    -
    - {{else}} - - - {{t 'profile.contacts'}} -
    {{contacts}}
    -
    - {{/if}} -
  • - {{/if}} diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index c47ff2ae2..9d33cf338 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -77,7 +77,6 @@ class PeopleController < ApplicationController end gon.preloads[:person] = @presenter.as_json gon.preloads[:photos_count] = Photo.visible(current_user, @person).count(:all) - gon.preloads[:contacts_count] = Contact.contact_contacts_for(current_user, @person).count(:all) respond_with @presenter, layout: "with_header" end @@ -123,30 +122,6 @@ class PeopleController < ApplicationController end end - def contacts - respond_to do |format| - format.json { head :not_acceptable } - - format.any do - @person = Person.find_by_guid(params[:person_id]) - - if @person - @contact = current_user.contact_for(@person) - @contacts_of_contact = Contact.contact_contacts_for(current_user, @person) - gon.preloads[:person] = PersonPresenter.new(@person, current_user).as_json - gon.preloads[:photos_count] = Photo.visible(current_user, @person).count(:all) - gon.preloads[:contacts_count] = @contacts_of_contact.count(:all) - @contacts_of_contact = @contacts_of_contact.paginate(page: params[:page], per_page: (params[:limit] || 15)) - @hashes = hashes_for_people @contacts_of_contact, @aspects - respond_with @person, layout: "with_header" - else - flash[:error] = I18n.t "people.show.does_not_exist" - redirect_to people_path - end - end - end - end - private def find_person diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 8ebc0908c..1f8a37182 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -31,7 +31,6 @@ class PhotosController < ApplicationController format.all do gon.preloads[:person] = @presenter.as_json gon.preloads[:photos_count] = Photo.visible(current_user, @person).count(:all) - gon.preloads[:contacts_count] = Contact.contact_contacts_for(current_user, @person).count(:all) render "people/show", layout: "with_header" end format.mobile { render "people/show" } diff --git a/app/models/contact.rb b/app/models/contact.rb index 6a7a5ce30..0fa2e4d89 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -61,17 +61,6 @@ class Contact < ApplicationRecord end end - def self.contact_contacts_for(user, person) - return none unless user - - if person == user.person - user.contact_people - else - contact = user.contact_for(person) - contact.try(:contacts) || none - end - end - # Follows back if user setting is set so def receive(_recipient_user_ids) user.share_with(person, user.auto_follow_back_aspect) if user.auto_follow_back && !receiving diff --git a/app/views/people/contacts.haml b/app/views/people/contacts.haml deleted file mode 100644 index 698f5951b..000000000 --- a/app/views/people/contacts.haml +++ /dev/null @@ -1,32 +0,0 @@ -- content_for :page_title do - = @person.name - -.container-fluid#profile_container - .row - .col-md-3 - .sidebar.profile-sidebar#profile - -# here be JS - - .col-md-9 - .profile_header - -# more JS - - .stream-container - #people-stream.stream - - @hashes.each do |hash| - = render partial: 'people/person', locals: hash - = will_paginate @contacts_of_contact, renderer: WillPaginate::ActionView::BootstrapLinkRenderer - --if user_signed_in? && @person - #new_status_message_pane - = render 'shared/modal', - path: new_status_message_path(:person_id => @person.id), - title: t('status_messages.new.mentioning', person: @person.name), - id: 'mentionModal' - - -if @contact - .conversations-form-container#new_conversation_pane - = render 'shared/modal', - path: new_conversation_path(:contact_id => @contact.id, name: @contact.person.name, modal: true), - title: t('conversations.index.new_conversation'), - id: 'conversationModal' diff --git a/config/locales/javascript/javascript.en.yml b/config/locales/javascript/javascript.en.yml index 63e8dee68..b935267b5 100644 --- a/config/locales/javascript/javascript.en.yml +++ b/config/locales/javascript/javascript.en.yml @@ -233,7 +233,6 @@ en: gender: "Gender" born: "Birthday" photos: "Photos" - contacts: "Contacts" posts: "Posts" conversation: diff --git a/config/routes.rb b/config/routes.rb index ab8b75ffe..846921b8b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -164,7 +164,6 @@ Rails.application.routes.draw do resources :people, only: %i(show index) do resources :status_messages, only: %i(new create) resources :photos, except: %i(new update) - get :contacts get :stream get :hovercard diff --git a/features/desktop/contacts.feature b/features/desktop/contacts.feature deleted file mode 100644 index 89ef019a3..000000000 --- a/features/desktop/contacts.feature +++ /dev/null @@ -1,17 +0,0 @@ -@javascript -Feature: show contacts - - Background: - Given following users exist: - | username | email | - | Bob Jones | bob@bob.bob | - | Alice Smith | alice@alice.alice | - | Robert Grimm | robert@grimm.grimm | - And I sign in as "robert@grimm.grimm" - And I am on "alice@alice.alice"'s page - And I add the person to my "Unicorns" aspect - - Scenario: see own contacts on profile - When I am on "robert@grimm.grimm"'s page - And I press the first "#contacts_link" - Then I should be on the contacts page diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 740744525..e979a9c00 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -580,40 +580,6 @@ describe PeopleController, :type => :controller do end end - - describe '#contacts' do - it 'assigns the contacts of a person' do - contact = alice.contact_for(bob.person) - contacts = contact.contacts - get :contacts, params: {person_id: bob.person.to_param} - expect(assigns(:contacts_of_contact).to_a).to eq(contacts.to_a) - expect(response).to be_success - end - - it 'shows an error when invalid person id' do - get :contacts, params: {person_id: "foo"} - expect(flash[:error]).to be_present - expect(response).to redirect_to people_path - end - - it "displays the correct number of photos" do - 16.times do |i| - eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => true) - end - get :contacts, params: {person_id: eve.person.to_param} - expect(response.body).to include ',"photos_count":16' - - eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => false) - get :contacts, params: {person_id: eve.person.to_param} - expect(response.body).to include ',"photos_count":16' # eve is not sharing with alice - end - - it "returns a 406 for json format" do - get :contacts, params: {person_id: "foo"}, format: :json - expect(response.code).to eq("406") - end - end - describe '#diaspora_id?' do it 'returns true for pods on urls' do expect(@controller.send(:diaspora_id?, "ilya_123@pod.geraspora.de")).to be true -- GitLab