Skip to content

Commit

Permalink
Removing 'showNavLinks' config option and displaying Avatar menu for …
Browse files Browse the repository at this point in the history
…serverless (#162140)

## Summary

Closes #160141

The avatar menu needs to be displayed for serverless. It was previously
required to be hidden in serverless, so a config 'showNavLinks' was
added. This config is no longer needed, so it has been removed.

## Testing

Start KB with the `--serverless` flag and login as `elastic`.

The Avatar should appear in the top right coner.
  • Loading branch information
kc13greiner authored Jul 31, 2023
1 parent f981722 commit 7770ccc
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 10 deletions.
1 change: 0 additions & 1 deletion config/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
interactiveSetup.enabled: false
newsfeed.enabled: false
xpack.security.showNavLinks: false
xpack.serverless.plugin.enabled: true
# Fleet settings
xpack.fleet.internal.fleetServerStandalone: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ export const ProjectHeader = ({
<EuiHeaderSection side="right">
<EuiHeaderSectionItem>
<HeaderNavControls navControls$={observables.navControlsCenter$} />
<HeaderNavControls navControls$={observables.navControlsRight$} />
</EuiHeaderSectionItem>

<EuiHeaderSectionItem>
Expand All @@ -263,6 +262,10 @@ export const ProjectHeader = ({
navigateToUrl={application.navigateToUrl}
/>
</EuiHeaderSectionItem>

<EuiHeaderSectionItem>
<HeaderNavControls navControls$={observables.navControlsRight$} />
</EuiHeaderSectionItem>
</EuiHeaderSection>
</EuiHeader>

Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/security/public/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export interface ConfigType {
loginAssistanceMessage: string;
showInsecureClusterWarning: boolean;
sameSiteCookies: 'Strict' | 'Lax' | 'None' | undefined;
showNavLinks: boolean;
ui: {
userManagementEnabled: boolean;
roleManagementEnabled: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ interface SetupDeps {
securityLicense: SecurityLicense;
logoutUrl: string;
securityApiClients: SecurityApiClients;
showNavLinks?: boolean;
}

interface StartDeps {
Expand All @@ -55,18 +54,16 @@ export class SecurityNavControlService {
private securityApiClients!: SecurityApiClients;

private navControlRegistered!: boolean;
private showNavLinks!: boolean;

private securityFeaturesSubscription?: Subscription;

private readonly stop$ = new ReplaySubject<void>(1);
private userMenuLinks$ = new BehaviorSubject<UserMenuLink[]>([]);

public setup({ securityLicense, logoutUrl, securityApiClients, showNavLinks = true }: SetupDeps) {
public setup({ securityLicense, logoutUrl, securityApiClients }: SetupDeps) {
this.securityLicense = securityLicense;
this.logoutUrl = logoutUrl;
this.securityApiClients = securityApiClients;
this.showNavLinks = showNavLinks;
}

public start({ core, authc }: StartDeps): SecurityNavControlServiceStart {
Expand All @@ -75,7 +72,7 @@ export class SecurityNavControlService {
const isAnonymousPath = core.http.anonymousPaths.isAnonymous(window.location.pathname);

const shouldRegisterNavControl =
this.showNavLinks && !isAnonymousPath && showLinks && !this.navControlRegistered;
!isAnonymousPath && showLinks && !this.navControlRegistered;
if (shouldRegisterNavControl) {
this.registerSecurityNavControl(core, authc);
}
Expand Down Expand Up @@ -121,8 +118,9 @@ export class SecurityNavControlService {

private registerSecurityNavControl(core: CoreStart, authc: AuthenticationServiceSetup) {
const { theme$ } = core.theme;

core.chrome.navControls.registerRight({
order: 2000,
order: 4000,
mount: (element: HTMLElement) => {
ReactDOM.render(
<Providers
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/security/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export class SecurityPlugin
securityLicense: license,
logoutUrl: getLogoutUrl(core.http),
securityApiClients: this.securityApiClients,
showNavLinks: this.config.showNavLinks,
});

this.analyticsService.setup({
Expand Down
16 changes: 16 additions & 0 deletions x-pack/plugins/security/server/config_deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,22 @@ describe('Config Deprecations', () => {
`);
});

it(`warns that 'xpack.security.showNavLinks' is unused`, () => {
const config = {
xpack: {
security: {
showNavLinks: true,
},
},
};
const { messages } = applyConfigDeprecations(cloneDeep(config));
expect(messages).toMatchInlineSnapshot(`
Array [
"You no longer need to configure \\"xpack.security.showNavLinks\\".",
]
`);
});

it(`warns that 'xpack.security.authc.providers.saml.<provider-name>.maxRedirectURLSize' is unused`, () => {
const config = {
xpack: {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/security/server/config_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({

unused('authorization.legacyFallback.enabled', { level: 'warning' }),
unused('authc.saml.maxRedirectURLSize', { level: 'warning' }),
unused('showNavLinks', { level: 'warning' }),

// Deprecation warning for the old array-based format of `xpack.security.authc.providers`.
(settings, _fromPath, addDeprecation, { branch }) => {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/serverless/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class ServerlessPlugin
const { currentType } = developer.projectSwitcher;

core.chrome.navControls.registerRight({
order: 500,
mount: (target) => this.mountProjectSwitcher(target, core, currentType),
});
}
Expand Down
12 changes: 12 additions & 0 deletions x-pack/test_serverless/functional/page_objects/svl_common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@ export function SvlCommonPageProvider({ getService }: FtrProviderContext) {
async assertProjectHeaderExists() {
await testSubjects.existOrFail('kibanaProjectHeader');
},

async clickUserAvatar() {
testSubjects.click('userMenuAvatar');
},

async assertUserAvatarExists() {
await testSubjects.existOrFail('userMenuAvatar');
},

async assertUserMenuExists() {
await testSubjects.existOrFail('userMenu');
},
};
}
3 changes: 3 additions & 0 deletions x-pack/test_serverless/functional/test_suites/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ export default function ({ loadTestFile }: FtrProviderContext) {
describe('serverless common UI', function () {
loadTestFile(require.resolve('./home_page'));
loadTestFile(require.resolve('./management'));

// platform security
loadTestFile(require.resolve('./security/navigation/avatar_menu'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getPageObject, getService }: FtrProviderContext) {
const svlCommonPage = getPageObject('svlCommonPage');
const svlCommonNavigation = getService('svlCommonNavigation');

describe('Avatar menu', function () {
it('is displayed', async () => {
await svlCommonNavigation.navigateToKibanaHome();
await svlCommonPage.assertUserAvatarExists();
});

it('displays User Menu when clicked', async () => {
await svlCommonNavigation.navigateToKibanaHome();
await svlCommonPage.clickUserAvatar();
await svlCommonPage.assertUserMenuExists();
});
});
}

0 comments on commit 7770ccc

Please sign in to comment.