Merge pull request #8095 from opf/feature/30678/hide-bcf-buttons

[30678] Hide BCF buttons when not allowed

[ci skip]
pull/8099/head
Oliver Günther 5 years ago committed by GitHub
commit aed5708f6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      frontend/src/app/modules/ifc_models/pages/viewer/ifc-models-data.service.ts
  2. 5
      frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.ts
  3. 2
      frontend/src/app/modules/ifc_models/toolbar/manage-ifc-models-button/bim-manage-ifc-models-button.component.ts
  4. 10
      frontend/src/app/modules/work_packages/routing/wp-view-page/wp-view-page.component.ts
  5. 3
      modules/bim/app/helpers/ifc_models_helper.rb
  6. 18
      modules/bim/spec/features/bcf_export_spec.rb
  7. 7
      modules/bim/spec/features/model_management_spec.rb
  8. 9
      modules/bim/spec/support/pages/ifc_models/index.rb

@ -5,7 +5,8 @@ import {GonService} from "core-app/modules/common/gon/gon.service";
import {CurrentProjectService} from "core-components/projects/current-project.service";
export interface IFCPermissionMap {
manage:boolean;
manage_ifc_models:boolean;
manage_bcf:boolean;
}
export interface IFCGonDefinition {
@ -54,8 +55,8 @@ export class IfcModelsDataService {
return this.paths.ifcModelsPath(this.currentProjectService.identifier!);
}
public get manageAllowed() {
return this.gonIFC.permissions.manage;
public allowed(permission:keyof IFCPermissionMap):boolean {
return !!this.gonIFC.permissions[permission];
}
private get gonIFC():IFCGonDefinition {

@ -44,9 +44,11 @@ export class IFCViewerPageComponent extends PartitionedQuerySpacePageComponent {
toolbarButtonComponents:ToolbarButtonComponentDefinition[] = [
{
component: BcfImportButtonComponent,
show: () => this.ifcData.allowed('manage_bcf')
},
{
component: BcfExportButtonComponent,
show: () => this.ifcData.allowed('manage_bcf')
},
{
component: WorkPackageFilterButtonComponent,
@ -61,7 +63,8 @@ export class IFCViewerPageComponent extends PartitionedQuerySpacePageComponent {
containerClasses: 'hidden-for-mobile'
},
{
component: BimManageIfcModelsButtonComponent
component: BimManageIfcModelsButtonComponent,
show: () => this.ifcData.allowed('manage_ifc_models')
}
];

@ -52,7 +52,7 @@ export class BimManageIfcModelsButtonComponent {
manage: this.I18n.t('js.ifc_models.models.manage'),
};
manageAllowed = this.ifcData.manageAllowed;
manageAllowed = this.ifcData.allowed('manage_ifc_models');
manageIFCPath = this.ifcData.manageIFCPath;
constructor(readonly I18n:I18nService,

@ -62,8 +62,6 @@ import {WorkPackageSettingsButtonComponent} from "core-components/wp-buttons/wp-
]
})
export class WorkPackageViewPageComponent extends PartitionedQuerySpacePageComponent implements OnInit {
@InjectField() bcfDetectorService:BcfDetectorService;
toolbarButtonComponents:ToolbarButtonComponentDefinition[] = [
{
component: WorkPackageCreateButtonComponent,
@ -72,14 +70,6 @@ export class WorkPackageViewPageComponent extends PartitionedQuerySpacePageCompo
allowed: ['work_packages.createWorkPackage']
}
},
{
component: BcfImportButtonComponent,
show: () => this.bcfDetectorService.isBcfActivated
},
{
component: BcfExportButtonComponent,
show: () => this.bcfDetectorService.isBcfActivated
},
{
component: WorkPackageFilterButtonComponent
},

@ -9,7 +9,8 @@ module IfcModelsHelper
xkt_attachment_ids: gon_ifc_model_xkt_attachment_ids(all_converted_models),
metadata_attachment_ids: gon_ifc_model_metadata_attachment_ids(all_converted_models),
permissions: {
manage: User.current.allowed_to?(:manage_ifc_models, @project)
manage_ifc_models: User.current.allowed_to?(:manage_ifc_models, @project),
manage_bcf: User.current.allowed_to?(:manage_bcf, @project),
}
}
end

@ -26,6 +26,7 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
require_relative '../support/pages/ifc_models/show_default'
describe 'work package export', type: :feature, js: true do
let(:status) { FactoryBot.create(:status, name: 'New', is_default: true) }
@ -39,7 +40,14 @@ describe 'work package export', type: :feature, js: true do
let(:current_user) { FactoryBot.create :admin }
let(:wp_table) { ::Pages::WorkPackagesTable.new(project) }
let!(:model) do
FactoryBot.create(:ifc_model_converted,
project: project,
uploader: current_user)
end
let(:model_page) { ::Pages::IfcModels::ShowDefault.new project }
let(:wp_cards) { ::Pages::WorkPackageCards.new(project) }
let(:filters) { ::Components::WorkPackages::Filters.new }
before do
@ -67,9 +75,9 @@ describe 'work package export', type: :feature, js: true do
end
it 'can export the open and closed BCF issues (Regression #30953)' do
wp_table.visit!
wp_table.expect_work_package_listed open_work_package
wp_table.ensure_work_package_not_listed! closed_work_package
model_page.visit!
wp_cards.expect_work_package_listed open_work_package
wp_cards.expect_work_package_not_listed closed_work_package
filters.expect_filter_count 1
# Expect only the open issue
@ -82,7 +90,7 @@ describe 'work package export', type: :feature, js: true do
filters.remove_filter 'status'
filters.expect_filter_count 0
wp_table.expect_work_package_listed open_work_package, closed_work_package
wp_cards.expect_work_package_listed open_work_package, closed_work_package
# Download again
extractor_list = export_into_bcf_extractor

@ -33,7 +33,7 @@ require_relative '../support/pages/ifc_models/index'
describe 'model management', type: :feature, js: true do
let(:project) { FactoryBot.create :project, enabled_module_names: %i[bim work_package_tracking] }
let(:index_page) { Pages::IfcModels::Index.new(project) }
let(:role) { FactoryBot.create(:role, permissions: %i[view_ifc_models manage_ifc_models view_work_packages]) }
let(:role) { FactoryBot.create(:role, permissions: %i[view_ifc_models manage_bcf manage_ifc_models view_work_packages]) }
let(:user) do
FactoryBot.create :user,
@ -75,9 +75,12 @@ describe 'model management', type: :feature, js: true do
it 'I can see single models and the defaults' do
index_page.model_listed true, model.title
index_page.show_model model
index_page.bcf_buttons true
index_page.visit!
index_page.model_listed true, model.title
index_page.show_defaults
index_page.bcf_buttons true
end
end
@ -107,6 +110,8 @@ describe 'model management', type: :feature, js: true do
index_page.model_listed true, model.title
index_page.show_model model
index_page.visit!
index_page.bcf_buttons false
index_page.model_listed true, model.title
index_page.show_defaults
end

@ -60,6 +60,11 @@ module Pages
end
end
def bcf_buttons(allowed)
expect(page).to have_conditional_selector(allowed, '.toolbar-item', text: 'Import')
expect(page).to have_conditional_selector(allowed, '.toolbar-item', text: 'Export')
end
def edit_model_allowed(model_name, allowed)
row = find_model_table_row model_name
within row do
@ -99,8 +104,6 @@ module Pages
expect_correct_page_loaded '.ifc-model-viewer--container'
expect(page).to have_selector('.editable-toolbar-title--fixed', text: model.title)
visit!
end
def show_defaults
@ -109,8 +112,6 @@ module Pages
expect_correct_page_loaded '.ifc-model-viewer--container'
expect(page).to have_selector('.editable-toolbar-title--fixed', text: 'Default IFC models')
visit!
end
private

Loading…
Cancel
Save