Merge pull request #10486 from opf/fix/40038/hide-team-planner-button-ee

[40038] Hide "new team planner" button on CE
pull/10487/head
Christophe Bliard 3 years ago committed by GitHub
commit 52807bd4f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.ts
  2. 24
      modules/team_planner/spec/features/team_planner_menu_spec.rb
  3. 2
      modules/team_planner/spec/features/team_planner_upsale_spec.rb

@ -1,15 +1,17 @@
import {
Component,
ChangeDetectionStrategy,
Input,
Component,
ElementRef,
HostBinding,
Input,
} from '@angular/core';
import { DatasetInputs } from 'core-app/shared/components/dataset-inputs.decorator';
import { CurrentUserService } from 'core-app/core/current-user/current-user.service';
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { BannersService } from 'core-app/core/enterprise/banners.service';
import { map } from 'rxjs/operators';
export const opTeamPlannerSidemenuSelector = 'op-team-planner-sidemenu';
@ -26,11 +28,15 @@ export class TeamPlannerSidemenuComponent extends UntilDestroyedMixin {
@Input() projectId:string|undefined;
canAddTeamPlanner$ = this.currentUserService.hasCapabilities$(
'team_planners/create',
this.currentProjectService.id || undefined,
)
.pipe(this.untilDestroyed());
canAddTeamPlanner$ = this
.currentUserService
.hasCapabilities$(
'team_planners/create',
this.currentProjectService.id || undefined,
)
.pipe(
map((val) => val && !this.bannersService.eeShowBanners),
);
text = {
create_new_team_planner: this.I18n.t('js.team_planner.create_new'),
@ -49,6 +55,7 @@ export class TeamPlannerSidemenuComponent extends UntilDestroyedMixin {
readonly elementRef:ElementRef,
readonly currentUserService:CurrentUserService,
readonly currentProjectService:CurrentProjectService,
readonly bannersService:BannersService,
readonly I18n:I18nService,
) {
super();

@ -68,14 +68,28 @@ describe 'Team planner sidemenu', type: :feature, js: true do
current_user { user_with_rights }
it 'shows the create team planner option' do
visit project_path(project)
context 'when EE disabled' do
it 'does not show the create team planner option' do
visit project_path(project)
within '#main-menu' do
click_link 'Team planners'
within '#main-menu' do
click_link 'Team planners'
end
expect(page).to have_no_selector('[data-qa-selector="team-planner--create-button"]')
end
end
context 'when EE enabled', with_ee: %i[team_planner_view] do
it 'shows the create team planner option' do
visit project_path(project)
expect(page).to have_selector('[data-qa-selector="team-planner--create-button"]')
within '#main-menu' do
click_link 'Team planners'
end
expect(page).to have_selector('[data-qa-selector="team-planner--create-button"]')
end
end
end
end

@ -43,7 +43,7 @@ describe 'Team planner index', type: :feature, js: true do
expect(page).to have_text 'Upgrade now'
click_on 'New team planner'
visit new_project_team_planners_path(project)
expect(page).to have_text 'Upgrade now'

Loading…
Cancel
Save