Merge branch 'release/8.1' into dev

pull/6820/head
Jens Ulferts 6 years ago
commit 5b6144581a
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 3
      Dockerfile
  2. BIN
      app/assets/images/apple-touch-icon-120x120.png
  3. BIN
      app/assets/images/logo_icon_finn_blue.png
  4. BIN
      app/assets/images/styleguide/logo_openproject.png
  5. 6
      app/assets/javascripts/admin_users.js
  6. 8
      app/assets/stylesheets/layout/_print.sass
  7. 3
      app/assets/stylesheets/layout/work_packages/_print.sass
  8. 4
      app/controllers/my_controller.rb
  9. 18
      app/controllers/work_packages/bulk_controller.rb
  10. 5
      app/models/custom_actions/actions/strategies/date.rb
  11. 3
      app/models/custom_value/string_strategy.rb
  12. 1
      app/models/group/destroy.rb
  13. 9
      app/models/journal_manager.rb
  14. 2
      app/seeders/demo_data/work_package_seeder.rb
  15. 12
      app/views/users/_form.html.erb
  16. 13
      app/views/users/_general.html.erb
  17. 8
      frontend/legacy/app/components/type-configuration/type-configuration.controller.ts
  18. 5
      frontend/src/app/components/attachments/attachment-list/attachment-list-item.html
  19. 1
      frontend/src/app/components/attachments/attachments-upload/attachments-upload.html
  20. 15
      frontend/src/app/components/routing/wp-list/wp-list.component.ts
  21. 6
      frontend/src/app/components/work-packages/wp-single-view/wp-single-view.html
  22. 7
      frontend/src/app/modules/hal/resources/mixins/attachable-mixin.ts
  23. 7
      lib/plugins/acts_as_journalized/lib/journal_changes.rb
  24. 9
      spec/controllers/my_controller_spec.rb
  25. 71
      spec/controllers/work_packages/bulk_controller_spec.rb
  26. 34
      spec/features/work_packages/navigation_spec.rb
  27. 16
      spec/models/journal_manager_spec.rb
  28. 52
      spec/support/components/html_title.rb

@ -48,6 +48,9 @@ RUN sed -i "s|Rails.groups(:opf_plugins)|Rails.groups(:opf_plugins, :docker)|" c
# Run the npm postinstall manually after it was copied
RUN DATABASE_URL=sqlite3:///tmp/db.sqlite3 SECRET_TOKEN=foobar RAILS_ENV=production bundle exec rake assets:precompile
# Include pandoc
RUN RAILS_ENV=production bundle exec rails runner "puts ::OpenProject::TextFormatting::Formats::Markdown::PandocDownloader.check_or_download!"
CMD ["./docker/web"]
ENTRYPOINT ["./docker/entrypoint.sh"]
VOLUME ["$APP_DATA"]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

@ -59,8 +59,14 @@
}
}
function on_password_change() {
var sendInformationField = jQuery('.send-information');
sendInformationField.toggleClass('-hidden', jQuery(this).val() === '');
}
jQuery(function init(){
jQuery('#user_assign_random_password').change(on_assign_random_password_change);
jQuery('#user_auth_source_id').on('change.togglePasswordFields', on_auth_source_change);
jQuery('#user_password').change(on_password_change);
});
})();

@ -11,6 +11,7 @@
.contextual,
.other-formats,
.toolbar-items,
.ui-helper-hidden-accessible,
#wiki_add_attachment
display: none !important
@ -42,6 +43,13 @@
th, td
border: 1px solid #aaa
// Show dot highlight in print
// even when bg not enabled
// not supported in all browsers
[class^="__hl_"]
color-adjust: exact
-webkit-print-color-adjust: exact
// Sizes from user agent stylesheet
h1
font-size: 2em

@ -115,6 +115,9 @@
overflow: visible
flex-basis: initial !important
// Ensure left side is not set to overflow: hidden
.work-packages-full-view--split-left
overflow: visible
// decrease padding under subject
.work-packages--show-view > .toolbar-container

