Skip to content

Commit

Permalink
[Feature Branch] Resolve review comments (#1155)
Browse files Browse the repository at this point in the history
Signed-off-by: Chang Liu <[email protected]>
  • Loading branch information
cliu123 authored Oct 25, 2022
1 parent fa1436c commit 2a827da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 1 addition & 3 deletions public/apps/account/account-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ export async function setupTopNavButton(coreStart: CoreStart, config: ClientConf
}

let tenant: string | undefined;
if (config.multitenancy.enabled && config.multitenancy.enable_aggregation_view) {
if (config.multitenancy.enabled) {
try {
tenant = await fetchCurrentTenant(coreStart.http);
} catch (e) {
console.log(e);
}
} else {
tenant = accountInfo.user_requested_tenant;
}

let shouldShowTenantPopup = true;
Expand Down
1 change: 1 addition & 0 deletions public/apps/configuration/utils/tenant-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ 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,
Expand Down
22 changes: 17 additions & 5 deletions server/saved_objects/saved_objects_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { Config } from 'packages/osd-config/target';
import { SecurityPluginConfigType } from '..';
import {
DEFAULT_TENANT,
globalTenantName,
GLOBAL_TENANT,
isPrivateTenant,
PRIVATE_TENANT,
Expand Down Expand Up @@ -95,17 +96,27 @@ export class SecuritySavedObjectsClientWrapper {
availableTenantNames.push(GLOBAL_TENANT);
}
if (isPrivateEnabled) {
availableTenantNames.push(PRIVATE_TENANT + state.authInfo?.user_name);
availableTenantNames.push(PRIVATE_TENANT + username);
}
const typeToNamespacesMap = {};
if (selectedTenant === '__user__') {
namespaceValue = selectedTenant + username;
if (availableTenantNames.includes(globalTenantName)) {
let index = availableTenantNames.indexOf(globalTenantName);
if (index > -1) {
availableTenantNames.splice(index, 1);
}
index = availableTenantNames.indexOf(username!);
if (index > -1) {
availableTenantNames.splice(index, 1);
}
}
const typeToNamespacesMap: any = {};
if (isPrivateTenant(selectedTenant!)) {
namespaceValue = selectedTenant! + username;
}
const searchTypes = Array.isArray(options.type) ? options.type : [options.type];
searchTypes.forEach((t) => {
if (t === 'config') {
if ('namespaces' in options) {
if (options.namespaces.includes(namespaceValue)) {
if (options.namespaces!.includes(namespaceValue!)) {
typeToNamespacesMap[t] = [namespaceValue];
}
} else {
Expand All @@ -122,6 +133,7 @@ export class SecuritySavedObjectsClientWrapper {
options.typeToNamespacesMap = new Map(Object.entries(typeToNamespacesMap));
options.type = '';
options.namespaces = [];

return await wrapperOptions.client.find(options);
};

Expand Down

0 comments on commit 2a827da

Please sign in to comment.