Skip to content

Commit

Permalink
Merge branch 'main' into eui/62.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Aug 12, 2022
2 parents 93fd826 + c868daa commit d9941d3
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 7 deletions.
5 changes: 4 additions & 1 deletion examples/user_profile_examples/public/avatar_demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import React, { FunctionComponent } from 'react';
import { EuiTitle, EuiSpacer } from '@elastic/eui';
import { UserAvatar } from '@kbn/user-profile-components';
import type { UserProfile, UserProfileAvatarData } from '@kbn/user-profile-components';
import { PanelWithCodeBlock } from './panel_with_code_block';

export const AvatarDemo: FunctionComponent = () => {
const userProfile = {
const userProfile: UserProfile<{ avatar: UserProfileAvatarData }> = {
uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0',
enabled: true,
user: {
username: 'delighted_nightingale',
email: '[email protected]',
Expand Down Expand Up @@ -49,6 +51,7 @@ const code = `import { UserAvatar } from '@kbn/user-profile-components';
const userProfile = {
uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0',
enabled: true,
user: {
username: 'delighted_nightingale',
email: '[email protected]',
Expand Down
7 changes: 6 additions & 1 deletion examples/user_profile_examples/public/popover_demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const PopoverDemo: FunctionComponent = () => {
const [selectedOptions, setSelectedOptions] = useState<UserProfileWithAvatar[]>([
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
data: {},
user: {
username: 'delighted_nightingale',
Expand All @@ -26,6 +27,7 @@ export const PopoverDemo: FunctionComponent = () => {
const defaultOptions: UserProfileWithAvatar[] = [
{
uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0',
enabled: true,
data: {},
user: {
username: 'damaged_raccoon',
Expand All @@ -35,6 +37,7 @@ export const PopoverDemo: FunctionComponent = () => {
},
{
uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0',
enabled: true,
data: {},
user: {
username: 'physical_dinosaur',
Expand All @@ -44,6 +47,7 @@ export const PopoverDemo: FunctionComponent = () => {
},
{
uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0',
enabled: true,
data: {},
user: {
username: 'wet_dingo',
Expand Down Expand Up @@ -83,6 +87,7 @@ const code = `import { UserProfilesPopover } from '@kbn/user-profile-components'
const [selectedOptions, setSelectedOptions] = useState([
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
data: {},
user: {
username: 'delighted_nightingale',
Expand All @@ -92,7 +97,7 @@ const [selectedOptions, setSelectedOptions] = useState([
},
]);
<UserProfilesPopover
<UserProfilesPopover
title="Edit assignees"
button={
<EuiButton>
Expand Down
5 changes: 5 additions & 0 deletions examples/user_profile_examples/public/selectable_demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const SelectableDemo: FunctionComponent = () => {
const [selectedOptions, setSelectedOptions] = useState<UserProfileWithAvatar[]>([
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
data: {},
user: {
username: 'delighted_nightingale',
Expand All @@ -25,6 +26,7 @@ export const SelectableDemo: FunctionComponent = () => {
const defaultOptions: UserProfileWithAvatar[] = [
{
uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0',
enabled: true,
data: {},
user: {
username: 'damaged_raccoon',
Expand All @@ -34,6 +36,7 @@ export const SelectableDemo: FunctionComponent = () => {
},
{
uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0',
enabled: true,
data: {},
user: {
username: 'physical_dinosaur',
Expand All @@ -43,6 +46,7 @@ export const SelectableDemo: FunctionComponent = () => {
},
{
uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0',
enabled: true,
data: {},
user: {
username: 'wet_dingo',
Expand All @@ -68,6 +72,7 @@ const code = `import { UserProfilesSelectable } from '@kbn/user-profile-componen
const [selectedOptions, setSelectedOptions] = useState([
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
data: {},
user: {
username: 'delighted_nightingale',
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-user-profile-components/src/user_profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export interface UserProfile<D extends UserProfileData = UserProfileData> {
*/
uid: string;

/**
* Indicates whether user profile is enabled or not.
*/
enabled: boolean;

/**
* Information about the user that owns profile.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { UserProfilesPopover } from './user_profiles_popover';
const userProfiles = [
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
data: {},
user: {
username: 'delighted_nightingale',
Expand All @@ -23,6 +24,7 @@ const userProfiles = [
},
{
uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0',
enabled: true,
data: {},
user: {
username: 'damaged_raccoon',
Expand All @@ -32,6 +34,7 @@ const userProfiles = [
},
{
uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0',
enabled: true,
data: {},
user: {
username: 'physical_dinosaur',
Expand All @@ -41,6 +44,7 @@ const userProfiles = [
},
{
uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0',
enabled: true,
data: {},
user: {
username: 'wet_dingo',
Expand Down Expand Up @@ -88,6 +92,7 @@ describe('UserProfilesPopover', () => {
Array [
Object {
"data": Object {},
"enabled": true,
"uid": "u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0",
"user": Object {
"email": "[email protected]",
Expand All @@ -101,6 +106,7 @@ describe('UserProfilesPopover', () => {
Array [
Object {
"data": Object {},
"enabled": true,
"uid": "u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0",
"user": Object {
"email": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { UserProfilesSelectable } from './user_profiles_selectable';
const userProfiles = [
{
uid: 'u_BOulL4QMPSyV9jg5lQI2JmCkUnokHTazBnet3xVHNv0_0',
enabled: true,
data: {},
user: {
username: 'delighted_nightingale',
Expand All @@ -23,6 +24,7 @@ const userProfiles = [
},
{
uid: 'u_J41Oh6L9ki-Vo2tOogS8WRTENzhHurGtRc87NgEAlkc_0',
enabled: true,
data: {},
user: {
username: 'damaged_raccoon',
Expand All @@ -32,6 +34,7 @@ const userProfiles = [
},
{
uid: 'u_A_tM4n0wPkdiQ9smmd8o0Hr_h61XQfu8aRPh9GMoRoc_0',
enabled: true,
data: {},
user: {
username: 'physical_dinosaur',
Expand All @@ -41,6 +44,7 @@ const userProfiles = [
},
{
uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0',
enabled: true,
data: {},
user: {
username: 'wet_dingo',
Expand Down
16 changes: 16 additions & 0 deletions x-pack/examples/embedded_lens_example/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ export const App = (props: {
from: 'now-5d',
to: 'now',
});
const [searchSession, setSearchSession] = useState(() =>
props.plugins.data.search.session.start()
);

const LensComponent = props.plugins.lens.EmbeddableComponent;
const LensSaveModalComponent = props.plugins.lens.SaveModalComponent;
Expand Down Expand Up @@ -239,13 +242,26 @@ export const App = (props: {
Change time range
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
aria-label="Refresh"
data-test-subj="lns-example-refresh"
isDisabled={!attributes}
onClick={() => {
setSearchSession(props.plugins.data.search.session.start());
}}
>
Refresh
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
<LensComponent
id=""
withDefaultActions
style={{ height: 500 }}
timeRange={time}
attributes={attributes}
searchSessionId={searchSession}
onLoad={(val) => {
setIsLoading(val);
}}
Expand Down
5 changes: 4 additions & 1 deletion x-pack/examples/embedded_lens_example/public/mount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ export const mount =
);

render(reactElement, element);
return () => unmountComponentAtNode(element);
return () => {
unmountComponentAtNode(element);
plugins.data.search.session.clear();
};
};
8 changes: 8 additions & 0 deletions x-pack/plugins/lens/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ if (!dataView) {
}
const dataViewIdForLens = dataView.id;
```
## Refreshing a Lens embeddable

The Lens embeddable is handling data fetching internally, this means as soon as the props change, it will trigger a new request if necessary. However, in some situations it's necessary to trigger a refresh even if the configuration of the chart doesn't change at all. Refreshing is managed using search sessions is Lens. To trigger a refresh without changing the actual configuration of a Lens embeddable, follow these steps:
* Pull in the contract of the `data` plugin. It contains the session service at `plugins.data.search.session`.
* When loading the app containing a Lens embeddable, start a new session using `session.start`. It returns the current session id - keep it in the state of our app (e.g. a `useState` hook or your redux store)
* Pass the current session id to the Lens embeddable component via the `searchSessionId` property
* When refreshing, simply call `session.start` again and update your state - Lens will discard the existing cache and re-fetch even if the query doesn't change at all
* When unmounting your app, call `session.clear` to end the current session

# Lens Development

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export default function ({ getService }: FtrProviderContext) {
const { createSnapshotRepository, cleanupRepositories } =
registerSnapshotRepositoriesHelpers(getService);

describe('snapshot policies', () => {
describe('snapshot policies', function describeSnapshotPoliciesTest() {
// skip Cloud failing test https://github.com/elastic/kibana/issues/136881
this.tags(['skipCloud']);

before(async () => Promise.all([cleanupPolicies(), cleanupRepositories()]));
after(async () => Promise.all([cleanupPolicies(), cleanupRepositories()]));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default function ({ getService }: FtrProviderContext) {
const { loadSnapshotRepositories, createSnapshotRepository, cleanupRepositories } =
registerSnapshotRepositoriesHelpers(getService);

describe('snapshot repositories', () => {
describe('snapshot repositories', function describeSnapshotRepositoriesTest() {
// skip Cloud failing test https://github.com/elastic/kibana/issues/136882
this.tags(['skipCloud']);

before(async () => {
isCloud = await deployment.isCloud();
await Promise.all([cleanupRepositories()]);
Expand Down
3 changes: 1 addition & 2 deletions x-pack/test/functional/apps/security/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const spaces = getService('spaces');

// FLAKY: https://github.com/elastic/kibana/issues/60132
describe.skip('Security', function () {
describe('Security', function () {
this.tags('includeFirefox');
describe('Login Page', () => {
before(async () => {
Expand Down

0 comments on commit d9941d3

Please sign in to comment.