From 03a4299a9c1cf1e6363ab4ee5c42fda972b67c63 Mon Sep 17 00:00:00 2001 From: Wu Jeremy <jeremyw@jihulab.com> Date: Mon, 10 Jul 2023 09:10:42 +0000 Subject: [PATCH] Fix: group id missing in new resource dropdown - Amend the code with a group path injection. - Update Specs against it. Changelog: fixed --- .../issues/list/components/empty_state_without_any_issues.vue | 2 ++ .../javascripts/issues/list/components/issues_list_app.vue | 2 ++ app/assets/javascripts/issues/list/index.js | 2 ++ app/helpers/issues_helper.rb | 3 ++- .../frontend/issues/list/components/issues_list_app_spec.js | 1 + .../list/components/empty_state_without_any_issues_spec.js | 1 + spec/frontend/issues/list/components/issues_list_app_spec.js | 1 + spec/helpers/issues_helper_spec.rb | 3 ++- 8 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/issues/list/components/empty_state_without_any_issues.vue b/app/assets/javascripts/issues/list/components/empty_state_without_any_issues.vue index 3f29fc66abb9..9f7fca0ceca3 100644 --- a/app/assets/javascripts/issues/list/components/empty_state_without_any_issues.vue +++ b/app/assets/javascripts/issues/list/components/empty_state_without_any_issues.vue @@ -28,6 +28,7 @@ export default { 'newProjectPath', 'showNewIssueLink', 'signInPath', + 'groupId', ], props: { currentTabCount: { @@ -95,6 +96,7 @@ export default { :query="$options.searchProjectsQuery" :query-variables="newIssueDropdownQueryVariables" :extract-projects="extractProjects" + :group-id="groupId" /> </template> </gl-empty-state> diff --git a/app/assets/javascripts/issues/list/components/issues_list_app.vue b/app/assets/javascripts/issues/list/components/issues_list_app.vue index 35ef5c147839..f7693dd7102b 100644 --- a/app/assets/javascripts/issues/list/components/issues_list_app.vue +++ b/app/assets/javascripts/issues/list/components/issues_list_app.vue @@ -166,6 +166,7 @@ export default { 'releasesPath', 'rssPath', 'showNewIssueLink', + 'groupId', ], props: { eeSearchTokens: { @@ -895,6 +896,7 @@ export default { :query="$options.searchProjectsQuery" :query-variables="newIssueDropdownQueryVariables" :extract-projects="extractProjects" + :group-id="groupId" /> <gl-disclosure-dropdown v-gl-tooltip.hover="$options.i18n.actionsLabel" diff --git a/app/assets/javascripts/issues/list/index.js b/app/assets/javascripts/issues/list/index.js index a97b59c1e4f5..d1b452940260 100644 --- a/app/assets/javascripts/issues/list/index.js +++ b/app/assets/javascripts/issues/list/index.js @@ -94,6 +94,7 @@ export async function mountIssuesListApp() { rssPath, showNewIssueLink, signInPath, + groupId = '', } = el.dataset; return new Vue({ @@ -153,6 +154,7 @@ export async function mountIssuesListApp() { markdownHelpPath, quickActionsHelpPath, resetPath, + groupId, }, render: (createComponent) => createComponent(IssuesListApp), }); diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 341c50abf84d..5da7795673c7 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -231,7 +231,8 @@ def group_issues_list_data(group, current_user) can_read_crm_organization: can?(current_user, :read_crm_organization, group).to_s, has_any_issues: @has_issues.to_s, has_any_projects: @has_projects.to_s, - new_project_path: new_project_path(namespace_id: group.id) + new_project_path: new_project_path(namespace_id: group.id), + group_id: group.id ) end diff --git a/ee/spec/frontend/issues/list/components/issues_list_app_spec.js b/ee/spec/frontend/issues/list/components/issues_list_app_spec.js index e57b40f11b63..4ef3cc38059e 100644 --- a/ee/spec/frontend/issues/list/components/issues_list_app_spec.js +++ b/ee/spec/frontend/issues/list/components/issues_list_app_spec.js @@ -77,6 +77,7 @@ describe('EE IssuesListApp component', () => { rssPath: 'rss/path', showNewIssueLink: true, signInPath: 'sign/in/path', + groupId: '', }; const defaultQueryResponse = cloneDeep(getIssuesQueryResponse); diff --git a/spec/frontend/issues/list/components/empty_state_without_any_issues_spec.js b/spec/frontend/issues/list/components/empty_state_without_any_issues_spec.js index a61e7ed1e862..8e69213ebba6 100644 --- a/spec/frontend/issues/list/components/empty_state_without_any_issues_spec.js +++ b/spec/frontend/issues/list/components/empty_state_without_any_issues_spec.js @@ -23,6 +23,7 @@ describe('EmptyStateWithoutAnyIssues component', () => { newProjectPath: 'new/project/path', showNewIssueLink: false, signInPath: 'sign/in/path', + groupId: '', }; const findCsvImportExportButtons = () => wrapper.findComponent(CsvImportExportButtons); diff --git a/spec/frontend/issues/list/components/issues_list_app_spec.js b/spec/frontend/issues/list/components/issues_list_app_spec.js index 0e87e5e6595c..72bf48260568 100644 --- a/spec/frontend/issues/list/components/issues_list_app_spec.js +++ b/spec/frontend/issues/list/components/issues_list_app_spec.js @@ -115,6 +115,7 @@ describe('CE IssuesListApp component', () => { rssPath: 'rss/path', showNewIssueLink: true, signInPath: 'sign/in/path', + groupId: '', }; let defaultQueryResponse = getIssuesQueryResponse; diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 38cbb5a1d66b..ba323140720e 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -364,7 +364,8 @@ jira_integration_path: help_page_url('integration/jira/issues', anchor: 'view-jira-issues'), new_project_path: new_project_path(namespace_id: group.id), rss_path: '#', - sign_in_path: new_user_session_path + sign_in_path: new_user_session_path, + group_id: group.id } expect(helper.group_issues_list_data(group, current_user)).to include(expected) -- GitLab