Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workplace Search] Convert Sources pages to new page template (+ personal dashboard) #102592

Merged
merged 15 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ import { NotFound } from '../shared/not_found';

import { AppLogic } from './app_logic';
import { WorkplaceSearchNav, WorkplaceSearchHeaderActions } from './components/layout';
import {
PersonalDashboardLayout,
PrivateSourcesSidebar,
AccountSettingsSidebar,
} from './components/layout';
import {
GROUPS_PATH,
SETUP_GUIDE_PATH,
Expand All @@ -34,11 +29,11 @@ import {
ROLE_MAPPINGS_PATH,
SECURITY_PATH,
PERSONAL_SETTINGS_PATH,
PERSONAL_PATH,
} from './routes';
import { AccountSettings } from './views/account_settings';
import { SourcesRouter } from './views/content_sources';
import { SourceAdded } from './views/content_sources/components/source_added';
import { SourceSubNav } from './views/content_sources/components/source_sub_nav';
import { ErrorState } from './views/error_state';
import { GroupsRouter } from './views/groups';
import { Overview } from './views/overview';
Expand All @@ -60,9 +55,6 @@ export const WorkplaceSearchConfigured: React.FC<InitialAppData> = (props) => {

const { pathname } = useLocation();

// We don't want so show the subnavs on the container root pages.
const showSourcesSubnav = pathname !== SOURCES_PATH && pathname !== PERSONAL_SOURCES_PATH;

/**
* Personal dashboard urls begin with /p/
* EX: http://localhost:5601/app/enterprise_search/workplace_search/p/sources
Expand Down Expand Up @@ -95,32 +87,18 @@ export const WorkplaceSearchConfigured: React.FC<InitialAppData> = (props) => {
<Route exact path="/">
<Overview />
</Route>
<Route path={PERSONAL_SOURCES_PATH}>
<PersonalDashboardLayout
restrictWidth
readOnlyMode={readOnlyMode}
sidebar={<PrivateSourcesSidebar />}
>
<SourcesRouter />
</PersonalDashboardLayout>
</Route>
<Route path={PERSONAL_SETTINGS_PATH}>
<PersonalDashboardLayout
restrictWidth
readOnlyMode={readOnlyMode}
sidebar={<AccountSettingsSidebar />}
>
<AccountSettings />
</PersonalDashboardLayout>
<Route path={PERSONAL_PATH}>
<Switch>
<Route path={PERSONAL_SOURCES_PATH}>
<SourcesRouter />
</Route>
<Route path={PERSONAL_SETTINGS_PATH}>
<AccountSettings />
</Route>
</Switch>
yakhinvadim marked this conversation as resolved.
Show resolved Hide resolved
</Route>
<Route path={SOURCES_PATH}>
<Layout
navigation={<WorkplaceSearchNav sourcesSubNav={showSourcesSubnav && <SourceSubNav />} />}
restrictWidth
readOnlyMode={readOnlyMode}
>
<SourcesRouter />
</Layout>
<SourcesRouter />
</Route>
<Route path={GROUPS_PATH}>
<GroupsRouter />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ import { Redirect, Route, Switch, useLocation } from 'react-router-dom';
import { Location } from 'history';
import { useActions, useValues } from 'kea';

import { FlashMessages } from '../../../shared/flash_messages';
import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { LicensingLogic } from '../../../shared/licensing';
import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import { AppLogic } from '../../app_logic';
import { NAV } from '../../constants';
import {
ADD_SOURCE_PATH,
SOURCE_DETAILS_PATH,
Expand Down Expand Up @@ -52,71 +48,53 @@ export const SourcesRouter: React.FC = () => {
}, [pathname]);

return (
<>
<FlashMessages />
<Switch>
<Route exact path={PERSONAL_SOURCES_PATH}>
<SetPageChrome trail={[NAV.SOURCES]} />
<SendTelemetry action="viewed" metric="personal_sources" />
<PrivateSources />
<Switch>
<Route exact path={PERSONAL_SOURCES_PATH}>
<PrivateSources />
</Route>
<Route exact path={SOURCES_PATH}>
<OrganizationSources />
</Route>
{staticSourceData.map(({ addPath, accountContextOnly }, i) => (
<Route key={i} exact path={getSourcesPath(addPath, isOrganization)}>
{!hasPlatinumLicense && accountContextOnly ? (
<Redirect exact from={ADD_SOURCE_PATH} to={SOURCES_PATH} />
) : (
<AddSource sourceIndex={i} />
)}
</Route>
<Route exact path={SOURCES_PATH}>
<SetPageChrome trail={[NAV.SOURCES]} />
<SendTelemetry action="viewed" metric="organization_sources" />
<OrganizationSources />
))}
{staticSourceData.map(({ addPath }, i) => (
<Route key={i} exact path={`${getSourcesPath(addPath, isOrganization)}/connect`}>
<AddSource connect sourceIndex={i} />
</Route>
{staticSourceData.map(({ addPath, accountContextOnly, name }, i) => (
<Route key={i} exact path={getSourcesPath(addPath, isOrganization)}>
<SetPageChrome trail={[NAV.SOURCES, NAV.ADD_SOURCE, name]} />
{!hasPlatinumLicense && accountContextOnly ? (
<Redirect exact from={ADD_SOURCE_PATH} to={SOURCES_PATH} />
) : (
<AddSource sourceIndex={i} />
)}
</Route>
))}
{staticSourceData.map(({ addPath, name }, i) => (
<Route key={i} exact path={`${getSourcesPath(addPath, isOrganization)}/connect`}>
<SetPageChrome trail={[NAV.SOURCES, NAV.ADD_SOURCE, name]} />
<AddSource connect sourceIndex={i} />
</Route>
))}
{staticSourceData.map(({ addPath, name }, i) => (
<Route key={i} exact path={`${getSourcesPath(addPath, isOrganization)}/reauthenticate`}>
<SetPageChrome trail={[NAV.SOURCES, NAV.ADD_SOURCE, name]} />
<AddSource reAuthenticate sourceIndex={i} />
</Route>
))}
{staticSourceData.map(({ addPath, name, configuration: { needsConfiguration } }, i) => {
if (needsConfiguration)
return (
<Route key={i} exact path={`${getSourcesPath(addPath, isOrganization)}/configure`}>
<SetPageChrome trail={[NAV.SOURCES, NAV.ADD_SOURCE, name]} />
<AddSource configure sourceIndex={i} />
</Route>
);
})}
{canCreatePersonalSources ? (
<Route exact path={getSourcesPath(ADD_SOURCE_PATH, false)}>
<SetPageChrome trail={[NAV.SOURCES, NAV.ADD_SOURCE]} />
<SendTelemetry action="viewed" metric="add_source" />
<AddSourceList />
</Route>
) : (
<Redirect
exact
from={getSourcesPath(ADD_SOURCE_PATH, false)}
to={PERSONAL_SOURCES_PATH}
/>
)}
<Route exact path={getSourcesPath(ADD_SOURCE_PATH, true)}>
<SetPageChrome trail={[NAV.SOURCES, NAV.ADD_SOURCE]} />
<AddSourceList />
))}
{staticSourceData.map(({ addPath }, i) => (
<Route key={i} exact path={`${getSourcesPath(addPath, isOrganization)}/reauthenticate`}>
<AddSource reAuthenticate sourceIndex={i} />
</Route>
<Route path={getSourcesPath(SOURCE_DETAILS_PATH, isOrganization)}>
<SourceRouter />
))}
{staticSourceData.map(({ addPath, configuration: { needsConfiguration } }, i) => {
if (needsConfiguration)
return (
<Route key={i} exact path={`${getSourcesPath(addPath, isOrganization)}/configure`}>
<AddSource configure sourceIndex={i} />
</Route>
);
})}
{canCreatePersonalSources ? (
<Route exact path={getSourcesPath(ADD_SOURCE_PATH, false)}>
<AddSourceList />
</Route>
</Switch>
</>
) : (
<Redirect exact from={getSourcesPath(ADD_SOURCE_PATH, false)} to={PERSONAL_SOURCES_PATH} />
)}
<Route exact path={getSourcesPath(ADD_SOURCE_PATH, true)}>
<AddSourceList />
</Route>
<Route path={getSourcesPath(SOURCE_DETAILS_PATH, isOrganization)}>
<SourceRouter />
</Route>
</Switch>
);
};