Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

hide manage button if user lacks permission

ulfertsda838c0ffcd1
diff --git a/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.html b/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.html
index 164f794ac89..ee9654c642c 100644
--- a/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.html
+++ b/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.html
@@ -5,7 +5,8 @@
</h2>
</div>
<ul class="toolbar-items">
- <li class="toolbar-item">
+ <li class="toolbar-item"
+ *ngIf="manageAllowed">
<a class="button"
[href]="manageIFCPath">
<op-icon icon-classes="button--icon icon-settings2"></op-icon>
diff --git a/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.ts b/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.ts
index db354b94fc4..fd85ff7b7bb 100644
--- a/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.ts
+++ b/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.ts
@@ -44,7 +44,7 @@ export class IFCIndexPageComponent {
if (this.state.current.name === 'bim_defaults') {
return this.i18n.t('js.ifc_models.models.default');
} else {
- return (this.gon.get('ifc_models') as any)['models'][0]['name'];
+ return this.gonIFC['models'][0]['name'];
}
}
@@ -56,6 +56,10 @@ export class IFCIndexPageComponent {
return this.paths.ifcModelsPath(this.projectIdentifier);
}
+ public get manageAllowed() {
+ return this.gonIFC.permissions.manage;
+ }
+
private applyFilters() {
// TODO: Limit to project
this.filters.push({
@@ -72,4 +76,8 @@ export class IFCIndexPageComponent {
showHierarchies: false
};
}
+
+ private get gonIFC() {
+ return (this.gon.get('ifc_models') as any)
+ }
}
diff --git a/modules/ifc_models/app/helpers/ifc_models_helper.rb b/modules/ifc_models/app/helpers/ifc_models_helper.rb
index a4952e13b62..fad48a7ec48 100644
--- a/modules/ifc_models/app/helpers/ifc_models_helper.rb
+++ b/modules/ifc_models/app/helpers/ifc_models_helper.rb
@@ -6,7 +6,10 @@ module IFCModelsHelper
models: gon_ifc_model_models(all_converted_models, models_to_load),
projects: [{ id: @project.identifier, name: @project.name }],
xkt_attachment_ids: gon_ifc_model_xkt_attachment_ids(all_converted_models),
- metadata_attachment_ids: gon_ifc_model_metadata_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)
+ }
}
end
diff --git a/modules/ifc_models/spec/support/pages/ifc_models/index.rb b/modules/ifc_models/spec/support/pages/ifc_models/index.rb
index 4ecac6f48e8..098cda79958 100644
--- a/modules/ifc_models/spec/support/pages/ifc_models/index.rb
+++ b/modules/ifc_models/spec/support/pages/ifc_models/index.rb
@@ -140,7 +140,8 @@ module Pages
def expect_correct_page_loaded(checked_selector, path)
expect(page).to have_selector(checked_selector)
- expect(current_path).to eql path
+ # Angular will append a slash to the path
+ expect(current_path).to eql path + '/'
end
def change_model_name(model_name, new_name)
diff --git a/modules/ifc_models/spec/support/pages/ifc_models/show.rb b/modules/ifc_models/spec/support/pages/ifc_models/show.rb
index 7d8a6edca86..889c9fb2282 100644
--- a/modules/ifc_models/spec/support/pages/ifc_models/show.rb
+++ b/modules/ifc_models/spec/support/pages/ifc_models/show.rb
@@ -43,10 +43,6 @@ module Pages
def path
ifc_models_project_ifc_model_path(project, id)
end
-
- def toolbar_items
- %w(Edit Delete)
- end
end
end
end