Commit 2a6f3299 authored by Phil Hughes's avatar Phil Hughes

Remove Vue file list feature flag

This removes the Vue file list feature and also improves
some performance around rendering the tree.
parent 5e090e9c
import $ from 'jquery';
import 'jquery.waitforimages';
import initBlob from '~/blob_edit/blob_bundle';
import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation';
import NotificationsForm from '~/notifications_form';
import UserCallout from '~/user_callout';
import TreeView from '~/tree';
import BlobViewer from '~/blob/viewer/index';
import Activities from '~/activities';
import { ajaxGet } from '~/lib/utils/common_utils';
import GpgBadges from '~/gpg_badges';
import initReadMore from '~/read_more';
import leaveByUrl from '~/namespaces/leave_by_url';
import Star from '../../../star';
import notificationsDropdown from '../../../notifications_dropdown';
import initNamespaceStorageLimitAlert from '~/namespace_storage_limit_alert';
import { showLearnGitLabProjectPopover } from '~/onboarding_issues';
import initTree from 'ee_else_ce/repository';
document.addEventListener('DOMContentLoaded', () => {
initReadMore();
......@@ -31,10 +26,10 @@ document.addEventListener('DOMContentLoaded', () => {
});
// Project show page loads different overview content based on user preferences
const treeSlider = document.querySelector('#tree-slider');
const treeSlider = document.getElementById('js-tree-list');
if (treeSlider) {
new TreeView(); // eslint-disable-line no-new
initBlob();
initTree();
}
if (document.querySelector('.blob-viewer')) {
......@@ -45,21 +40,7 @@ document.addEventListener('DOMContentLoaded', () => {
new Activities(); // eslint-disable-line no-new
}
$(treeSlider).waitForImages(() => {
ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath);
});
GpgBadges.fetch();
leaveByUrl('project');
if (document.getElementById('js-tree-list')) {
initBlob();
import('ee_else_ce/repository')
.then(m => m.default())
.catch(e => {
throw e;
});
}
showLearnGitLabProjectPopover();
});
import $ from 'jquery';
import 'jquery.waitforimages';
import Vue from 'vue';
import initBlob from '~/blob_edit/blob_bundle';
import commitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue';
import GpgBadges from '~/gpg_badges';
import TreeView from '../../../../tree';
import ShortcutsNavigation from '../../../../behaviors/shortcuts/shortcuts_navigation';
import BlobViewer from '../../../../blob/viewer';
import NewCommitForm from '../../../../new_commit_form';
import { ajaxGet } from '../../../../lib/utils/common_utils';
import initTree from 'ee_else_ce/repository';
document.addEventListener('DOMContentLoaded', () => {
new ShortcutsNavigation(); // eslint-disable-line no-new
new TreeView(); // eslint-disable-line no-new
new BlobViewer(); // eslint-disable-line no-new
new NewCommitForm($('.js-create-dir-form')); // eslint-disable-line no-new
$('#tree-slider').waitForImages(() =>
ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath),
);
initBlob();
const commitPipelineStatusEl = document.querySelector('.js-commit-pipeline-status');
const statusLink = document.querySelector('.commit-actions .ci-status-link');
if (statusLink != null) {
statusLink.remove();
// eslint-disable-next-line no-new
new Vue({
el: commitPipelineStatusEl,
components: {
commitPipelineStatus,
},
render(createElement) {
return createElement('commit-pipeline-status', {
props: {
endpoint: commitPipelineStatusEl.dataset.endpoint,
},
});
},
});
}
GpgBadges.fetch();
if (document.getElementById('js-tree-list')) {
import('ee_else_ce/repository')
.then(m => m.default())
.catch(e => {
throw e;
});
}
initTree();
});
......@@ -80,7 +80,7 @@ export default {
<table-header v-once />
<tbody>
<parent-row
v-show="showParentRow"
v-if="showParentRow"
:commit-ref="escapedRef"
:path="path"
:loading-path="loadingPath"
......
......@@ -20,7 +20,7 @@ class Projects::TreeController < Projects::ApplicationController
end
def show
return render_404 unless @repository.commit(@ref)
return render_404 unless @commit
if tree.entries.empty?
if @repository.blob_at(@commit.id, @path)
......@@ -29,14 +29,6 @@ class Projects::TreeController < Projects::ApplicationController
return redirect_to_tree_root_for_missing_path(@project, @ref, @path)
end
end
respond_to do |format|
format.html do
lfs_blob_ids if Feature.disabled?(:vue_file_list, @project, default_enabled: true)
@last_commit = @repository.last_commit_for_path(@commit.id, @tree.path, literal_pathspec: true) || @commit
end
end
end
def create_dir
......
......@@ -22,7 +22,6 @@ class ProjectsController < Projects::ApplicationController
before_action :assign_ref_vars, if: -> { action_name == 'show' && repo_exists? }
before_action :tree,
if: -> { action_name == 'show' && repo_exists? && project_view_files? }
before_action :lfs_blob_ids, if: :show_blob_ids?, only: :show
before_action :project_export_enabled, only: [:export, :download_export, :remove_export, :generate_new_export]
before_action :present_project, only: [:edit]
before_action :authorize_download_code!, only: [:refs]
......@@ -302,10 +301,6 @@ class ProjectsController < Projects::ApplicationController
private
def show_blob_ids?
repo_exists? && project_view_files? && Feature.disabled?(:vue_file_list, @project, default_enabled: true)
end
# Render project landing depending of which features are available
# So if page is not available in the list it renders the next page
#
......
......@@ -732,10 +732,6 @@ module ProjectsHelper
!project.repository.gitlab_ci_yml
end
def vue_file_list_enabled?
Feature.enabled?(:vue_file_list, @project, default_enabled: true)
end
def native_code_navigation_enabled?(project)
Feature.enabled?(:code_navigation, project, default_enabled: true)
end
......
- is_project_overview = local_assigns.fetch(:is_project_overview, false)
- commit = local_assigns.fetch(:commit) { @repository.commit }
- ref = local_assigns.fetch(:ref) { current_ref }
- project = local_assigns.fetch(:project) { @project }
- content_url = local_assigns.fetch(:content_url) { @tree.readme ? project_blob_path(@project, tree_join(@ref, @tree.readme.path)) : project_tree_path(@project, @ref) }
- show_auto_devops_callout = show_auto_devops_callout?(@project)
- add_page_startup_api_call logs_file_project_ref_path(@project, ref, @path, format: "json", offset: 0)
- if @tree.readme
......@@ -12,19 +10,13 @@
.nav-block
= render 'projects/tree/tree_header', tree: @tree
- if vue_file_list_enabled?
#js-last-commit
- elsif commit
= render 'shared/commit_well', commit: commit, ref: ref, project: project
#js-last-commit
- if is_project_overview
.project-buttons.gl-mb-3{ class: ("js-show-on-project-root" if vue_file_list_enabled?) }
.project-buttons.gl-mb-3.js-show-on-project-root
= render 'stat_anchor_list', anchors: @project.statistics_buttons(show_auto_devops_callout: show_auto_devops_callout)
- if vue_file_list_enabled?
#js-tree-list{ data: vue_file_list_data(project, ref) }
- if can_edit_tree?
= render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: project_create_blob_path(@project, @id), method: :post
= render 'projects/blob/new_dir'
- else
= render 'projects/tree/tree_content', tree: @tree, content_url: content_url
#js-tree-list{ data: vue_file_list_data(project, ref) }
- if can_edit_tree?
= render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: project_create_blob_path(@project, @id), method: :post
= render 'projects/blob/new_dir'
......@@ -3,7 +3,7 @@
- max_project_topic_length = 15
- emails_disabled = @project.emails_disabled?
.project-home-panel{ class: [("empty-project" if empty_repo), ("js-show-on-project-root" if vue_file_list_enabled?)] }
.project-home-panel.js-show-on-project-root{ class: [("empty-project" if empty_repo)] }
.row.gl-mb-3
.home-panel-title-row.col-md-12.col-lg-6.d-flex
.avatar-container.rect-avatar.s64.home-panel-avatar.append-right-default.float-none
......
......@@ -12,13 +12,7 @@
%h5.m-0.dropdown-bold-header= _('Download source code')
.dropdown-menu-content
= render 'projects/buttons/download_links', project: project, ref: ref, archive_prefix: archive_prefix, path: nil
- if vue_file_list_enabled?
#js-directory-downloads{ data: { links: directory_download_links(project, ref, archive_prefix).to_json } }
- elsif directory?
%section.border-top.pt-1.mt-1
%h5.m-0.dropdown-bold-header= _('Download this directory')
.dropdown-menu-content
= render 'projects/buttons/download_links', project: project, ref: ref, archive_prefix: archive_prefix, path: @path
#js-directory-downloads{ data: { links: directory_download_links(project, ref, archive_prefix).to_json } }
- if pipeline && pipeline.latest_builds_with_artifacts.any?
%section.border-top.pt-1.mt-1
%h5.m-0.dropdown-bold-header= _('Download artifacts')
......
......@@ -7,10 +7,6 @@
= render partial: 'flash_messages', locals: { project: @project }
- if !@project.empty_repo? && can?(current_user, :download_code, @project) && !vue_file_list_enabled?
- signatures_path = project_signatures_path(@project, @project.default_branch)
.js-signature-container{ data: { 'signatures-path': signatures_path } }
%div{ class: [("limit-container-width" unless fluid_layout)] }
= render "projects/last_push"
......
- if readme.rich_viewer
%article.file-holder.readme-holder{ id: 'readme', class: [("limited-width-container" unless fluid_layout), ("js-show-on-root" if vue_file_list_enabled?)] }
%article.file-holder.readme-holder{ id: 'readme', class: [("limited-width-container" unless fluid_layout)] }
.js-file-title.file-title-flex-parent
.file-header-content
= blob_icon readme.mode, readme.name
......
......@@ -5,92 +5,17 @@
.tree-ref-holder
= render 'shared/ref_switcher', destination: 'tree', path: @path, show_create: true
- if on_top_of_branch?
- addtotree_toggle_attributes = { 'data-toggle': 'dropdown', 'data-target': '.add-to-tree-dropdown', 'data-boundary': 'window' }
- else
- addtotree_toggle_attributes = { title: _("You can only add files when you are on a branch"), data: { container: 'body' }, class: 'disabled has-tooltip' }
- if vue_file_list_enabled?
#js-repo-breadcrumb{ data: breadcrumb_data_attributes }
- else
%ul.breadcrumb.repo-breadcrumb
%li.breadcrumb-item
= link_to project_tree_path(@project, @ref) do
= @project.path
- path_breadcrumbs do |title, path|
%li.breadcrumb-item
= link_to truncate(title, length: 40), project_tree_path(@project, tree_join(@ref, path))
- if can_collaborate || can_create_mr_from_fork
%li.breadcrumb-item
%button.btn.add-to-tree.qa-add-to-tree{ addtotree_toggle_attributes, type: 'button' }
= sprite_icon('plus', size: 16, css_class: 'float-left')
= sprite_icon('chevron-down', size: 16, css_class: 'float-left')
- if on_top_of_branch?
.add-to-tree-dropdown
%ul.dropdown-menu
- if can_edit_tree?
%li.dropdown-header
#{ _('This directory') }
%li
= link_to project_new_blob_path(@project, @id), class: 'qa-new-file-option' do
#{ _('New file') }
%li
= link_to '#modal-upload-blob', { 'data-target' => '#modal-upload-blob', 'data-toggle' => 'modal' } do
#{ _('Upload file') }
%li
= link_to '#modal-create-new-dir', { 'data-target' => '#modal-create-new-dir', 'data-toggle' => 'modal' } do
#{ _('New directory') }
- elsif can_create_mr_from_fork
%li
- continue_params = { to: project_new_blob_path(@project, @id),
notice: edit_in_new_fork_notice,
notice_now: edit_in_new_fork_notice_now }
- fork_path = project_forks_path(@project, namespace_key: current_user.namespace.id, continue: continue_params)
= link_to fork_path, method: :post do
#{ _('New file') }
%li
- continue_params = { to: request.fullpath,
notice: edit_in_new_fork_notice + " Try to upload a file again.",
notice_now: edit_in_new_fork_notice_now }
- fork_path = project_forks_path(@project, namespace_key: current_user.namespace.id, continue: continue_params)
= link_to fork_path, method: :post do
#{ _('Upload file') }
%li
- continue_params = { to: request.fullpath,
notice: edit_in_new_fork_notice + " Try to create a new directory again.",
notice_now: edit_in_new_fork_notice_now }
- fork_path = project_forks_path(@project, namespace_key: current_user.namespace.id, continue: continue_params)
= link_to fork_path, method: :post do
#{ _('New directory') }
- if can?(current_user, :push_code, @project)
%li.divider
%li.dropdown-header
#{ _('This repository') }
%li
= link_to new_project_branch_path(@project) do
#{ _('New branch') }
%li
= link_to new_project_tag_path(@project) do
#{ _('New tag') }
#js-repo-breadcrumb{ data: breadcrumb_data_attributes }
.tree-controls
.d-block.d-sm-flex.flex-wrap.align-items-start.gl-children-ml-sm-3<
= render_if_exists 'projects/tree/lock_link'
- if vue_file_list_enabled?
#js-tree-history-link.d-inline-block{ data: { history_link: project_commits_path(@project, @ref) } }
- else
= link_to s_('Commits|History'), project_commits_path(@project, @id), class: 'btn'
#js-tree-history-link.d-inline-block{ data: { history_link: project_commits_path(@project, @ref) } }
= render 'projects/find_file_link'
- if can_collaborate || current_user&.already_forked?(@project)
- if vue_file_list_enabled?
#js-tree-web-ide-link.d-inline-block
- else
= link_to ide_edit_path(@project, @ref, @path), class: 'btn btn-default qa-web-ide-button' do
= _('Web IDE')
#js-tree-web-ide-link.d-inline-block
- elsif can_create_mr_from_fork
= link_to '#modal-confirm-fork', class: 'btn btn-default qa-web-ide-button', data: { target: '#modal-confirm-fork', toggle: 'modal'} do
= _('Web IDE')
......
- breadcrumb_title _("Repository")
- @content_class = "limit-container-width" unless fluid_layout
- signatures_path = namespace_project_signatures_path(namespace_id: @project.namespace.full_path, project_id: @project.path, id: @last_commit)
- page_title @path.presence || _("Files"), @ref
= content_for :meta_tags do
= auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, rss_url_options), title: "#{@project.name}:#{@ref} commits")
- unless vue_file_list_enabled?
.js-signature-container{ data: { 'signatures-path': signatures_path } }
= render 'projects/last_push'
= render 'projects/files', commit: @last_commit, project: @project, ref: @ref, content_url: project_tree_path(@project, @id)
import '~/pages/projects/tree/show/index';
import initPathLocks from 'ee/path_locks';
import { parseBoolean } from '~/lib/utils/common_utils';
document.addEventListener('DOMContentLoaded', () => {
const treeContent = document.querySelector('.js-tree-content');
if (treeContent && parseBoolean(treeContent.dataset.pathLocksAvailable)) {
initPathLocks(treeContent.dataset.pathLocksToggle, treeContent.dataset.pathLocksPath);
}
});
......@@ -5,9 +5,6 @@ module EE
def lock_file_link(project = @project, path = @path, html_options: {})
return unless project.feature_available?(:file_locks)
return unless current_user
# Always render the link if `vue_file_list` is enabled, the link will be hidden
# by the vue app if the path was blank
return if path.blank? && !vue_file_list_enabled?
path_lock = project.find_path_lock(path, downstream: true)
......
= lock_file_link(html_options: { class: "btn path-lock js-path-lock js-hide-on-root #{'hidden' if vue_file_list_enabled?}" })
= lock_file_link(html_options: { class: "btn path-lock js-path-lock js-hide-on-root hidden" })
......@@ -26102,9 +26102,6 @@ msgstr ""
msgid "You can now submit a merge request to get this change into the original project."
msgstr ""
msgid "You can only add files when you are on a branch"
msgstr ""
msgid "You can only edit files when you are on a branch"
msgstr ""
......
......@@ -51,9 +51,12 @@ module QA
element :quick_actions
end
view 'app/views/projects/tree/_tree_header.html.haml' do
view 'app/assets/javascripts/repository/components/breadcrumbs.vue' do
element :add_to_tree
element :new_file_option
end
view 'app/assets/javascripts/repository/index.js' do
element :web_ide_button
end
......
......@@ -89,34 +89,6 @@ RSpec.describe Projects::TreeController do
end
end
describe "GET show" do
context 'lfs_blob_ids instance variable' do
let(:id) { 'master' }
context 'with vue tree view enabled' do
before do
get(:show, params: { namespace_id: project.namespace.to_param, project_id: project, id: id })
end
it 'is not set' do
expect(assigns[:lfs_blob_ids]).to be_nil
end
end
context 'with vue tree view disabled' do
before do
stub_feature_flags(vue_file_list: false)
get(:show, params: { namespace_id: project.namespace.to_param, project_id: project, id: id })
end
it 'is set' do
expect(assigns[:lfs_blob_ids]).not_to be_nil
end
end
end
end
describe 'GET show with whitespace in ref' do
render_views
......
......@@ -386,36 +386,6 @@ RSpec.describe ProjectsController do
end
end
context 'lfs_blob_ids instance variable' do
let(:project) { create(:project, :public, :repository) }
before do
sign_in(user)
end
context 'with vue tree view enabled' do
before do
get :show, params: { namespace_id: project.namespace, id: project }
end
it 'is not set' do
expect(assigns[:lfs_blob_ids]).to be_nil
end
end
context 'with vue tree view disabled' do
before do
stub_feature_flags(vue_file_list: false)
get :show, params: { namespace_id: project.namespace, id: project }
end
it 'is set' do
expect(assigns[:lfs_blob_ids]).not_to be_nil
end
end
end
context 'namespace storage limit' do
let_it_be(:project) { create(:project, :public, :repository ) }
let(:namespace) { project.namespace }
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'projects/show.html.haml' do
include Devise::Test::ControllerHelpers
let(:user) { create(:admin) }
let(:project) { create(:project, :repository) }
before do
presented_project = project.present(current_user: user)
allow(presented_project).to receive(:default_view).and_return('customize_workflow')
allow(controller).to receive(:current_user).and_return(user)
assign(:project, presented_project)
end
context 'commit signatures' do
context 'with vue tree view enabled' do
it 'are not rendered via js-signature-container' do
render
expect(rendered).not_to have_css('.js-signature-container')
end
end
context 'with vue tree view disabled' do
before do
stub_feature_flags(vue_file_list: false)
end
it 'rendered via js-signature-container' do
render
expect(rendered).to have_css('.js-signature-container')
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'projects/tree/_tree_header' do
let(:project) { create(:project, :repository) }
let(:current_user) { create(:user) }
let(:repository) { project.repository }
before do
stub_feature_flags(vue_file_list: false)
assign(:project, project)
assign(:repository, repository)
assign(:id, File.join('master', ''))
assign(:ref, 'master')
allow(view).to receive(:current_user).and_return(current_user)
allow(view).to receive(:can_collaborate_with_project?) { true }
end
it 'renders the WebIDE button when user can collaborate but not create fork or MR' do
allow(view).to receive(:can?) { false }
render
expect(rendered).to have_link('Web IDE')
end
it 'renders the WebIDE button when user can create fork and can open MR in project' do
allow(view).to receive(:can?) { true }
render
expect(rendered).to have_link('Web IDE')
end
it 'opens a popup confirming a fork if the user can create fork/MR but cannot collaborate with the project' do
allow(view).to receive(:can?) { true }
allow(view).to receive(:can_collaborate_with_project?) { false }
render
expect(rendered).to have_link('Web IDE', href: '#modal-confirm-fork')
end
it 'does not render the WebIDE button when user cannot collaborate or create mr' do
allow(view).to receive(:can?) { false }
allow(view).to receive(:can_collaborate_with_project?) { false }
render
expect(rendered).not_to have_link('Web IDE')
end
end
......@@ -39,26 +39,4 @@ RSpec.describe 'projects/tree/show' do
expect(rendered).to have_css('.js-project-refs-dropdown .dropdown-toggle-text', text: ref)
end
end
context 'commit signatures' do
context 'with vue tree view disabled' do
before do
stub_feature_flags(vue_file_list: false)
end
it 'rendered via js-signature-container' do
render
expect(rendered).to have_css('.js-signature-container')
end
end
context 'with vue tree view enabled' do
it 'are not rendered via js-signature-container' do
render
expect(rendered).not_to have_css('.js-signature-container')
end
end
end
end
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