Skip to content

Commit

Permalink
Merge branch '8.x' into backport/8.x/pr-193195
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Sep 19, 2024
2 parents 8663c12 + 446d593 commit 84de004
Show file tree
Hide file tree
Showing 374 changed files with 8,822 additions and 4,771 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

VALIDATION_PACKAGE_DIR="packages/kbn-esql-validation-autocomplete"
EDITOR_PACKAGE_DIR="packages/kbn-text-based-editor"
EDITOR_PACKAGE_DIR="packages/kbn-language-documentation-popover"
GIT_SCOPE="$VALIDATION_PACKAGE_DIR/**/* $EDITOR_PACKAGE_DIR/**/*"

report_main_step () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ of features within the management screens.
|See <<example-3-discover,Example 3>>
|The set of subfeatures that enables finer access control than the `all` and `read` feature privileges. These options are only available in the Gold subscription level and higher.

|`scope` (optional)
|`string[]`
|`["spaces", "security"]`
| Default `security`. Scope identifies if feature should appear in both Spaces Visibility Toggles and Security Feature Privileges or only in Security Feature Privileges.

|===

==== Privilege definition
Expand Down
2 changes: 2 additions & 0 deletions examples/feature_control_examples/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
FeaturesPluginSetup,
// PluginStartContract as FeaturesPluginStart,
} from '@kbn/features-plugin/server';
import { KibanaFeatureScope } from '@kbn/features-plugin/common';
import { FEATURE_PRIVILEGES_PLUGIN_ID } from '../common';

export interface FeatureControlExampleDeps {
Expand All @@ -27,6 +28,7 @@ export class FeatureControlsPluginExample
name: 'Feature Plugin Examples',
category: DEFAULT_APP_CATEGORIES.management,
app: ['FeaturePluginExample'],
scope: [KibanaFeatureScope.Spaces, KibanaFeatureScope.Security],
privileges: {
all: {
app: ['FeaturePluginExample'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@
"pretty-ms": "6.0.0",
"prop-types": "^15.8.1",
"proxy-from-env": "1.0.0",
"puppeteer": "22.13.1",
"puppeteer": "23.3.1",
"query-string": "^6.13.2",
"rbush": "^3.0.1",
"re-resizable": "^6.9.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-utils/src/utils/append_to_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function appendWhereClauseToESQLQuery(
default:
operator = '==';
}
let filterValue = typeof value === 'string' ? `"${value.replace(/"/g, '\\"')}"` : value;
let filterValue = typeof value === 'string' ? `"${value.replace(/\"/g, '\\"')}"` : value;
// Adding the backticks here are they are needed for special char fields
let fieldName = `\`${field}\``;

Expand Down
180 changes: 180 additions & 0 deletions packages/kbn-expandable-flyout/src/components/container.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React from 'react';
import { render } from '@testing-library/react';

import { Panel } from '../types';
import {
LEFT_SECTION_TEST_ID,
PREVIEW_SECTION_TEST_ID,
SETTINGS_MENU_BUTTON_TEST_ID,
RIGHT_SECTION_TEST_ID,
} from './test_ids';
import { initialUiState, type State } from '../store/state';
import { TestProvider } from '../test/provider';
import { REDUX_ID_FOR_MEMORY_STORAGE } from '../constants';
import { Container } from './container';

const id = REDUX_ID_FOR_MEMORY_STORAGE;
const registeredPanels: Panel[] = [
{
key: 'key',
component: () => <div>{'component'}</div>,
},
];

describe('Container', () => {
it(`shouldn't render flyout if no panels`, () => {
const state: State = {
panels: {
byId: {},
},
ui: initialUiState,
};

const result = render(
<TestProvider state={state}>
<Container registeredPanels={registeredPanels} />
</TestProvider>
);

expect(result.asFragment()).toMatchInlineSnapshot(`<DocumentFragment />`);
});

it('should render collapsed flyout (right section)', () => {
const state: State = {
panels: {
byId: {
[id]: {
right: {
id: 'key',
},
left: undefined,
preview: undefined,
},
},
},
ui: initialUiState,
};

const { getByTestId } = render(
<TestProvider state={state}>
<Container registeredPanels={registeredPanels} />
</TestProvider>
);

expect(getByTestId(RIGHT_SECTION_TEST_ID)).toBeInTheDocument();
});

it('should render expanded flyout (right and left sections)', () => {
const state: State = {
panels: {
byId: {
[id]: {
right: {
id: 'key',
},
left: {
id: 'key',
},
preview: undefined,
},
},
},
ui: initialUiState,
};

const { getByTestId } = render(
<TestProvider state={state}>
<Container registeredPanels={registeredPanels} />
</TestProvider>
);

expect(getByTestId(LEFT_SECTION_TEST_ID)).toBeInTheDocument();
});

it('should render preview section', () => {
const state: State = {
panels: {
byId: {
[id]: {
right: undefined,
left: undefined,
preview: [
{
id: 'key',
},
],
},
},
},
ui: initialUiState,
};

const { getByTestId } = render(
<TestProvider state={state}>
<Container registeredPanels={registeredPanels} />
</TestProvider>
);

expect(getByTestId(PREVIEW_SECTION_TEST_ID)).toBeInTheDocument();
});

it('should not render flyout when right has value but does not matches registered panels', () => {
const state: State = {
panels: {
byId: {
[id]: {
right: {
id: 'key1',
},
left: undefined,
preview: undefined,
},
},
},
ui: initialUiState,
};

const { queryByTestId } = render(
<TestProvider state={state}>
<Container data-test-subj="my-test-flyout" registeredPanels={registeredPanels} />
</TestProvider>
);

expect(queryByTestId('my-test-flyout')).toBeNull();
expect(queryByTestId(RIGHT_SECTION_TEST_ID)).toBeNull();
});

it('should render the menu to change display options', () => {
const state: State = {
panels: {
byId: {
[id]: {
right: {
id: 'key',
},
left: undefined,
preview: undefined,
},
},
},
ui: initialUiState,
};

const { getByTestId } = render(
<TestProvider state={state}>
<Container registeredPanels={registeredPanels} />
</TestProvider>
);

expect(getByTestId(SETTINGS_MENU_BUTTON_TEST_ID)).toBeInTheDocument();
});
});
Loading

0 comments on commit 84de004

Please sign in to comment.