Skip to content

Commit

Permalink
Merge branch '7.9' into backport/7.9/pr-72097
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 27, 2020
2 parents a706a35 + 8ea0417 commit 9b53ef0
Show file tree
Hide file tree
Showing 31 changed files with 217 additions and 73 deletions.
3 changes: 1 addition & 2 deletions test/functional/apps/dashboard/embeddable_rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ export default function ({ getService, getPageObjects }) {
await dashboardExpect.vegaTextsDoNotExist(['5,000']);
};

// FLAKY: https://github.com/elastic/kibana/issues/46305
describe.skip('dashboard embeddable rendering', function describeIndexTests() {
describe('dashboard embeddable rendering', function describeIndexTests() {
before(async () => {
await esArchiver.load('dashboard/current/kibana');
await kibanaServer.uiSettings.replace({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/public/state/selectors/workpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ export function getRenderedWorkpad(state: State) {
const workpad = getWorkpad(state);

// eslint-disable-next-line no-unused-vars
const { pages, ...rest } = workpad;
const { pages, variables, ...rest } = workpad;

return {
pages: renderedPages,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/shareable_runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ There are a number of options for the build script:

### Prerequisite

Before testing or running this PR locally, you **must** run `node scripts/runtime` from `/canvas` _after_ `yarn kbn bootstrap` and _before_ starting Kibana. It is only built automatically when Kibana is built to avoid slowing down other development activities.
Before testing or running this PR locally, you **must** run `node scripts/shareable_runtime` from `/canvas` _after_ `yarn kbn bootstrap` and _before_ starting Kibana. It is only built automatically when Kibana is built to avoid slowing down other development activities.

### Webpack Dev Server

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/shareable_runtime/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ module.exports = {
options: {
presets: [require.resolve('@kbn/babel-preset/webpack_preset')],
},
sideEffects: false,
},
{
test: /\.tsx?$/,
Expand Down Expand Up @@ -92,6 +91,7 @@ module.exports = {
},
},
],
sideEffects: true,
},
{
test: /\.module\.s(a|c)ss$/,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ export abstract class AbstractExploreDataAction<Context extends { embeddable?: I
public async isCompatible({ embeddable }: Context): Promise<boolean> {
if (!embeddable) return false;

const { core, plugins } = this.params.start();
const { capabilities } = core.application;

if (capabilities.discover && !capabilities.discover.show) return false;
if (!plugins.discover.urlGenerator) return false;
const isDashboardOnlyMode = !!this.params
.start()
.plugins.kibanaLegacy?.dashboardConfig.getHideWriteControls();
if (isDashboardOnlyMode) return false;

if (!this.params.start().plugins.discover.urlGenerator) return false;
if (!shared.hasExactlyOneIndexPattern(embeddable)) return false;
if (embeddable.getInput().viewMode !== ViewMode.VIEW) return false;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,19 @@ describe('"Explore underlying data" panel action', () => {

expect(isCompatible).toBe(false);
});

test('returns false if Discover app is disabled', async () => {
const { action, context, core } = setup();

core.application.capabilities = { ...core.application.capabilities };
(core.application.capabilities as any).discover = {
show: false,
};

const isCompatible = await action.isCompatible(context);

expect(isCompatible).toBe(false);
});
});

describe('getHref()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ describe('"Explore underlying data" panel action', () => {

expect(isCompatible).toBe(false);
});

test('returns false if Discover app is disabled', async () => {
const { action, context, core } = setup();

core.application.capabilities = { ...core.application.capabilities };
(core.application.capabilities as any).discover = {
show: false,
};

const isCompatible = await action.isCompatible(context);

expect(isCompatible).toBe(false);
});
});

describe('getHref()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4203,6 +4203,7 @@
"FAILED",
"STOPPING",
"STOPPED",
"DEGRADED",
"DATA_DUMP",
"ACKNOWLEDGED",
"UNKNOWN"
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ingest_manager/common/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface NewAgentEvent {
| 'FAILED'
| 'STOPPING'
| 'STOPPED'
| 'DEGRADED'
// Action results
| 'DATA_DUMP'
// Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ export const StepDefinePackageConfig: React.FunctionComponent<{
.sort();

updatePackageConfig({
name: `${packageInfo.name}-${
dsWithMatchingNames.length ? dsWithMatchingNames[dsWithMatchingNames.length - 1] + 1 : 1
}`,
name:
// For Endpoint packages, the user must fill in the name, thus we don't attempt to generate
// a default one here.
// FIXME: Improve package configs name uniqueness - https://github.com/elastic/kibana/issues/72948
packageInfo.name !== 'endpoint'
? `${packageInfo.name}-${
dsWithMatchingNames.length
? dsWithMatchingNames[dsWithMatchingNames.length - 1] + 1
: 1
}`
: '',
package: {
name: packageInfo.name,
title: packageInfo.title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ export const SUBTYPE_LABEL: { [key in AgentEvent['subtype']]: JSX.Element } = {
/>
</EuiBadge>
),
DEGRADED: (
<EuiBadge color="hollow">
<FormattedMessage
id="xpack.ingestManager.agentEventSubtype.degradedLabel"
defaultMessage="Degraded"
/>
</EuiBadge>
),
DATA_DUMP: (
<EuiBadge color="hollow">
<FormattedMessage
Expand Down
17 changes: 10 additions & 7 deletions x-pack/plugins/ingest_manager/server/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ const AgentEventBase = {
]),
subtype: schema.oneOf([
// State
schema.literal('RUNNING'),
schema.literal('STARTING'),
schema.literal('IN_PROGRESS'),
schema.literal('CONFIG'),
schema.literal('FAILED'),
schema.literal('STOPPING'),
schema.literal('STOPPED'),
schema.oneOf([
schema.literal('RUNNING'),
schema.literal('STARTING'),
schema.literal('IN_PROGRESS'),
schema.literal('CONFIG'),
schema.literal('FAILED'),
schema.literal('STOPPING'),
schema.literal('STOPPED'),
schema.literal('DEGRADED'),
]),
// Action results
schema.literal('DATA_DUMP'),
// Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ export class JobsListView extends Component {
this.showDeleteJobModal = () => {};
this.showStartDatafeedModal = () => {};
this.showCreateWatchFlyout = () => {};
// work around to keep track of whether the component is mounted
// used to block timeouts for results polling
// which can run after unmounting
this._isMounted = false;
}

componentDidMount() {
this._isMounted = true;
this.refreshJobSummaryList(true);

if (this.props.isManagementTable !== true) {
Expand All @@ -87,6 +92,7 @@ export class JobsListView extends Component {
if (this.props.isManagementTable === undefined) {
deletingJobsRefreshTimeout = null;
}
this._isMounted = false;
}

openAutoStartDatafeedModal() {
Expand Down Expand Up @@ -232,7 +238,7 @@ export class JobsListView extends Component {
};

async refreshJobSummaryList(forceRefresh = false) {
if (forceRefresh === true || this.props.blockRefresh !== true) {
if (this._isMounted && (forceRefresh === true || this.props.blockRefresh !== true)) {
// Set loading to true for jobs_list table for initial job loading
if (this.state.loading === null) {
this.setState({ loading: true });
Expand Down Expand Up @@ -283,6 +289,10 @@ export class JobsListView extends Component {
}

async checkDeletingJobTasks(forceRefresh = false) {
if (this._isMounted === false) {
return;
}

const { jobIds: taskJobIds } = await ml.jobs.deletingJobTasks();

const taskListHasChanged =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,27 +258,19 @@ export const JobSettingsForm: FC<JobSettingsFormProps> = ({
fill
type="submit"
isLoading={saveState === SAVE_STATE.SAVING}
disabled={!validationResult.formValid}
disabled={!validationResult.formValid || saveState === SAVE_STATE.SAVING}
onClick={() => {
onSubmit(formState);
}}
aria-label={i18n.translate('xpack.ml.newJob.recognize.createJobButtonAriaLabel', {
defaultMessage: 'Create job',
})}
>
{saveState === SAVE_STATE.NOT_SAVED && (
<FormattedMessage
id="xpack.ml.newJob.recognize.createJobButtonLabel"
defaultMessage="Create {numberOfJobs, plural, zero {Job} one {Job} other {Jobs}}"
values={{ numberOfJobs: jobs.length }}
/>
)}
{saveState === SAVE_STATE.SAVING && (
<FormattedMessage
id="xpack.ml.newJob.recognize.analysisRunningLabel"
defaultMessage="Analysis running"
/>
)}
<FormattedMessage
id="xpack.ml.newJob.recognize.createJobButtonLabel"
defaultMessage="Create {numberOfJobs, plural, zero {Job} one {Job} other {Jobs}}"
values={{ numberOfJobs: jobs.length }}
/>
</EuiButton>
</EuiTextAlign>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,17 @@ export const EXCEPTION_OPERATORS: OperatorOption[] = [
isInListOperator,
isNotInListOperator,
];

export const EXCEPTION_OPERATORS_SANS_LISTS: OperatorOption[] = [
isOperator,
isNotOperator,
isOneOfOperator,
isNotOneOfOperator,
existsOperator,
doesNotExistOperator,
];

export const EXCEPTION_OPERATORS_ONLY_LISTS: OperatorOption[] = [
isInListOperator,
isNotInListOperator,
];
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ export const AddExceptionModal = memo(function AddExceptionModal({
signalIndexName,
]);

const isSubmitButtonDisabled = useCallback(
() => fetchOrCreateListError || exceptionItemsToAdd.length === 0,
const isSubmitButtonDisabled = useMemo(
() => fetchOrCreateListError || exceptionItemsToAdd.every((item) => item.entries.length === 0),
[fetchOrCreateListError, exceptionItemsToAdd]
);

Expand Down Expand Up @@ -377,7 +377,7 @@ export const AddExceptionModal = memo(function AddExceptionModal({
<EuiButton
onClick={onAddExceptionConfirm}
isLoading={addExceptionIsLoading}
isDisabled={isSubmitButtonDisabled()}
isDisabled={isSubmitButtonDisabled}
fill
>
{i18n.ADD_EXCEPTION}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe('BuilderEntryItem', () => {
title: 'logstash-*',
fields,
}}
showLabel={false}
showLabel={true}
listType="detection"
addNested={false}
onChange={jest.fn()}
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('BuilderEntryItem', () => {
title: 'logstash-*',
fields,
}}
showLabel={false}
showLabel={true}
listType="detection"
addNested={false}
onChange={jest.fn()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
getEntryOnMatchAnyChange,
getEntryOnListChange,
} from './helpers';
import { EXCEPTION_OPERATORS_ONLY_LISTS } from '../../autocomplete/operators';

interface EntryItemProps {
entry: FormattedBuilderEntry;
Expand All @@ -35,6 +36,7 @@ interface EntryItemProps {
listType: ExceptionListType;
addNested: boolean;
onChange: (arg: BuilderEntry, i: number) => void;
onlyShowListOperators?: boolean;
}

export const BuilderEntryItem: React.FC<EntryItemProps> = ({
Expand All @@ -44,6 +46,7 @@ export const BuilderEntryItem: React.FC<EntryItemProps> = ({
addNested,
showLabel,
onChange,
onlyShowListOperators = false,
}): JSX.Element => {
const handleFieldChange = useCallback(
([newField]: IFieldType[]): void => {
Expand Down Expand Up @@ -124,11 +127,14 @@ export const BuilderEntryItem: React.FC<EntryItemProps> = ({
);

const renderOperatorInput = (isFirst: boolean): JSX.Element => {
const operatorOptions = getOperatorOptions(
entry,
listType,
entry.field != null && entry.field.type === 'boolean'
);
const operatorOptions = onlyShowListOperators
? EXCEPTION_OPERATORS_ONLY_LISTS
: getOperatorOptions(
entry,
listType,
entry.field != null && entry.field.type === 'boolean',
isFirst
);
const comboBox = (
<OperatorComponent
placeholder={i18n.EXCEPTION_OPERATOR_PLACEHOLDER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface ExceptionListItemProps {
addNested: boolean;
onDeleteExceptionItem: (item: ExceptionsBuilderExceptionItem, index: number) => void;
onChangeExceptionItem: (item: ExceptionsBuilderExceptionItem, index: number) => void;
onlyShowListOperators?: boolean;
}

export const ExceptionListItemComponent = React.memo<ExceptionListItemProps>(
Expand All @@ -58,6 +59,7 @@ export const ExceptionListItemComponent = React.memo<ExceptionListItemProps>(
andLogicIncluded,
onDeleteExceptionItem,
onChangeExceptionItem,
onlyShowListOperators = false,
}) => {
const handleEntryChange = useCallback(
(entry: BuilderEntry, entryIndex: number): void => {
Expand Down Expand Up @@ -169,6 +171,7 @@ export const ExceptionListItemComponent = React.memo<ExceptionListItemProps>(
exceptionItemIndex === 0 && index === 0 && item.nested !== 'child'
}
onChange={handleEntryChange}
onlyShowListOperators={onlyShowListOperators}
/>
</EuiFlexItem>
{getDeleteButton(
Expand Down
Loading

0 comments on commit 9b53ef0

Please sign in to comment.