Skip to content

Commit

Permalink
Merge branch 'master' into fc/hide-management
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Sep 10, 2020
2 parents fac5cfe + 046345d commit b28a951
Show file tree
Hide file tree
Showing 152 changed files with 8,056 additions and 873 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
QueryStringInput: React.FC<Pick<Props, "query" | "prepend" | "size" | "className" | "placeholder" | "onChange" | "onBlur" | "onSubmit" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition" | "onChangeQueryInputFocus">>
QueryStringInput: React.FC<Pick<Props, "query" | "prepend" | "size" | "className" | "placeholder" | "onChange" | "onBlur" | "onSubmit" | "isInvalid" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition" | "onChangeQueryInputFocus">>
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"uiFramework:createComponent": "cd packages/kbn-ui-framework && yarn createComponent",
"uiFramework:documentComponent": "cd packages/kbn-ui-framework && yarn documentComponent",
"kbn:watch": "node scripts/kibana --dev --logging.json=false",
"build:types": "tsc --p tsconfig.types.json",
"build:types": "rm -rf ./target/types && tsc --p tsconfig.types.json",
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
"kbn:bootstrap": "node scripts/build_ts_refs && node scripts/register_git_hook",
"spec_to_console": "node scripts/spec_to_console",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@
border-radius: 0;
border-left-width: 0;
}

.kuiLocalSearchAssistedInput {
display: flex;
flex: 1 1 100%;
position: relative;
}

