Skip to content

Commit

Permalink
Define functions for global and private tenant cases (#1147)
Browse files Browse the repository at this point in the history
Signed-off-by: Chang Liu <lc12251109@gmail.com>
  • Loading branch information
cliu123 committed Oct 18, 2022
1 parent f6d4710 commit 3d1c7ac
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const APP_LIST_FOR_READONLY_ROLE = [APP_ID_HOME, APP_ID_DASHBOARDS, APP_ID_OPENS
const GLOBAL_TENANT_RENDERING_TEXT = 'Global';
const PRIVATE_TENANT_RENDERING_TEXT = 'Private';
const GLOBAL_TENANT = '';
const PRIVATE_TENANT = '__user__';

export class SecurityPlugin
implements
Expand Down Expand Up @@ -169,9 +170,9 @@ export class SecurityPlugin
dataType: 'string',
render: (value: any[][]) => {
let text = value[0][0];
if (text === null || text === GLOBAL_TENANT) {
if (isGlobalTenant(text)) {
text = GLOBAL_TENANT_RENDERING_TEXT;
} else if (text.startsWith('__user__')) {
} else if (isPrivateTenant(text)) {
text = PRIVATE_TENANT_RENDERING_TEXT;
}
text = i18n.translate('savedObjectsManagement.objectsTable.table.columnTenantName', {
Expand Down Expand Up @@ -213,3 +214,11 @@ export class SecurityPlugin

public stop() {}
}

function isPrivateTenant(selectedTenant: string) {
return selectedTenant.startsWith('__user__');
}

function isGlobalTenant(selectedTenant: string) {
return selectedTenant === null || selectedTenant === GLOBAL_TENANT;
}

0 comments on commit 3d1c7ac

Please sign in to comment.