Skip to content

Commit

Permalink
Merge branch 'dev' into implementation/50212-convert-the-edit-page-to…
Browse files Browse the repository at this point in the history
…-primer-design
  • Loading branch information
akabiru committed Oct 25, 2023
2 parents 6628edf + 668c735 commit f544fbe
Show file tree
Hide file tree
Showing 531 changed files with 7,226 additions and 3,734 deletions.
5 changes: 4 additions & 1 deletion .redocly.lint-ignore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ tmp/oas-generated.yml:
info-license:
- '#/info'
operation-2xx-response:
- '#/paths/~1api~1v3~1work_packages~1{id}~1relations/get/responses'
- '#/paths/~1api~1v3~1file_links~1{file_link_id}~1open/get/responses'
- '#/paths/~1api~1v3~1project_storages~1{id}~1open/get/responses'
- '#/paths/~1api~1v3~1storages~1{id}~1open/get/responses'
- '#/paths/~1api~1v3~1work_packages~1{id}~1relations/get/responses'
operation-4xx-response:
- '#/paths/~1api~1v3/get/responses'
- '#/paths/~1api~1v3~1help_texts/get/responses'
- '#/paths/~1api~1v3~1work_packages~1form/post/responses'
no-ambiguous-paths:
- '#/paths/~1api~1v3~1queries~1{id}~1form'
- '#/paths/~1api~1v3~1queries~1{id}~1star'
Expand Down
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ Rails/DynamicFindBy:
- 'spec/support/**/*.rb'
- 'modules/*/spec/features/**/*.rb'

# We have config.active_record.belongs_to_required_by_default = false ,
# which means, we do have to declare presence validators on belongs_to relations.
Rails/RedundantPresenceValidationOnBelongsTo:
Enabled: false

# See RSpec/ExampleLength for why feature specs are excluded
RSpec/MultipleExpectations:
Max: 15
Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ gem 'okcomputer', '~> 1.18.1'
gem 'gon', '~> 6.4.0'

# Lograge to provide sane and non-verbose logging
gem 'lograge', '~> 0.13.0'
gem 'lograge', '~> 0.14.0'

# Structured warnings to selectively disable them in production
gem 'structured_warnings', '~> 0.4.0'
Expand Down Expand Up @@ -251,7 +251,7 @@ group :test do
gem 'capybara', '~> 3.39.0'
gem 'capybara-screenshot', '~> 1.0.17'
gem 'cuprite', '~> 0.14.3'
gem 'selenium-webdriver', '~> 4.13.0'
gem 'selenium-webdriver', '~> 4.14.0'

gem 'fuubar', '~> 2.5.0'
gem 'timecop', '~> 0.9.0'
Expand Down Expand Up @@ -345,7 +345,7 @@ platforms :mri, :mingw, :x64_mingw do
end

# Support application loading when no database exists yet.
gem 'activerecord-nulldb-adapter', '~> 0.9.0'
gem 'activerecord-nulldb-adapter', '~> 1.0.0'

# Have application level locks on the database to have a mutex shared between workers/hosts.
# We e.g. employ this to safeguard the creation of journals.
Expand All @@ -364,6 +364,6 @@ gemfiles.each do |file|
send(:eval_gemfile, file) if File.readable?(file)
end

gem "openproject-primer_view_components", '~>0.12.1'
gem "openproject-primer_view_components", '~>0.13.0'
gem "openproject-octicons", '~>19.7.0'
gem "openproject-octicons_helper", '~>19.7.0'
38 changes: 19 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ GIT

