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

Commit 870ca0d

Browse files
committed
Merge branch 'release-0.36'
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))
2 parents c6b4b1e + b0a9fd3 commit 870ca0d

File tree

122 files changed

+5587
-1383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+5587
-1383
lines changed

.rubocop.yml

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ AllCops:
44
Exclude:
55
- "bin/**/*"
66
- "db/schema.rb"
7+
- "*.inky-slim"
8+
- "**/*.erb"
79

810
Metrics/BlockLength:
911
Enabled: true

CHANGELOG.md

+29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# CHANGELOG
22

3+
## v0.36 (Feb 18, 2019)
4+
5+
**Features:**
6+
- Changes suggested in contributions are now relative to point in time when the
7+
contribution was created. In addition, only files with suggested changes will
8+
be overwritten in the project. Any other files in the project, whether changed
9+
or not, will remain untouched when accepting the contribution.
10+
([#325](https://github.com/OpenlyOne/openly/issues/325))
11+
- Contributions now have a discussion tab where users can create replies to
12+
the contribution and discuss it. When a reply is created, it notifies the
13+
project team, contribution creator, and other discussion participants.
14+
([#280](https://github.com/OpenlyOne/openly/issues/280))
15+
16+
**Enhancements:**
17+
- The contributions feature is now enabled for all projects. The feature toggle
18+
has been removed.
19+
- Creating and accepting a contribution now triggers notifications to the
20+
project team, contribution creator, and contribution discussion participants
21+
([#285](https://github.com/OpenlyOne/openly/issues/285))
22+
- Add a link to the contribution navigation to allow users to open the
23+
contribution's root folder in Google Drive
24+
([#273](https://github.com/OpenlyOne/openly/issues/273))
25+
- Display an accurate list of changes in the contribution review tab after the
26+
contribution has been accepted by tracking the accepted revision
27+
([#284](https://github.com/OpenlyOne/openly/issues/284))
28+
- Admins can edit email addresses of accounts via the admin panel. Users
29+
continue to be prevented from editing their own email addresses.
30+
([#266](https://github.com/OpenlyOne/openly/issues/266))
31+
332
## v0.35.1 (Feb 16, 2019)
433

534
**Fixes:**
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// CSS styles meant to apply to specific controllers
22

33
@import 'errors';
4-
@import 'contributions';
54
@import 'file_changes';
65
@import 'folders';
76
@import 'notifications';
87
@import 'profiles';
98
@import 'project_setups';
9+
@import 'replies';
1010
@import 'revisions';
1111
@import 'static';

app/assets/stylesheets/controllers/contributions.scss

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Styling for RepliesController
2+
3+
.c-replies {
4+
5+
// Reduce margin top on first paragraph
6+
.description {
7+
p:first-of-type {
8+
margin-top: 0;
9+
}
10+
}
11+
12+
.with-triangle {
13+
position: relative;
14+
15+
16+
// need z-index, so that triangle shadow is below element and
17+
> * {
18+
position: relative;
19+
z-index: 10;
20+
}
21+
22+
// styling for the triangle
23+
&::before,
24+
&::after {
25+
color: color('shades', 'white');
26+
content: '';
27+
margin-top: 10px;
28+
position: absolute;
29+
right: calc(100% - 1px);
30+
top: 0;
31+
}
32+
33+
// shadow is below element
34+
&::before {
35+
@extend %text-z-depth-1;
36+
z-index: 5;
37+
}
38+
39+
&::after {
40+
z-index: 15;
41+
}
42+
}
43+
44+
.reply {
45+
padding: 20px;
46+
47+
p:first-of-type {
48+
margin-top: 0;
49+
}
50+
51+
p:last-of-type {
52+
margin-bottom: 0;
53+
}
54+
}
55+
}

app/assets/stylesheets/shared/all.scss

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
@import 'navbar';
1717
@import 'page-heading';
1818
@import 'profiles';
19+
@import 'shadows';
1920
@import 'spacing';
2021
@import 'tabs';
2122
@import 'toasts';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// scss-lint:disable ColorVariable
2+
3+
%text-z-depth-1 {
4+
// uses the same values as .z-depth-1
5+
text-shadow: 0 2px 2px rgba(0, 0, 0, .14),
6+
0 3px 1px rgba(0, 0, 0, .12),
7+
0 1px 5px rgba(0, 0, 0, .2);
8+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
# Devise-overwrite for editing, updating, and deleting accounts
4+
class AccountsController < Devise::RegistrationsController
5+
protected
6+
7+
# If you have extra params to permit, append them to the sanitizer.
8+
def account_update_params
9+
params.require(:account)
10+
.permit(:current_password, :password, :password_confirmation)
11+
end
12+
end

app/controllers/contributions/acceptances_controller.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class AcceptancesController < ApplicationController
1515
# TODO: Refactor
1616
# rubocop:disable Metrics/MethodLength
1717
def create
18-
if @contribution.accept(revision: @revision)
18+
if @contribution.accept(revision: @revision, acceptor: current_user)
1919
# Successfully accepted
2020
redirect_with_success_to(
2121
profile_project_root_folder_path(@project.owner, @project),
@@ -26,7 +26,8 @@ def create
2626
# Error occurred while accepting contribution
2727
@user_can_accept_contribution = true
2828
@revision.preload_file_diffs_with_versions
29-
render 'contributions/reviews/show', layout: 'contributions/reviews'
29+
render 'contributions/reviews/show_suggested_changes',
30+
layout: 'contributions/reviews'
3031
end
3132
end
3233
# rubocop:enable Metrics/MethodLength
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# frozen_string_literal: true
2+
3+
module Contributions
4+
# Controller for replies to contributions
5+
class RepliesController < ApplicationController
6+
include CanSetProjectContext
7+
8+
before_action :authenticate_account!, except: :index
9+
before_action :set_project_where_setup_is_complete
10+
before_action :authorize_project_access
11+
before_action :find_contribution
12+
before_action :authorize_action, except: :index
13+
before_action :set_replies, only: :index
14+
before_action :build_reply
15+
before_action :set_user_can_reply_to_contribution, only: :index
16+
17+
def index; end
18+
19+
def create
20+
if @reply.update(reply_params)
21+
redirect_with_success_to(contribution_replies_path)
22+
else
23+
set_replies
24+
set_user_can_reply_to_contribution
25+
render 'index'
26+
end
27+
end
28+
29+
private
30+
31+
rescue_from CanCan::AccessDenied do |exception|
32+
can_can_access_denied(exception)
33+
end
34+
35+
def authorize_action
36+
authorize! :reply, @contribution
37+
end
38+
39+
def can_can_access_denied(exception)
40+
super || redirect_to(contribution_replies_path, alert: exception.message)
41+
end
42+
43+
def build_reply
44+
@reply = @contribution.replies.build(author: current_user)
45+
end
46+
47+
def contribution_replies_path
48+
profile_project_contribution_replies_path(
49+
@project.owner, @project, @contribution
50+
)
51+
end
52+
53+
def find_contribution
54+
@contribution = @project.contributions.find(params[:contribution_id])
55+
end
56+
57+
def set_replies
58+
@replies = @contribution.replies.includes(:author)
59+
end
60+
61+
def set_user_can_reply_to_contribution
62+
@user_can_reply_to_contribution = can?(:reply, @contribution)
63+
end
64+
65+
def reply_params
66+
params.require(:reply).permit(:content)
67+
end
68+
end
69+
end

app/controllers/contributions/reviews_controller.rb

+24-3
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,40 @@ class ReviewsController < ApplicationController
88
before_action :set_project_where_setup_is_complete
99
before_action :authorize_project_access
1010
before_action :set_contribution
11-
before_action :set_user_can_accept_contribution
11+
before_action :set_revision, if: :contribution_accepted?
12+
before_action :prepare_revision_for_acceptance,
13+
unless: :contribution_accepted?
14+
before_action :set_user_can_accept_contribution,
15+
unless: :contribution_accepted?
1216

1317
def show
14-
@contribution
15-
.prepare_revision_for_acceptance(author: current_user_or_fallback)
18+
if contribution_accepted?
19+
render 'show_accepted_changes'
20+
else
21+
render 'show_suggested_changes'
22+
end
1623
end
1724

1825
private
1926

27+
def contribution_accepted?
28+
@contribution.accepted?
29+
end
30+
31+
def prepare_revision_for_acceptance
32+
@contribution
33+
.prepare_revision_for_acceptance(author: current_user_or_fallback)
34+
end
35+
2036
def set_contribution
2137
@contribution = @project.contributions.find(params[:contribution_id])
2238
end
2339

40+
def set_revision
41+
@revision =
42+
@contribution.accepted_revision.tap(&:preload_file_diffs_with_versions)
43+
end
44+
2445
def set_user_can_accept_contribution
2546
@user_can_accept_contribution = can?(:accept, @contribution)
2647
end

app/controllers/contributions_controller.rb

+9-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class ContributionsController < ApplicationController
77
before_action :authenticate_account!, except: %i[index show]
88
before_action :set_project_where_setup_is_complete
99
before_action :authorize_project_access
10-
before_action :require_contribution_feature_enabled
1110
before_action :build_contribution, only: %i[new create]
1211
before_action :authorize_action, only: %i[new create]
1312
before_action :find_contribution, only: :show
@@ -30,7 +29,11 @@ def create
3029
end
3130
end
3231

33-
def show; end
32+
def show
33+
redirect_to profile_project_contribution_replies_path(
34+
@project.owner, @project, @contribution
35+
)
36+
end
3437

3538
private
3639

@@ -43,7 +46,10 @@ def authorize_action
4346
end
4447

4548
def build_contribution
46-
@contribution = @project.contributions.build(creator: current_user)
49+
@contribution = @project.contributions.build(
50+
creator: current_user,
51+
origin_revision: @project.revisions.last
52+
)
4753
end
4854

4955
def find_contribution
@@ -60,8 +66,4 @@ def can_can_access_denied(exception)
6066
def contribution_params
6167
params.require(:contribution).permit(:title, :description)
6268
end
63-
64-
def require_contribution_feature_enabled
65-
raise ActiveRecord::RecordNotFound unless @project.contributions_enabled?
66-
end
6769
end

app/controllers/notifications_controller.rb

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ class NotificationsController < ApplicationController
66

77
# GET /notifications
88
def index
9-
# HACK: Preload the repository relationship. Only works because we have
10-
# => only one type of notification and that notification supports the
11-
# => repository relationship.
12-
@notifications =
13-
notifications.includes(:notifier, notifiable: %i[repository])
9+
@notifications = notifications.includes(:notifier, :notifiable)
1410
end
1511

1612
# GET /notifications/:id

app/controllers/projects_controller.rb

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class ProjectsController < ApplicationController
1212
before_action :authorize_project_access, only: :show
1313
before_action :set_user_can_create_private_projects, only: %i[new create]
1414

15-
1615
def new; end
1716

1817
def create

app/dashboards/project_dashboard.rb

-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class ProjectDashboard < Administrate::BaseDashboard
1919
description: Field::Text,
2020
tag_list: Field::String.with_options(searchable: false),
2121
is_public: Field::Boolean,
22-
are_contributions_enabled: Field::Boolean,
2322
created_at: Field::DateTime,
2423
updated_at: Field::DateTime
2524
}.freeze
@@ -48,7 +47,6 @@ class ProjectDashboard < Administrate::BaseDashboard
4847
description
4948
tag_list
5049
is_public
51-
are_contributions_enabled
5250
created_at
5351
updated_at
5452
].freeze
@@ -64,7 +62,6 @@ class ProjectDashboard < Administrate::BaseDashboard
6462
description
6563
tag_list
6664
is_public
67-
are_contributions_enabled
6865
].freeze
6966

7067
# Overwrite this method to customize how accounts are displayed

app/models/ability.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def initialize(user)
5757
end
5858

5959
# Users can create contributions for projects that they can access
60-
can %i[new create], Contribution do |contribution|
60+
# Users can reply to contributions of projects that they can access
61+
can %i[new create reply], Contribution do |contribution|
6162
can?(:access, contribution.project)
6263
end
6364

app/models/account.rb

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ class Account < ApplicationRecord
1717

1818
# Attributes
1919
accepts_nested_attributes_for :user
20-
# Do not allow email change
21-
attr_readonly :email
2220

2321
# Delegations
2422
delegate :handle, to: :user, prefix: true

0 commit comments

Comments
 (0)