Commit 715ea16f authored by Tim Zallmann's avatar Tim Zallmann

Merge branch...

Merge branch 'ee-35955-searchable-settings-puts-expand-collapse-toggle-in-an-invalid-state' into 'master'

Port of Resolve "Searchable settings puts expand/collapse toggle in an invalid state." to EE

See merge request gitlab-org/gitlab-ee!3153
parents a63ae584 e0caa628
function expandSectionParent($section, $content) {
$section.addClass('expanded');
$content.off('animationend.expandSectionParent');
}
function expandSection($section) { function expandSection($section) {
$section.find('.js-settings-toggle').text('Collapse'); $section.find('.js-settings-toggle').text('Collapse');
$section.find('.settings-content').off('scroll.expandSection').scrollTop(0);
const $content = $section.find('.settings-content'); $section.addClass('expanded');
$content.addClass('expanded').off('scroll.expandSection').scrollTop(0); if (!$section.hasClass('no-animate')) {
$section.addClass('animating')
if ($content.hasClass('no-animate')) { .one('animationend.animateSection', () => $section.removeClass('animating'));
expandSectionParent($section, $content);
} else {
$content.on('animationend.expandSectionParent', () => expandSectionParent($section, $content));
} }
} }
function closeSection($section) { function closeSection($section) {
$section.find('.js-settings-toggle').text('Expand'); $section.find('.js-settings-toggle').text('Expand');
$section.find('.settings-content').on('scroll.expandSection', () => expandSection($section));
const $content = $section.find('.settings-content');
$content.removeClass('expanded').on('scroll.expandSection', () => expandSection($section));
$section.removeClass('expanded'); $section.removeClass('expanded');
if (!$section.hasClass('no-animate')) {
$section.addClass('animating')
.one('animationend.animateSection', () => $section.removeClass('animating'));
}
} }
function toggleSection($section) { function toggleSection($section) {
const $content = $section.find('.settings-content'); $section.removeClass('no-animate');
$content.removeClass('no-animate'); if ($section.hasClass('expanded')) {
if ($content.hasClass('expanded')) {
closeSection($section); closeSection($section);
} else { } else {
expandSection($section); expandSection($section);
...@@ -39,10 +31,19 @@ export default function initSettingsPanels() { ...@@ -39,10 +31,19 @@ export default function initSettingsPanels() {
$('.settings').each((i, elm) => { $('.settings').each((i, elm) => {
const $section = $(elm); const $section = $(elm);
$section.on('click.toggleSection', '.js-settings-toggle', () => toggleSection($section)); $section.on('click.toggleSection', '.js-settings-toggle', () => toggleSection($section));
$section.find('.settings-content:not(.expanded)').on('scroll.expandSection', () => expandSection($section));
if (!$section.hasClass('expanded')) {
$section.find('.settings-content').on('scroll.expandSection', () => {
$section.removeClass('no-animate');
expandSection($section);
});
}
}); });
if (location.hash) { if (location.hash) {
expandSection($(location.hash)); const $target = $(location.hash);
if ($target.length && $target.hasClass('.settings')) {
expandSection($target);
}
} }
} }
...@@ -23,15 +23,14 @@ ...@@ -23,15 +23,14 @@
} }
.settings { .settings {
overflow: hidden;
border-bottom: 1px solid $gray-darker; border-bottom: 1px solid $gray-darker;
&:first-of-type { &:first-of-type {
margin-top: 10px; margin-top: 10px;
} }
&.expanded { &.animating {
overflow: visible; overflow: hidden;
} }
} }
...@@ -56,14 +55,18 @@ ...@@ -56,14 +55,18 @@
overflow-y: scroll; overflow-y: scroll;
padding-right: 110px; padding-right: 110px;
animation: collapseMaxHeight 300ms ease-out; animation: collapseMaxHeight 300ms ease-out;
// Keep the section from expanding when we scroll over it
pointer-events: none;
&.expanded { .settings.expanded & {
max-height: none; max-height: none;
overflow-y: visible; overflow-y: visible;
animation: expandMaxHeight 300ms ease-in; animation: expandMaxHeight 300ms ease-in;
// Reset and allow clicks again when expanded
pointer-events: auto;
} }
&.no-animate { .settings.no-animate & {
animation: none; animation: none;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
- project = local_assigns.fetch(:project) - project = local_assigns.fetch(:project)
- expanded = Rails.env.test? - expanded = Rails.env.test?
%section.settings %section.settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Export project Export project
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Export this project with all its related data in order to move your project to a new GitLab instance. Once the export is finished, you can import the file from the "New Project" page. Export this project with all its related data in order to move your project to a new GitLab instance. Once the export is finished, you can import the file from the "New Project" page.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
.bs-callout.bs-callout-info .bs-callout.bs-callout-info
%p.append-bottom-0 %p.append-bottom-0
%p %p
......
- expanded = Rails.env.test? - expanded = Rails.env.test?
%section.settings %section.settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Deploy Keys Deploy Keys
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Deploy keys allow read-only or read-write (if enabled) access to your repository. Deploy keys can be used for CI, staging or production servers. You can create a deploy key or add an existing one. Deploy keys allow read-only or read-write (if enabled) access to your repository. Deploy keys can be used for CI, staging or production servers. You can create a deploy key or add an existing one.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
%h5.prepend-top-0 %h5.prepend-top-0
Create a new deploy key for this project Create a new deploy key for this project
= render @deploy_keys.form_partial_path = render @deploy_keys.form_partial_path
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= webpack_bundle_tag('service_desk') = webpack_bundle_tag('service_desk')
.project-edit-container .project-edit-container
%section.settings.general-settings %section.settings.general-settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
General project settings General project settings
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Update your project name, description, avatar, and other general settings. Update your project name, description, avatar, and other general settings.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
.project-edit-errors .project-edit-errors
= form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "edit-project" }, authenticity_token: true do |f| = form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "edit-project" }, authenticity_token: true do |f|
%fieldset %fieldset
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
= link_to 'Remove avatar', project_avatar_path(@project), data: { confirm: "Project avatar will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-sm remove-avatar" = link_to 'Remove avatar', project_avatar_path(@project), data: { confirm: "Project avatar will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-sm remove-avatar"
= f.submit 'Save changes', class: "btn btn-save" = f.submit 'Save changes', class: "btn btn-save"
%section.settings.sharing-permissions %section.settings.sharing-permissions.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Permissions Permissions
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Enable or disable certain project features and choose access levels. Enable or disable certain project features and choose access levels.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
= form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "sharing-permissions-form" }, authenticity_token: true do |f| = form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "sharing-permissions-form" }, authenticity_token: true do |f|
%script.js-project-permissions-form-data{ type: "application/json" }= project_permissions_panel_data(@project) %script.js-project-permissions-form-data{ type: "application/json" }= project_permissions_panel_data(@project)
.js-project-permissions-form .js-project-permissions-form
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
= render 'projects/ee/issues_settings' = render 'projects/ee/issues_settings'
%section.settings.merge-requests-feature{ class: ("hidden" if @project.project_feature.send(:merge_requests_access_level) == 0) } %section.settings.merge-requests-feature.no-animate{ class: [('expanded' if expanded), ('hidden' if @project.project_feature.send(:merge_requests_access_level) == 0)] }
.settings-header .settings-header
%h4 %h4
Merge request settings Merge request settings
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Customize your merge request restrictions. Customize your merge request restrictions.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
= render 'shared/promotions/promote_mr_features' = render 'shared/promotions/promote_mr_features'
= form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "merge-request-settings-form" }, authenticity_token: true do |f| = form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "merge-request-settings-form" }, authenticity_token: true do |f|
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
= render 'export', project: @project = render 'export', project: @project
%section.settings.advanced-settings %section.settings.advanced-settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Advanced settings Advanced settings
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Perform advanced options such as housekeeping, archiving, renaming, transferring, or removing your project. Perform advanced options such as housekeeping, archiving, renaming, transferring, or removing your project.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
.sub-section .sub-section
%h4 Housekeeping %h4 Housekeeping
%p %p
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- import_data = @project.import_data || @project.build_import_data - import_data = @project.import_data || @project.build_import_data
- protocols = AddressableUrlValidator::DEFAULT_OPTIONS[:protocols].join('|') - protocols = AddressableUrlValidator::DEFAULT_OPTIONS[:protocols].join('|')
%section.settings.project-mirror-settings %section.settings.project-mirror-settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Pull from a remote repository Pull from a remote repository
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
Set up your project to automatically have its branches, tags, and commits Set up your project to automatically have its branches, tags, and commits
updated from an upstream repository. updated from an upstream repository.
= link_to 'Read more', help_page_path('workflow/repository_mirroring', anchor: 'pulling-from-a-remote-repository'), target: '_blank' = link_to 'Read more', help_page_path('workflow/repository_mirroring', anchor: 'pulling-from-a-remote-repository'), target: '_blank'
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
= form_for @project, url: project_mirror_path(@project), html: { class: 'gl-show-field-errors project-mirror-push-form js-project-mirror-push-form', autocomplete: 'false', data: { project_mirror_endpoint: ssh_host_keys_project_mirror_path(@project, :json) } } do |f| = form_for @project, url: project_mirror_path(@project), html: { class: 'gl-show-field-errors project-mirror-push-form js-project-mirror-push-form', autocomplete: 'false', data: { project_mirror_endpoint: ssh_host_keys_project_mirror_path(@project, :json) } } do |f|
%div %div
= form_errors(@project) = form_errors(@project)
......
- expanded = Rails.env.test? - expanded = Rails.env.test?
%section.settings %section.settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Push to a remote repository Push to a remote repository
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
Set up the remote repository that you want to update with the content of the current repository Set up the remote repository that you want to update with the content of the current repository
every time someone pushes to it. every time someone pushes to it.
= link_to 'Read more', help_page_path('workflow/repository_mirroring', anchor: 'pushing-to-a-remote-repository'), target: '_blank' = link_to 'Read more', help_page_path('workflow/repository_mirroring', anchor: 'pushing-to-a-remote-repository'), target: '_blank'
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
= form_for @project, url: project_mirror_path(@project) do |f| = form_for @project, url: project_mirror_path(@project) do |f|
%div %div
= form_errors(@project) = form_errors(@project)
......
- expanded = Rails.env.test? - expanded = Rails.env.test?
%section.settings %section.settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Protected Branches Protected Branches
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Keep stable branches secure and force developers to use merge requests. Keep stable branches secure and force developers to use merge requests.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
%p %p
By default, protected branches are designed to: By default, protected branches are designed to:
%ul %ul
......
- expanded = Rails.env.test? - expanded = Rails.env.test?
%section.settings %section.settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Protected Tags Protected Tags
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Limit access to creating and updating tags. Limit access to creating and updating tags.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
%p %p
By default, protected tags are designed to: By default, protected tags are designed to:
%ul %ul
......
- return unless @project.feature_available?(:push_rules) - return unless @project.feature_available?(:push_rules)
- expanded = Rails.env.test? - expanded = Rails.env.test?
%section.settings %section.settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Push Rules Push Rules
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Push Rules outline what is accepted for this project. Push Rules outline what is accepted for this project.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
%h5 %h5
Add new push rule Add new push rule
= form_for [@project.namespace.becomes(Namespace), @project, @push_rule] do |f| = form_for [@project.namespace.becomes(Namespace), @project, @push_rule] do |f|
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
- expanded = Rails.env.test? - expanded = Rails.env.test?
%section.settings#js-general-pipeline-settings %section.settings#js-general-pipeline-settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
General pipelines settings General pipelines settings
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Update your CI/CD configuration, like job timeout or Auto DevOps. Update your CI/CD configuration, like job timeout or Auto DevOps.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
= render 'projects/pipelines_settings/show' = render 'projects/pipelines_settings/show'
%section.settings %section.settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Runners settings Runners settings
...@@ -23,10 +23,10 @@ ...@@ -23,10 +23,10 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Register and see your runners for this project. Register and see your runners for this project.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
= render 'projects/runners/index' = render 'projects/runners/index'
%section.settings %section.settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Secret variables Secret variables
...@@ -35,10 +35,10 @@ ...@@ -35,10 +35,10 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
= render "ci/variables/content" = render "ci/variables/content"
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
= render 'ci/variables/index' = render 'ci/variables/index'
%section.settings %section.settings.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Pipeline triggers Pipeline triggers
...@@ -48,5 +48,5 @@ ...@@ -48,5 +48,5 @@
Triggers can force a specific branch or tag to get rebuilt with an API call. These tokens will Triggers can force a specific branch or tag to get rebuilt with an API call. These tokens will
impersonate their associated user including their access to projects and their project impersonate their associated user including their access to projects and their project
permissions. permissions.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
= render 'projects/triggers/index' = render 'projects/triggers/index'
- if @project.feature_available?(:issuable_default_templates) - if @project.feature_available?(:issuable_default_templates)
- expanded = Rails.env.test? - expanded = Rails.env.test?
%section.settings.issues-feature{ class: ("hidden" if @project.project_feature.send(:issues_access_level) == 0) } %section.settings.issues-feature.no-animate{ class: [('expanded' if expanded), ('hidden' if @project.project_feature.send(:issues_access_level) == 0)] }
.settings-header .settings-header
%h4 %h4
Issue settings Issue settings
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= expanded ? 'Collapse' : 'Expand' = expanded ? 'Collapse' : 'Expand'
%p %p
Customize your issue restrictions. Customize your issue restrictions.
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
= form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "issue-settings-form" }, authenticity_token: true do |f| = form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { multipart: true, class: "issue-settings-form" }, authenticity_token: true do |f|
.form-group .form-group
= f.label :issues_template, class: 'label-light' do = f.label :issues_template, class: 'label-light' do
......
- if EE::Gitlab::ServiceDesk.enabled?(project: @project) || (show_promotions? && show_callout?('promote_service_desk_dismissed')) - if EE::Gitlab::ServiceDesk.enabled?(project: @project) || (show_promotions? && show_callout?('promote_service_desk_dismissed'))
- expanded = Rails.env.test? - expanded = Rails.env.test?
%section.settings.js-service-desk-setting-wrapper %section.settings.js-service-desk-setting-wrapper.no-animate{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
Service Desk Service Desk
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
%p %p
Customize your service desk settings. Customize your service desk settings.
= link_to "Learn more about service desk.", help_page_path('user/project/service_desk') = link_to "Learn more about service desk.", help_page_path('user/project/service_desk')
.settings-content.no-animate{ class: ('expanded' if expanded) } .settings-content
- if EE::Gitlab::ServiceDesk.enabled?(project: @project) - if EE::Gitlab::ServiceDesk.enabled?(project: @project)
.js-service-desk-setting-root{ data: { endpoint: project_service_desk_path(@project), .js-service-desk-setting-root{ data: { endpoint: project_service_desk_path(@project),
enabled: "#{@project.service_desk_enabled}", enabled: "#{@project.service_desk_enabled}",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment