Product/components used and version/fix level:
Cumulocity Production
Detailed explanation of the problem:
I have cloned a custom cockpit application with version: 1015.0.249
We have a two users Admin and Guest. We need to disable copy and paste dashboard option to the guest user, which has only a reader access or not having admin access.
can we disable the copy and paste dashboard option based on the roles ?
Error messages / full error message screenshot / log file:
Regards
Mohan
Hi Mohan,
in general the Copy dashboard
functionality was not designed in a way to be removable.
You could try removing it by filtering the items$
of the ActionBarService.
I’ve been e.g. able to remove the Copy dashboard
button by using:
import { Injectable, Injector } from '@angular/core';
import { Router } from '@angular/router';
import { ActionBarService } from '@c8y/ngx-components';
import { map } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class CustomActionBarService extends ActionBarService {
constructor(rootInjector: Injector, router: Router) {
super(rootInjector, router);
this.items$ = this.items$.pipe(
map(items => {
return items.filter(item => item.placement !== 'more' || item.priority !== -2000);
})
);
}
}
and overriding the original ActionBarService with our custom implementation, by adding this to the providers of the app.module.ts:
providers: [{ provide: ActionBarService, useClass: CustomActionBarService }]
There is sadly no unique identifier to specifically identify the Copy dashboard
ActionBarItem… Using the filter from above could potentially remove also other items in the more
menu of the action bar, which use the same priority. So you might want to double check that you are not removing further items.
The above sample removes the Copy dashboard
item completely, but you should be able to adapt this in case you only want to do this under certain conditions.
Similar procedures should also apply for e.g. the left navigation, the tabs and probably also further extension points.
Regards,
Tristan
1 Like
Okay ! Thanks for the update Tristan
Regards
Mohan