Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into better-popup-texts
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaindik committed Dec 11, 2024
2 parents d340f8c + 2dcbc5d commit 46af2d1
Show file tree
Hide file tree
Showing 262 changed files with 1,857 additions and 277 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,6 @@ x-pack/plugins/snapshot_restore @elastic/kibana-management
x-pack/plugins/spaces @elastic/kibana-security
x-pack/plugins/stack_alerts @elastic/response-ops
x-pack/plugins/stack_connectors @elastic/response-ops
x-pack/plugins/streams @elastic/streams-program-team
x-pack/plugins/streams_app @elastic/streams-program-team
x-pack/plugins/task_manager @elastic/response-ops
x-pack/plugins/telemetry_collection_xpack @elastic/kibana-core
x-pack/plugins/threat_intelligence @elastic/security-threat-hunting-investigations
Expand All @@ -997,6 +995,8 @@ x-pack/plugins/upgrade_assistant @elastic/kibana-management
x-pack/plugins/watcher @elastic/kibana-management
x-pack/solutions/observability/plugins/observability_solution/entities_data_access @elastic/obs-entities
x-pack/solutions/observability/plugins/observability_solution/entity_manager_app @elastic/obs-entities
x-pack/solutions/observability/plugins/streams @elastic/streams-program-team
x-pack/solutions/observability/plugins/streams_app @elastic/streams-program-team
x-pack/test
x-pack/test_serverless
x-pack/test/alerting_api_integration/common/plugins/aad @elastic/response-ops
Expand Down
4 changes: 2 additions & 2 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -917,11 +917,11 @@ routes, etc.
|The stack_connectors plugin provides connector types shipped with Kibana, built on top of the framework provided in the actions plugin.
|{kib-repo}blob/{branch}/x-pack/plugins/streams/README.md[streams]
|{kib-repo}blob/{branch}/x-pack/solutions/observability/plugins/streams/README.md[streams]
|This plugin provides an interface to manage streams
|{kib-repo}blob/{branch}/x-pack/plugins/streams_app/README.md[streamsApp]
|{kib-repo}blob/{branch}/x-pack/solutions/observability/plugins/streams_app/README.md[streamsApp]
|Home of the Streams app plugin, which allows users to manage Streams via the UI.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -941,8 +941,8 @@
"@kbn/status-plugin-a-plugin": "link:test/server_integration/plugins/status_plugin_a",
"@kbn/status-plugin-b-plugin": "link:test/server_integration/plugins/status_plugin_b",
"@kbn/std": "link:packages/kbn-std",
"@kbn/streams-app-plugin": "link:x-pack/plugins/streams_app",
"@kbn/streams-plugin": "link:x-pack/plugins/streams",
"@kbn/streams-app-plugin": "link:x-pack/solutions/observability/plugins/streams_app",
"@kbn/streams-plugin": "link:x-pack/solutions/observability/plugins/streams",
"@kbn/synthetics-plugin": "link:x-pack/plugins/observability_solution/synthetics",
"@kbn/synthetics-private-location": "link:x-pack/packages/kbn-synthetics-private-location",
"@kbn/task-manager-fixture-plugin": "link:x-pack/test/alerting_api_integration/common/plugins/task_manager_fixture",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,30 @@ interface IndexAlias {
*
* @param esClient An {@link ElasticsearchClient}
* @param alias alias name used to filter results
* @param index index name used to filter results
*
* @returns an array of {@link IndexAlias} objects
*/
export const getIndexAliases = async ({
esClient,
alias,
index,
}: {
esClient: ElasticsearchClient;
alias: string;
index?: string;
}): Promise<IndexAlias[]> => {
const response = await esClient.indices.getAlias(
{
name: alias,
...(index ? { index } : {}),
},
{ meta: true }
);

return Object.keys(response.body).map((index) => ({
return Object.keys(response.body).map((indexName) => ({
alias,
index,
isWriteIndex: response.body[index].aliases[alias]?.is_write_index === true,
index: indexName,
isWriteIndex: response.body[indexName].aliases[alias]?.is_write_index === true,
}));
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import type { ChartsPluginSetup } from '@kbn/charts-plugin/public';
import DateMath from '@kbn/datemath';
import { EuiButtonGroup, EuiLoadingSpinner, EuiSpacer, EuiText, EuiTitle } from '@elastic/eui';
import {
EuiButtonGroup,
EuiLoadingSpinner,
EuiSpacer,
EuiText,
EuiTitle,
useEuiTheme,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import {
Axis,
Expand Down Expand Up @@ -120,14 +127,17 @@ const FieldStatsComponent: React.FC<FieldStatsProps> = ({
toDate,
dataViewOrDataViewId,
field,
color = getDefaultColor(),
color: originalColor,
'data-test-subj': dataTestSubject = 'fieldStats',
overrideMissingContent,
overrideFooter,
onAddFilter,
overrideFieldTopValueBar,
onStateChange,
}) => {
const { euiTheme } = useEuiTheme();
const color = originalColor ?? getDefaultColor(euiTheme.themeName);

const { fieldFormats, uiSettings, charts, dataViews, data } = services;
const [state, changeState] = useState<FieldStatsState>({
isLoading: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('UnifiedFieldList <FieldTopValues />', () => {
key: 'sourceB',
},
],
color: '#000',
'data-test-subj': 'testing',
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface FieldTopValuesProps {
dataView: DataView;
field: DataViewField;
sampledValuesCount: number;
color?: string;
color: string;
'data-test-subj': string;
onAddFilter?: AddFieldFilterHandler;
overrideFieldTopValueBar?: OverrideFieldTopValueBarCallback;
Expand All @@ -32,7 +32,7 @@ export const FieldTopValues: React.FC<FieldTopValuesProps> = ({
dataView,
field,
sampledValuesCount,
color = getDefaultColor(),
color,
'data-test-subj': dataTestSubject,
onAddFilter,
overrideFieldTopValueBar,
Expand Down Expand Up @@ -106,7 +106,10 @@ export const FieldTopValues: React.FC<FieldTopValuesProps> = ({
);
};

export const getDefaultColor = () => euiPaletteColorBlind()[1];
export const getDefaultColor = (euiThemeName: string) =>
euiThemeName?.toLowerCase().includes('borealis')
? euiPaletteColorBlind()[2]
: euiPaletteColorBlind()[1]; // FIXME: remove in 9.x when Borealis becomes the default theme

export const getFormattedPercentageValue = (
currentValue: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import {
EuiProgress,
EuiText,
EuiTextBlockTruncate,
EuiThemeComputed,
EuiToolTip,
makeHighContrastColor,
useEuiTheme,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { css } from '@emotion/react';
Expand Down Expand Up @@ -53,6 +56,7 @@ const FieldTopValuesBucket: React.FC<FieldTopValuesBucketProps> = ({
overrideFieldTopValueBar,
...fieldTopValuesBucketOverridableProps
}) => {
const { euiTheme } = useEuiTheme();
const overrides = overrideFieldTopValueBar
? overrideFieldTopValueBar(fieldTopValuesBucketOverridableProps)
: ({} as FieldTopValuesBucketParams);
Expand Down Expand Up @@ -141,7 +145,7 @@ const FieldTopValuesBucket: React.FC<FieldTopValuesBucketProps> = ({
})}
delay="long"
>
<EuiText size="xs" textAlign="left" color={color}>
<EuiText size="xs" textAlign="left" color={getPercentageColor(euiTheme, color)}>
{formattedPercentage}
</EuiText>
</EuiToolTip>
Expand Down Expand Up @@ -207,6 +211,11 @@ const FieldTopValuesBucket: React.FC<FieldTopValuesBucketProps> = ({
);
};

const getPercentageColor = (euiTheme: EuiThemeComputed, color: string) =>
euiTheme.themeName?.toLowerCase().includes('borealis')
? makeHighContrastColor(color)(euiTheme)
: color; // FIXME: remove in 9.x when Borealis becomes the default theme

// Necessary for React.lazy
// eslint-disable-next-line import/no-default-export
export default FieldTopValuesBucket;
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ export const shareModalStrings = {
defaultMessage:
'One or more panels on this dashboard have changed. Before you generate a snapshot, save the dashboard.',
}),
getDraftSharePanelChangesWarning: () =>
i18n.translate('dashboard.snapshotShare.panelChangesWarning', {
defaultMessage:
'You are about to share a dashboard with unsaved changes, and the link may not work properly. Save the dashboard first to create a permanent link.',
}),
getEmbedSharePanelChangesWarning: () =>
i18n.translate('dashboard.embedShare.draftWarning', {
defaultMessage:
'You are about to create an embedded dashboard with unsaved changes, and the embed code may not work properly. Save the dashboard first to create a permanent embedded dashboard.',
}),
getDraftShareWarning: (shareType: 'embed' | 'link') =>
i18n.translate('dashboard.snapshotShare.draftWarning', {
defaultMessage:
'This dashboard has unsaved changes. Consider saving your dashboard before generating the {shareType}.',
values: { shareType: shareType === 'embed' ? 'embed code' : 'link' },
}),
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import { omit } from 'lodash';
import moment from 'moment';
import React, { ReactElement, useState } from 'react';

import { EuiCheckboxGroup } from '@elastic/eui';
import { EuiCallOut, EuiCheckboxGroup } from '@elastic/eui';
import type { Capabilities } from '@kbn/core/public';
import { QueryState } from '@kbn/data-plugin/common';
import { DASHBOARD_APP_LOCATOR } from '@kbn/deeplinks-analytics';
import { ViewMode } from '@kbn/embeddable-plugin/public';
import { i18n } from '@kbn/i18n';
import { getStateFromKbnUrl, setStateToKbnUrl, unhashUrl } from '@kbn/kibana-utils-plugin/public';

import { FormattedMessage } from '@kbn/i18n-react';
import { convertPanelMapToPanelsArray, DashboardPanelMap } from '../../../../common';
import { DashboardLocatorParams } from '../../../dashboard_container';
import {
Expand Down Expand Up @@ -122,7 +123,7 @@ export function ShowShareModal({
const allUnsavedPanels = (() => {
if (
Object.keys(unsavedDashboardState?.panels ?? {}).length === 0 &&
Object.keys(panelModifications ?? {}).length === 0
Object.keys(omit(panelModifications ?? {}, PANELS_CONTROL_GROUP_KEY)).length === 0
) {
// if this dashboard has no modifications or unsaved panels return early. No overrides needed.
return;
Expand Down Expand Up @@ -195,18 +196,58 @@ export function ShowShareModal({
unhashUrl(baseUrl)
);

const allowShortUrl = getDashboardCapabilities().createShortUrl;

shareService.toggleShareContextMenu({
isDirty,
anchorElement,
allowEmbed: true,
allowShortUrl: getDashboardCapabilities().createShortUrl,
allowShortUrl,
shareableUrl,
objectId: savedObjectId,
objectType: 'dashboard',
objectTypeMeta: {
title: i18n.translate('dashboard.share.shareModal.title', {
defaultMessage: 'Share this dashboard',
}),
config: {
link: {
draftModeCallOut: (
<EuiCallOut
color="warning"
data-test-subj="DashboardDraftModeCopyLinkCallOut"
title={
<FormattedMessage
id="dashboard.share.shareModal.draftModeCallout.title"
defaultMessage="Unsaved changes"
/>
}
>
{Boolean(unsavedDashboardState?.panels)
? shareModalStrings.getDraftSharePanelChangesWarning()
: shareModalStrings.getDraftShareWarning('link')}
</EuiCallOut>
),
},
embed: {
draftModeCallOut: (
<EuiCallOut
color="warning"
data-test-subj="DashboardDraftModeEmbedCallOut"
title={
<FormattedMessage
id="dashboard.share.shareModal.draftModeCallout.title"
defaultMessage="Unsaved changes"
/>
}
>
{Boolean(unsavedDashboardState?.panels)
? shareModalStrings.getEmbedSharePanelChangesWarning()
: shareModalStrings.getDraftShareWarning('embed')}
</EuiCallOut>
),
},
},
},
sharingData: {
title:
Expand Down
47 changes: 45 additions & 2 deletions src/plugins/share/common/url_service/locators/locator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import { KibanaLocation } from '../../../public';
import { LocatorGetUrlParams } from '.';
import { decompressFromBase64 } from 'lz-string';

const setup = () => {
const baseUrl = 'http://localhost:5601';
const setup = (
{ baseUrl = 'http://localhost:5601' }: { baseUrl: string } = { baseUrl: 'http://localhost:5601' }
) => {
const version = '1.2.3';
const deps: LocatorDependencies = {
baseUrl,
Expand Down Expand Up @@ -88,6 +89,48 @@ describe('Locator', () => {
baz: 'b',
});
});

test('returns URL of the redirect endpoint with custom spaceid', async () => {
const { locator } = setup();
const url = await locator.getRedirectUrl(
{ foo: 'a', baz: 'b' },
{ spaceId: 'custom-space-id' }
);

expect(url).toBe(
'http://localhost:5601/s/custom-space-id/app/r?l=TEST_LOCATOR&v=1.2.3&lz=N4IgZg9hIFwghiANCARvAXrNIC%2BQ'
);
});

test('returns URL of the redirect endpoint with replaced spaceid', async () => {
const { locator } = setup({ baseUrl: 'http://localhost:5601/s/space-id' });
const url = await locator.getRedirectUrl(
{ foo: 'a', baz: 'b' },
{ spaceId: 'custom-space-id' }
);

expect(url).toBe(
'http://localhost:5601/s/custom-space-id/app/r?l=TEST_LOCATOR&v=1.2.3&lz=N4IgZg9hIFwghiANCARvAXrNIC%2BQ'
);
});

test('returns URL of the redirect endpoint without spaceid', async () => {
const { locator } = setup({ baseUrl: 'http://localhost:5601/s/space-id' });
const url = await locator.getRedirectUrl({ foo: 'a', baz: 'b' }, { spaceId: 'default' });

expect(url).toBe(
'http://localhost:5601/app/r?l=TEST_LOCATOR&v=1.2.3&lz=N4IgZg9hIFwghiANCARvAXrNIC%2BQ'
);
});

test('returns URL of the redirect endpoint with untouched spaceId', async () => {
const { locator } = setup({ baseUrl: 'http://localhost:5601/s/space-id' });
const url = await locator.getRedirectUrl({ foo: 'a', baz: 'b' });

expect(url).toBe(
'http://localhost:5601/s/space-id/app/r?l=TEST_LOCATOR&v=1.2.3&lz=N4IgZg9hIFwghiANCARvAXrNIC%2BQ'
);
});
});

describe('.navigate()', () => {
Expand Down
Loading

0 comments on commit 46af2d1

Please sign in to comment.