GIT
remote: https://github.com/opf/omniauth-openid_connect-providers.git
revision: 7559f44e70203f94572a90e1b4d1d1f8279cd40f
ref: 7559f44e70203f94572a90e1b4d1d1f8279cd40f
revision: c7e2498a8b093cfc5693d4960cae2e903a5e10cd
ref: c7e2498a8b093cfc5693d4960cae2e903a5e10cd
specs:
omniauth-openid_connect-providers (0.2.0)
omniauth-openid-connect (>= 0.2.1)
Expand Down Expand Up @@ -268,8 +268,8 @@ GEM
activesupport (= 7.0.8)
activerecord-import (1.5.0)
activerecord (>= 4.2)
activerecord-nulldb-adapter (0.9.0)
activerecord (>= 5.2.0, < 7.1)
activerecord-nulldb-adapter (1.0.1)
activerecord (>= 5.2.0, < 7.2)
activerecord-session_store (2.1.0)
actionpack (>= 6.1)
activerecord (>= 6.1)
Expand Down Expand Up @@ -310,7 +310,7 @@ GEM
awesome_nested_set (3.6.0)
activerecord (>= 4.0.0, < 7.2)
aws-eventstream (1.2.0)
aws-partitions (1.834.0)
aws-partitions (1.838.0)
aws-sdk-core (3.185.1)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
Expand Down Expand Up @@ -450,7 +450,7 @@ GEM
rainbow
rubocop
smart_properties
erblint-github (0.5.0)
erblint-github (0.5.1)
erubi (1.12.0)
escape_utils (1.3.0)
et-orbi (1.2.7)
Expand Down Expand Up @@ -561,7 +561,7 @@ GEM
ice_cube (0.16.4)
interception (0.5)
io-console (0.6.0)
irb (1.8.1)
irb (1.8.3)
rdoc
reline (>= 0.3.8)
iso8601 (0.13.0)
Expand Down Expand Up @@ -598,7 +598,7 @@ GEM
omniauth (~> 1.1)
omniauth-openid-connect (>= 0.2.1)
rails (>= 3.2.21)
lograge (0.13.0)
lograge (0.14.0)
actionpack (>= 4)
activesupport (>= 4)
railties (>= 4)
Expand Down Expand Up @@ -642,7 +642,7 @@ GEM
ruby2_keywords (~> 0.0.1)
mustermann-grape (1.0.2)
mustermann (>= 1.0.0)
net-imap (0.4.0)
net-imap (0.4.1)
date
net-protocol
net-ldap (0.18.0)
Expand Down Expand Up @@ -680,7 +680,7 @@ GEM
actionview
openproject-octicons (= 19.7.0)
railties
openproject-primer_view_components (0.12.1)
openproject-primer_view_components (0.13.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
openproject-octicons (>= 19.7.0)
Expand Down Expand Up @@ -728,7 +728,7 @@ GEM
pry-rescue (1.5.2)
interception (>= 0.5)
pry (>= 0.12.0)
psych (5.1.0)
psych (5.1.1.1)
stringio
public_suffix (5.0.3)
puffing-billy (4.0.0)
Expand Down Expand Up @@ -812,7 +812,7 @@ GEM
rbtree3 (0.7.1)
rdoc (6.5.0)
psych (>= 4.0.0)
recaptcha (5.15.0)
recaptcha (5.16.0)
redcarpet (3.6.0)
regexp_parser (2.8.2)
reline (0.3.9)
Expand Down Expand Up @@ -897,7 +897,7 @@ GEM
ruby-prof (1.6.3)
ruby-progressbar (1.13.0)
ruby-rc4 (0.1.5)
ruby-saml (1.15.0)
ruby-saml (1.16.0)
nokogiri (>= 1.13.10)
rexml
ruby2_keywords (0.0.5)
Expand All @@ -908,7 +908,7 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
secure_headers (6.5.0)
selenium-webdriver (4.13.1)
selenium-webdriver (4.14.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand Down Expand Up @@ -956,7 +956,7 @@ GEM
table_print (1.5.7)
test-prof (1.2.3)
text-hyphen (1.5.0)
thor (1.2.2)
thor (1.3.0)
timecop (0.9.8)
timeout (0.4.0)
trailblazer-option (0.1.2)
Expand Down Expand Up @@ -1019,7 +1019,7 @@ DEPENDENCIES
actionpack-xml_parser (~> 2.0.0)
activemodel-serializers-xml (~> 1.0.1)
activerecord-import (~> 1.5.0)
activerecord-nulldb-adapter (~> 0.9.0)
activerecord-nulldb-adapter (~> 1.0.0)
activerecord-session_store (~> 2.1.0)
acts_as_list (~> 1.1.0)
acts_as_tree (~> 2.9.0)
Expand Down Expand Up @@ -1086,7 +1086,7 @@ DEPENDENCIES
lefthook
letter_opener
listen (~> 3.8.0)
lograge (~> 0.13.0)
lograge (~> 0.14.0)
lookbook (~> 2.1.0)
mail (= 2.8.1)
matrix (~> 0.4.2)
Expand Down Expand Up @@ -1118,7 +1118,7 @@ DEPENDENCIES
openproject-octicons (~> 19.7.0)
openproject-octicons_helper (~> 19.7.0)
openproject-openid_connect!
openproject-primer_view_components (~> 0.12.1)
openproject-primer_view_components (~> 0.13.0)
openproject-recaptcha!
openproject-reporting!
openproject-storages!
Expand Down Expand Up @@ -1172,7 +1172,7 @@ DEPENDENCIES
rubytree (~> 2.0.0)
sanitize (~> 6.1.0)
secure_headers (~> 6.5.0)
selenium-webdriver (~> 4.13.0)
selenium-webdriver (~> 4.14.0)
semantic (~> 1.6.1)
shoulda-context (~> 2.0)
shoulda-matchers (~> 5.0)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.modules
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end

gem 'omniauth-openid_connect-providers',
git: 'https://github.com/opf/omniauth-openid_connect-providers.git',
ref: '7559f44e70203f94572a90e1b4d1d1f8279cd40f'
ref: 'c7e2498a8b093cfc5693d4960cae2e903a5e10cd'

gem 'omniauth-openid-connect',
git: 'https://github.com/opf/omniauth-openid-connect.git',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
end

new_user_row.with_column do
render(Primer::Beta::Button.new(scheme: :primary, type: :submit)) { I18n.t('work_package.sharing.invite') }
render(Primer::Beta::Button.new(scheme: :primary, type: :submit)) { I18n.t('work_package.sharing.share') }
end
end
end
Expand Down
10 changes: 6 additions & 4 deletions app/components/work_packages/share/modal_body_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
render(WorkPackages::Share::InviteUserFormComponent.new(work_package: @work_package))
end

if shared_users.none?
if shared_principals.none?
modal_content.with_row(mt: 3) do
render(Primer::Beta::Blankslate.new(border: true)) do |component|
component.with_visual_icon(icon: :people, size: :medium)
Expand All @@ -23,11 +23,13 @@
modal_content.with_row(mt: 3, data: { 'test-selector': 'op-share-wp-active-list'}) do
invited_user_list do |border_box|
border_box.with_header(color: :subtle, data: { 'test-selector': 'op-share-wp-active-count' }) do
render(WorkPackages::Share::ShareCounterComponent.new(count: shared_users.count))
render(WorkPackages::Share::ShareCounterComponent.new(count: shared_principals.count))
end

shared_users.each do |user|
share = user.work_package_shares.where(entity: @work_package).first
shared_principals.each do |principal|
share = principal.work_package_shares
.where(entity: @work_package)
.first

render(WorkPackages::Share::ShareRowComponent.new(share:,
container: border_box))
Expand Down
13 changes: 7 additions & 6 deletions app/components/work_packages/share/modal_body_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ def set_id_on_list_element(list_container)
list_container.instance_variable_set(:@list_arguments, new_list_arguments)
end

def shared_users
@shared_users ||= User
.having_entity_membership(@work_package)
.includes(work_package_shares: :roles)
.where(work_package_shares: { entity: @work_package })
.ordered_by_name
def shared_principals
@shared_principals ||= Principal
.having_entity_membership(@work_package)
.includes(work_package_shares: :roles)
.where(work_package_shares: { entity: @work_package })
.merge(MemberRole.only_non_inherited)
.ordered_by_name
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ def options
end

def active_role
# TODO: handle having more than one role
share.roles.first
if share.persisted?
share.roles
.merge(MemberRole.only_non_inherited)
.first
else
share.roles.first
end
end

def permission_name(value)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<%=
component_wrapper(:border_box_row, data: { 'test-selector': "op-share-wp-active-user-#{user.id}" }) do
component_wrapper(:border_box_row, data: { 'test-selector': "op-share-wp-active-user-#{principal.id}" }) do
grid_layout('op-share-wp-modal-body--user-row', tag: :div, align_items: :center, classes: 'ellipsis') do |user_row_grid|
user_row_grid.with_area(:user, tag: :div, classes: ' ellipsis') do
render(Users::AvatarComponent.new(user: user, size: :medium))
render(Users::AvatarComponent.new(user: principal, size: :medium))
end


Expand Down
4 changes: 2 additions & 2 deletions app/components/work_packages/share/share_row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def initialize(share:,

@share = share
@work_package = share.entity
@user = share.principal
@principal = share.principal
@container = container
end

Expand All @@ -64,7 +64,7 @@ def border_box_row(wrapper_arguments, &)

private

attr_reader :share, :work_package, :user, :container
attr_reader :share, :work_package, :principal, :container

def share_editable?
@share_editable ||= User.current != share.principal && sharing_manageable?
Expand Down
2 changes: 1 addition & 1 deletion app/contracts/backups/create_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def user_allowed_to_create_backup
end

def user_allowed_to_create_backup?
user.allowed_to_globally? Backup.permission
user.allowed_globally?(Backup.permission)
end

def pending_statuses
Expand Down
2 changes: 1 addition & 1 deletion app/contracts/placeholder_users/base_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def user_allowed_to_modify
end

def user_allowed_to_add?
user.allowed_to_globally?(:manage_placeholder_user)
user.allowed_globally?(:manage_placeholder_user)
end
end
end
2 changes: 1 addition & 1 deletion app/contracts/placeholder_users/delete_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DeleteContract < ::DeleteContract
#
# @param actor [User] User who wants to delete the given placeholder user.
def self.deletion_allowed?(placeholder_user, actor)
actor.allowed_to_globally?(:manage_placeholder_user) &&
actor.allowed_globally?(:manage_placeholder_user) &&
affected_projects_managed_by_actor?(placeholder_user, actor)
end

Expand Down
2 changes: 1 addition & 1 deletion app/contracts/projects/create_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CreateContract < BaseContract
private

def validate_user_allowed_to_manage
unless user.allowed_to_globally?(:add_project) ||
unless user.allowed_globally?(:add_project) ||
(model.parent && user.allowed_to?(:add_subprojects, model.parent))

errors.add :base, :error_unauthorized
Expand Down
6 changes: 2 additions & 4 deletions app/contracts/relations/base_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
# See COPYRIGHT and LICENSE files for more details.
#++

require 'model_contract'

module Relations
class BaseContract < ::ModelContract
attribute :relation_type
Expand All @@ -46,7 +44,7 @@ def self.model
Relation
end

def validate!(*args)
def valid?(*args)
# same as before_validation callback
model.send(:reverse_if_needed)

Expand All @@ -65,7 +63,7 @@ def validate_to_exists

def validate_nodes_relatable
if (model.from_id_changed? || model.to_id_changed?) &&
WorkPackage.relatable(model.from, model.relation_type).where(id: model.to).empty?
WorkPackage.relatable(model.from, model.relation_type, ignored_relation: model).where(id: model.to_id).empty?
errors.add :base, I18n.t(:'activerecord.errors.messages.circular_dependency')
end
end
Expand Down
Loading

0 comments on commit f544fbe

Please sign in to comment.