diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 15:09:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 15:09:30 +0300 |
commit | 0549ffef0d4f862a7354847dd185725cc196eed0 (patch) | |
tree | ab738498979b577ad3c89a986c6690250bcff104 /app | |
parent | 03409cccee9b1cd8104484077338790add355c7d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
24 files changed, 316 insertions, 87 deletions
diff --git a/app/assets/javascripts/emoji/components/category.vue b/app/assets/javascripts/emoji/components/category.vue index db6ead3ff69..39881979c4f 100644 --- a/app/assets/javascripts/emoji/components/category.vue +++ b/app/assets/javascripts/emoji/components/category.vue @@ -39,7 +39,7 @@ export default { <template> <gl-intersection-observer class="gl-px-5 gl-h-full" @appear="categoryAppeared"> - <div class="gl-top-0 gl-py-3 gl-w-full emoji-picker-category-header"> + <div class="gl-top-0 gl-py-3 gl-w-full gl-z-index-1 emoji-picker-category-header"> <b>{{ categoryTitle }}</b> </div> <template v-if="emojis.length"> diff --git a/app/assets/javascripts/emoji/components/picker.vue b/app/assets/javascripts/emoji/components/picker.vue index cbcc5dcff3a..71cabe80529 100644 --- a/app/assets/javascripts/emoji/components/picker.vue +++ b/app/assets/javascripts/emoji/components/picker.vue @@ -101,7 +101,7 @@ export default { v-for="(category, index) in categoryNames" :key="category.name" :class="{ - 'gl-text-black-normal! emoji-picker-category-active': index === currentCategory, + 'gl-text-body! emoji-picker-category-active': index === currentCategory, }" type="button" class="gl-border-0 gl-border-b-2 gl-border-b-solid gl-flex-fill-1 gl-text-gray-300 gl-pt-3 gl-pb-3 gl-bg-transparent emoji-picker-category-tab" diff --git a/app/assets/javascripts/notebook/cells/markdown.vue b/app/assets/javascripts/notebook/cells/markdown.vue index e4cde0d4ff3..c09db6851e5 100644 --- a/app/assets/javascripts/notebook/cells/markdown.vue +++ b/app/assets/javascripts/notebook/cells/markdown.vue @@ -37,6 +37,11 @@ const katexRegexString = `( .replace(/\s/g, '') .trim(); +function deHTMLify(t) { + // get some specific characters back, that are allowed for KaTex rendering + const text = t.replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>'); + return text; +} function renderKatex(t) { let text = t; let numInline = 0; // number of successfull converted math formulas @@ -57,9 +62,7 @@ function renderKatex(t) { while (matches !== null) { try { - const renderedKatex = katex.renderToString( - matches[0].replace(/\$/g, '').replace(/'/g, "'"), - ); // get the tick ' back again from HTMLified string + const renderedKatex = katex.renderToString(deHTMLify(matches[0].replace(/\$/g, ''))); text = `${text.replace(matches[0], ` ${renderedKatex}`)}`; } catch { numInline -= 1; @@ -68,7 +71,7 @@ function renderKatex(t) { } } else { try { - text = katex.renderToString(matches[2].replace(/'/g, "'")); + text = katex.renderToString(deHTMLify(matches[2])); } catch (error) { numInline -= 1; } diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index b5139ba7638..18aa0d3013d 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -82,7 +82,7 @@ $darken-border-dashed-factor: 25% !default; $white: #fff !default; $white-normal: #f0f0f0 !default; $white-dark: #eaeaea !default; -$white-transparent: rgba(255, 255, 255, 0.8) !default; +$white-transparent: rgba($white, 0.8) !default; $gray-lightest: #fdfdfd !default; $gray-light: #fafafa !default; diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index 5df7ff0632a..ec7ab8a2fa8 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -24,8 +24,6 @@ class Groups::GroupMembersController < Groups::ApplicationController def index @sort = params[:sort].presence || sort_value_name - @project = @group.projects.find(params[:project_id]) if params[:project_id] - @members = GroupMembersFinder .new(@group, current_user, params: filter_params) .execute(include_relations: requested_relations) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 68c3738d19e..4be6cd4276b 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -746,25 +746,6 @@ module ProjectsHelper ] end - def sidebar_repository_paths - %w[ - tree - blob - blame - edit_tree - new_tree - find_file - commit - commits - compare - projects/repositories - tags - branches - graphs - network - ] - end - def sidebar_operations_paths %w[ environments diff --git a/app/helpers/sidebars_helper.rb b/app/helpers/sidebars_helper.rb index b0fffe93c25..31dfe21671a 100644 --- a/app/helpers/sidebars_helper.rb +++ b/app/helpers/sidebars_helper.rb @@ -14,8 +14,10 @@ module SidebarsHelper end end - def project_sidebar_context(project, user) - Sidebars::Projects::Context.new(**project_sidebar_context_data(project, user)) + def project_sidebar_context(project, user, current_ref) + context_data = project_sidebar_context_data(project, user, current_ref) + + Sidebars::Projects::Context.new(**context_data) end private @@ -32,11 +34,12 @@ module SidebarsHelper tracking_attrs('user_side_navigation', 'render', 'user_side_navigation') end - def project_sidebar_context_data(project, user) + def project_sidebar_context_data(project, user, current_ref) { current_user: user, container: project, - learn_gitlab_experiment_enabled: learn_gitlab_experiment_enabled?(project) + learn_gitlab_experiment_enabled: learn_gitlab_experiment_enabled?(project), + current_ref: current_ref } end end diff --git a/app/models/concerns/sidebars/container_with_html_options.rb b/app/models/concerns/sidebars/container_with_html_options.rb index 8cb2fc7d6b2..12ea366c66a 100644 --- a/app/models/concerns/sidebars/container_with_html_options.rb +++ b/app/models/concerns/sidebars/container_with_html_options.rb @@ -7,7 +7,7 @@ module Sidebars # `link_to` or the div containing the container. def container_html_options { - title: title + aria: { label: title } }.merge(extra_container_html_options) end diff --git a/app/models/namespaces/traversal/linear.rb b/app/models/namespaces/traversal/linear.rb index dd9ca8d9bea..294ef83b9b4 100644 --- a/app/models/namespaces/traversal/linear.rb +++ b/app/models/namespaces/traversal/linear.rb @@ -86,7 +86,25 @@ module Namespaces raise UnboundedSearch.new('Must bound search by a top') unless top without_sti_condition - .traversal_ids_contains("{#{top.id}}") + .traversal_ids_contains(latest_traversal_ids(top)) + end + + # traversal_ids are a cached value. + # + # The traversal_ids value in a loaded object can become stale when compared + # to the database value. For example, if you load a hierarchy and then move + # a group, any previously loaded descendant objects will have out of date + # traversal_ids. + # + # To solve this problem, we never depend on the object's traversal_ids + # value. We always query the database first with a sub-select for the + # latest traversal_ids. + # + # Note that ActiveRecord will cache query results. You can avoid this by + # using `Model.uncached { ... }` + def latest_traversal_ids(namespace = self) + without_sti_condition.where('id = (?)', namespace) + .select('traversal_ids as latest_traversal_ids') end end end diff --git a/app/models/sidebars/projects/menus/project_overview/menu_items/details.rb b/app/models/sidebars/projects/menus/project_overview/menu_items/details.rb index c8cf5d503ab..c40c2ed8fa2 100644 --- a/app/models/sidebars/projects/menus/project_overview/menu_items/details.rb +++ b/app/models/sidebars/projects/menus/project_overview/menu_items/details.rb @@ -14,7 +14,7 @@ module Sidebars override :extra_container_html_options def extra_container_html_options { - title: _('Project details'), + aria: { label: _('Project details') }, class: 'shortcuts-project' } end diff --git a/app/models/sidebars/projects/menus/repository/menu.rb b/app/models/sidebars/projects/menus/repository/menu.rb new file mode 100644 index 00000000000..f49a0479521 --- /dev/null +++ b/app/models/sidebars/projects/menus/repository/menu.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + module Repository + class Menu < ::Sidebars::Menu + override :configure_menu_items + def configure_menu_items + add_item(MenuItems::Files.new(context)) + add_item(MenuItems::Commits.new(context)) + add_item(MenuItems::Branches.new(context)) + add_item(MenuItems::Tags.new(context)) + add_item(MenuItems::Contributors.new(context)) + add_item(MenuItems::Graphs.new(context)) + add_item(MenuItems::Compare.new(context)) + end + + override :link + def link + project_tree_path(context.project) + end + + override :extra_container_html_options + def extra_container_html_options + { + class: 'shortcuts-tree' + } + end + + override :title + def title + _('Repository') + end + + override :title_html_options + def title_html_options + { + id: 'js-onboarding-repo-link' + } + end + + override :sprite_icon + def sprite_icon + 'doc-text' + end + + override :render? + def render? + can?(context.current_user, :download_code, context.project) && + !context.project.empty_repo? + end + end + end + end + end +end + +Sidebars::Projects::Menus::Repository::Menu.prepend_if_ee('EE::Sidebars::Projects::Menus::Repository::Menu') diff --git a/app/models/sidebars/projects/menus/repository/menu_items/branches.rb b/app/models/sidebars/projects/menus/repository/menu_items/branches.rb new file mode 100644 index 00000000000..4a62803dd2b --- /dev/null +++ b/app/models/sidebars/projects/menus/repository/menu_items/branches.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + module Repository + module MenuItems + class Branches < ::Sidebars::MenuItem + override :link + def link + project_branches_path(context.project) + end + + override :extra_container_html_options + def extra_container_html_options + { + id: 'js-onboarding-branches-link' + } + end + + override :active_routes + def active_routes + { controller: :branches } + end + + override :title + def title + _('Branches') + end + end + end + end + end + end +end diff --git a/app/models/sidebars/projects/menus/repository/menu_items/commits.rb b/app/models/sidebars/projects/menus/repository/menu_items/commits.rb new file mode 100644 index 00000000000..647cf89133e --- /dev/null +++ b/app/models/sidebars/projects/menus/repository/menu_items/commits.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + module Repository + module MenuItems + class Commits < ::Sidebars::MenuItem + override :link + def link + project_commits_path(context.project, context.current_ref) + end + + override :extra_container_html_options + def extra_container_html_options + { + id: 'js-onboarding-commits-link' + } + end + + override :active_routes + def active_routes + { controller: %w(commit commits) } + end + + override :title + def title + _('Commits') + end + end + end + end + end + end +end diff --git a/app/models/sidebars/projects/menus/repository/menu_items/compare.rb b/app/models/sidebars/projects/menus/repository/menu_items/compare.rb new file mode 100644 index 00000000000..4812636b63f --- /dev/null +++ b/app/models/sidebars/projects/menus/repository/menu_items/compare.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + module Repository + module MenuItems + class Compare < ::Sidebars::MenuItem + override :link + def link + project_compare_index_path(context.project, from: context.project.repository.root_ref, to: context.current_ref) + end + + override :active_routes + def active_routes + { controller: :compare } + end + + override :title + def title + _('Compare') + end + end + end + end + end + end +end diff --git a/app/models/sidebars/projects/menus/repository/menu_items/contributors.rb b/app/models/sidebars/projects/menus/repository/menu_items/contributors.rb new file mode 100644 index 00000000000..d60fd05bb64 --- /dev/null +++ b/app/models/sidebars/projects/menus/repository/menu_items/contributors.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + module Repository + module MenuItems + class Contributors < ::Sidebars::MenuItem + override :link + def link + project_graph_path(context.project, context.current_ref) + end + + override :active_routes + def active_routes + { path: 'graphs#show' } + end + + override :title + def title + _('Contributors') + end + end + end + end + end + end +end diff --git a/app/models/sidebars/projects/menus/repository/menu_items/files.rb b/app/models/sidebars/projects/menus/repository/menu_items/files.rb new file mode 100644 index 00000000000..4989efe9fa5 --- /dev/null +++ b/app/models/sidebars/projects/menus/repository/menu_items/files.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + module Repository + module MenuItems + class Files < ::Sidebars::MenuItem + override :link + def link + project_tree_path(context.project, context.current_ref) + end + + override :active_routes + def active_routes + { controller: %w[tree blob blame edit_tree new_tree find_file] } + end + + override :title + def title + _('Files') + end + end + end + end + end + end +end diff --git a/app/models/sidebars/projects/menus/repository/menu_items/graphs.rb b/app/models/sidebars/projects/menus/repository/menu_items/graphs.rb new file mode 100644 index 00000000000..a57021be4d0 --- /dev/null +++ b/app/models/sidebars/projects/menus/repository/menu_items/graphs.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + module Repository + module MenuItems + class Graphs < ::Sidebars::MenuItem + override :link + def link + project_network_path(context.project, context.current_ref) + end + + override :active_routes + def active_routes + { controller: :network } + end + + override :title + def title + _('Graph') + end + end + end + end + end + end +end diff --git a/app/models/sidebars/projects/menus/repository/menu_items/tags.rb b/app/models/sidebars/projects/menus/repository/menu_items/tags.rb new file mode 100644 index 00000000000..d84bc89b93c --- /dev/null +++ b/app/models/sidebars/projects/menus/repository/menu_items/tags.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + module Repository + module MenuItems + class Tags < ::Sidebars::MenuItem + override :link + def link + project_tags_path(context.project) + end + + override :active_routes + def active_routes + { controller: :tags } + end + + override :title + def title + _('Tags') + end + end + end + end + end + end +end diff --git a/app/models/sidebars/projects/panel.rb b/app/models/sidebars/projects/panel.rb index 60cb804f5e8..ec4fac53a40 100644 --- a/app/models/sidebars/projects/panel.rb +++ b/app/models/sidebars/projects/panel.rb @@ -9,6 +9,7 @@ module Sidebars add_menu(Sidebars::Projects::Menus::ProjectOverview::Menu.new(context)) add_menu(Sidebars::Projects::Menus::LearnGitlab::Menu.new(context)) + add_menu(Sidebars::Projects::Menus::Repository::Menu.new(context)) end override :render_raw_menus_partial diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index fa6248c9a3d..e34808665bb 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -101,7 +101,7 @@ enabled: Gitlab.config.registry.enabled, doc_href: help_page_path('user/packages/container_registry/index')) - = feature_entry(_('Gitlab Pages'), + = feature_entry(_('GitLab Pages'), enabled: Gitlab.config.pages.enabled, doc_href: help_instance_configuration_url) diff --git a/app/views/devise/mailer/_confirmation_instructions_secondary.html.haml b/app/views/devise/mailer/_confirmation_instructions_secondary.html.haml index f14d50eaf71..97fdf0249da 100644 --- a/app/views/devise/mailer/_confirmation_instructions_secondary.html.haml +++ b/app/views/devise/mailer/_confirmation_instructions_secondary.html.haml @@ -1,8 +1,8 @@ #content - = email_default_heading("#{sanitize_name(@resource.user.name)}, confirm your email address now!") - %p Click the link below to confirm your email address (#{@resource.email}) + = email_default_heading(_("%{name}, confirm your email address now!") % { name: sanitize_name(@resource.user.name) }) + %p= _('Click the link below to confirm your email address (%{email})') % { email: @resource.email } #cta - = link_to 'Confirm your email address', confirmation_url(@resource, confirmation_token: @token) + = link_to _('Confirm your email address'), confirmation_url(@resource, confirmation_token: @token) %p - If this email was added in error, you can remove it here: - = link_to "Emails", profile_emails_url + = _('If this email was added in error, you can remove it here:') + = link_to _("Emails"), profile_emails_url diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml index 5cb109cf275..3d0c6baffd5 100644 --- a/app/views/layouts/nav/sidebar/_project.html.haml +++ b/app/views/layouts/nav/sidebar/_project.html.haml @@ -1,3 +1,3 @@ -# We're migration the project sidebar to a logical model based structure. If you need to update -# any of the existing menus, you can find them in app/views/layouts/nav/sidebar/_project_menus.html.haml. -= render partial: 'shared/nav/sidebar', object: Sidebars::Projects::Panel.new(project_sidebar_context(@project, current_user)) += render partial: 'shared/nav/sidebar', object: Sidebars::Projects::Panel.new(project_sidebar_context(@project, current_user, current_ref)) diff --git a/app/views/layouts/nav/sidebar/_project_menus.html.haml b/app/views/layouts/nav/sidebar/_project_menus.html.haml index 8f2da398164..ed072c0f6a2 100644 --- a/app/views/layouts/nav/sidebar/_project_menus.html.haml +++ b/app/views/layouts/nav/sidebar/_project_menus.html.haml @@ -1,47 +1,3 @@ -- if project_nav_tab? :files - = nav_link(controller: sidebar_repository_paths, unless: -> { current_path?('projects/graphs#charts') }) do - = link_to project_tree_path(@project), class: 'shortcuts-tree', data: { qa_selector: "repository_link" } do - .nav-icon-container - = sprite_icon('doc-text') - %span.nav-item-name#js-onboarding-repo-link - = _('Repository') - - %ul.sidebar-sub-level-items - = nav_link(controller: sidebar_repository_paths, html_options: { class: "fly-out-top-item" } ) do - = link_to project_tree_path(@project) do - %strong.fly-out-top-item-name - = _('Repository') - %li.divider.fly-out-top-item - = nav_link(controller: %w(tree blob blame edit_tree new_tree find_file)) do - = link_to project_tree_path(@project) do - = _('Files') - - = nav_link(controller: [:commit, :commits]) do - = link_to project_commits_path(@project, current_ref), id: 'js-onboarding-commits-link' do - = _('Commits') - - = nav_link(html_options: {class: branches_tab_class}) do - = link_to project_branches_path(@project), data: { qa_selector: "branches_link" }, id: 'js-onboarding-branches-link' do - = _('Branches') - - = nav_link(controller: [:tags]) do - = link_to project_tags_path(@project), data: { qa_selector: "tags_link" } do - = _('Tags') - - = nav_link(path: 'graphs#show') do - = link_to project_graph_path(@project, current_ref) do - = _('Contributors') - - = nav_link(controller: %w(network)) do - = link_to project_network_path(@project, current_ref) do - = _('Graph') - - = nav_link(controller: :compare) do - = link_to project_compare_index_path(@project, from: @repository.root_ref, to: current_ref) do - = _('Compare') - - = render_if_exists 'projects/sidebar/repository_locked_files' - - if project_nav_tab? :issues = nav_link(controller: @project.issues_enabled? ? ['projects/issues', :labels, :milestones, :boards, :iterations] : 'projects/issues') do = link_to project_issues_path(@project), class: 'shortcuts-issues qa-issues-item' do diff --git a/app/views/shared/nav/_sidebar_menu.html.haml b/app/views/shared/nav/_sidebar_menu.html.haml index cd3222294f3..c6e86a90ba7 100644 --- a/app/views/shared/nav/_sidebar_menu.html.haml +++ b/app/views/shared/nav/_sidebar_menu.html.haml @@ -15,7 +15,7 @@ %ul.sidebar-sub-level-items{ class: ('is-fly-out-only' unless sidebar_menu.has_items?) } = nav_link(**sidebar_menu.all_active_routes, html_options: { class: 'fly-out-top-item' } ) do - = link_to sidebar_menu.link, title: sidebar_menu.title do + = link_to sidebar_menu.link, aria: { label: sidebar_menu.title } do %strong.fly-out-top-item-name = sidebar_menu.title - if sidebar_menu.has_pill? |