Commit bbd69351 authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch 'nfriend-add-skeleton-add-new-release-vue-app' into 'master'

Add placehold Vue app for "New Release" page

See merge request gitlab-org/gitlab!35367
parents 17b5c329 220264c8
import ZenMode from '~/zen_mode';
import initNewRelease from '~/releases/mount_new';
document.addEventListener('DOMContentLoaded', () => {
new ZenMode(); // eslint-disable-line no-new
initNewRelease();
});
<script>
export default {
name: 'ReleaseNewApp',
components: {},
};
</script>
<template>
<div></div>
</template>
import Vue from 'vue';
import ReleaseNewApp from './components/app_new.vue';
import createStore from './stores';
import createDetailModule from './stores/modules/detail';
export default () => {
const el = document.getElementById('js-new-release-page');
const store = createStore({
modules: {
detail: createDetailModule(el.dataset),
},
});
return new Vue({
el,
store,
render: h => h(ReleaseNewApp),
});
};
export default ({
projectId,
tagName,
releasesPagePath,
markdownDocsPath,
markdownPreviewPath,
updateReleaseApiDocsPath,
releaseAssetsDocsPath,
manageMilestonesPath,
newMilestonePath,
tagName = null,
releasesPagePath = null,
defaultBranch = null,
}) => ({
projectId,
tagName,
releasesPagePath,
markdownDocsPath,
markdownPreviewPath,
updateReleaseApiDocsPath,
......@@ -19,6 +19,10 @@ export default ({
manageMilestonesPath,
newMilestonePath,
tagName,
releasesPagePath,
defaultBranch,
/** The Release object */
release: null,
......
......@@ -26,11 +26,11 @@ class Projects::ReleasesController < Projects::ApplicationController
def show
return render_404 unless Feature.enabled?(:release_show_page, project, default_enabled: true)
end
respond_to do |format|
format.html do
render :show
end
def new
unless Feature.enabled?(:new_release_page, project)
return redirect_to(new_project_tag_path(@project))
end
end
......@@ -38,22 +38,12 @@ class Projects::ReleasesController < Projects::ApplicationController
redirect_to link.url
end
protected
private
def releases
ReleasesFinder.new(@project, current_user).execute
end
def edit
respond_to do |format|
format.html do
render :edit
end
end
end
private
def authorize_update_release!
access_denied! unless can?(current_user, :update_release, release)
end
......
......@@ -18,17 +18,36 @@ module ReleasesHelper
illustration_path: illustration,
documentation_path: help_page
}.tap do |data|
data[:new_release_path] = new_project_tag_path(@project) if can?(current_user, :create_release, @project)
if can?(current_user, :create_release, @project)
data[:new_release_path] = if Feature.enabled?(:new_release_page, @project)
new_project_release_path(@project)
else
new_project_tag_path(@project)
end
end
end
end
def data_for_edit_release_page
new_edit_pages_shared_data.merge(
tag_name: @release.tag,
releases_page_path: project_releases_path(@project, anchor: @release.tag)
)
end
def data_for_new_release_page
new_edit_pages_shared_data.merge(
default_branch: @project.default_branch
)
end
private
def new_edit_pages_shared_data
{
project_id: @project.id,
tag_name: @release.tag,
markdown_preview_path: preview_markdown_path(@project),
markdown_docs_path: help_page_path('user/markdown'),
releases_page_path: project_releases_path(@project, anchor: @release.tag),
update_release_api_docs_path: help_page_path('api/releases/index.md', anchor: 'update-a-release'),
release_assets_docs_path: help_page(anchor: 'release-assets'),
manage_milestones_path: project_milestones_path(@project),
......
- page_title s_('Releases|New Release')
#js-new-release-page{ data: data_for_new_release_page }
import Vue from 'vue';
import Vuex from 'vuex';
import { mount } from '@vue/test-utils';
import ReleaseNewApp from '~/releases/components/app_new.vue';
Vue.use(Vuex);
describe('Release new component', () => {
let wrapper;
const factory = () => {
const store = new Vuex.Store();
wrapper = mount(ReleaseNewApp, { store });
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('renders the app', () => {
factory();
expect(wrapper.exists()).toBe(true);
});
});
......@@ -22,6 +22,7 @@ RSpec.describe ReleasesHelper do
let(:can_user_create_release) { false }
let(:common_keys) { [:project_id, :illustration_path, :documentation_path] }
# rubocop: disable CodeReuse/ActiveRecord
before do
helper.instance_variable_set(:@project, project)
helper.instance_variable_set(:@release, release)
......@@ -30,6 +31,7 @@ RSpec.describe ReleasesHelper do
.with(user, :create_release, project)
.and_return(can_user_create_release)
end
# rubocop: enable CodeReuse/ActiveRecord
describe '#data_for_releases_page' do
it 'includes the required data for displaying release blocks' do
......@@ -41,7 +43,20 @@ RSpec.describe ReleasesHelper do
it 'includes new_release_path' do
expect(helper.data_for_releases_page.keys).to contain_exactly(*common_keys, :new_release_path)
expect(helper.data_for_releases_page[:new_release_path]).to eq(new_project_tag_path(project))
end
it 'points new_release_path to the "New Release" page' do
expect(helper.data_for_releases_page[:new_release_path]).to eq(new_project_release_path(project))
end
context 'when the "new_release_page" feature flag is disabled' do
before do
stub_feature_flags(new_release_page: false)
end
it 'points new_release_path to the "New Tag" page' do
expect(helper.data_for_releases_page[:new_release_path]).to eq(new_project_tag_path(project))
end
end
end
end
......@@ -57,7 +72,23 @@ RSpec.describe ReleasesHelper do
release_assets_docs_path
manage_milestones_path
new_milestone_path)
expect(helper.data_for_edit_release_page.keys).to eq(keys)
expect(helper.data_for_edit_release_page.keys).to match_array(keys)
end
end
describe '#data_for_new_release_page' do
it 'has the needed data to display the "new release" page' do
keys = %i(project_id
markdown_preview_path
markdown_docs_path
update_release_api_docs_path
release_assets_docs_path
manage_milestones_path
new_milestone_path
default_branch)
expect(helper.data_for_new_release_page.keys).to match_array(keys)
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