Skip to content

Commit

Permalink
Merge branch 'main' into rep-et
Browse files Browse the repository at this point in the history
  • Loading branch information
rshen91 authored May 18, 2023
2 parents 393da2c + 1cb0ee6 commit 46a4e31
Show file tree
Hide file tree
Showing 74 changed files with 1,216 additions and 705 deletions.
19 changes: 18 additions & 1 deletion docs/api-generated/rules/rule-apis-passthru.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Any modifications made to this file will be overwritten.
"warning" : "warning",
"outcome" : "succeeded"
},
"api_key_created_by_user" : false,
"params" : {
"key" : ""
},
Expand Down Expand Up @@ -142,6 +143,7 @@ Any modifications made to this file will be overwritten.
"params" : {
"key" : ""
},
"uuid" : "1c7a1280-f28c-4e06-96b2-e4e5f05d1d61",
"connector_type_id" : ".server-log",
"frequency" : {
"summary" : true,
Expand All @@ -154,6 +156,7 @@ Any modifications made to this file will be overwritten.
"params" : {
"key" : ""
},
"uuid" : "1c7a1280-f28c-4e06-96b2-e4e5f05d1d61",
"connector_type_id" : ".server-log",
"frequency" : {
"summary" : true,
Expand Down Expand Up @@ -407,6 +410,7 @@ Any modifications made to this file will be overwritten.
"warning" : "warning",
"outcome" : "succeeded"
},
"api_key_created_by_user" : false,
"params" : {
"key" : ""
},
Expand Down Expand Up @@ -438,6 +442,7 @@ Any modifications made to this file will be overwritten.
"params" : {
"key" : ""
},
"uuid" : "1c7a1280-f28c-4e06-96b2-e4e5f05d1d61",
"connector_type_id" : ".server-log",
"frequency" : {
"summary" : true,
Expand All @@ -450,6 +455,7 @@ Any modifications made to this file will be overwritten.
"params" : {
"key" : ""
},
"uuid" : "1c7a1280-f28c-4e06-96b2-e4e5f05d1d61",
"connector_type_id" : ".server-log",
"frequency" : {
"summary" : true,
Expand All @@ -473,6 +479,7 @@ Any modifications made to this file will be overwritten.
"warning" : "warning",
"outcome" : "succeeded"
},
"api_key_created_by_user" : false,
"params" : {
"key" : ""
},
Expand Down Expand Up @@ -504,6 +511,7 @@ Any modifications made to this file will be overwritten.
"params" : {
"key" : ""
},
"uuid" : "1c7a1280-f28c-4e06-96b2-e4e5f05d1d61",
"connector_type_id" : ".server-log",
"frequency" : {
"summary" : true,
Expand All @@ -516,6 +524,7 @@ Any modifications made to this file will be overwritten.
"params" : {
"key" : ""
},
"uuid" : "1c7a1280-f28c-4e06-96b2-e4e5f05d1d61",
"connector_type_id" : ".server-log",
"frequency" : {
"summary" : true,
Expand Down Expand Up @@ -654,6 +663,7 @@ Any modifications made to this file will be overwritten.
"warning" : "warning",
"outcome" : "succeeded"
},
"api_key_created_by_user" : false,
"params" : {
"key" : ""
},
Expand Down Expand Up @@ -685,6 +695,7 @@ Any modifications made to this file will be overwritten.
"params" : {
"key" : ""
},
"uuid" : "1c7a1280-f28c-4e06-96b2-e4e5f05d1d61",
"connector_type_id" : ".server-log",
"frequency" : {
"summary" : true,
Expand All @@ -697,6 +708,7 @@ Any modifications made to this file will be overwritten.
"params" : {
"key" : ""
},
"uuid" : "1c7a1280-f28c-4e06-96b2-e4e5f05d1d61",
"connector_type_id" : ".server-log",
"frequency" : {
"summary" : true,
Expand Down Expand Up @@ -2012,6 +2024,7 @@ Any modifications made to this file will be overwritten.
"warning" : "warning",
"outcome" : "succeeded"
},
"api_key_created_by_user" : false,
"params" : {
"key" : ""
},
Expand Down Expand Up @@ -2043,6 +2056,7 @@ Any modifications made to this file will be overwritten.
"params" : {
"key" : ""
},
"uuid" : "1c7a1280-f28c-4e06-96b2-e4e5f05d1d61",
"connector_type_id" : ".server-log",
"frequency" : {
"summary" : true,
Expand All @@ -2055,6 +2069,7 @@ Any modifications made to this file will be overwritten.
"params" : {
"key" : ""
},
"uuid" : "1c7a1280-f28c-4e06-96b2-e4e5f05d1d61",
"connector_type_id" : ".server-log",
"frequency" : {
"summary" : true,
Expand Down Expand Up @@ -2231,6 +2246,7 @@ Any modifications made to this file will be overwritten.
<div class="param">group (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> The group name for the actions. If you don't need to group actions, set to <code>default</code>. </div>
<div class="param">id (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> The identifier for the connector saved object. </div>
<div class="param">params (optional)</div><div class="param-desc"><span class="param-type"><a href="#AnyType">map[String, oas_any_type_not_mapped]</a></span> The parameters for the action, which are sent to the connector. The <code>params</code> are handled as Mustache templates and passed a default set of context. </div>
<div class="param">uuid (optional)</div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> A universally unique identifier (UUID) for the action. </div>
</div> <!-- field-items -->
</div>
<div class="model">
Expand Down Expand Up @@ -2566,7 +2582,8 @@ Any modifications made to this file will be overwritten.
<div class='model-description'></div>
<div class="field-items">
<div class="param">actions </div><div class="param-desc"><span class="param-type"><a href="#actions_inner">array[actions_inner]</a></span> </div>
<div class="param">api_key_owner </div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> </div>
<div class="param">api_key_created_by_user (optional)</div><div class="param-desc"><span class="param-type"><a href="#boolean">Boolean</a></span> Indicates whether the API key that is associated with the rule was created by the user. </div>
<div class="param">api_key_owner </div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> The owner of the API key that is associated with the rule and used to run background tasks. </div>
<div class="param">consumer </div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> The application or feature that owns the rule. For example, <code>alerts</code>, <code>apm</code>, <code>discover</code>, <code>infrastructure</code>, <code>logs</code>, <code>metrics</code>, <code>ml</code>, <code>monitoring</code>, <code>securitySolution</code>, <code>siem</code>, <code>stackAlerts</code>, or <code>uptime</code>. </div>
<div class="param">created_at </div><div class="param-desc"><span class="param-type"><a href="#DateTime">Date</a></span> The date and time that the rule was created. format: date-time</div>
<div class="param">created_by </div><div class="param-desc"><span class="param-type"><a href="#string">String</a></span> The identifier for the user that created the rule. </div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
border-radius: 0;
}

.embPanel__content {
border-radius: 0;
}

.dshDashboardGrid__item--highlighted {
border-radius: 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ async function mountComponent(
state: { columns: [], query, hideChart: false, interval: 'auto' },
stateContainer,
setExpandedDoc: jest.fn(),
persistDataView: jest.fn(),
updateDataViewList: jest.fn(),
};
stateContainer.searchSessionManager = createSearchSessionMock(session).searchSessionManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { METRIC_TYPE } from '@kbn/analytics';
import classNames from 'classnames';
import { generateFilters } from '@kbn/data-plugin/public';
import { DragContext } from '@kbn/dom-drag-drop';
import { DataView, DataViewField, DataViewType } from '@kbn/data-views-plugin/public';
import { DataViewField, DataViewType } from '@kbn/data-views-plugin/public';
import { useSavedSearchInitial } from '../../services/discover_state_provider';
import { DiscoverStateContainer } from '../../services/discover_state';
import { VIEW_MODE } from '../../../../../common/constants';
Expand Down Expand Up @@ -59,14 +59,9 @@ const TopNavMemoized = React.memo(DiscoverTopNav);
export interface DiscoverLayoutProps {
navigateTo: (url: string) => void;
stateContainer: DiscoverStateContainer;
persistDataView: (dataView: DataView) => Promise<DataView | undefined>;
}

export function DiscoverLayout({
navigateTo,
stateContainer,
persistDataView,
}: DiscoverLayoutProps) {
export function DiscoverLayout({ navigateTo, stateContainer }: DiscoverLayoutProps) {
const {
trackUiMetric,
capabilities,
Expand Down Expand Up @@ -284,7 +279,6 @@ export function DiscoverLayout({
isPlainRecord={isPlainRecord}
textBasedLanguageModeErrors={textBasedLanguageModeErrors}
onFieldEdited={onFieldEdited}
persistDataView={persistDataView}
/>
<EuiPageBody className="dscPageBody" aria-describedby="savedSearchTitle">
<SavedSearchURLConflictCallout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function getProps(savePermissions = true): DiscoverTopNavProps {
onOpenInspector: jest.fn(),
onFieldEdited: jest.fn(),
isPlainRecord: false,
persistDataView: jest.fn(),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export type DiscoverTopNavProps = Pick<DiscoverLayoutProps, 'navigateTo'> & {
isPlainRecord: boolean;
textBasedLanguageModeErrors?: Error;
onFieldEdited: () => Promise<void>;
persistDataView: (dataView: DataView) => Promise<DataView | undefined>;
};

export const DiscoverTopNav = ({
Expand All @@ -44,7 +43,6 @@ export const DiscoverTopNav = ({
isPlainRecord,
textBasedLanguageModeErrors,
onFieldEdited,
persistDataView,
}: DiscoverTopNavProps) => {
const adHocDataViews = useInternalStateSelector((state) => state.adHocDataViews);
const dataView = useInternalStateSelector((state) => state.dataView!);
Expand Down Expand Up @@ -120,18 +118,8 @@ export const DiscoverTopNav = ({
onOpenInspector,
isPlainRecord,
adHocDataViews,
persistDataView,
}),
[
dataView,
navigateTo,
services,
stateContainer,
onOpenInspector,
isPlainRecord,
adHocDataViews,
persistDataView,
]
[dataView, navigateTo, services, stateContainer, onOpenInspector, isPlainRecord, adHocDataViews]
);

const onEditDataView = async (editedDataView: DataView) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ test('getTopNavLinks result', () => {
services,
state,
isPlainRecord: false,
persistDataView: jest.fn(),
adHocDataViews: [],
});
expect(topNavLinks).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -93,7 +92,6 @@ test('getTopNavLinks result for sql mode', () => {
services,
state,
isPlainRecord: true,
persistDataView: jest.fn(),
adHocDataViews: [],
});
expect(topNavLinks).toMatchInlineSnapshot(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import { i18n } from '@kbn/i18n';
import type { DataView } from '@kbn/data-views-plugin/public';
import { unhashUrl } from '@kbn/kibana-utils-plugin/public';
import type { TopNavMenuData } from '@kbn/navigation-plugin/public';
import type { DiscoverAppLocatorParams } from '../../../../../common';
import { showOpenSearchPanel } from './show_open_search_panel';
import { getSharingData, showPublicUrlSwitch } from '../../../../utils/get_sharing_data';
import { DiscoverServices } from '../../../../build_services';
Expand All @@ -28,7 +28,6 @@ export const getTopNavLinks = ({
state,
onOpenInspector,
isPlainRecord,
persistDataView,
adHocDataViews,
}: {
dataView: DataView;
Expand All @@ -38,7 +37,6 @@ export const getTopNavLinks = ({
onOpenInspector: () => void;
isPlainRecord: boolean;
adHocDataViews: DataView[];
persistDataView: (dataView: DataView) => Promise<DataView | undefined>;
}): TopNavMenuData[] => {
const options = {
id: 'options',
Expand Down Expand Up @@ -143,17 +141,7 @@ export const getTopNavLinks = ({
}),
testId: 'shareTopNavButton',
run: async (anchorElement: HTMLElement) => {
if (!services.share) {
return;
}
// this prompts the user to save the dataview if adhoc dataview is detected
// for text based languages we don't want this check
if (!isPlainRecord) {
const updatedDataView = await persistDataView(dataView);
if (!updatedDataView) {
return;
}
}
if (!services.share) return;
const savedSearch = state.savedSearchState.getState();
const sharingData = await getSharingData(
savedSearch.searchSource,
Expand All @@ -162,11 +150,46 @@ export const getTopNavLinks = ({
isPlainRecord
);

const { locator } = services;
const appState = state.appState.getState();
const { timefilter } = services.data.query.timefilter;
const timeRange = timefilter.getTime();
const refreshInterval = timefilter.getRefreshInterval();
const { grid, ...otherState } = appState;
const filters = services.filterManager.getFilters();

// Share -> Get links -> Snapshot
const params: DiscoverAppLocatorParams = {
...otherState,
...(savedSearch.id ? { savedSearchId: savedSearch.id } : {}),
...(dataView?.isPersisted()
? { dataViewId: dataView?.id }
: { dataViewSpec: dataView?.toSpec() }),
filters,
timeRange,
refreshInterval,
};
const relativeUrl = locator.getRedirectUrl(params);

// This logic is duplicated from `relativeToAbsolute` (for bundle size reasons). Ultimately, this should be
// replaced when https://github.com/elastic/kibana/issues/153323 is implemented.
const link = document.createElement('a');
link.setAttribute('href', relativeUrl);
const shareableUrl = link.href;

// Share -> Get links -> Saved object
const shareableUrlForSavedObject = await locator.getUrl(
{ savedSearchId: savedSearch.id },
{ absolute: true }
);

services.share.toggleShareContextMenu({
anchorElement,
allowEmbed: false,
allowShortUrl: !!services.capabilities.discover.createShortUrl,
shareableUrl: unhashUrl(window.location.href),
shareableUrl,
shareableUrlForSavedObject,
shareableUrlLocatorParams: { locator, params },
objectId: savedSearch.id,
objectType: 'search',
sharingData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ export function DiscoverMainApp(props: DiscoverMainProps) {
/**
* Adhoc data views functionality
*/
const { persistDataView } = useAdHocDataViews({
stateContainer,
services,
});
useAdHocDataViews({ stateContainer, services });

/**
* State changes (data view, columns), when a text base query result is returned
Expand Down Expand Up @@ -97,11 +94,7 @@ export function DiscoverMainApp(props: DiscoverMainProps) {

return (
<RootDragDropProvider>
<DiscoverLayoutMemoized
navigateTo={navigateTo}
stateContainer={stateContainer}
persistDataView={persistDataView}
/>
<DiscoverLayoutMemoized navigateTo={navigateTo} stateContainer={stateContainer} />
</RootDragDropProvider>
);
}
Loading

0 comments on commit 46a4e31

Please sign in to comment.