Skip to content

Commit

Permalink
Fix paths and update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed May 16, 2024
1 parent fd09f20 commit 428e0a4
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 88 deletions.
32 changes: 23 additions & 9 deletions public/apps/configuration/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ const ROUTE_MAP: { [key: string]: RouteItem } = {
name: 'Tenants',
href: buildUrl(ResourceType.tenants),
},
[ResourceType.tenantsConfigureTab]: {
name: '',
href: buildUrl(ResourceType.tenantsConfigureTab),
},
[ResourceType.auth]: {
name: 'Authentication',
href: buildUrl(ResourceType.auth),
Expand All @@ -90,10 +94,11 @@ const getRouteList = (multitenancyEnabled: boolean) => {
ROUTE_MAP[ResourceType.permissions],
...(multitenancyEnabled ? [ROUTE_MAP[ResourceType.tenants]] : []),
ROUTE_MAP[ResourceType.auditLogging],
...(multitenancyEnabled ? [ROUTE_MAP[ResourceType.tenantsConfigureTab]] : []),
];
};

const allNavPanelUrls = (multitenancyEnabled: boolean) =>
export const allNavPanelUrls = (multitenancyEnabled: boolean) =>
getRouteList(multitenancyEnabled)
.map((route) => route.href)
.concat([
Expand Down Expand Up @@ -161,13 +166,22 @@ export function AppRouter(props: AppDependencies) {
function getTenancyRoutes() {
if (multitenancyEnabled) {
return (
<Route
path={ROUTE_MAP.tenants.href}
render={() => {
setGlobalBreadcrumbs(ResourceType.tenants);
return <TenantList tabID={'Manage'} {...props} />;
}}
/>
<>
<Route
path={ROUTE_MAP.tenants.href}
render={() => {
setGlobalBreadcrumbs(ResourceType.tenants);
return <TenantList tabID={'Manage'} {...props} />;
}}
/>
<Route
path={ROUTE_MAP.tenantsConfigureTab.href}
render={() => {
setGlobalBreadcrumbs(ResourceType.tenants);
return <TenantList tabID={'Configure'} {...props} />;
}}
/>
</>
);
}
return null;
Expand Down Expand Up @@ -279,14 +293,14 @@ export function AppRouter(props: AppDependencies) {
return <PermissionList {...props} />;
}}
/>
{getTenancyRoutes()}
<Route
path={ROUTE_MAP.getStarted.href}
render={() => {
setGlobalBreadcrumbs();
return <GetStarted {...props} />;
}}
/>
{getTenancyRoutes()}
<Redirect exact from="/" to={LANDING_PAGE_URL} />
</Switch>
</EuiPageBody>
Expand Down
68 changes: 35 additions & 33 deletions public/apps/configuration/panels/get-started.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,39 +276,41 @@ export function GetStarted(props: AppDependencies) {

<EuiSpacer size="l" />

<EuiPanel paddingSize="l">
<EuiTitle size="s">
<h3>Optional: Multi-tenancy</h3>
</EuiTitle>
<EuiText size="s" color="subdued">
<p>
By default tenancy is activated in Dashboards. Tenants in OpenSearch Dashboards are
spaces for saving index patterns, visualizations, dashboards, and other OpenSearch
Dashboards objects.
</p>
<EuiFlexGroup gutterSize="s">
<EuiFlexItem grow={false}>
<EuiButton
fill
onClick={() => {
window.location.href = buildHashUrl(ResourceType.tenants);
}}
>
Manage Multi-tenancy
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
onClick={() => {
window.location.href = buildHashUrl(ResourceType.tenantsConfigureTab);
}}
>
Configure Multi-tenancy
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiText>
</EuiPanel>
{props.config.multitenancy.enabled ? (
<EuiPanel paddingSize="l">
<EuiTitle size="s">
<h3>Optional: Multi-tenancy</h3>
</EuiTitle>
<EuiText size="s" color="subdued">
<p>
By default tenancy is activated in Dashboards. Tenants in OpenSearch Dashboards are
spaces for saving index patterns, visualizations, dashboards, and other OpenSearch
Dashboards objects.
</p>
<EuiFlexGroup gutterSize="s">
<EuiFlexItem grow={false}>
<EuiButton
fill
onClick={() => {
window.location.href = buildHashUrl(ResourceType.tenants);
}}
>
Manage Multi-tenancy
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
onClick={() => {
window.location.href = buildHashUrl(ResourceType.tenantsConfigureTab);
}}
>
Configure Multi-tenancy
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiText>
</EuiPanel>
) : null}
</div>
<EuiGlobalToastList toasts={toasts} toastLifeTimeMs={10000} dismissToast={removeToast} />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ exports[`Get started (landing page) renders when backend configuration is disabl
<Memo()
config={
Object {
"multitenancy": Object {
"enabled": true,
},
"ui": Object {
"backend_configurable": false,
},
Expand Down Expand Up @@ -284,6 +287,9 @@ exports[`Get started (landing page) renders when backend configuration is enable
<Memo()
config={
Object {
"multitenancy": Object {
"enabled": true,
},
"ui": Object {
"backend_configurable": true,
},
Expand Down
6 changes: 6 additions & 0 deletions public/apps/configuration/panels/test/get-started.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ describe('Get started (landing page)', () => {
ui: {
backend_configurable: true,
},
multitenancy: {
enabled: true,
},
};

it('renders when backend configuration is enabled', () => {
Expand All @@ -62,6 +65,9 @@ describe('Get started (landing page)', () => {
ui: {
backend_configurable: false,
},
multitenancy: {
enabled: true,
},
};
const component = shallow(
<GetStarted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
Expand Down Expand Up @@ -103,6 +107,10 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
Expand Down Expand Up @@ -149,6 +157,10 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
Expand Down Expand Up @@ -195,6 +207,10 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
Expand Down Expand Up @@ -241,6 +257,10 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
Expand Down Expand Up @@ -287,6 +307,10 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
Expand Down Expand Up @@ -333,6 +357,10 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
Expand Down Expand Up @@ -379,6 +407,60 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
</EuiPageSideBar>
</Route>
<Route
exact={true}
key="/tenantsConfigureTab"
path="/tenantsConfigureTab"
>
<EuiPageSideBar>
<NavPanel
items={
Array [
Object {
"href": "/getstarted",
"name": "Get Started",
},
Object {
"href": "/auth",
"name": "Authentication",
},
Object {
"href": "/roles",
"name": "Roles",
},
Object {
"href": "/users",
"name": "Internal users",
},
Object {
"href": "/serviceAccounts",
"name": "Service Accounts",
},
Object {
"href": "/permissions",
"name": "Permissions",
},
Object {
"href": "/tenants",
"name": "Tenants",
},
Object {
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
Expand Down Expand Up @@ -425,6 +507,10 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
Expand Down Expand Up @@ -471,6 +557,10 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
"href": "/auditLogging",
"name": "Audit logs",
},
Object {
"href": "/tenantsConfigureTab",
"name": "",
},
]
}
/>
Expand Down Expand Up @@ -526,12 +616,16 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab
path="/permissions"
render={[Function]}
/>
<Route
path="/getstarted"
render={[Function]}
/>
<Route
path="/tenants"
render={[Function]}
/>
<Route
path="/getstarted"
path="/tenantsConfigureTab"
render={[Function]}
/>
<Redirect
Expand Down
Loading

0 comments on commit 428e0a4

Please sign in to comment.