[#40130] Mentioning should not be possible in long text Custom fields

https://community.openproject.org/work_packages/40130
pull/11138/head
Andreas Pfohl 2 years ago committed by Oliver Günther
parent 39f1870879
commit 0ed1a884a7
  1. 6
      frontend/src/app/features/hal/resources/work-package-resource.ts
  2. 2
      frontend/src/app/shared/components/editor/components/ckeditor/ckeditor.types.ts
  3. 2
      frontend/src/vendor/ckeditor/ckeditor.js
  4. 2
      frontend/src/vendor/ckeditor/ckeditor.js.map
  5. 5
      spec/features/work_packages/details/custom_fields/custom_field_spec.rb
  6. 70
      spec/features/work_packages/details/inplace_editor/shared_examples.rb
  7. 14
      spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb

@ -188,7 +188,11 @@ export class WorkPackageBaseResource extends HalResource {
}
public getEditorContext(fieldName:string):ICKEditorContext {
return { type: fieldName === 'description' ? 'full' : 'constrained', macros: false };
return {
type: fieldName === 'description' ? 'full' : 'constrained',
macros: false,
...(fieldName.startsWith('customField') && { disabledMentions: ['user'] }),
};
}
public isParentOf(otherWorkPackage:WorkPackageResource) {

@ -66,4 +66,6 @@ export interface ICKEditorContext {
};
// context link to append on preview requests
previewContext?:string;
// disabled specific mentions
disabledMentions?:['user'|'work_package'];
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -59,6 +59,7 @@ describe 'custom field inplace editor', js: true do
end
it_behaves_like 'a workpackage autocomplete field'
it_behaves_like 'not a principal autocomplete field'
end
describe 'custom field lists' do
@ -151,7 +152,7 @@ describe 'custom field inplace editor', js: true do
end
end
context 'no restrictions' do
context 'with no restrictions' do
let(:args) { {} }
it 'renders errors for invalid entries' do
@ -175,7 +176,7 @@ describe 'custom field inplace editor', js: true do
end
end
context 'required' do
context 'when required' do
let(:args) { { is_required: true } }
it 'renders errors for invalid entries' do

@ -1,4 +1,4 @@
shared_examples 'an accessible inplace editor' do
shared_examples 'as an accessible inplace editor' do
it 'triggers edit mode on click' do
scroll_to_element(field.display_element)
field.activate_edition
@ -23,9 +23,9 @@ shared_examples 'an accessible inplace editor' do
end
end
shared_examples 'an auth aware field' do
shared_examples 'as an auth aware field' do
context 'when is editable' do
it_behaves_like 'an accessible inplace editor'
it_behaves_like 'as an accessible inplace editor'
end
context 'when user is authorized' do
@ -52,7 +52,7 @@ shared_examples 'an auth aware field' do
end
end
shared_context 'having a single validation point' do
shared_context 'as a single validation point' do
let(:other_field) { EditField.new page, :type }
before do
other_field.activate_edition
@ -67,7 +67,7 @@ shared_context 'having a single validation point' do
end
end
shared_context 'a required field' do
shared_context 'as a required field' do
before do
field.activate_edition
field.input_element.set ''
@ -86,11 +86,11 @@ shared_examples 'a cancellable field' do
field.expect_state_text(work_package.send(property_name))
active_class_name = page.evaluate_script('document.activeElement.className')
expect(active_class_name).to include(field.display_selector[1..-1])
expect(active_class_name).to include(field.display_selector[1..])
end
end
context 'by escape' do
context 'for escape' do
before do
field.activate!
sleep 1
@ -163,15 +163,67 @@ shared_examples 'a principal autocomplete field' do
end
end
context 'in project' do
context 'with the project page' do
let(:wp_page) { Pages::SplitWorkPackage.new(work_package, project) }
it_behaves_like 'principal autocomplete on field'
end
context 'outside project' do
context 'without the project page' do
let(:wp_page) { Pages::SplitWorkPackage.new(work_package) }
it_behaves_like 'principal autocomplete on field'
end
end
shared_examples 'not a principal autocomplete field' do
let(:role) { create(:role, permissions: %i[view_work_packages edit_work_packages]) }
let!(:user) do
create :user,
member_in_project: project,
member_through_role: role,
firstname: 'John'
end
let!(:mentioned_user) do
create :user,
member_in_project: project,
member_through_role: role,
firstname: 'Laura',
lastname: 'Foobar'
end
let!(:mentioned_group) do
create(:group, lastname: 'Laudators').tap do |group|
create :member,
principal: group,
project:,
roles: [role]
end
end
shared_examples 'not principal autocomplete on field' do
before do
wp_page.visit!
wp_page.ensure_page_loaded
end
it 'does not autocompletes links to user profiles' do
field.activate!
field.clear with_backspace: true
field.input_element.send_keys(" @lau")
sleep 2
expect(page).not_to have_selector('.mention-list-item')
end
end
context 'with the project page' do
let(:wp_page) { Pages::SplitWorkPackage.new(work_package, project) }
it_behaves_like 'not principal autocomplete on field'
end
context 'without the project page' do
let(:wp_page) { Pages::SplitWorkPackage.new(work_package) }
it_behaves_like 'not principal autocomplete on field'
end
end

@ -22,18 +22,18 @@ describe 'subject inplace editor', js: true, selenium: true do
work_packages_page.ensure_page_loaded
end
context 'in read state' do
context 'as a read state' do
it 'has correct content' do
field.expect_state_text(work_package.send(property_name))
end
end
it_behaves_like 'an auth aware field'
it_behaves_like 'as an auth aware field'
it_behaves_like 'a cancellable field'
it_behaves_like 'having a single validation point'
it_behaves_like 'a required field'
it_behaves_like 'as a single validation point'
it_behaves_like 'as a required field'
context 'in edit state' do
context 'as an edit state' do
before do
field.activate_edition
end
@ -59,7 +59,7 @@ describe 'subject inplace editor', js: true, selenium: true do
notification.expect_error('Subject is too long (maximum is 255 characters)')
end
context 'on save' do
context 'when save' do
before do
field.input_element.set 'Aloha'
end
@ -76,7 +76,7 @@ describe 'subject inplace editor', js: true, selenium: true do
end
end
context 'conflicting modification' do
context 'with conflicting modification' do
it 'shows a conflict when modified elsewhere' do
work_package.subject = 'Some other subject!'
work_package.save!

Loading…
Cancel
Save