@ -132,7 +132,7 @@ class MyController < ApplicationController
def generate_rss_key
if request.post?
token = Token::Rss.create!(user: current_user)
flash[:notice] = [
flash[:info] = [
t('my.access_token.notice_reset_token', type: 'RSS'),
"<strong>#{token.plain_value}</strong>".html_safe,
t('my.access_token.token_value_warning')
@ -149,7 +149,7 @@ class MyController < ApplicationController
def generate_api_key
if request.post?
token = Token::Api.create!(user: current_user)
flash[:notice] = [
flash[:info] = [
t('my.access_token.notice_reset_token', type: 'API'),
"<strong>#{token.plain_value}</strong>".html_safe,
t('my.access_token.token_value_warning')

@ -36,7 +36,6 @@ class WorkPackages::BulkController < ApplicationController
include RelationsHelper
include QueriesHelper
include IssuesHelper
include ::WorkPackages::Shared::UpdateAncestors
def edit
@available_statuses = @projects.map { |p| Workflow.available_statuses(p) }.inject { |memo, w| memo & w }
@ -50,25 +49,26 @@ class WorkPackages::BulkController < ApplicationController
unsaved_work_package_ids = []
saved_work_packages = []
@work_packages.each do |work_package|
work_package.reload
work_package.add_journal(User.current, params[:notes])
# filter parameters by whitelist and add defaults
attributes = parse_params_for_bulk_work_package_attributes params, work_package.project
work_package.assign_attributes attributes
call_hook(:controller_work_packages_bulk_edit_before_save, params: params, work_package: work_package)
JournalManager.send_notification = params[:send_notification] == '0' ? false : true
if work_package.save
saved_work_packages << work_package
service_call = WorkPackages::UpdateService
.new(user: user, work_package: work_package)
.call(attributes: attributes, send_notifications: params[:send_notification] == '1')
if service_call.success?
saved_work_packages << service_call.result
else
unsaved_work_package_ids << work_package.id
end
end
update_ancestors(saved_work_packages)
set_flash_from_bulk_save(@work_packages, unsaved_work_package_ids)
redirect_back_or_default(controller: '/work_packages', action: :index, project_id: @project)
end
@ -121,7 +121,9 @@ class WorkPackages::BulkController < ApplicationController
safe_params = permitted_params.update_work_package project: project
attributes = safe_params.reject { |_k, v| v.blank? }
attributes.keys.each do |k| attributes[k] = '' if attributes[k] == 'none' end
attributes.keys.each do |k|
attributes[k] = '' if attributes[k] == 'none'
end
attributes[:custom_field_values].reject! { |_k, v| v.blank? } if attributes[:custom_field_values]
attributes.delete :custom_field_values if not attributes.has_key?(:custom_field_values) or attributes[:custom_field_values].empty?
attributes

@ -38,7 +38,10 @@ module CustomActions::Actions::Strategies::Date
end
def apply(work_package)
work_package.send("#{self.class.key}=", date_to_apply)
accessor = :"#{self.class.key}="
if work_package.respond_to? accessor
work_package.send(accessor, date_to_apply)
end
end
private

@ -32,6 +32,5 @@ class CustomValue::StringStrategy < CustomValue::FormatStrategy
value
end
def validate_type_of_value
end
def validate_type_of_value; end
end

@ -93,6 +93,7 @@ module Group::Destroy
.joins("INNER JOIN #{members}
ON #{members}.project_id = categories.project_id
AND #{members}.user_id = categories.assigned_to_id")
.where("#{members}.user_id" => self.id)
.update_all "assigned_to_id = NULL"
self.users.delete_all # remove all users from this group

@ -68,7 +68,7 @@ class JournalManager
def changed_references(merged_references)
merged_references
.select { |_, (old_value, new_value)| old_value.present? && new_value.present? && old_value != new_value }
.select { |_, (old_value, new_value)| old_value.present? && new_value.present? && old_value.strip != new_value.strip }
end
def to_changes_format(references, key)
@ -250,7 +250,8 @@ class JournalManager
def self.create_journal(journable, journal_attributes, user = User.current, notes = '')
type = base_class(journable.class)
extended_journal_attributes = journal_attributes.merge(journable_type: type.to_s)
extended_journal_attributes = journal_attributes
.merge(journable_type: type.to_s)
.merge(notes: notes)
.except(:details)
.except(:id)
@ -320,9 +321,9 @@ class JournalManager
end
def self.normalize_newlines(data)
data.each_with_object({}) { |e, h|
data.each_with_object({}) do |e, h|
h[e[0]] = (e[1].is_a?(String) ? e[1].gsub(/\r\n/, "\n") : e[1])
}
end
end
def self.with_send_notifications(send_notifications, &block)

@ -145,7 +145,7 @@ module DemoData
Array(attributes[:attachments]).each do |file_name|
attachment = work_package.attachments.build
attachment.author = work_package.author
attachment.file = File.new("config/locales/media/#{I18n.locale}/#{file_name}")
attachment.file = File.new("config/locales/media/en/#{file_name}")
attachment.save!
end

@ -118,6 +118,18 @@ See docs/COPYRIGHT.rdoc for more details.
container_class: '-middle' %>
</div>
<% end %>
<% if @user.active? -%>
<div class="form--field send-information -hidden">
<%= styled_label_tag 'send_information', t(:label_send_information) %>
<div class="form--field-container">
<%= styled_check_box_tag("send_information",
"1",
true) %>
</div>
</div>
<% end -%>
<div class="form--field">
<%= f.check_box :force_password_change,
disabled: assign_random_password_enabled %>

@ -46,15 +46,6 @@ See docs/COPYRIGHT.rdoc for more details.
autocomplete: 'off' },
as: :user do |f| %>
<%= render partial: 'form', locals: { f: f } %>
<% if @user.active? -%>
<div class="form--field -no-label">
<div class="form--field-container">
<label class="form--label-with-check-box">
<%= styled_check_box_tag 'send_information', 1, true %>
<%= l(:label_send_information) %>
</label>
</div>
</div>
<% end -%>
<div><%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark' %></div>
<%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark' %>
<% end %>

@ -55,8 +55,14 @@ function typesFormConfigurationCtrl(
return !$scope.updateHiddenFields();
});
$scope.showNotificationWhileDragging
// Setup autoscroll
var scroll = autoScroll(window, {
var scroll = autoScroll(
[
document.getElementById('content-wrapper')
],
{
margin: 20,
maxSpeed: 5,
scrollWhenOutside: true,

@ -8,8 +8,9 @@
<op-icon icon-classes="icon-context icon-attachment"></op-icon>
<a
class="work-package--attachments--filename"
[attr.href]="downloadPath || '#'"
download>
target="_blank"
rel="noopener"
[attr.href]="downloadPath || '#'">
{{ attachment.fileName || attachment.customName || attachment.name }}

@ -1,4 +1,5 @@
<div
*ngIf="resource.canAddAttachments"
class="wp-attachment-upload hide-when-print"
(drop)="onDropFiles($event)"
(dragover)="onDragOver($event)"

@ -53,6 +53,7 @@ import {LoadingIndicatorService} from "core-app/modules/common/loading-indicator
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {WorkPackageStaticQueriesService} from 'core-components/wp-query-select/wp-static-queries.service';
import {WorkPackageTableHighlightingService} from "core-components/wp-fast-table/state/wp-table-highlighting.service";
import {OpTitleService} from "core-components/html/op-title.service";
@Component({
selector: 'wp-list',
@ -70,7 +71,6 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
tableInformationLoaded = false;
selectedTitle?:string;
staticTitle?:string;
titleEditingEnabled:boolean;
currentQuery:QueryResource;
@ -96,6 +96,7 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
readonly $transitions:TransitionService,
readonly $state:StateService,
readonly I18n:I18nService,
readonly titleService:OpTitleService,
readonly wpStaticQueries:WorkPackageStaticQueriesService) {
}
@ -115,6 +116,13 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
// Listen for refresh changes
this.setupRefreshObserver();
// Update title on entering this state
this.$transitions.onSuccess({ to: 'work-packages.list' }, () => {
if (this.selectedTitle) {
this.titleService.setFirstPart(this.selectedTitle);
}
});
// Listen for param changes
this.removeTransitionSubscription = this.$transitions.onSuccess({}, (transition):any => {
let options = transition.options();
@ -256,5 +264,10 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
this.selectedTitle = this.wpStaticQueries.getStaticName(query);
this.titleEditingEnabled = false;
}
// Update the title if we're in the list state alone
if (this.$state.current.name === 'work-packages.list') {
this.titleService.setFirstPart(this.selectedTitle);
}
}
}

@ -112,10 +112,10 @@
</div>
</div>
<div class="work-packages--attachments attributes-group">
<div class="work-packages--attachments attributes-group"
*ngIf="workPackage.canAddAttachments || workPackage.hasAttachments">
<div class="work-packages--atachments-container">
<div class="attributes-group--header"
*ngIf="workPackage.attachments">
<div class="attributes-group--header">
<div class="attributes-group--header-container">
<h3 class="attributes-group--header-text" [textContent]="text.attachments.label"></h3>
</div>

@ -61,6 +61,13 @@ export function Attachable<TBase extends Constructor<HalResource>>(Base:TBase) {
return !!this.$links.addAttachment || this.isNew;
}
/**
*
*/
public get hasAttachments():boolean {
return _.get(this.attachments, 'elements.length', 0) > 0;
}
/**
* Try to find an existing file's download URL given its filename
* @param file

@ -36,12 +36,13 @@ module JournalChanges
@changes = HashWithIndifferentAccess.new
if predecessor.nil?
@changes = data.journaled_attributes
@changes = data
.journaled_attributes
.reject { |_, new_value| new_value.nil? }
.inject({}) { |result, (attribute, new_value)|
.inject({}) do |result, (attribute, new_value)|
result[attribute] = [nil, new_value]
result
}
end
else
normalized_new_data = JournalManager.normalize_newlines(data.journaled_attributes)
normalized_old_data = JournalManager.normalize_newlines(predecessor.data.journaled_attributes)

@ -30,6 +30,7 @@ require 'spec_helper'
describe MyController, type: :controller do
let(:user) { FactoryBot.create(:user) }
before(:each) do
login_as(user)
end
@ -221,7 +222,7 @@ describe MyController, type: :controller do
post :generate_rss_key
expect(user.reload.rss_token).to be_present
expect(flash[:notice]).to be_present
expect(flash[:info]).to be_present
expect(flash[:error]).not_to be_present
expect(response).to redirect_to action: :access_token
@ -239,7 +240,7 @@ describe MyController, type: :controller do
expect(new_token.value).not_to eq(key.value)
expect(new_token.value).to eq(user.rss_key)
expect(flash[:notice]).to be_present
expect(flash[:info]).to be_present
expect(flash[:error]).not_to be_present
expect(response).to redirect_to action: :access_token
end
@ -255,7 +256,7 @@ describe MyController, type: :controller do
new_token = user.reload.api_token
expect(new_token).to be_present
expect(flash[:notice]).to be_present
expect(flash[:info]).to be_present
expect(flash[:error]).not_to be_present
expect(response).to redirect_to action: :access_token
@ -273,7 +274,7 @@ describe MyController, type: :controller do
new_token = user.reload.api_token
expect(new_token).not_to eq(key)
expect(new_token.value).not_to eq(key.value)
expect(flash[:notice]).to be_present
expect(flash[:info]).to be_present
expect(flash[:error]).not_to be_present
expect(response).to redirect_to action: :access_token

@ -378,12 +378,31 @@ describe WorkPackages::BulkController, type: :controller do
describe '#groups' do
let(:group) { FactoryBot.create(:group) }
let(:group_id) { group.id }
subject { work_packages.map(&:assigned_to_id).uniq }
include_context 'update_request'
context 'allowed' do
let!(:member_group_p1) {
FactoryBot.create(:member,
project: project_1,
principal: group,
roles: [role])
}
subject { work_packages.map(&:assigned_to_id).uniq }
include_context 'update_request'
it 'does succeed' do
expect(flash[:error]).to be_nil
expect(subject).to match_array [group.id]
end
end
it { is_expected.to match_array [group_id] }
context 'not allowed' do
include_context 'update_request'
it 'does not succeed' do
expect(flash[:error]).to include(work_package_ids.join(', #'))
expect(subject).to match_array [user.id]
end
end
end
describe '#responsible' do
@ -565,6 +584,52 @@ describe WorkPackages::BulkController, type: :controller do
it_behaves_like :delivered
end
end
describe 'updating two children with dates to a new parent (Regression #28670)' do
let(:task1) do
FactoryBot.create :work_package,
project: project_1,
start_date: Date.today - 5.days,
due_date: Date.today
end
let(:task2) do
FactoryBot.create :work_package,
project: project_1,
start_date: Date.today - 2.days,
due_date: Date.today + 1.days
end
let(:new_parent) do
FactoryBot.create :work_package, project: project_1
end
before do
expect(new_parent.start_date).to be_nil
expect(new_parent.due_date).to be_nil
put :update,
params: {
ids: [task1.id, task2.id],
notes: 'Bulk editing',
work_package: { parent_id: new_parent.id }
}
end
it 'should update the parent dates as well' do
expect(response.response_code).to eq(302)
task1.reload
task2.reload
new_parent.reload
expect(task1.parent_id).to eq(new_parent.id)
expect(task2.parent_id).to eq(new_parent.id)
expect(new_parent.start_date).to eq Date.today - 5.days
expect(new_parent.due_date).to eq Date.today + 1.days
end
end
end
describe '#destroy' do

@ -30,8 +30,22 @@ require 'spec_helper'
RSpec.feature 'Work package navigation', js: true, selenium: true do
let(:user) { FactoryBot.create(:admin) }
let(:project) { FactoryBot.create(:project) }
let(:project) { FactoryBot.create(:project, name: 'Some project') }
let(:work_package) { FactoryBot.build(:work_package, project: project) }
let(:global_html_title) { ::Components::HtmlTitle.new }
let(:project_html_title) { ::Components::HtmlTitle.new project }
let(:wp_title_segment) do
"#{work_package.type.name}: #{work_package.subject} (##{work_package.id})"
end
let!(:query) do
query = FactoryBot.build(:query, user: user, project: project)
query.column_names = %w(id subject)
query.name = "My fancy query"
query.save!
query
end
before do
login_as(user)
@ -45,6 +59,7 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
global_work_packages.visit!
global_work_packages.expect_work_package_listed(work_package)
global_html_title.expect_first_segment 'All open'
# open details pane for work package
@ -52,12 +67,14 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
split_work_package.expect_subject
split_work_package.expect_current_path
global_html_title.expect_first_segment wp_title_segment
# Go to full screen by double click
full_work_package = global_work_packages.open_full_screen_by_doubleclick(work_package)
full_work_package.expect_subject
full_work_package.expect_current_path
global_html_title.expect_first_segment wp_title_segment
# deep link work package details pane
@ -77,6 +94,18 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
project_work_packages.visit!
project_work_packages.expect_work_package_listed(work_package)
project_html_title.expect_first_segment 'All open'
# Visit query with project wp
project_work_packages.visit_query query
project_work_packages.expect_work_package_listed(work_package)
project_html_title.expect_first_segment 'My fancy query'
# Go back to work packages without query
page.execute_script('window.history.back()')
project_work_packages.expect_work_package_listed(work_package)
project_html_title.expect_first_segment 'All open'
# open project work package details pane
@ -84,17 +113,20 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
split_project_work_package.expect_subject
split_project_work_package.expect_current_path
project_html_title.expect_first_segment wp_title_segment
# open work package full screen by button
full_work_package = split_project_work_package.switch_to_fullscreen
full_work_package.expect_subject
expect(current_path).to eq project_work_package_path(project, work_package, 'activity')
project_html_title.expect_first_segment wp_title_segment
# Back to table using the button
find('.work-packages-list-view-button').click
global_work_packages.expect_work_package_listed(work_package)
expect(current_path).to eq project_work_packages_path(project)
project_html_title.expect_first_segment 'All open'
# Link to full screen from index
global_work_packages.open_full_screen_by_link(work_package)

@ -101,7 +101,7 @@ describe JournalManager, type: :model do
end
end
describe 'self.#update_user_references' do
describe '.update_user_references' do
let!(:work_package) { FactoryBot.create :work_package }
let!(:doomed_user) { work_package.author }
let!(:data1) do
@ -146,4 +146,18 @@ describe JournalManager, type: :model do
expect(some_other_journal.reload.user.is_a?(DeletedUser)).to be_falsey
end
end
describe '.changes_on_association' do
context 'with one of the values having a newline' do
let(:current) { { id: 2, value: 'some value', custom_field_id: 123 }.with_indifferent_access }
let(:predecessor) { { id: 1, value: "some value\n", custom_field_id: 123 }.with_indifferent_access }
it 'does not identify a change' do
changes = JournalManager.changes_on_association([current], [predecessor], 'custom_fields', :custom_field_id, :value)
expect(changes)
.to be_empty
end
end
end
end

@ -0,0 +1,52 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
module Components
class HtmlTitle
include Capybara::DSL
include RSpec::Matchers
attr_reader :project
def initialize(project = nil)
@project = project
end
def expect_first_segment(title_part)
expect(page).to have_title full_title(title_part)
end
def full_title(first_segment)
if project
"#{first_segment} | #{project.name} | #{Setting.app_title}"
else
"#{first_segment} | #{Setting.app_title}"
end
end
end
end
Loading…
Cancel
Save