Commit 16697417 authored by Coung Ngo's avatar Coung Ngo

Refactor Vue issues list

Rename some variable names so that they are less project-specific
as the component will be reused for groups list pages too.
parent 52828e6a
......@@ -117,9 +117,15 @@ export default {
exportCsvPath: {
default: '',
},
fullPath: {
default: '',
},
groupEpicsPath: {
default: '',
},
hasAnyIssues: {
default: false,
},
hasBlockedIssuesFeature: {
default: false,
},
......@@ -132,9 +138,6 @@ export default {
hasMultipleIssueAssigneesFeature: {
default: false,
},
hasProjectIssues: {
default: false,
},
initialEmail: {
default: '',
},
......@@ -150,9 +153,6 @@ export default {
newIssuePath: {
default: '',
},
projectPath: {
default: '',
},
rssPath: {
default: '',
},
......@@ -198,7 +198,7 @@ export default {
createFlash({ message: this.$options.i18n.errorFetchingIssues, captureError: true, error });
},
skip() {
return !this.hasProjectIssues;
return !this.hasAnyIssues;
},
debounce: 200,
},
......@@ -211,7 +211,7 @@ export default {
};
},
skip() {
return !this.hasProjectIssues;
return !this.hasAnyIssues;
},
},
countClosed: {
......@@ -223,7 +223,7 @@ export default {
};
},
skip() {
return !this.hasProjectIssues;
return !this.hasAnyIssues;
},
},
countAll: {
......@@ -235,7 +235,7 @@ export default {
};
},
skip() {
return !this.hasProjectIssues;
return !this.hasAnyIssues;
},
},
},
......@@ -243,7 +243,7 @@ export default {
queryVariables() {
return {
isSignedIn: this.isSignedIn,
projectPath: this.projectPath,
fullPath: this.fullPath,
search: this.searchQuery,
sort: this.sortKey,
state: this.state,
......@@ -465,7 +465,7 @@ export default {
return this.$apollo
.query({
query: searchLabelsQuery,
variables: { projectPath: this.projectPath, search },
variables: { fullPath: this.fullPath, search },
})
.then(({ data }) => data.project.labels.nodes);
},
......@@ -473,7 +473,7 @@ export default {
return this.$apollo
.query({
query: searchMilestonesQuery,
variables: { projectPath: this.projectPath, search },
variables: { fullPath: this.fullPath, search },
})
.then(({ data }) => data.project.milestones.nodes);
},
......@@ -481,8 +481,8 @@ export default {
const id = Number(search);
const variables =
!search || Number.isNaN(id)
? { projectPath: this.projectPath, search }
: { projectPath: this.projectPath, id };
? { fullPath: this.fullPath, search }
: { fullPath: this.fullPath, id };
return this.$apollo
.query({
......@@ -495,7 +495,7 @@ export default {
return this.$apollo
.query({
query: searchUsersQuery,
variables: { projectPath: this.projectPath, search },
variables: { fullPath: this.fullPath, search },
})
.then(({ data }) => data.project.projectMembers.nodes.map((member) => member.user));
},
......@@ -607,9 +607,9 @@ export default {
</script>
<template>
<div v-if="hasProjectIssues">
<div v-if="hasAnyIssues">
<issuable-list
:namespace="projectPath"
:namespace="fullPath"
recent-searches-storage-key="issues"
:search-input-placeholder="$options.i18n.searchPlaceholder"
:search-tokens="searchTokens"
......
......@@ -118,13 +118,14 @@ export function mountIssuesListApp() {
emailsHelpPagePath,
emptyStateSvgPath,
exportCsvPath,
fullPath,
groupEpicsPath,
hasAnyIssues,
hasBlockedIssuesFeature,
hasIssuableHealthStatusFeature,
hasIssueWeightsFeature,
hasIterationsFeature,
hasMultipleIssueAssigneesFeature,
hasProjectIssues,
importCsvIssuesPath,
initialEmail,
isSignedIn,
......@@ -134,7 +135,6 @@ export function mountIssuesListApp() {
maxAttachmentSize,
newIssuePath,
projectImportJiraPath,
projectPath,
quickActionsHelpPath,
resetPath,
rssPath,
......@@ -150,18 +150,18 @@ export function mountIssuesListApp() {
calendarPath,
canBulkUpdate: parseBoolean(canBulkUpdate),
emptyStateSvgPath,
fullPath,
groupEpicsPath,
hasAnyIssues: parseBoolean(hasAnyIssues),
hasBlockedIssuesFeature: parseBoolean(hasBlockedIssuesFeature),
hasIssuableHealthStatusFeature: parseBoolean(hasIssuableHealthStatusFeature),
hasIssueWeightsFeature: parseBoolean(hasIssueWeightsFeature),
hasIterationsFeature: parseBoolean(hasIterationsFeature),
hasMultipleIssueAssigneesFeature: parseBoolean(hasMultipleIssueAssigneesFeature),
hasProjectIssues: parseBoolean(hasProjectIssues),
isSignedIn: parseBoolean(isSignedIn),
issuesPath,
jiraIntegrationPath,
newIssuePath,
projectPath,
rssPath,
showNewIssueLink: parseBoolean(showNewIssueLink),
signInPath,
......@@ -172,9 +172,9 @@ export function mountIssuesListApp() {
importCsvIssuesPath,
maxAttachmentSize,
projectImportJiraPath,
showExportButton: parseBoolean(hasProjectIssues),
showExportButton: parseBoolean(hasAnyIssues),
showImportButton: parseBoolean(canImportIssues),
showLabel: !parseBoolean(hasProjectIssues),
showLabel: !parseBoolean(hasAnyIssues),
// For IssuableByEmail component
emailsHelpPagePath,
initialEmail,
......
#import "~/graphql_shared/fragments/pageInfo.fragment.graphql"
#import "./issue.fragment.graphql"
query getProjectIssues(
query getIssues(
$isSignedIn: Boolean = false
$projectPath: ID!
$fullPath: ID!
$search: String
$sort: IssueSort
$state: IssuableState
......@@ -20,7 +20,7 @@ query getProjectIssues(
$firstPageSize: Int
$lastPageSize: Int
) {
project(fullPath: $projectPath) {
project(fullPath: $fullPath) {
issues(
search: $search
sort: $sort
......
query getProjectIssuesCount(
$projectPath: ID!
query getIssuesCount(
$fullPath: ID!
$search: String
$state: IssuableState
$assigneeId: String
......@@ -11,7 +11,7 @@ query getProjectIssuesCount(
$types: [IssueType!]
$not: NegatedIssueFilterInput
) {
project(fullPath: $projectPath) {
project(fullPath: $fullPath) {
issues(
search: $search
state: $state
......
query searchIterations($projectPath: ID!, $search: String, $id: ID) {
project(fullPath: $projectPath) {
query searchIterations($fullPath: ID!, $search: String, $id: ID) {
project(fullPath: $fullPath) {
iterations(title: $search, id: $id) {
nodes {
id
......
query searchLabels($projectPath: ID!, $search: String) {
project(fullPath: $projectPath) {
query searchLabels($fullPath: ID!, $search: String) {
project(fullPath: $fullPath) {
labels(searchTerm: $search, includeAncestorGroups: true) {
nodes {
id
......
query searchMilestones($projectPath: ID!, $search: String) {
project(fullPath: $projectPath) {
query searchMilestones($fullPath: ID!, $search: String) {
project(fullPath: $fullPath) {
milestones(searchTitle: $search, includeAncestors: true) {
nodes {
id
......
query searchUsers($projectPath: ID!, $search: String) {
project(fullPath: $projectPath) {
query searchUsers($fullPath: ID!, $search: String) {
project(fullPath: $fullPath) {
projectMembers(search: $search) {
nodes {
user {
......
......@@ -214,7 +214,8 @@ module IssuesHelper
emails_help_page_path: help_page_path('development/emails', anchor: 'email-namespace'),
empty_state_svg_path: image_path('illustrations/issues.svg'),
export_csv_path: export_csv_project_issues_path(project),
has_project_issues: project_issues(project).exists?.to_s,
full_path: project.full_path,
has_any_issues: project_issues(project).exists?.to_s,
import_csv_issues_path: import_csv_namespace_project_issues_path,
initial_email: project.new_issuable_address(current_user, 'issue'),
is_signed_in: current_user.present?.to_s,
......@@ -224,7 +225,6 @@ module IssuesHelper
max_attachment_size: number_to_human_size(Gitlab::CurrentSettings.max_attachment_size.megabytes),
new_issue_path: new_project_issue_path(project, issue: { milestone_id: finder.milestones.first.try(:id) }),
project_import_jira_path: project_import_jira_path(project),
project_path: project.full_path,
quick_actions_help_path: help_page_path('user/project/quick_actions'),
reset_path: new_issuable_address_project_path(project, issuable_type: 'issue'),
rss_path: url_for(safe_params.merge(rss_url_options)),
......
#import "~/graphql_shared/fragments/pageInfo.fragment.graphql"
#import "~/issues_list/queries/issue.fragment.graphql"
query getProjectIssues(
query getIssues(
$isSignedIn: Boolean = false
$projectPath: ID!
$fullPath: ID!
$search: String
$sort: IssueSort
$state: IssuableState
......@@ -24,7 +24,7 @@ query getProjectIssues(
$firstPageSize: Int
$lastPageSize: Int
) {
project(fullPath: $projectPath) {
project(fullPath: $fullPath) {
issues(
search: $search
sort: $sort
......
query getProjectIssuesCount(
$projectPath: ID!
query getIssuesCount(
$fullPath: ID!
$search: String
$state: IssuableState
$assigneeId: String
......@@ -15,7 +15,7 @@ query getProjectIssuesCount(
$weight: String
$not: NegatedIssueFilterInput
) {
project(fullPath: $projectPath) {
project(fullPath: $fullPath) {
issues(
search: $search
state: $state
......
......@@ -63,15 +63,15 @@ describe('IssuesListApp component', () => {
canBulkUpdate: false,
emptyStateSvgPath: 'empty-state.svg',
exportCsvPath: 'export/csv/path',
fullPath: 'path/to/project',
hasAnyIssues: true,
hasBlockedIssuesFeature: true,
hasIssueWeightsFeature: true,
hasIterationsFeature: true,
hasProjectIssues: true,
isSignedIn: true,
issuesPath: 'path/to/issues',
jiraIntegrationPath: 'jira/integration/path',
newIssuePath: 'new/issue/path',
projectPath: 'path/to/project',
rssPath: 'rss/path',
showNewIssueLink: true,
signInPath: 'sign/in/path',
......@@ -134,7 +134,7 @@ describe('IssuesListApp component', () => {
it('renders', () => {
expect(findIssuableList().props()).toMatchObject({
namespace: defaultProvide.projectPath,
namespace: defaultProvide.fullPath,
recentSearchesStorageKey: 'issues',
searchInputPlaceholder: IssuesListApp.i18n.searchPlaceholder,
sortOptions: getSortOptions(true, true),
......@@ -349,7 +349,7 @@ describe('IssuesListApp component', () => {
beforeEach(() => {
setWindowLocation(`?search=no+results`);
wrapper = mountComponent({ provide: { hasProjectIssues: true }, mountFn: mount });
wrapper = mountComponent({ provide: { hasAnyIssues: true }, mountFn: mount });
});
it('shows empty state', () => {
......@@ -363,7 +363,7 @@ describe('IssuesListApp component', () => {
describe('when "Open" tab has no issues', () => {
beforeEach(() => {
wrapper = mountComponent({ provide: { hasProjectIssues: true }, mountFn: mount });
wrapper = mountComponent({ provide: { hasAnyIssues: true }, mountFn: mount });
});
it('shows empty state', () => {
......@@ -379,7 +379,7 @@ describe('IssuesListApp component', () => {
beforeEach(() => {
setWindowLocation(`?state=${IssuableStates.Closed}`);
wrapper = mountComponent({ provide: { hasProjectIssues: true }, mountFn: mount });
wrapper = mountComponent({ provide: { hasAnyIssues: true }, mountFn: mount });
});
it('shows empty state', () => {
......@@ -395,7 +395,7 @@ describe('IssuesListApp component', () => {
describe('when user is logged in', () => {
beforeEach(() => {
wrapper = mountComponent({
provide: { hasProjectIssues: false, isSignedIn: true },
provide: { hasAnyIssues: false, isSignedIn: true },
mountFn: mount,
});
});
......@@ -434,7 +434,7 @@ describe('IssuesListApp component', () => {
describe('when user is logged out', () => {
beforeEach(() => {
wrapper = mountComponent({
provide: { hasProjectIssues: false, isSignedIn: false },
provide: { hasAnyIssues: false, isSignedIn: false },
});
});
......
......@@ -314,7 +314,8 @@ RSpec.describe IssuesHelper do
emails_help_page_path: help_page_path('development/emails', anchor: 'email-namespace'),
empty_state_svg_path: '#',
export_csv_path: export_csv_project_issues_path(project),
has_project_issues: project_issues(project).exists?.to_s,
full_path: project.full_path,
has_any_issues: project_issues(project).exists?.to_s,
import_csv_issues_path: '#',
initial_email: project.new_issuable_address(current_user, 'issue'),
is_signed_in: current_user.present?.to_s,
......@@ -324,7 +325,6 @@ RSpec.describe IssuesHelper do
max_attachment_size: number_to_human_size(Gitlab::CurrentSettings.max_attachment_size.megabytes),
new_issue_path: new_project_issue_path(project, issue: { milestone_id: finder.milestones.first.id }),
project_import_jira_path: project_import_jira_path(project),
project_path: project.full_path,
quick_actions_help_path: help_page_path('user/project/quick_actions'),
reset_path: new_issuable_address_project_path(project, issuable_type: 'issue'),
rss_path: '#',
......
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