Add counter to github tab (#11938)

pull/11940/head
Oliver Günther 2 years ago committed by GitHub
parent 998c89d905
commit 20e9280d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      modules/github_integration/frontend/module/main.ts
  2. 6
      modules/github_integration/spec/features/work_package_github_tab_spec.rb

@ -35,6 +35,21 @@ import { GitActionsMenuDirective } from './git-actions-menu/git-actions-menu.dir
import { GitActionsMenuComponent } from './git-actions-menu/git-actions-menu.component';
import { WorkPackagesGithubPrsService } from './tab-prs/wp-github-prs.service';
import { PullRequestComponent } from './pull-request/pull-request.component';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
export function workPackageGithubPrsCount(
workPackage:WorkPackageResource,
injector:Injector,
):Observable<number> {
const githubPrsService = injector.get(WorkPackagesGithubPrsService);
return githubPrsService
.requireAndStream(workPackage)
.pipe(
map((prs) => prs.length),
);
}
export function initializeGithubIntegrationPlugin(injector:Injector) {
const wpTabService = injector.get(WorkPackageTabsService);
@ -43,6 +58,7 @@ export function initializeGithubIntegrationPlugin(injector:Injector) {
name: I18n.t('js.github_integration.work_packages.tab_name'),
id: 'github',
displayable: (workPackage) => !!workPackage.github,
count: workPackageGithubPrsCount,
});
}

@ -47,6 +47,9 @@ describe 'Open the GitHub tab', js: true do
let(:pull_request) { create :github_pull_request, :open, work_packages: [work_package], title: 'A Test PR title' }
let(:check_run) { create :github_check_run, github_pull_request: pull_request, name: 'a check run name' }
let(:tabs) { Components::WorkPackages::Tabs.new(work_package) }
let(:github_tab_element) { find('.op-tab-row--link_selected', text: 'GITHUB') }
shared_examples_for "a github tab" do
before do
check_run
@ -70,6 +73,8 @@ describe 'Open the GitHub tab', js: true do
work_package_page.visit!
work_package_page.switch_to_tab(tab: 'github')
tabs.expect_counter(github_tab_element, 1)
github_tab.git_actions_menu_button.click
github_tab.git_actions_copy_branch_name_button.click
expect(page).to have_text('Copied!')
@ -86,6 +91,7 @@ describe 'Open the GitHub tab', js: true do
it 'shows the github tab with an empty-pull-requests message' do
work_package_page.visit!
work_package_page.switch_to_tab(tab: 'github')
tabs.expect_no_counter(github_tab_element)
expect(page).to have_content('There are no pull requests')
expect(page).to have_content("Link an existing PR by using the code OP##{work_package.id}")
end

Loading…
Cancel
Save