Tab visibility

Use the csApiSession to check the against different roles which can be defined for the different tabs to control their visibility (New asset/ Asset from template / Asset from file).

Please mind that user roles are defined by the system administrators.

  • Backend:

    • Command Handler path: censhare-Client5/web/src/ng1/client/DAM/dialogs/csAssetCreateDialog
    • Command Handler name: com.censhare.api.dam.dialog.create.asset.config
    • Command Handler public methods: public OutputData execute(final CommandContext context) - returns an ordered list of tabs
  • Frontend:

    • File localtion: censhare-Client5/web/src/ng1/client/frames/csMainFrame/main-frame.directive.ts
    • function openAssetCreateDialog() - calls the getCreateAssetDialogContext() function.
    • It retrieves the tabs from the com.censhare.api.dam.dialog.create.asset.config commandHandler and returns the dialog context.
    • Then it opens the csAssetCreateDialog from the csAssetCreateDialogModule.

csApiSession.execute('com.censhare.api.dam.dialog.create.asset.config', {})
   .then((response: {tabs: string[]}) => {...});

The response contains an array of the allowed tabs for the current user role:

{
    tabs: ['addNewAssetTab', 'addAssetFromTemplateTab', 'addUploadTab', 'addAssetTab']
}

Result

The return value of the dialog contains:

  • action - the operation performed by the user: ‘new’, ‘new-template’, ‘add’, ‘upload’
  • promise - the promise returned by the executed command

csAssetCreateDialog.open(globalDialogManagerPromise, context).then((result: IcsAssetCreateDialogResultData) => {
    if (result && result.promise) {
        result.promise.then(function (asset) {
            if (asset && asset.editPage) {
                workspaceManager.getNavigationManager().openPage(asset.editPage);
            }
        });
    }
});

Retrieving tabs

This is the process csAssetCreateDialog follows to retrieve tabs, when the Create Asset action is triggered:

  1. function openAssetCreateDialog() is triggered which on its own turn calls the getCreateAssetDialogContext() function.
  2. getCreateAssetDialogContext() retrieves the tabs from the com.censhare.api.dam.dialog.create.asset.configcommandHandler and returns the dialog context.
  3. Finally, the csAssetCreateDialog opens from the csAssetCreateDialogModule.

If no tabs are configured in the dialog for the current user, the following message will be displayed: Not possible to create a new asset: You have no permission to create new assets in this context.