Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into 164059-untracked-di…
Browse files Browse the repository at this point in the history
…sabled-alerts
  • Loading branch information
Zacqary committed Sep 26, 2023
2 parents 645e1e6 + f42b40f commit e6ee727
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 49 deletions.
30 changes: 22 additions & 8 deletions .buildkite/scripts/steps/check_types_commits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,28 @@ if [[ "${CI-}" == "true" ]]; then
sha1=$(git merge-base $GITHUB_PR_TARGET_BRANCH $GITHUB_PR_TRIGGERED_SHA)
sha2="${GITHUB_PR_TRIGGERED_SHA-}"
else
# Script take between 0 and 2 arguments representing two commit SHA's:
# If 0, it will diff HEAD and HEAD^
# If 1 (SHA1), it will diff SHA1 and SHA1^
# If 2 (SHA1, SHA2), it will diff SHA1 and SHA2
sha1="${1-HEAD}"
sha2="${2-$sha1^}"
if [[ "${1-}" == "--cached" ]]; then
# Only check staged files
sha1=$1
sha2=""
else
# Script take between 0 and 2 arguments representing two commit SHA's:
# If 0, it will diff HEAD and HEAD^
# If 1 (SHA1), it will diff SHA1 and SHA1^
# If 2 (SHA1, SHA2), it will diff SHA1 and SHA2
sha1="${1-HEAD}"
sha2="${2-$sha1^}"
fi
fi

uniq_dirs=()
uniq_tsconfigs=()

echo "Detecting files changed between $sha1 and $sha2..."
if [[ "$sha1" == "--cached" ]]; then
echo "Detecting files changed in staging area..."
else
echo "Detecting files changed between $sha1 and $sha2..."
fi

files=($(git diff --name-only $sha1 $sha2))

Expand Down Expand Up @@ -102,7 +112,11 @@ do
done

