Commit 6f602c0e authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '222763-show-iteration-reports-in-sub-groups-projects' into 'master'

Show iteration list in project iteration page

See merge request gitlab-org/gitlab!37961
parents 116d7b5c f9d0812c
...@@ -17,7 +17,7 @@ export default { ...@@ -17,7 +17,7 @@ export default {
GlTabs, GlTabs,
}, },
props: { props: {
groupPath: { fullPath: {
type: String, type: String,
required: true, required: true,
}, },
...@@ -33,7 +33,7 @@ export default { ...@@ -33,7 +33,7 @@ export default {
}, },
}, },
apollo: { apollo: {
group: { namespace: {
query: GroupIterationQuery, query: GroupIterationQuery,
variables() { variables() {
return this.queryVariables; return this.queryVariables;
...@@ -51,7 +51,7 @@ export default { ...@@ -51,7 +51,7 @@ export default {
}, },
data() { data() {
return { return {
group: { namespace: {
iterations: [], iterations: [],
pageInfo: { pageInfo: {
hasNextPage: true, hasNextPage: true,
...@@ -68,7 +68,7 @@ export default { ...@@ -68,7 +68,7 @@ export default {
computed: { computed: {
queryVariables() { queryVariables() {
const vars = { const vars = {
fullPath: this.groupPath, fullPath: this.fullPath,
state: this.state, state: this.state,
}; };
...@@ -83,10 +83,10 @@ export default { ...@@ -83,10 +83,10 @@ export default {
return vars; return vars;
}, },
iterations() { iterations() {
return this.group.iterations; return this.namespace.iterations;
}, },
loading() { loading() {
return this.$apollo.queries.group.loading; return this.$apollo.queries.namespace.loading;
}, },
state() { state() {
switch (this.tabIndex) { switch (this.tabIndex) {
...@@ -100,15 +100,15 @@ export default { ...@@ -100,15 +100,15 @@ export default {
} }
}, },
prevPage() { prevPage() {
return Number(this.group.pageInfo.hasPreviousPage); return Number(this.namespace.pageInfo.hasPreviousPage);
}, },
nextPage() { nextPage() {
return Number(this.group.pageInfo.hasNextPage); return Number(this.namespace.pageInfo.hasNextPage);
}, },
}, },
methods: { methods: {
handlePageChange(page) { handlePageChange(page) {
const { startCursor, endCursor } = this.group.pageInfo; const { startCursor, endCursor } = this.namespace.pageInfo;
if (page > this.pagination.currentPage) { if (page > this.pagination.currentPage) {
this.pagination = { this.pagination = {
......
...@@ -21,7 +21,7 @@ export function initIterationsList() { ...@@ -21,7 +21,7 @@ export function initIterationsList() {
render(createElement) { render(createElement) {
return createElement(Iterations, { return createElement(Iterations, {
props: { props: {
groupPath: el.dataset.groupFullPath, fullPath: el.dataset.fullPath,
canAdmin: parseBoolean(el.dataset.canAdmin), canAdmin: parseBoolean(el.dataset.canAdmin),
newIterationPath: el.dataset.newIterationPath, newIterationPath: el.dataset.newIterationPath,
}, },
......
import { initIterationsList } from 'ee/iterations';
document.addEventListener('DOMContentLoaded', initIterationsList);
- page_title _("Iterations") - page_title _("Iterations")
- if Feature.enabled?(:group_iterations, @group, default_enabled: true) - if Feature.enabled?(:group_iterations, @group, default_enabled: true)
.js-iterations-list{ data: { group_full_path: @group.full_path, can_admin: can?(current_user, :create_iteration, @group).to_s, new_iteration_path: new_group_iteration_path(@group) } } .js-iterations-list{ data: { full_path: @group.full_path, can_admin: can?(current_user, :create_iteration, @group).to_s, new_iteration_path: new_group_iteration_path(@group) } }
- return unless Feature.enabled?(:project_iterations, @project.group, default_enabled: false) - return unless Feature.enabled?(:project_iterations, @project.group)
- return unless @project.feature_available?(:iterations) - return unless @project.feature_available?(:iterations)
- return unless can?(current_user, :read_iteration, @project) - return unless can?(current_user, :read_iteration, @project)
......
- page_title _("Iterations") - page_title _("Iterations")
- if Feature.enabled?(:project_iterations, @project.group)
.js-iterations-list{ data: { full_path: @project.group.full_path } }
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Iterations list', :js do
let(:now) { Time.now }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, :public, group: group) }
let_it_be(:user) { create(:user) }
let!(:started_iteration) { create(:iteration, :skip_future_date_validation, group: group, start_date: now - 1.day, due_date: now) }
let!(:upcoming_iteration) { create(:iteration, group: group, start_date: now + 1.day, due_date: now + 2.days) }
let!(:closed_iteration) { create(:closed_iteration, :skip_future_date_validation, group: group, start_date: now - 3.days, due_date: now - 2.days) }
context 'as guest' do
before do
visit project_iterations_path(project)
end
it 'shows iterations on each tab' do
expect(page).to have_link(started_iteration.title)
expect(page).to have_link(upcoming_iteration.title)
expect(page).not_to have_link(closed_iteration.title)
click_link('Closed')
expect(page).to have_link(closed_iteration.title)
expect(page).not_to have_link(started_iteration.title)
expect(page).not_to have_link(upcoming_iteration.title)
click_link('All')
expect(page).to have_link(started_iteration.title)
expect(page).to have_link(upcoming_iteration.title)
expect(page).to have_link(closed_iteration.title)
end
end
context 'as authorized user' do
before do
project.add_developer(user)
sign_in(user)
visit project_iterations_path(project)
end
it 'does not show "New iteration" button' do
expect(page).not_to have_link('New iteration')
end
end
end
...@@ -6,7 +6,7 @@ import { GlAlert, GlLoadingIcon, GlPagination, GlTab, GlTabs } from '@gitlab/ui' ...@@ -6,7 +6,7 @@ import { GlAlert, GlLoadingIcon, GlPagination, GlTab, GlTabs } from '@gitlab/ui'
describe('Iterations tabs', () => { describe('Iterations tabs', () => {
let wrapper; let wrapper;
const defaultProps = { const defaultProps = {
groupPath: 'gitlab-org', fullPath: 'gitlab-org',
}; };
const mountComponent = ({ props = defaultProps, loading = false } = {}) => { const mountComponent = ({ props = defaultProps, loading = false } = {}) => {
...@@ -14,7 +14,7 @@ describe('Iterations tabs', () => { ...@@ -14,7 +14,7 @@ describe('Iterations tabs', () => {
propsData: props, propsData: props,
mocks: { mocks: {
$apollo: { $apollo: {
queries: { group: { loading } }, queries: { namespace: { loading } },
}, },
}, },
stubs: { stubs: {
...@@ -74,7 +74,7 @@ describe('Iterations tabs', () => { ...@@ -74,7 +74,7 @@ describe('Iterations tabs', () => {
loading: false, loading: false,
}); });
wrapper.setData({ wrapper.setData({
group: { namespace: {
pageInfo: { pageInfo: {
hasNextPage: true, hasNextPage: true,
hasPreviousPage: false, hasPreviousPage: false,
...@@ -102,7 +102,7 @@ describe('Iterations tabs', () => { ...@@ -102,7 +102,7 @@ describe('Iterations tabs', () => {
expect(wrapper.vm.queryVariables).toEqual({ expect(wrapper.vm.queryVariables).toEqual({
beforeCursor: 'first-item', beforeCursor: 'first-item',
lastPageSize: 20, lastPageSize: 20,
fullPath: defaultProps.groupPath, fullPath: defaultProps.fullPath,
state: 'opened', state: 'opened',
}); });
}); });
...@@ -113,7 +113,7 @@ describe('Iterations tabs', () => { ...@@ -113,7 +113,7 @@ describe('Iterations tabs', () => {
expect(wrapper.vm.queryVariables).toEqual({ expect(wrapper.vm.queryVariables).toEqual({
afterCursor: 'last-item', afterCursor: 'last-item',
firstPageSize: 20, firstPageSize: 20,
fullPath: defaultProps.groupPath, fullPath: defaultProps.fullPath,
state: 'opened', state: 'opened',
}); });
}); });
......
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