kibana/x-pack/plugins/cloud/public/user_menu_links.ts
Ryan Keairns b301d416b7
Update Cloud plugin to handle new config in kibana.yml (#95569)
* Handle cloud urls from kibana.yml

* Add types to utils params

* Update utils

* address nits

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-03-31 07:49:50 -05:00

42 lines
1.3 KiB
TypeScript

/*
* 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 { i18n } from '@kbn/i18n';
import { UserMenuLink } from '../../security/public';
import { CloudConfigType } from '.';
import { getFullCloudUrl } from './utils';
export const createUserMenuLinks = (config: CloudConfigType): UserMenuLink[] => {
const { profile_url: profileUrl, organization_url: organizationUrl, base_url: baseUrl } = config;
const userMenuLinks = [] as UserMenuLink[];
if (baseUrl && profileUrl) {
userMenuLinks.push({
label: i18n.translate('xpack.cloud.userMenuLinks.profileLinkText', {
defaultMessage: 'Profile',
}),
iconType: 'user',
href: getFullCloudUrl(baseUrl, profileUrl),
order: 100,
setAsProfile: true,
});
}
if (baseUrl && organizationUrl) {
userMenuLinks.push({
label: i18n.translate('xpack.cloud.userMenuLinks.accountLinkText', {
defaultMessage: 'Account & Billing',
}),
iconType: 'gear',
href: getFullCloudUrl(baseUrl, organizationUrl),
order: 200,
});
}
return userMenuLinks;
};