Skip to content

Commit

Permalink
Merge remote-tracking branch 'grafana/master' into columnar2
Browse files Browse the repository at this point in the history
* grafana/master:
  CI: Fail build if yarn.lock is not up to date (grafana#18555)
  Chore: Updates react-dependant packages to address react warnings (grafana#18549)
  Prometheus: Fix regression of rerunning query on legend/interval change (grafana#18147)
  Explore/Prometheus: More consistently allows for multi-line queries (grafana#18362)
  Login: Fixes undefined redirect (grafana#18545)
  • Loading branch information
ryantxu committed Aug 14, 2019
2 parents abdc7f6 + 11f9049 commit f7cee2d
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ jobs:
key: dependency-cache-{{ checksum "yarn.lock" }}
- run:
name: yarn install
command: 'yarn install --pure-lockfile --no-progress'
command: 'yarn install --frozen-lockfile --no-progress'
no_output_timeout: 15m
- save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"@types/react-dom": "16.8.5",
"@types/react-grid-layout": "0.16.7",
"@types/react-select": "2.0.15",
"@types/react-transition-group": "2.0.16",
"@types/react-virtualized": "9.18.12",
"@types/react-window": "1.7.0",
"@types/react-transition-group": "4.2.2",
"@types/react-virtualized": "9.21.4",
"@types/react-window": "1.8.1",
"angular-mocks": "1.6.6",
"autoprefixer": "9.5.0",
"axios": "0.19.0",
Expand Down Expand Up @@ -179,9 +179,9 @@
"@types/marked": "0.6.5",
"@types/mousetrap": "1.6.3",
"@types/prismjs": "1.16.0",
"@types/react-redux": "7.0.8",
"@types/react-redux": "7.1.1",
"@types/react-table": "6.8.5",
"@types/react-test-renderer": "16.8.2",
"@types/react-test-renderer": "16.9.0",
"@types/redux-logger": "3.0.7",
"@types/redux-mock-store": "1.0.1",
"@types/reselect": "2.2.0",
Expand Down Expand Up @@ -217,16 +217,16 @@
"react": "16.9.0",
"react-dom": "16.9.0",
"react-grid-layout": "0.16.6",
"react-highlight-words": "0.11.0",
"react-popper": "1.3.3",
"react-redux": "5.1.1",
"react-sizeme": "2.5.2",
"react-table": "6.9.2",
"react-transition-group": "2.6.1",
"react-use": "9.0.0",
"react-virtualized": "9.21.0",
"react-window": "1.7.1",
"redux": "4.0.1",
"react-highlight-words": "0.16.0",
"react-popper": "1.3.4",
"react-redux": "7.1.0",
"react-sizeme": "2.6.7",
"react-table": "6.10.0",
"react-transition-group": "4.2.2",
"react-use": "10.5.0",
"react-virtualized": "9.21.1",
"react-window": "1.8.5",
"redux": "4.0.4",
"redux-logger": "3.0.6",
"redux-observable": "1.1.0",
"redux-thunk": "2.3.0",
Expand Down
14 changes: 1 addition & 13 deletions public/app/core/components/Login/LoginCtrl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,10 @@ export class LoginCtrl extends PureComponent<Props, State> {
// Use window.location.href to force page reload
if (params.redirect && params.redirect[0] === '/') {
window.location.href = config.appSubUrl + params.redirect;

// this.props.updateLocation({
// path: config.appSubUrl + params.redirect,
// });
} else if (this.result.redirectUrl) {
window.location.href = config.appSubUrl + params.redirect;

// this.props.updateLocation({
// path: this.result.redirectUrl,
// });
window.location.href = config.appSubUrl + this.result.redirectUrl;
} else {
window.location.href = config.appSubUrl + '/';

// this.props.updateLocation({
// path: '/',
// });
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`DashboardPage Dashboard init completed Should render dashboard grid 1`
<div
className=""
>
<Connect(DashNav)
<Component
$injector={Object {}}
dashboard={
DashboardModel {
Expand Down Expand Up @@ -241,7 +241,7 @@ exports[`DashboardPage When dashboard has editview url state should render setti
<div
className="dashboard-page--settings-opening"
>
<Connect(DashNav)
<Component
$injector={Object {}}
dashboard={
DashboardModel {
Expand Down
5 changes: 2 additions & 3 deletions public/app/features/dashboard/dashgrid/DashboardGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import React, { PureComponent } from 'react';
import { hot } from 'react-hot-loader';
import ReactGridLayout, { ItemCallback } from 'react-grid-layout';
import classNames from 'classnames';
// @ts-ignore
import sizeMe from 'react-sizeme';
import { withSize } from 'react-sizeme';

// Types
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT } from 'app/core/constants';
Expand Down Expand Up @@ -78,7 +77,7 @@ function GridWrapper({
);
}

const SizedReactLayoutGrid = sizeMe({ monitorWidth: true })(GridWrapper);
const SizedReactLayoutGrid = withSize({ monitorWidth: true })(GridWrapper);

export interface Props {
dashboard: DashboardModel;
Expand Down
18 changes: 15 additions & 3 deletions public/app/features/explore/QueryField.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,28 @@ import { shallow } from 'enzyme';
import { QueryField } from './QueryField';

describe('<QueryField />', () => {
it('renders with null initial value', () => {
it('should render with null initial value', () => {
const wrapper = shallow(<QueryField initialQuery={null} />);
expect(wrapper.find('div').exists()).toBeTruthy();
});
it('renders with empty initial value', () => {

it('should render with empty initial value', () => {
const wrapper = shallow(<QueryField initialQuery="" />);
expect(wrapper.find('div').exists()).toBeTruthy();
});
it('renders with initial value', () => {

it('should render with initial value', () => {
const wrapper = shallow(<QueryField initialQuery="my query" />);
expect(wrapper.find('div').exists()).toBeTruthy();
});

it('should execute query when enter is pressed and there are no suggestions visible', () => {
const wrapper = shallow(<QueryField initialQuery="my query" />);
const instance = wrapper.instance() as QueryField;
instance.executeOnChangeAndRunQueries = jest.fn();
const handleEnterAndTabKeySpy = jest.spyOn(instance, 'handleEnterAndTabKey');
instance.onKeyDown({ key: 'Enter', preventDefault: () => {} } as KeyboardEvent, {});
expect(handleEnterAndTabKeySpy).toBeCalled();
expect(instance.executeOnChangeAndRunQueries).toBeCalled();
});
});
32 changes: 13 additions & 19 deletions public/app/features/explore/QueryField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,29 +307,23 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS

handleEnterAndTabKey = (event: KeyboardEvent, change: Change) => {
const { typeaheadIndex, suggestions } = this.state;
if (this.menuEl) {
// Dont blur input
event.preventDefault();
if (!suggestions || suggestions.length === 0) {
return undefined;
}

const suggestion = getSuggestionByIndex(suggestions, typeaheadIndex);
const nextChange = this.applyTypeahead(change, suggestion);
event.preventDefault();

const insertTextOperation = nextChange.operations.find((operation: any) => operation.type === 'insert_text');
if (insertTextOperation) {
return undefined;
}

return true;
} else if (!event.shiftKey) {
// Run queries if Shift is not pressed, otherwise pass through
if (event.shiftKey) {
// pass through if shift is pressed
return undefined;
} else if (!this.menuEl) {
this.executeOnChangeAndRunQueries();

return true;
} else if (!suggestions || suggestions.length === 0) {
return undefined;
}
return undefined;

const suggestion = getSuggestionByIndex(suggestions, typeaheadIndex);
const nextChange = this.applyTypeahead(change, suggestion);

const insertTextOperation = nextChange.operations.find((operation: any) => operation.type === 'insert_text');
return insertTextOperation ? true : undefined;
};

onKeyDown = (event: KeyboardEvent, change: Change) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ exports[`Render should render team members 1`] = `
</tr>
</thead>
<tbody>
<Connect(TeamMemberRow)
<Component
editorsCanAdmin={false}
key="1"
member={
Expand All @@ -197,7 +197,7 @@ exports[`Render should render team members 1`] = `
signedInUserIsTeamAdmin={true}
syncEnabled={false}
/>
<Connect(TeamMemberRow)
<Component
editorsCanAdmin={false}
key="2"
member={
Expand All @@ -217,7 +217,7 @@ exports[`Render should render team members 1`] = `
signedInUserIsTeamAdmin={true}
syncEnabled={false}
/>
<Connect(TeamMemberRow)
<Component
editorsCanAdmin={false}
key="3"
member={
Expand All @@ -237,7 +237,7 @@ exports[`Render should render team members 1`] = `
signedInUserIsTeamAdmin={true}
syncEnabled={false}
/>
<Connect(TeamMemberRow)
<Component
editorsCanAdmin={false}
key="4"
member={
Expand All @@ -257,7 +257,7 @@ exports[`Render should render team members 1`] = `
signedInUserIsTeamAdmin={true}
syncEnabled={false}
/>
<Connect(TeamMemberRow)
<Component
editorsCanAdmin={false}
key="5"
member={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports[`Render should render group sync page 1`] = `
<PageContents
isLoading={true}
>
<Connect(TeamGroupSync) />
<Component />
</PageContents>
</Page>
`;
Expand All @@ -29,7 +29,7 @@ exports[`Render should render member page if team not empty 1`] = `
<PageContents
isLoading={true}
>
<Connect(TeamMembers)
<Component
members={Array []}
syncEnabled={true}
/>
Expand All @@ -44,7 +44,7 @@ exports[`Render should render settings and preferences page 1`] = `
<PageContents
isLoading={true}
>
<Connect(TeamSettings) />
<Component />
</PageContents>
</Page>
`;
Expand All @@ -66,7 +66,7 @@ exports[`Render when feature toggle editorsCanAdmin is turned on should render s
<PageContents
isLoading={true}
>
<Connect(TeamSettings) />
<Component />
</PageContents>
</Page>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exports[`Render should render invitees 1`] = `
</tr>
</thead>
<tbody>
<Connect(InviteeRow)
<Component
invitee={
Object {
"code": "asdfasdfsadf-0",
Expand All @@ -70,7 +70,7 @@ exports[`Render should render invitees 1`] = `
}
key="0-0"
/>
<Connect(InviteeRow)
<Component
invitee={
Object {
"code": "asdfasdfsadf-1",
Expand All @@ -91,7 +91,7 @@ exports[`Render should render invitees 1`] = `
}
key="1-1"
/>
<Connect(InviteeRow)
<Component
invitee={
Object {
"code": "asdfasdfsadf-2",
Expand All @@ -112,7 +112,7 @@ exports[`Render should render invitees 1`] = `
}
key="2-2"
/>
<Connect(InviteeRow)
<Component
invitee={
Object {
"code": "asdfasdfsadf-3",
Expand All @@ -133,7 +133,7 @@ exports[`Render should render invitees 1`] = `
}
key="3-3"
/>
<Connect(InviteeRow)
<Component
invitee={
Object {
"code": "asdfasdfsadf-4",
Expand All @@ -154,7 +154,7 @@ exports[`Render should render invitees 1`] = `
}
key="4-4"
/>
<Connect(InviteeRow)
<Component
invitee={
Object {
"code": "asdfasdfsadf-5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`Render should render List page 1`] = `
<PageContents
isLoading={false}
>
<Connect(UsersActionBar)
<Component
onShowInvites={[Function]}
showInvites={false}
/>
Expand Down Expand Up @@ -45,7 +45,7 @@ exports[`Render should render component 1`] = `
<PageContents
isLoading={true}
>
<Connect(UsersActionBar)
<Component
onShowInvites={[Function]}
showInvites={false}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class PromQueryEditor extends PureComponent<Props, State> {
super(props);
const { query } = props;
this.query = query;
// Query target properties that are fullu controlled inputs
// Query target properties that are fully controlled inputs
this.state = {
// Fully controlled text inputs
interval: query.interval,
Expand Down Expand Up @@ -123,6 +123,7 @@ export class PromQueryEditor extends PureComponent<Props, State> {
placeholder="legend format"
value={legendFormat}
onChange={this.onLegendChange}
onBlur={this.onRunQuery}
/>
</div>

Expand All @@ -140,6 +141,7 @@ export class PromQueryEditor extends PureComponent<Props, State> {
className="gf-form-input width-8"
placeholder={interval}
onChange={this.onIntervalChange}
onBlur={this.onRunQuery}
value={interval}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ exports[`Render PromQueryEditor with basic options should render 1`] = `
</Component>
<input
className="gf-form-input"
onBlur={[Function]}
onChange={[Function]}
placeholder="legend format"
type="text"
Expand All @@ -53,6 +54,7 @@ exports[`Render PromQueryEditor with basic options should render 1`] = `
</Component>
<input
className="gf-form-input width-8"
onBlur={[Function]}
onChange={[Function]}
type="text"
/>
Expand Down
Loading

0 comments on commit f7cee2d

Please sign in to comment.