Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release-0.36'
Browse files Browse the repository at this point in the history
Release v0.36: Relative contributions and contribution replies

**Features:**
- Changes suggested in contributions are now relative to point in time
  when the contribution was created. In addition, only files with
  suggested changes will be overwritten in the project. Any other files
  in the project, whether changed or not, will remain untouched when
  accepting the contribution.
  ([#325](https://github.com/OpenlyOne/openly/issues/325))
- Contributions now have a discussion tab where users can create replies
  to the contribution and discuss it. When a reply is created, it
  notifies the project team, contribution creator, and other discussion
  participants.
  ([#280](https://github.com/OpenlyOne/openly/issues/280))

**Enhancements:**
- The contributions feature is now enabled for all projects. The feature
  toggle has been removed.
- Creating and accepting a contribution now triggers notifications to
  the project team, contribution creator, and contribution discussion
  participants
  ([#285](https://github.com/OpenlyOne/openly/issues/285))
- Add a link to the contribution navigation to allow users to open the
  contribution's root folder in Google Drive
  ([#273](https://github.com/OpenlyOne/openly/issues/273))
- Display an accurate list of changes in the contribution review tab
  after the contribution has been accepted by tracking the accepted
  revision
  ([#284](https://github.com/OpenlyOne/openly/issues/284))
- Admins can edit email addresses of accounts via the admin panel. Users
  continue to be prevented from editing their own email addresses.
  ([#266](https://github.com/OpenlyOne/openly/issues/266))
  • Loading branch information
FinnWoelm committed Feb 18, 2019
2 parents c6b4b1e + b0a9fd3 commit 870ca0d
Show file tree
Hide file tree
Showing 122 changed files with 5,587 additions and 1,383 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ AllCops:
Exclude:
- "bin/**/*"
- "db/schema.rb"
- "*.inky-slim"
- "**/*.erb"

Metrics/BlockLength:
Enabled: true
Expand Down
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# CHANGELOG

## v0.36 (Feb 18, 2019)

**Features:**
- Changes suggested in contributions are now relative to point in time when the
contribution was created. In addition, only files with suggested changes will
be overwritten in the project. Any other files in the project, whether changed
or not, will remain untouched when accepting the contribution.
([#325](https://github.com/OpenlyOne/openly/issues/325))
- Contributions now have a discussion tab where users can create replies to
the contribution and discuss it. When a reply is created, it notifies the
project team, contribution creator, and other discussion participants.
([#280](https://github.com/OpenlyOne/openly/issues/280))

**Enhancements:**
- The contributions feature is now enabled for all projects. The feature toggle
has been removed.
- Creating and accepting a contribution now triggers notifications to the
project team, contribution creator, and contribution discussion participants
([#285](https://github.com/OpenlyOne/openly/issues/285))
- Add a link to the contribution navigation to allow users to open the
contribution's root folder in Google Drive
([#273](https://github.com/OpenlyOne/openly/issues/273))
- Display an accurate list of changes in the contribution review tab after the
contribution has been accepted by tracking the accepted revision
([#284](https://github.com/OpenlyOne/openly/issues/284))
- Admins can edit email addresses of accounts via the admin panel. Users
continue to be prevented from editing their own email addresses.
([#266](https://github.com/OpenlyOne/openly/issues/266))

## v0.35.1 (Feb 16, 2019)

**Fixes:**
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/controllers/all.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// CSS styles meant to apply to specific controllers

@import 'errors';
@import 'contributions';
@import 'file_changes';
@import 'folders';
@import 'notifications';
@import 'profiles';
@import 'project_setups';
@import 'replies';
@import 'revisions';
@import 'static';
11 changes: 0 additions & 11 deletions app/assets/stylesheets/controllers/contributions.scss

This file was deleted.

55 changes: 55 additions & 0 deletions app/assets/stylesheets/controllers/replies.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Styling for RepliesController

.c-replies {

// Reduce margin top on first paragraph
.description {
p:first-of-type {
margin-top: 0;
}
}

.with-triangle {
position: relative;


// need z-index, so that triangle shadow is below element and
> * {
position: relative;
z-index: 10;
}

// styling for the triangle
&::before,
&::after {
color: color('shades', 'white');
content: '';
margin-top: 10px;
position: absolute;
right: calc(100% - 1px);
top: 0;
}

// shadow is below element
&::before {
@extend %text-z-depth-1;
z-index: 5;
}

&::after {
z-index: 15;
}
}

.reply {
padding: 20px;

p:first-of-type {
margin-top: 0;
}

p:last-of-type {
margin-bottom: 0;
}
}
}
1 change: 1 addition & 0 deletions app/assets/stylesheets/shared/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@import 'navbar';
@import 'page-heading';
@import 'profiles';
@import 'shadows';
@import 'spacing';
@import 'tabs';
@import 'toasts';
Expand Down
8 changes: 8 additions & 0 deletions app/assets/stylesheets/shared/shadows.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// scss-lint:disable ColorVariable

%text-z-depth-1 {
// uses the same values as .z-depth-1
text-shadow: 0 2px 2px rgba(0, 0, 0, .14),
0 3px 1px rgba(0, 0, 0, .12),
0 1px 5px rgba(0, 0, 0, .2);
}
12 changes: 12 additions & 0 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

# Devise-overwrite for editing, updating, and deleting accounts
class AccountsController < Devise::RegistrationsController
protected

# If you have extra params to permit, append them to the sanitizer.
def account_update_params
params.require(:account)
.permit(:current_password, :password, :password_confirmation)
end
end
5 changes: 3 additions & 2 deletions app/controllers/contributions/acceptances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AcceptancesController < ApplicationController
# TODO: Refactor
# rubocop:disable Metrics/MethodLength
def create
if @contribution.accept(revision: @revision)
if @contribution.accept(revision: @revision, acceptor: current_user)
# Successfully accepted
redirect_with_success_to(
profile_project_root_folder_path(@project.owner, @project),
Expand All @@ -26,7 +26,8 @@ def create
# Error occurred while accepting contribution
@user_can_accept_contribution = true
@revision.preload_file_diffs_with_versions
render 'contributions/reviews/show', layout: 'contributions/reviews'
render 'contributions/reviews/show_suggested_changes',
layout: 'contributions/reviews'
end
end
# rubocop:enable Metrics/MethodLength
Expand Down
69 changes: 69 additions & 0 deletions app/controllers/contributions/replies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# frozen_string_literal: true

module Contributions
# Controller for replies to contributions
class RepliesController < ApplicationController
include CanSetProjectContext

before_action :authenticate_account!, except: :index
before_action :set_project_where_setup_is_complete
before_action :authorize_project_access
before_action :find_contribution
before_action :authorize_action, except: :index
before_action :set_replies, only: :index
before_action :build_reply
before_action :set_user_can_reply_to_contribution, only: :index

def index; end

def create
if @reply.update(reply_params)
redirect_with_success_to(contribution_replies_path)
else
set_replies
set_user_can_reply_to_contribution
render 'index'
end
end

private

rescue_from CanCan::AccessDenied do |exception|
can_can_access_denied(exception)
end

def authorize_action
authorize! :reply, @contribution
end

def can_can_access_denied(exception)
super || redirect_to(contribution_replies_path, alert: exception.message)
end

def build_reply
@reply = @contribution.replies.build(author: current_user)
end

def contribution_replies_path
profile_project_contribution_replies_path(
@project.owner, @project, @contribution
)
end

def find_contribution
@contribution = @project.contributions.find(params[:contribution_id])
end

def set_replies
@replies = @contribution.replies.includes(:author)
end

def set_user_can_reply_to_contribution
@user_can_reply_to_contribution = can?(:reply, @contribution)
end

def reply_params
params.require(:reply).permit(:content)
end
end
end
27 changes: 24 additions & 3 deletions app/controllers/contributions/reviews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,40 @@ class ReviewsController < ApplicationController
before_action :set_project_where_setup_is_complete
before_action :authorize_project_access
before_action :set_contribution
before_action :set_user_can_accept_contribution
before_action :set_revision, if: :contribution_accepted?
before_action :prepare_revision_for_acceptance,
unless: :contribution_accepted?
before_action :set_user_can_accept_contribution,
unless: :contribution_accepted?

def show
@contribution
.prepare_revision_for_acceptance(author: current_user_or_fallback)
if contribution_accepted?
render 'show_accepted_changes'
else
render 'show_suggested_changes'
end
end

private

def contribution_accepted?
@contribution.accepted?
end

def prepare_revision_for_acceptance
@contribution
.prepare_revision_for_acceptance(author: current_user_or_fallback)
end

def set_contribution
@contribution = @project.contributions.find(params[:contribution_id])
end

def set_revision
@revision =
@contribution.accepted_revision.tap(&:preload_file_diffs_with_versions)
end

def set_user_can_accept_contribution
@user_can_accept_contribution = can?(:accept, @contribution)
end
Expand Down
16 changes: 9 additions & 7 deletions app/controllers/contributions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class ContributionsController < ApplicationController
before_action :authenticate_account!, except: %i[index show]
before_action :set_project_where_setup_is_complete
before_action :authorize_project_access
before_action :require_contribution_feature_enabled
before_action :build_contribution, only: %i[new create]
before_action :authorize_action, only: %i[new create]
before_action :find_contribution, only: :show
Expand All @@ -30,7 +29,11 @@ def create
end
end

def show; end
def show
redirect_to profile_project_contribution_replies_path(
@project.owner, @project, @contribution
)
end

private

Expand All @@ -43,7 +46,10 @@ def authorize_action
end

def build_contribution
@contribution = @project.contributions.build(creator: current_user)
@contribution = @project.contributions.build(
creator: current_user,
origin_revision: @project.revisions.last
)
end

def find_contribution
Expand All @@ -60,8 +66,4 @@ def can_can_access_denied(exception)
def contribution_params
params.require(:contribution).permit(:title, :description)
end

def require_contribution_feature_enabled
raise ActiveRecord::RecordNotFound unless @project.contributions_enabled?
end
end
6 changes: 1 addition & 5 deletions app/controllers/notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ class NotificationsController < ApplicationController

# GET /notifications
def index
# HACK: Preload the repository relationship. Only works because we have
# => only one type of notification and that notification supports the
# => repository relationship.
@notifications =
notifications.includes(:notifier, notifiable: %i[repository])
@notifications = notifications.includes(:notifier, :notifiable)
end

# GET /notifications/:id
Expand Down
1 change: 0 additions & 1 deletion app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ProjectsController < ApplicationController
before_action :authorize_project_access, only: :show
before_action :set_user_can_create_private_projects, only: %i[new create]


def new; end

def create
Expand Down
3 changes: 0 additions & 3 deletions app/dashboards/project_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class ProjectDashboard < Administrate::BaseDashboard
description: Field::Text,
tag_list: Field::String.with_options(searchable: false),
is_public: Field::Boolean,
are_contributions_enabled: Field::Boolean,
created_at: Field::DateTime,
updated_at: Field::DateTime
}.freeze
Expand Down Expand Up @@ -48,7 +47,6 @@ class ProjectDashboard < Administrate::BaseDashboard
description
tag_list
is_public
are_contributions_enabled
created_at
updated_at
].freeze
Expand All @@ -64,7 +62,6 @@ class ProjectDashboard < Administrate::BaseDashboard
description
tag_list
is_public
are_contributions_enabled
].freeze

# Overwrite this method to customize how accounts are displayed
Expand Down
3 changes: 2 additions & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def initialize(user)
end

# Users can create contributions for projects that they can access
can %i[new create], Contribution do |contribution|
# Users can reply to contributions of projects that they can access
can %i[new create reply], Contribution do |contribution|
can?(:access, contribution.project)
end

Expand Down
2 changes: 0 additions & 2 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Account < ApplicationRecord

# Attributes
accepts_nested_attributes_for :user
# Do not allow email change
attr_readonly :email

# Delegations
delegate :handle, to: :user, prefix: true
Expand Down
Loading

0 comments on commit 870ca0d

Please sign in to comment.