Skip to content

Commit

Permalink
Small fixes for dynamic tenancy
Browse files Browse the repository at this point in the history
Signed-off-by: Abhi Kalra <[email protected]>
  • Loading branch information
Abhi Kalra committed May 5, 2023
1 parent c7ed2d1 commit 2710020
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
21 changes: 10 additions & 11 deletions public/apps/configuration/panels/tenant-list/manage_tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,29 @@ export function ManageTab(props: AppDependencies) {
const [isPrivateTenantEnabled, setIsPrivateTenantEnabled] = useState(false);
const [dashboardsDefaultTenant, setDashboardsDefaultTenant] = useState('');

const { http } = props.coreStart;

const fetchData = useCallback(async () => {
try {
setLoading(true);
const rawTenantData = await fetchTenants(props.coreStart.http);
const rawTenantData = await fetchTenants(http);
const processedTenantData = transformTenantData(rawTenantData);
const activeTenant = await fetchCurrentTenant(props.coreStart.http);
const currentUser = await getCurrentUser(props.coreStart.http);
const activeTenant = await fetchCurrentTenant(http);
const currentUser = await getCurrentUser(http);
setCurrentUsername(currentUser);
setCurrentTenant(resolveTenantName(activeTenant, currentUser));
setTenantData(processedTenantData);
setIsMultiTenancyEnabled(
(await getDashboardsInfo(props.coreStart.http)).multitenancy_enabled
);
setIsPrivateTenantEnabled(
(await getDashboardsInfo(props.coreStart.http)).private_tenant_enabled
);
setDashboardsDefaultTenant((await getDashboardsInfo(props.coreStart.http)).default_tenant);
const tenancyConfig = await getDashboardsInfo(http);
setIsMultiTenancyEnabled(tenancyConfig.multitenancy_enabled);
setIsPrivateTenantEnabled(tenancyConfig.private_tenant_enabled);
setDashboardsDefaultTenant(tenancyConfig.default_tenant);
} catch (e) {
console.log(e);
setErrorFlag(true);
} finally {
setLoading(false);
}
}, [props.coreStart.http]);
}, [http]);

React.useEffect(() => {
fetchData();
Expand Down
6 changes: 5 additions & 1 deletion public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ export class SecurityPlugin
})
);

if (multitenancyEnabled && config.multitenancy.enable_aggregation_view) {
if (
multitenancyEnabled &&
config.multitenancy.enabled &&
config.multitenancy.enable_aggregation_view
) {
deps.savedObjectsManagement.columns.register(
(tenantColumn as unknown) as SavedObjectsManagementColumn<string>
);
Expand Down
2 changes: 1 addition & 1 deletion server/multitenancy/tenant_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { SecurityPluginConfigType } from '..';
import { GLOBAL_TENANT_SYMBOL, PRIVATE_TENANT_SYMBOL, globalTenantName } from '../../common';

export const PRIVATE_TENANTS: string[] = [PRIVATE_TENANT_SYMBOL, 'private'];
export const GLOBAL_TENANTS: string[] = ['global', GLOBAL_TENANT_SYMBOL];
export const GLOBAL_TENANTS: string[] = ['global', GLOBAL_TENANT_SYMBOL, 'Global'];
/**
* Resovles the tenant the user is using.
*
Expand Down

0 comments on commit 2710020

Please sign in to comment.