/**
* 1. em used for right padding so documentation link and query string
* won't overlap if the user increases their default browser font size
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ export interface QueryStateChange extends QueryStateChangePartial {
// Warning: (ae-missing-release-tag) "QueryStringInput" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const QueryStringInput: React.FC<Pick<Props_3, "query" | "prepend" | "size" | "className" | "placeholder" | "onChange" | "onBlur" | "onSubmit" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition" | "onChangeQueryInputFocus">>;
export const QueryStringInput: React.FC<Pick<Props_3, "query" | "prepend" | "size" | "className" | "placeholder" | "onChange" | "onBlur" | "onSubmit" | "isInvalid" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition" | "onChangeQueryInputFocus">>;

// @public (undocumented)
export type QuerySuggestion = QuerySuggestionBasic | QuerySuggestionField;
Expand Down
23 changes: 15 additions & 8 deletions src/plugins/data/public/ui/query_string_input/_query_bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,37 @@
border-right: none !important;
}

.kbnQueryBar__textareaWrap {
overflow: visible !important; // Override EUI form control
display: flex;
flex: 1 1 100%;
position: relative;
}

.kbnQueryBar__textarea {
z-index: $euiZContentMenu;
resize: none !important; // When in the group, it will autosize
height: $euiSizeXXL;
height: $euiFormControlHeight;
// Unlike most inputs within layout control groups, the text area still needs a border.
// These adjusts help it sit above the control groups shadow to line up correctly.
padding-top: $euiSizeS + 3px !important;
transform: translateY(-2px);
padding: $euiSizeS - 1px;
padding: $euiSizeS;
padding-top: $euiSizeS + 3px;
transform: translateY(-1px) translateX(-1px);

&:not(:focus) {
&:not(:focus):not(:invalid) {
@include euiYScrollWithShadows;
}

&:not(:focus) {
white-space: nowrap;
overflow-y: hidden;
overflow-x: hidden;
border: none;
box-shadow: none;
}

// When focused, let it scroll
&:focus {
overflow-x: auto;
overflow-y: auto;
width: calc(100% + 1px); // To overtake the group's fake border
white-space: normal;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import React, { Component, RefObject, createRef } from 'react';
import { i18n } from '@kbn/i18n';

import classNames from 'classnames';
import {
EuiTextArea,
Expand Down Expand Up @@ -63,6 +64,7 @@ interface Props {
dataTestSubj?: string;
size?: SuggestionsListSize;
className?: string;
isInvalid?: boolean;
}

interface State {
Expand Down Expand Up @@ -591,6 +593,7 @@ export class QueryStringInputUI extends Component<Props, State> {
'euiFormControlLayout euiFormControlLayout--group kbnQueryBar__wrap',
this.props.className
);

return (
<div className={className}>
{this.props.prepend}
Expand All @@ -607,7 +610,7 @@ export class QueryStringInputUI extends Component<Props, State> {
>
<div
role="search"
className="euiFormControlLayout__childrenWrapper kuiLocalSearchAssistedInput"
className="euiFormControlLayout__childrenWrapper kbnQueryBar__textareaWrap"
ref={this.queryBarInputDivRefInstance}
>
<EuiTextArea
Expand Down Expand Up @@ -651,6 +654,7 @@ export class QueryStringInputUI extends Component<Props, State> {
}
role="textbox"
data-test-subj={this.props.dataTestSubj || 'queryInput'}
isInvalid={this.props.isInvalid}
>
{this.getQueryString()}
</EuiTextArea>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/ui/typeahead/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ export const SUGGESTIONS_LIST_REQUIRED_BOTTOM_SPACE = 250;
* A distance in px to display suggestions list right under the query input without a gap
* @public
*/
export const SUGGESTIONS_LIST_REQUIRED_TOP_OFFSET = 2;
export const SUGGESTIONS_LIST_REQUIRED_TOP_OFFSET = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export class SuggestionsComponent extends Component<Props> {
const StyledSuggestionsListDiv = styled.div`
${(props: { queryBarRect: DOMRect; verticalListPosition: string }) => `
position: absolute;
z-index: 4001;
left: ${props.queryBarRect.left}px;
width: ${props.queryBarRect.width}px;
${props.verticalListPosition}`}
Expand Down
27 changes: 22 additions & 5 deletions src/plugins/input_control_vis/public/vis_controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
*/

import React from 'react';
import { isEqual } from 'lodash';
import { render, unmountComponentAtNode } from 'react-dom';

import { Subscription } from 'rxjs';
import { I18nStart } from 'kibana/public';
import { InputControlVis } from './components/vis/input_control_vis';
import { getControlFactory } from './control/control_factory';
Expand All @@ -34,11 +36,13 @@ import { VisParams, Vis } from '../../visualizations/public';
export const createInputControlVisController = (deps: InputControlVisDependencies) => {
return class InputControlVisController {
private I18nContext?: I18nStart['Context'];
private isLoaded = false;

controls: Array<RangeControl | ListControl>;
queryBarUpdateHandler: () => void;
filterManager: FilterManager;
updateSubsciption: any;
timeFilterSubscription: Subscription;
visParams?: VisParams;

constructor(public el: Element, public vis: Vis) {
Expand All @@ -50,19 +54,32 @@ export const createInputControlVisController = (deps: InputControlVisDependencie
this.updateSubsciption = this.filterManager
.getUpdates$()
.subscribe(this.queryBarUpdateHandler);
this.timeFilterSubscription = deps.data.query.timefilter.timefilter
.getTimeUpdate$()
.subscribe(() => {
if (this.visParams?.useTimeFilter) {
this.isLoaded = false;
}
});
}

async render(visData: any, visParams: VisParams) {
this.visParams = visParams;
this.controls = [];
this.controls = await this.initControls();
const [{ i18n }] = await deps.core.getStartServices();
this.I18nContext = i18n.Context;
if (!this.I18nContext) {
const [{ i18n }] = await deps.core.getStartServices();
this.I18nContext = i18n.Context;
}
if (!this.isLoaded || !isEqual(visParams, this.visParams)) {
this.visParams = visParams;
this.controls = [];
this.controls = await this.initControls();
this.isLoaded = true;
}
this.drawVis();
}

destroy() {
this.updateSubsciption.unsubscribe();
this.timeFilterSubscription.unsubscribe();
unmountComponentAtNode(this.el);
this.controls.forEach((control) => control.destroy());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,28 @@ describe('AppLogic', () => {
});

const DEFAULT_VALUES = {
account: {},
hasInitialized: false,
isFederatedAuth: true,
organization: {},
};

const expectedLogicValues = {
account: {
canCreateInvitations: true,
canCreatePersonalSources: true,
groups: ['Default', 'Cats'],
id: 'some-id-string',
isAdmin: true,
isCurated: false,
viewedOnboardingPage: true,
},
hasInitialized: true,
isFederatedAuth: false,
organization: {
defaultOrgName: 'My Organization',
name: 'ACME Donuts',
},
};

it('has expected default values', () => {
Expand All @@ -27,9 +48,7 @@ describe('AppLogic', () => {
it('sets values based on passed props', () => {
AppLogic.actions.initializeAppData(DEFAULT_INITIAL_APP_DATA);

expect(AppLogic.values).toEqual({
hasInitialized: true,
});
expect(AppLogic.values).toEqual(expectedLogicValues);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,26 @@
import { kea, MakeLogicType } from 'kea';

import { IInitialAppData } from '../../../common/types';
import { IWorkplaceSearchInitialData } from '../../../common/types/workplace_search';
import {
IOrganization,
IWorkplaceSearchInitialData,
IAccount,
} from '../../../common/types/workplace_search';

export interface IAppValues extends IWorkplaceSearchInitialData {
hasInitialized: boolean;
isFederatedAuth: boolean;
}
export interface IAppActions {
initializeAppData(props: IInitialAppData): void;
initializeAppData(props: IInitialAppData): IInitialAppData;
}

export const AppLogic = kea<MakeLogicType<IAppValues, IAppActions>>({
actions: {
initializeAppData: ({ workplaceSearch }) => workplaceSearch,
initializeAppData: ({ workplaceSearch, isFederatedAuth }) => ({
workplaceSearch,
isFederatedAuth,
}),
},
reducers: {
hasInitialized: [
Expand All @@ -27,5 +35,23 @@ export const AppLogic = kea<MakeLogicType<IAppValues, IAppActions>>({
initializeAppData: () => true,
},
],
isFederatedAuth: [
true,
{
initializeAppData: (_, { isFederatedAuth }) => !!isFederatedAuth,
},
],
organization: [
{} as IOrganization,
{
initializeAppData: (_, { workplaceSearch }) => workplaceSearch!.organization,
},
],
account: [
{} as IAccount,
{
initializeAppData: (_, { workplaceSearch }) => workplaceSearch!.account,
},
],
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { setMockValues, mockValues, mockActions } from './overview_logic.mock';
export { setMockValues, mockOverviewValues, mockActions } from './overview_logic.mock';
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
*/

import { IOverviewValues } from '../overview_logic';
import { IAccount, IOrganization } from '../../../types';

export const mockValues = {
import { DEFAULT_INITIAL_APP_DATA } from '../../../../../../common/__mocks__';

const { workplaceSearch: mockAppValues } = DEFAULT_INITIAL_APP_DATA;

export const mockOverviewValues = {
accountsCount: 0,
activityFeed: [],
canCreateContentSources: false,
canCreateInvitations: false,
fpAccount: {} as IAccount,
hasOrgSources: false,
hasUsers: false,
isFederatedAuth: true,
isOldAccount: false,
organization: {} as IOrganization,
pendingInvitationsCount: 0,
personalSourcesCount: 0,
sourcesCount: 0,
Expand All @@ -28,6 +27,8 @@ export const mockActions = {
initializeOverview: jest.fn(() => ({})),
};

const mockValues = { ...mockOverviewValues, ...mockAppValues, isFederatedAuth: true };

jest.mock('kea', () => ({
...(jest.requireActual('kea') as object),
useActions: jest.fn(() => ({ ...mockActions })),
Expand All @@ -37,8 +38,5 @@ jest.mock('kea', () => ({
import { useValues } from 'kea';

export const setMockValues = (values: object) => {
(useValues as jest.Mock).mockImplementationOnce(() => ({
...mockValues,
...values,
}));
(useValues as jest.Mock).mockImplementation(() => ({ ...mockValues, ...values }));
};
Loading

0 comments on commit b28a951

Please sign in to comment.