if [ ${#uniq_tsconfigs[@]} -eq 0 ]; then
echo "No tsconfig.json files found for changes in $sha1 $sha2"
if [[ "$sha1" == "--cached" ]]; then
echo "No tsconfig.json files found for staged changes"
else
echo "No tsconfig.json files found for changes between $sha1 and $sha2"
fi
exit
fi

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@
"del": "^6.1.0",
"elastic-apm-node": "^4.0.0",
"email-addresses": "^5.0.0",
"execa": "^4.0.2",
"execa": "^5.1.1",
"expiry-js": "0.1.7",
"extract-zip": "^2.0.1",
"fast-deep-equal": "^3.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const IMAGE = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8
describe('ChangeImageLink', () => {
const defaultProps: ChangeImageLinkProps = {
field: {
name: 'test',
id: 'test',
type: 'image',
ariaAttributes: {
ariaLabel: 'test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
*/

export { FieldInputFooter, type FieldInputFooterProps } from './input_footer';
export { InputResetLink, type FieldResetLinkProps } from './reset_link';
export { InputResetLink } from './reset_link';
export type { InputResetLinkProps } from './reset_link';
6 changes: 3 additions & 3 deletions src/plugins/console/public/lib/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -998,12 +998,12 @@ export default function ({
) {
// will simulate autocomplete on 'GET /a/b/' with a filter by index
return {
tokenPath: context.urlTokenPath.slice(0, -1),
predicate: (term) => term.meta === 'index',
tokenPath: context.urlTokenPath?.slice(0, -1),
predicate: (term: any) => term.meta === 'index',
};
} else {
// will do nothing special
return { tokenPath: context.urlTokenPath, predicate: (term) => true };
return { tokenPath: context.urlTokenPath, predicate: () => true };
}
})();

Expand Down
5 changes: 2 additions & 3 deletions test/functional/apps/console/_autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,10 @@ GET _search
'pressRight',
'pressLeft',
'pressLeft',
];
] as const;
for (const keyPress of keyPresses) {
await PageObjects.console.sleepForDebouncePeriod();
log.debug('Key', keyPress);
// @ts-ignore
await PageObjects.console[keyPress]();
expect(await PageObjects.console.isAutocompleteVisible()).to.be.eql(false);
}
Expand Down Expand Up @@ -258,7 +257,7 @@ GET _search
for (const char of [method.at(-1), ' ', '_']) {
await PageObjects.console.sleepForDebouncePeriod();
log.debug('Key type "%s"', char);
await PageObjects.console.enterText(char ?? ''); // e.g. 'Post ' -> 'Post _'
await PageObjects.console.enterText(char!); // e.g. 'Post ' -> 'Post _'
}

await retry.waitFor('autocomplete to be visible', () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, { useEffect, useState, ChangeEvent } from 'react';
import { useActions, useValues } from 'kea';

import {
EuiCallOut,
EuiFieldSearch,
EuiFlexGroup,
EuiFlexItem,
Expand Down Expand Up @@ -74,7 +75,7 @@ export const SearchIndexDocuments: React.FC = () => {

const { makeRequest: getDocuments } = useActions(documentLogic);
const { makeRequest: getMappings } = useActions(mappingLogic);
const { data, status } = useValues(documentLogic);
const { data, status, error } = useValues(documentLogic);
const { data: mappingData, status: mappingStatus } = useValues(mappingLogic);

const docs = data?.results?.hits.hits ?? [];
Expand All @@ -84,6 +85,8 @@ export const SearchIndexDocuments: React.FC = () => {

const shouldShowAccessControlSwitcher =
hasDocumentLevelSecurityFeature && productFeatures.hasDocumentLevelSecurityEnabled;
const isAccessControlIndexNotFound =
shouldShowAccessControlSwitcher && error?.body?.statusCode === 404;

useEffect(() => {
getDocuments({
Expand Down Expand Up @@ -141,11 +144,29 @@ export const SearchIndexDocuments: React.FC = () => {
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem>
{docs.length === 0 &&
{isAccessControlIndexNotFound && (
<EuiCallOut
size="m"
title={i18n.translate(
'xpack.enterpriseSearch.content.searchIndex.documents.noIndex.title',
{ defaultMessage: 'Access Control Index not found' }
)}
iconType="iInCircle"
>
<p>
{i18n.translate('xpack.enterpriseSearch.content.searchIndex.documents.noIndex', {
defaultMessage:
"An Access Control Index won't be created until you enable document-level security and run your first access control sync.",
})}
</p>
</EuiCallOut>
)}
{!isAccessControlIndexNotFound &&
docs.length === 0 &&
i18n.translate('xpack.enterpriseSearch.content.searchIndex.documents.noMappings', {
defaultMessage: 'No documents found for index',
})}
{docs.length > 0 && (
{!isAccessControlIndexNotFound && docs.length > 0 && (
<DocumentList
docs={docs}
docsPerPage={pagination.pageSize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, { useEffect, useState } from 'react';
import { useActions, useValues } from 'kea';

import {
EuiCallOut,
EuiCode,
EuiCodeBlock,
EuiFlexGroup,
Expand Down Expand Up @@ -55,9 +56,12 @@ export const SearchIndexIndexMappings: React.FC = () => {
? indexName
: stripSearchPrefix(indexName, CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX);
const { makeRequest: makeMappingRequest } = useActions(mappingsWithPropsApiLogic(indexToShow));
const { data: mappingData } = useValues(mappingsWithPropsApiLogic(indexToShow));
const { data: mappingData, error } = useValues(mappingsWithPropsApiLogic(indexToShow));
const shouldShowAccessControlSwitch =
hasDocumentLevelSecurityFeature && productFeatures.hasDocumentLevelSecurityEnabled;
const isAccessControlIndexNotFound =
shouldShowAccessControlSwitch && error?.body?.statusCode === 404;

useEffect(() => {
makeMappingRequest({ indexName: indexToShow });
}, [indexToShow, indexName]);
Expand All @@ -77,9 +81,27 @@ export const SearchIndexIndexMappings: React.FC = () => {
</EuiFlexItem>
)}
<EuiFlexItem grow>
<EuiCodeBlock language="json" isCopyable>
{JSON.stringify(mappingData, null, 2)}
</EuiCodeBlock>
{isAccessControlIndexNotFound ? (
<EuiCallOut
size="m"
title={i18n.translate(
'xpack.enterpriseSearch.content.searchIndex.mappings.noIndex.title',
{ defaultMessage: 'Access Control Index not found' }
)}
iconType="iInCircle"
>
<p>
{i18n.translate('xpack.enterpriseSearch.content.searchIndex.mappings.noIndex', {
defaultMessage:
"An Access Control Index won't be created until you enable document-level security and run your first access control sync.",
})}
</p>
</EuiCallOut>
) : (
<EuiCodeBlock language="json" isCopyable>
{JSON.stringify(mappingData, null, 2)}
</EuiCodeBlock>
)}
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ml/common/constants/new_job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export enum CREATED_BY_LABEL {
SINGLE_METRIC = 'single-metric-wizard',
MULTI_METRIC = 'multi-metric-wizard',
POPULATION = 'population-wizard',
ADVANCED = 'advanced-wizard',
CATEGORIZATION = 'categorization-wizard',
RARE = 'rare-wizard',
GEO = 'geo-wizard',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { mlCalendarService } from '../../../services/calendar_service';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
import { ML_PAGES } from '../../../../../common/constants/locator';
import { PLUGIN_ID } from '../../../../../common/constants/app';
import { CREATED_BY_LABEL } from '../../../../../common/constants/new_job';

export function loadFullJob(jobId) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -240,7 +241,12 @@ export async function cloneJob(jobId) {
return;
}

if (cloneableJob !== undefined && originalJob?.custom_settings?.created_by !== undefined) {
const createdBy = originalJob?.custom_settings?.created_by;
if (
cloneableJob !== undefined &&
createdBy !== undefined &&
createdBy !== CREATED_BY_LABEL.ADVANCED
) {
// if the job is from a wizards, i.e. contains a created_by property
// use tempJobCloningObjects to temporarily store the job
mlJobService.tempJobCloningObjects.createdBy = originalJob?.custom_settings?.created_by;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import type { Field, Aggregation, SplitField } from '@kbn/ml-anomaly-utils';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';

import { JobCreator } from './job_creator';
import {
import type {
Job,
Datafeed,
Detector,
CustomRule,
} from '../../../../../../common/types/anomaly_detection_jobs';
import { createBasicDetector } from './util/default_configs';
import { JOB_TYPE } from '../../../../../../common/constants/new_job';
import { CREATED_BY_LABEL, JOB_TYPE } from '../../../../../../common/constants/new_job';
import { getRichDetectors } from './util/general';
import { isValidJson } from '../../../../../../common/util/validation_utils';

Expand All @@ -41,6 +41,7 @@ export class AdvancedJobCreator extends JobCreator {

constructor(indexPattern: DataView, savedSearch: SavedSearch | null, query: object) {
super(indexPattern, savedSearch, query);
this.createdBy = CREATED_BY_LABEL.ADVANCED;

this._queryString = JSON.stringify(this._datafeed_config.query);

Expand Down Expand Up @@ -182,6 +183,7 @@ export class AdvancedJobCreator extends JobCreator {

public cloneFromExistingJob(job: Job, datafeed: Datafeed) {
this._overrideConfigs(job, datafeed);
this.createdBy = CREATED_BY_LABEL.ADVANCED;
const detectors = getRichDetectors(job, datafeed, this.additionalFields, true);

// keep track of the custom rules for each detector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import type { DataView } from '@kbn/data-views-plugin/public';
import type { Field, Aggregation, SplitField, AggFieldPair } from '@kbn/ml-anomaly-utils';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { JobCreator } from './job_creator';
import { Job, Datafeed, Detector } from '../../../../../../common/types/anomaly_detection_jobs';
import type {
Job,
Datafeed,
Detector,
} from '../../../../../../common/types/anomaly_detection_jobs';
import { createBasicDetector } from './util/default_configs';
import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job';
import { getRichDetectors } from './util/general';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import type { DataView } from '@kbn/data-views-plugin/public';
import type { Field, Aggregation, SplitField, AggFieldPair } from '@kbn/ml-anomaly-utils';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { JobCreator } from './job_creator';
import { Job, Datafeed, Detector } from '../../../../../../common/types/anomaly_detection_jobs';
import type {
Job,
Datafeed,
Detector,
} from '../../../../../../common/types/anomaly_detection_jobs';
import { createBasicDetector } from './util/default_configs';
import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job';
import { getRichDetectors } from './util/general';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import type { DataView } from '@kbn/data-views-plugin/public';
import type { Field, Aggregation, SplitField, AggFieldPair } from '@kbn/ml-anomaly-utils';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { JobCreator } from './job_creator';
import { Job, Datafeed, Detector } from '../../../../../../common/types/anomaly_detection_jobs';
import type {
Job,
Datafeed,
Detector,
} from '../../../../../../common/types/anomaly_detection_jobs';
import { createBasicDetector } from './util/default_configs';
import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job';
import { getRichDetectors } from './util/general';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import {
} from '@kbn/ml-anomaly-utils';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { JobCreator } from './job_creator';
import { Job, Datafeed, Detector } from '../../../../../../common/types/anomaly_detection_jobs';
import type {
Job,
Datafeed,
Detector,
} from '../../../../../../common/types/anomaly_detection_jobs';
import { JOB_TYPE, CREATED_BY_LABEL } from '../../../../../../common/constants/new_job';
import { getRichDetectors, isSparseDataJob } from './util/general';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { parseInterval } from '../../../../../../common/util/parse_interval';
import { JobCreator } from './job_creator';
import {
import type {
Job,
Datafeed,
Detector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ async function getWizardUrlFromCloningJob(createdBy: string | undefined, dataVie
case CREATED_BY_LABEL.GEO:
page = JOB_TYPE.GEO;
break;
case CREATED_BY_LABEL.ADVANCED:
default:
page = JOB_TYPE.ADVANCED;
break;
Expand Down
8 changes: 2 additions & 6 deletions x-pack/plugins/task_manager/server/task_validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ describe('TaskValidator', () => {
expect(result).toEqual(task);
});

// TODO: Remove skip once all task types have defined their state schema.
// https://github.com/elastic/kibana/issues/159347
it.skip(`should fail to validate the state schema when the task type doesn't have stateSchemaByVersion defined`, () => {
it(`should fail to validate the state schema when the task type doesn't have stateSchemaByVersion defined`, () => {
const definitions = new TaskTypeDictionary(mockLogger());
definitions.registerTaskDefinitions({
foo: fooTaskDefinition,
Expand Down Expand Up @@ -322,9 +320,7 @@ describe('TaskValidator', () => {
expect(result).toEqual(task);
});

// TODO: Remove skip once all task types have defined their state schema.
// https://github.com/elastic/kibana/issues/159347
it.skip(`should fail to validate the state schema when the task type doesn't have stateSchemaByVersion defined`, () => {
it(`should fail to validate the state schema when the task type doesn't have stateSchemaByVersion defined`, () => {
const definitions = new TaskTypeDictionary(mockLogger());
definitions.registerTaskDefinitions({
foo: fooTaskDefinition,
Expand Down
Loading

0 comments on commit e6ee727

Please sign in to comment.