Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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,6 +19,7 @@ export const mockKibanaValues = {
history: mockHistory,
navigateToUrl: jest.fn(),
setBreadcrumbs: jest.fn(),
setChromeIsVisible: jest.fn(),
setDocTitle: jest.fn(),
renderHeaderActions: jest.fn(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const renderApp = (
history: params.history,
navigateToUrl: core.application.navigateToUrl,
setBreadcrumbs: core.chrome.setBreadcrumbs,
setChromeIsVisible: core.chrome.setIsVisible,
setDocTitle: core.chrome.docTitle.change,
renderHeaderActions: (HeaderActions) =>
params.setHeaderActionMenu((el) => renderHeaderActions(HeaderActions, store, el)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface KibanaLogicProps {
charts: ChartsPluginStart;
navigateToUrl: ApplicationStart['navigateToUrl'];
setBreadcrumbs(crumbs: ChromeBreadcrumb[]): void;
setChromeIsVisible(isVisible: boolean): void;
setDocTitle(title: string): void;
renderHeaderActions(HeaderActions: FC): void;
}
Expand All @@ -47,6 +48,7 @@ export const KibanaLogic = kea<MakeLogicType<KibanaValues>>({
{},
],
setBreadcrumbs: [props.setBreadcrumbs, {}],
setChromeIsVisible: [props.setChromeIsVisible, {}],
setDocTitle: [props.setDocTitle, {}],
renderHeaderActions: [props.renderHeaderActions, {}],
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ describe('WorkplaceSearchConfigured', () => {
setMockActions({ initializeAppData, setContext });
});

it('renders layout and header actions', () => {
it('renders layout, chrome, and header actions', () => {
const wrapper = shallow(<WorkplaceSearchConfigured />);

expect(wrapper.find(Layout).first().prop('readOnlyMode')).toBeFalsy();
expect(wrapper.find(OverviewMVP)).toHaveLength(1);

expect(mockKibanaValues.setChromeIsVisible).toHaveBeenCalledWith(true);
expect(mockKibanaValues.renderHeaderActions).toHaveBeenCalledWith(WorkplaceSearchHeaderActions);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const WorkplaceSearch: React.FC<InitialAppData> = (props) => {
export const WorkplaceSearchConfigured: React.FC<InitialAppData> = (props) => {
const { hasInitialized } = useValues(AppLogic);
const { initializeAppData, setContext } = useActions(AppLogic);
const { renderHeaderActions } = useValues(KibanaLogic);
const { renderHeaderActions, setChromeIsVisible } = useValues(KibanaLogic);
const { errorConnecting, readOnlyMode } = useValues(HttpLogic);

const { pathname } = useLocation();
Expand All @@ -66,11 +66,13 @@ export const WorkplaceSearchConfigured: React.FC<InitialAppData> = (props) => {
* Personal dashboard urls begin with /p/
* EX: http://localhost:5601/app/enterprise_search/workplace_search/p/sources
*/
const personalSourceUrlRegex = /^\/p\//g; // matches '/p/*'
useEffect(() => {
const personalSourceUrlRegex = /^\/p\//g; // matches '/p/*'
const isOrganization = !pathname.match(personalSourceUrlRegex); // TODO: Once auth is figured out, we need to have a check for the equivilent of `isAdmin`.

// TODO: Once auth is figured out, we need to have a check for the equivilent of `isAdmin`.
const isOrganization = !pathname.match(personalSourceUrlRegex);
setContext(isOrganization);
setContext(isOrganization);
setChromeIsVisible(isOrganization);
}, [pathname]);

useEffect(() => {
if (!hasInitialized) {
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/enterprise_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ export class EnterpriseSearchPlugin implements Plugin {
const { chrome, http } = kibanaDeps.core;
chrome.docTitle.change(WORKPLACE_SEARCH_PLUGIN.NAME);

// The Workplace Search Personal dashboard needs the chrome hidden. We hide it globally
// here first to prevent a flash of chrome on the Personal dashboard and unhide it for admin routes.
Comment on lines +117 to +118
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 This comment is great/adds tons of context!

chrome.setIsVisible(false);
await this.getInitialData(http);
const pluginData = this.getPluginData();

Expand Down