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 @@ -7,42 +7,33 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { useEuiTheme } from '@elastic/eui';
import React from 'react';

export const CPSIcon = () => {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none">
<path
fill="currentColor"
fillRule="evenodd"
d="M8.5 9h4a1 1 0 0 1 1 1v2.065A1.999 1.999 0 1 1 11 14c0-.932.638-1.712 1.5-1.935V10h-4v2.065A1.999 1.999 0 1 1 6 14c0-.932.638-1.712 1.5-1.935V10h-4v2.065A1.999 1.999 0 1 1 1 14c0-.932.638-1.712 1.5-1.935V10a1 1 0 0 1 1-1h4V7h1v2ZM3 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2Zm5 0a1 1 0 1 0 0 2 1 1 0 0 0 0-2Zm5 0a1 1 0 1 0 0 2 1 1 0 0 0 0-2ZM7 0a3 3 0 0 1 3 3c0 .648-.208 1.246-.557 1.736l1.91 1.91-.707.708-1.91-1.91A3 3 0 1 1 7 0Zm0 1a2 2 0 1 0 0 4 2 2 0 0 0 0-4Z"
clipRule="evenodd"
/>
</svg>
);
};
import { useEuiTheme } from '@elastic/eui';

export const CPSIconDisabled = () => {
const { euiTheme } = useEuiTheme();
const {
euiTheme: {
colors: { textDisabled },
},
} = useEuiTheme();
return (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none">
<path
fill={euiTheme.colors.textDisabled}
fill={textDisabled}
d="M4.856 13.264c.091.228.144.475.144.736a2 2 0 0 1-2 2c-.26 0-.508-.053-.736-.144l.866-.866a.998.998 0 0 0 .86-.86l.866-.866Z"
/>
<path
fill={euiTheme.colors.textDisabled}
fill={textDisabled}
fillRule="evenodd"
d="M12.5 9a1 1 0 0 1 1 1v2.065A1.999 1.999 0 1 1 11 14c0-.932.638-1.712 1.5-1.935V10h-4v2.065A1.999 1.999 0 1 1 6 14c0-.932.638-1.712 1.5-1.935v-1.444L9.121 9H12.5ZM8 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2Zm5 0a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"
clipRule="evenodd"
/>
<path
fill={euiTheme.colors.textDisabled}
fill={textDisabled}
d="M15.354 1.354 1.447 15.259l-.093.095-.708-.707 14-14 .707.707ZM3.879 10H3.5v.379l-1 1V10a1 1 0 0 1 1-1h1.379l-1 1Z"
/>
<path
fill={euiTheme.colors.textDisabled}
fill={textDisabled}
fillRule="evenodd"
d="M7 0a3 3 0 0 1 3 3c0 .383-.075.748-.207 1.085L8.085 5.793A2.969 2.969 0 0 1 7 6a3 3 0 0 1 0-6Zm0 1a2 2 0 1 0 0 4 2 2 0 0 0 0-4Z"
clipRule="evenodd"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import type { UseEuiTheme } from '@elastic/eui';
import {
EuiPopover,
EuiToolTip,
EuiHeaderSectionItemButton,
EuiIcon,
EuiTourStep,
EuiButton,
EuiButtonIcon,
EuiButtonEmpty,
} from '@elastic/eui';
import { css } from '@emotion/react';
import type { ProjectRouting } from '@kbn/es-query';
Expand All @@ -27,7 +26,7 @@ import { ProjectPickerContent } from './project_picker_content';
import { useFetchProjects } from './use_fetch_projects';
import { useProjectPickerTour } from './use_project_picker_tour';
import { strings } from './strings';
import { CPSIcon, CPSIconDisabled } from './cps_icon';
import { CPSIconDisabled } from './cps_icon';

export interface ProjectPickerProps {
projectRouting?: ProjectRouting;
Expand All @@ -53,26 +52,27 @@ export const ProjectPicker = ({
return null;
}

const totalProjects = linkedProjects.length + 1;
const activeProjectsCount = projectRouting === PROJECT_ROUTING.ALL ? totalProjects : 1;

const button = (
<EuiToolTip
delay="long"
content={strings.getProjectPickerButtonLabel(
projectRouting === PROJECT_ROUTING.ORIGIN ? 1 : linkedProjects.length + 1,
linkedProjects.length + 1
)}
content={strings.getProjectPickerButtonLabel(activeProjectsCount, totalProjects)}
disableScreenReaderOutput
>
<EuiHeaderSectionItemButton
<EuiButtonEmpty
aria-label={strings.getProjectPickerButtonAriaLabel()}
data-test-subj="project-picker-button"
onClick={() => setShowPopover(!showPopover)}
size="s"
notification={projectRouting !== PROJECT_ROUTING.ALL ? 1 : undefined}
notificationColor="success"
css={styles.button}
iconType="crossProjectSearch"
onClick={() => setShowPopover(!showPopover)}
color="text"
>
<EuiIcon type={CPSIcon} />
</EuiHeaderSectionItemButton>
{activeProjectsCount === totalProjects
? strings.allButtonLabel()
: `${activeProjectsCount}/${totalProjects}`}
</EuiButtonEmpty>
</EuiToolTip>
);

Expand Down Expand Up @@ -150,13 +150,4 @@ const projectPickerStyles = {
css({
margin: euiTheme.size.s,
}),
button: ({ euiTheme }: UseEuiTheme) =>
css({
svg: {
verticalAlign: 'middle',
},
'.euiNotificationBadge': {
insetInlineEnd: `-${euiTheme.size.s}`,
},
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import { i18n } from '@kbn/i18n';

export const strings = {
allButtonLabel: () =>
i18n.translate('cpsUtils.projectPicker.allButtonLabel', {
defaultMessage: 'All',
}),
getProjectPickerButtonAriaLabel: () =>
i18n.translate('cpsUtils.projectPicker.projectPickerButtonLabel', {
defaultMessage: 'Cross-project search project picker',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class CpsUsageOverridesBadge
}

public getIconType() {
return 'beaker';
return 'crossProjectSearch';
}

public async isCompatible({ embeddable }: EmbeddableApiContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { schema } from '@kbn/config-schema';
import type { IRouter, PluginInitializerContext } from '@kbn/core/server';
import type { ProjectTagsResponse } from '@kbn/cps-utils';

Expand All @@ -17,7 +18,11 @@ export const registerGetProjectTagsRoute = (
router.get(
{
path: '/internal/cps/projects_tags',
validate: false,
validate: {
query: schema.object({
project_routing: schema.maybe(schema.string()),
}),
},
security: {
authz: {
enabled: false,
Expand All @@ -28,10 +33,13 @@ export const registerGetProjectTagsRoute = (
async (requestHandlerContext, request, response) => {
try {
const core = await requestHandlerContext.core;
const { project_routing } = request.query;

const result: ProjectTagsResponse =
await core.elasticsearch.client.asCurrentUser.transport.request({
method: 'GET',
path: `/_project/tags`,
querystring: project_routing ? { project_routing } : undefined,
});

return response.ok({
Expand Down
Loading