diff --git a/public/apps/account/account-app.tsx b/public/apps/account/account-app.tsx index d6b4af397..e76fd1412 100644 --- a/public/apps/account/account-app.tsx +++ b/public/apps/account/account-app.tsx @@ -46,7 +46,11 @@ export async function setupTopNavButton(coreStart: CoreStart, config: ClientConf let tenant: string | undefined; if (config.multitenancy.enabled && config.multitenancy.enable_aggregation_view) { - tenant = await fetchCurrentTenant(coreStart.http); + try { + tenant = await fetchCurrentTenant(coreStart.http); + } catch (e) { + console.log(e); + } } else { tenant = accountInfo.user_requested_tenant; } diff --git a/public/apps/configuration/utils/tenant-utils.tsx b/public/apps/configuration/utils/tenant-utils.tsx index 590fb22a7..606ba2fa7 100644 --- a/public/apps/configuration/utils/tenant-utils.tsx +++ b/public/apps/configuration/utils/tenant-utils.tsx @@ -15,6 +15,8 @@ import { HttpStart } from 'opensearch-dashboards/public'; import { map } from 'lodash'; +import React from 'react'; +import { i18n } from '@osd/i18n'; import { API_ENDPOINT_TENANTS, API_ENDPOINT_MULTITENANCY, @@ -39,6 +41,8 @@ export const globalTenantName = 'global_tenant'; export const GLOBAL_TENANT = ''; export const PRIVATE_TENANT = '__user__'; export const DEFAULT_TENANT = 'default'; +export const GLOBAL_TENANT_RENDERING_TEXT = 'Global'; +export const PRIVATE_TENANT_RENDERING_TEXT = 'Private'; export const GLOBAL_USER_DICT: { [key: string]: string } = { Label: 'Global', Value: GLOBAL_TENANT, @@ -181,3 +185,25 @@ export function isPrivateTenant(selectedTenant: string | null) { export function isGlobalTenant(selectedTenant: string | null) { return selectedTenant !== null && selectedTenant === GLOBAL_TENANT; } + +export const tenantColumn = { + id: 'tenant_column', + euiColumn: { + field: 'namespaces', + name:
Tenant
, + dataType: 'string', + render: (value: any[][]) => { + let text = value.flat()[0]; + if (isGlobalTenant(text)) { + text = GLOBAL_TENANT_RENDERING_TEXT; + } else if (isPrivateTenant(text)) { + text = PRIVATE_TENANT_RENDERING_TEXT; + } + text = i18n.translate('savedObjectsManagement.objectsTable.table.columnTenantName', { + defaultMessage: text, + }); + return
{text}
; + }, + }, + loadData: () => {}, +}; diff --git a/public/plugin.tsx b/public/plugin.ts similarity index 86% rename from public/plugin.tsx rename to public/plugin.ts index 89f837179..2adb33a83 100644 --- a/public/plugin.tsx +++ b/public/plugin.ts @@ -15,8 +15,6 @@ import { BehaviorSubject } from 'rxjs'; import { SavedObjectsManagementColumn } from 'src/plugins/saved_objects_management/public'; -import React from 'react'; -import { i18n } from '@osd/i18n'; import { AppMountParameters, AppStatus, @@ -48,7 +46,7 @@ import { } from './types'; import { addTenantToShareURL } from './services/shared-link'; import { interceptError } from './utils/logout-utils'; -import { isGlobalTenant, isPrivateTenant } from './apps/configuration/utils/tenant-utils'; +import { tenantColumn } from './apps/configuration/utils/tenant-utils'; async function hasApiPermission(core: CoreSetup): Promise { try { @@ -156,27 +154,9 @@ export class SecurityPlugin ); if (config.multitenancy.enabled && config.multitenancy.enable_aggregation_view) { - deps.savedObjectsManagement.columns.register(({ - id: 'tenant_column', - euiColumn: { - field: 'namespaces', - name:
Tenant
, - dataType: 'string', - render: (value: any[][]) => { - let text = value.flat()[0]; - if (isGlobalTenant(text)) { - text = GLOBAL_TENANT_RENDERING_TEXT; - } else if (isPrivateTenant(text)) { - text = PRIVATE_TENANT_RENDERING_TEXT; - } - text = i18n.translate('savedObjectsManagement.objectsTable.table.columnTenantName', { - defaultMessage: text, - }); - return
{text}
; - }, - }, - loadData: () => {}, - } as unknown) as SavedObjectsManagementColumn); + deps.savedObjectsManagement.columns.register( + (tenantColumn as unknown) as SavedObjectsManagementColumn + ); } // Return methods that should be available to other plugins