Skip to content

Commit

Permalink
Merge branch '8.16' into backport/8.16/pr-203684
Browse files Browse the repository at this point in the history
  • Loading branch information
jeramysoucy authored Dec 16, 2024
2 parents 4c78b3f + e10e6ff commit 02dab31
Show file tree
Hide file tree
Showing 19 changed files with 97 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const featuresList = {
'Did you know the new self-managed Elastic open crawler is now available? You can keep your web content in sync with your search-optimized indices!',
}),
title: i18n.translate('xpack.enterpriseSearch.appSearch.gateForm.webCrawler.featureName', {
defaultMessage: 'Web crawler',
defaultMessage: 'Web Crawler',
}),
},
analyticsAndLogs: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const CAPITALIZATION_MAP = {
[LogRetentionOptions.Crawler]: {
capitalized: i18n.translate(
'xpack.enterpriseSearch.appSearch.logRetention.type.crawler.title.capitalized',
{ defaultMessage: 'Web crawler' }
{ defaultMessage: 'Web Crawler' }
),
lowercase: i18n.translate(
'xpack.enterpriseSearch.appSearch.logRetention.type.crawler.title.lowercase',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { i18n } from '@kbn/i18n';

import { DeleteConnectorResponse } from '../../../../../common/types/connectors';

Expand All @@ -12,30 +13,42 @@ import { HttpLogic } from '../../../shared/http';

export interface DeleteConnectorApiLogicArgs {
connectorId: string;
connectorName: string;
shouldDeleteIndex: boolean;
}

export interface DeleteConnectorApiLogicResponse {
acknowledged: boolean;
connectorName: string;
}

export const deleteConnector = async ({
connectorId,
connectorName,
shouldDeleteIndex = false,
}: DeleteConnectorApiLogicArgs) => {
return await HttpLogic.values.http.delete(
`/internal/enterprise_search/connectors/${connectorId}`,
{
query: {
shouldDeleteIndex,
},
}
);
}: DeleteConnectorApiLogicArgs): Promise<DeleteConnectorApiLogicResponse> => {
await HttpLogic.values.http.delete(`/internal/enterprise_search/connectors/${connectorId}`, {
query: {
shouldDeleteIndex,
},
});
return { connectorName };
};

export const DeleteConnectorApiLogic = createApiLogic(
['delete_connector_api_logic'],
deleteConnector
deleteConnector,
{
showSuccessFlashFn: ({ connectorName }) =>
i18n.translate(
'xpack.enterpriseSearch.content.connectors.deleteConnector.successToast.title',
{
defaultMessage: 'The connector {connectorName} was successfully deleted',
values: {
connectorName,
},
}
),
}
);

export type DeleteConnectorApiLogicActions = Actions<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const ConnectorType: React.FC<ConnectorTypeProps> = ({ serviceType }) =>
<p>
{serviceType === CRAWLER_SERVICE_TYPE
? i18n.translate('xpack.enterpriseSearch.content.connectors.connectorType.crawler', {
defaultMessage: 'Web crawler',
defaultMessage: 'Web Crawler',
})
: connector?.name ?? '-'}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const Connectors: React.FC<ConnectorsProps> = ({ isCrawler }) => {
defaultMessage: 'Elasticsearch connectors',
})
: i18n.translate('xpack.enterpriseSearch.crawlers.title', {
defaultMessage: 'Elasticsearch web crawlers',
defaultMessage: 'Elastic Web Crawler',
}),
rightSideGroupProps: {
gutterSize: 's',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { useValues } from 'kea';
import { EuiButton, EuiEmptyPrompt, EuiPanel } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { CRAWLER } from '../../../../../common/constants';
import { HttpLogic } from '../../../shared/http';
import { GithubIcon } from '../../../shared/icons/github_icon';
import { KibanaLogic } from '../../../shared/kibana';
Expand Down Expand Up @@ -49,7 +48,8 @@ export const CrawlerEmptyState: React.FC = () => {
color="primary"
fill
iconType={GithubIcon}
href={CRAWLER.github_repo}
href={'https://github.com/elastic/crawler'}
target="_blank"
>
{i18n.translate(
'xpack.enterpriseSearch.crawlerEmptyState.openSourceCrawlerButtonLabel',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const DeleteConnectorModal: React.FC<DeleteConnectorModalProps> = ({ isCr
isDeleteModalVisible,
} = useValues(ConnectorsLogic);

const connectorName = isCrawler ? deleteModalIndexName : deleteModalConnectorName;
const connectorName = (isCrawler ? deleteModalIndexName : deleteModalConnectorName) || '';

const [inputConnectorName, setInputConnectorName] = useState('');
const [shouldDeleteIndex, setShouldDeleteIndex] = useState(false);
Expand Down Expand Up @@ -80,6 +80,7 @@ export const DeleteConnectorModal: React.FC<DeleteConnectorModalProps> = ({ isCr
} else {
deleteConnector({
connectorId,
connectorName,
shouldDeleteIndex,
});
setConnectorUiOptions(omit(connectorUiOptions, connectorId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const NEW_INDEX_TEMPLATE_TYPES: { [key: string]: string } = {
defaultMessage: 'Connector',
}),
crawler: i18n.translate('xpack.enterpriseSearch.content.newIndex.types.crawler', {
defaultMessage: 'Web crawler',
defaultMessage: 'Web Crawler',
}),
elasticsearch: i18n.translate('xpack.enterpriseSearch.content.newIndex.types.elasticsearch', {
defaultMessage: 'Elasticsearch index',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const METHOD_CARD_OPTIONS: Record<INGESTION_METHOD_IDS, MethodCardOptions> = {
},
icon: getIngestionMethodIconType(INGESTION_METHOD_IDS.CRAWLER),
title: i18n.translate('xpack.enterpriseSearch.content.newIndex.methodCard.crawler.title', {
defaultMessage: 'Web crawler',
defaultMessage: 'Web Crawler',
}),
},
[INGESTION_METHOD_IDS.CONNECTOR]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export const NewSearchIndexTemplate: React.FC<Props> = ({
{i18n.translate(
'xpack.enterpriseSearch.content.newIndex.newSearchIndexTemplate.learnMoreCrawler.linkText',
{
defaultMessage: 'Learn more about the Elastic web crawler',
defaultMessage: 'Learn more about the Elastic Web Crawler',
}
)}
</EuiLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ describe('PipelinesLogic', () => {
describe('apiSuccess', () => {
it('should call flashSuccessToast', () => {
PipelinesLogic.actions.apiSuccess({ connectorId: 'a', pipeline: newPipeline });
expect(flashSuccessToast).toHaveBeenCalledWith('Pipelines updated');
expect(flashSuccessToast).toHaveBeenCalledWith('Pipelines updated', {
'aria-live': 'assertive',
role: 'alert',
});
});
});
describe('createCustomPipelineError', () => {
Expand All @@ -154,7 +157,10 @@ describe('PipelinesLogic', () => {
PipelinesLogic.actions.fetchCustomPipeline = jest.fn();
PipelinesLogic.actions.fetchIndexApiSuccess(connectorIndex);
PipelinesLogic.actions.createCustomPipelineSuccess({ [connectorIndex.name]: {} });
expect(flashSuccessToast).toHaveBeenCalledWith('Custom pipeline created');
expect(flashSuccessToast).toHaveBeenCalledWith('Custom pipeline created', {
'aria-live': 'assertive',
role: 'alert',
});
expect(PipelinesLogic.actions.setPipelineState).toHaveBeenCalledWith({
...PipelinesLogic.values.pipelineState,
name: connectorIndex.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ describe('CreateApiLogic', () => {
const { mount: messageMount } = messageLogic;
messageMount();
messageLogic.actions.apiSuccess({});
expect(flashSuccessToast).toHaveBeenCalledWith('test message');
expect(flashSuccessToast).toHaveBeenCalledWith('test message', {
'aria-live': 'assertive',
role: 'alert',
});
});
});
describe('apiError', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export const createApiLogic = <Result, Args>(
},
apiSuccess: (result) => {
if (options.showSuccessFlashFn) {
flashSuccessToast(options.showSuccessFlashFn(result));
flashSuccessToast(options.showSuccessFlashFn(result), {
'aria-live': 'assertive',
role: 'alert',
});
}
},
makeRequest: async (args, breakpoint) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,18 @@ describe('toastAPIErrors', () => {
it('converts API errors into flash messages', () => {
toastAPIErrors(mockHttpError);

expect(flashErrorToast).toHaveBeenNthCalledWith(1, 'Could not find X');
expect(flashErrorToast).toHaveBeenNthCalledWith(2, 'Could not find Y');
expect(flashErrorToast).toHaveBeenNthCalledWith(3, 'Something else bad happened');
expect(flashErrorToast).toHaveBeenNthCalledWith(1, 'Could not find X', {
'aria-live': 'assertive',
role: 'alert',
});
expect(flashErrorToast).toHaveBeenNthCalledWith(2, 'Could not find Y', {
'aria-live': 'assertive',
role: 'alert',
});
expect(flashErrorToast).toHaveBeenNthCalledWith(3, 'Something else bad happened', {
'aria-live': 'assertive',
role: 'alert',
});
});

it('falls back to the basic message for http responses without an errors array', () => {
Expand All @@ -117,7 +126,10 @@ describe('toastAPIErrors', () => {
},
} as any);

expect(flashErrorToast).toHaveBeenCalledWith('Not Found');
expect(flashErrorToast).toHaveBeenCalledWith('Not Found', {
'aria-live': 'assertive',
role: 'alert',
});
});

it('displays a generic error message and re-throws non-API errors', () => {
Expand All @@ -127,7 +139,10 @@ describe('toastAPIErrors', () => {
toastAPIErrors(error as any);
}).toThrowError(error);

expect(flashErrorToast).toHaveBeenCalledWith(expect.any(String));
expect(flashErrorToast).toHaveBeenCalledWith(expect.any(String), {
'aria-live': 'assertive',
role: 'alert',
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export const toastAPIErrors = (response: HttpResponse<ErrorResponse>) => {
const messages = getErrorsFromHttpResponse(response);

for (const message of messages) {
flashErrorToast(message);
flashErrorToast(message, {
'aria-live': 'assertive',
role: 'alert',
});
}
// If this was a programming error or a failed request (such as a CORS) error,
// we rethrow the error so it shows up in the developer console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export interface IFlashMessage {

// @see EuiGlobalToastListToast for more props
export interface ToastOptions {
'aria-live'?: 'assertive' | 'polite'; // Defaults to 'polite'
iconType?: string;
role?: string; // Defaults to the log role. The alert role can be considered only if all toasts in this list will require immediate user attention.
text?: string; // Additional text below the message/title, same as EuiToast['text']
toastLifeTimeMs?: number; // Allows customizing per-toast timeout
}
2 changes: 1 addition & 1 deletion x-pack/plugins/enterprise_search/server/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const registerEnterpriseSearchIntegrations = (
customIntegrations.registerCustomIntegration({
id: 'web_crawler',
title: i18n.translate('xpack.enterpriseSearch.integrations.webCrawlerName', {
defaultMessage: 'Web crawler',
defaultMessage: 'Web Crawler',
}),
description: i18n.translate('xpack.enterpriseSearch.integrations.webCrawlerDescription', {
defaultMessage: 'Add search to your website with the web crawler.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
EuiPopover,
EuiPopoverFooter,
EuiPopoverTitle,
EuiLoadingSpinner,
EuiText,
useEuiPaddingCSS,
} from '@elastic/eui';
Expand Down Expand Up @@ -58,13 +59,14 @@ export const DataViewSelectPopover: React.FunctionComponent<DataViewSelectPopove
onSelectDataView,
onChangeMetaData,
}) => {
const [loadingDataViews, setLoadingDataViews] = useState(false);
const [dataViewItems, setDataViewsItems] = useState<DataViewListItemEnhanced[]>([]);
const [dataViewPopoverOpen, setDataViewPopoverOpen] = useState(false);

const closeDataViewEditor = useRef<() => void | undefined>();

const allDataViewItems = useMemo(
() => [...dataViewItems, ...metadata.adHocDataViewList.map(toDataViewListItem)],
() => [...(dataViewItems ?? []), ...metadata.adHocDataViewList.map(toDataViewListItem)],
[dataViewItems, metadata.adHocDataViewList]
);

Expand All @@ -80,10 +82,16 @@ export const DataViewSelectPopover: React.FunctionComponent<DataViewSelectPopove
);

const loadPersistedDataViews = useCallback(async () => {
const ids = await dataViews.getIds();
const dataViewsList = await Promise.all(ids.map((id) => dataViews.get(id)));

setDataViewsItems(dataViewsList.map(toDataViewListItem));
setLoadingDataViews(true);
try {
// Calling getIds with refresh = true to make sure we don't get stale data
const ids = await dataViews.getIds(true);
const dataViewsList = await Promise.all(ids.map((id) => dataViews.get(id)));
setDataViewsItems(dataViewsList.map(toDataViewListItem));
} catch (e) {
// Error fetching data views
}
setLoadingDataViews(false);
}, [dataViews]);

const onAddAdHocDataView = useCallback(
Expand Down Expand Up @@ -146,8 +154,10 @@ export const DataViewSelectPopover: React.FunctionComponent<DataViewSelectPopove
[dataViews, onAddAdHocDataView, onChangeDataView]
);

if (!allDataViewItems) {
return null;
if (loadingDataViews) {
// The loading indicator is to make sure we don't render an
// empty popover when the DV cache is initially loading
return <EuiLoadingSpinner />;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ import {
} from '../../screens/ai_assistant';
import { visit, visitGetStartedPage } from '../../tasks/navigation';

describe('AI Assistant Conversations', { tags: ['@ess', '@serverless'] }, () => {
// Failing: See https://github.com/elastic/kibana/issues/204167
describe.skip('AI Assistant Conversations', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
deleteConnectors();
deleteConversations();
Expand Down

0 comments on commit 02dab31

Please sign in to comment.