Skip to content

Commit

Permalink
Merge branch 'master' into sidecar-multi-config-and-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mpfz0r authored Sep 20, 2022
2 parents 920fec3 + 57ff695 commit 377b5d8
Show file tree
Hide file tree
Showing 28 changed files with 323 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ void testInvalidValueType() {
validatableResponse.assertThat().body("explanations.error_type[0]", equalTo("INVALID_VALUE_TYPE"));
}

@ContainerMatrixTest
void testSuccessfullyValidatesExistsTerms() {
verifyQueryIsValidatedSuccessfully("_exists_:timestamp");
verifyQueryIsValidatedSuccessfully("_exists_:level");
}

@ContainerMatrixTest
void testQuotedDefaultField() {
// if the validation correctly recognizes the quoted text, it should not warn about lowercase or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.common.collect.ImmutableList;

import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private List<ValidationMessage> validateQueryValues(PositionTrackingQuery decora
final Map<String, MappedFieldTypeDTO> fields = availableFields.stream().collect(Collectors.toMap(MappedFieldTypeDTO::name, Function.identity()));

return parsedQuery.terms().stream()
.filter(term -> !term.isExistsField())
.map(term -> {
final MappedFieldTypeDTO fieldType = fields.get(term.getRealFieldName());
final Optional<String> typeName = Optional.ofNullable(fieldType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
import React from 'react';
import PropTypes from 'prop-types';

import ModalSubmit from 'components/common/ModalSubmit';

import Modal from './Modal';
import BootstrapModalWrapper from './BootstrapModalWrapper';
import Button from './Button';

/**
* Component that displays a confirmation dialog box that the user can
Expand All @@ -34,8 +35,6 @@ class BootstrapModalConfirm extends React.Component {
PropTypes.string,
PropTypes.element,
]).isRequired,
/** Text to use in the cancel button. */
cancelButtonText: PropTypes.string,
/** Text to use in the confirmation button. */
confirmButtonText: PropTypes.string,
/** Indicates whether the cancel button should be disabled or not. */
Expand Down Expand Up @@ -65,7 +64,6 @@ class BootstrapModalConfirm extends React.Component {

static defaultProps = {
showModal: false,
cancelButtonText: 'Cancel',
confirmButtonText: 'Confirm',
cancelButtonDisabled: false,
confirmButtonDisabled: false,
Expand All @@ -88,6 +86,7 @@ class BootstrapModalConfirm extends React.Component {
onConfirm(this.close);
};

// eslint-disable-next-line react/no-unused-class-component-methods
open = () => {
this.modal.open();
};
Expand All @@ -105,7 +104,6 @@ class BootstrapModalConfirm extends React.Component {
children,
cancelButtonDisabled,
confirmButtonDisabled,
cancelButtonText,
confirmButtonText,
} = this.props;

Expand All @@ -125,8 +123,12 @@ class BootstrapModalConfirm extends React.Component {
</Modal.Body>

<Modal.Footer>
<Button type="button" onClick={this.onCancel} disabled={cancelButtonDisabled}>{cancelButtonText}</Button>
<Button type="button" onClick={this.onConfirm} bsStyle="primary" disabled={confirmButtonDisabled}>{confirmButtonText}</Button>
<ModalSubmit disabledCancel={cancelButtonDisabled}
disabledSubmit={confirmButtonDisabled}
onCancel={this.onCancel}
onSubmit={this.onConfirm}
submitButtonText={confirmButtonText}
submitButtonType="button" />
</Modal.Footer>
</BootstrapModalWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import PropTypes from 'prop-types';
import React from 'react';
import $ from 'jquery';

import ModalSubmit from 'components/common/ModalSubmit';

import Modal from './Modal';
import BootstrapModalWrapper from './BootstrapModalWrapper';
import Button from './Button';

/**
* Encapsulates a form element inside a bootstrap modal, hiding some custom logic that this kind of component
Expand All @@ -43,8 +44,6 @@ class BootstrapModalForm extends React.Component {
onCancel: PropTypes.func,
/* Object with additional props to pass to the form */
formProps: PropTypes.object,
/* Text to use in the cancel button. "Cancel" is the default */
cancelButtonText: PropTypes.string,
/* Text to use in the submit button. "Submit" is the default */
submitButtonText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
submitButtonDisabled: PropTypes.bool,
Expand All @@ -54,7 +53,6 @@ class BootstrapModalForm extends React.Component {
static defaultProps = {
backdrop: undefined,
formProps: {},
cancelButtonText: 'Cancel',
submitButtonText: 'Submit',
submitButtonDisabled: false,
onModalOpen: () => {},
Expand Down Expand Up @@ -104,7 +102,6 @@ class BootstrapModalForm extends React.Component {
formProps,
bsSize,
onModalClose,
cancelButtonText,
show,
submitButtonText,
onModalOpen,
Expand Down Expand Up @@ -136,8 +133,9 @@ class BootstrapModalForm extends React.Component {
{body}
</Modal.Body>
<Modal.Footer>
<Button type="button" onClick={this.onModalCancel}>{cancelButtonText}</Button>
<Button type="submit" disabled={submitButtonDisabled} bsStyle="primary">{submitButtonText}</Button>
<ModalSubmit disabledSubmit={submitButtonDisabled}
onCancel={this.onModalCancel}
submitButtonText={submitButtonText} />
</Modal.Footer>
</form>
</BootstrapModalWrapper>
Expand Down
19 changes: 18 additions & 1 deletion graylog2-web-interface/src/components/bootstrap/NavDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/

import * as React from 'react';
// eslint-disable-next-line no-restricted-imports
import { NavDropdown as BootstrapNavDropdown } from 'react-bootstrap';
import styled from 'styled-components';
import PropTypes from 'prop-types';

import menuItemStyles from './styles/menuItem';

Expand All @@ -41,10 +43,25 @@ class ModifiedBootstrapNavDropdown extends BootstrapNavDropdown {
}
}

const NavDropdown = styled(BootstrapNavDropdown)`
const StyledNavDropdown = styled(BootstrapNavDropdown)`
${menuItemStyles}
`;

const NavDropdown = ({ inactiveTitle, title, ...props }) => {
const isActive = inactiveTitle ? inactiveTitle !== title : undefined;

return <StyledNavDropdown {...props} title={title} active={isActive} />;
};

NavDropdown.propTypes = {
inactiveTitle: PropTypes.string,
title: PropTypes.node.isRequired,
};

NavDropdown.defaultProps = {
inactiveTitle: undefined,
};

const ModifiedNavDropdown = styled(ModifiedBootstrapNavDropdown)`
${menuItemStyles}
`;
Expand Down
26 changes: 26 additions & 0 deletions graylog2-web-interface/src/components/bootstrap/NavItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import * as React from 'react';
// eslint-disable-next-line no-restricted-imports
import { NavItem as BootstrapNavItem } from 'react-bootstrap';

const NavItem = (props: React.ComponentProps<typeof NavItem>) => <BootstrapNavItem {...props} />;

NavItem.displayName = 'NavItem';

/** @component */
export default NavItem;
7 changes: 5 additions & 2 deletions graylog2-web-interface/src/components/bootstrap/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ const Navbar = styled(BootstrapNavbar)(({ theme }) => css`
color: ${theme.colors.variant.darkest.default};
background-color: ${theme.colors.gray[90]};
&:hover,
&:focus {
&:hover {
color: ${theme.colors.variant.darkest.default};
background-color: ${theme.colors.gray[80]};
}
&:focus {
background-color: ${theme.colors.gray[90]};
}
}
> .disabled > a,
Expand Down
1 change: 0 additions & 1 deletion graylog2-web-interface/src/components/bootstrap/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export {
Dropdown,
Form,
Grid,
NavItem,
Pager,
PanelGroup,
Radio, // NOTE: do we want custom or keep OS styles
Expand Down
1 change: 1 addition & 0 deletions graylog2-web-interface/src/components/bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export { default as MenuItem } from './MenuItem';
export { default as Modal } from './Modal';
export { default as Nav } from './Nav';
export { default as NavDropdown } from './NavDropdown';
export { default as NavItem } from './NavItem';
export { default as Navbar } from './Navbar';
export { default as Panel } from './Panel';
export { default as Popover } from './Popover';
Expand Down
77 changes: 77 additions & 0 deletions graylog2-web-interface/src/components/common/FormSubmit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import * as React from 'react';

import { Button, ButtonToolbar } from 'components/bootstrap';
import type { IconName } from 'components/common/Icon';
import Icon from 'components/common/Icon';
import Spinner from 'components/common/Spinner';

type Props = {
className?: string,
disableCancel?: boolean,
disabledSubmit?: boolean,
isSubmitting?: boolean,
leftCol?: React.ReactNode,
onCancel: () => void,
onSubmit?: () => void,
submitButtonText: string,
submitIcon?: IconName,
submitButtonType?: 'submit' | 'button',
submitLoadingText?: string,
}

const FormSubmit = ({
className,
disableCancel,
disabledSubmit,
isSubmitting,
leftCol,
onCancel,
onSubmit,
submitButtonText,
submitButtonType,
submitIcon,
submitLoadingText,
}: Props) => (
<ButtonToolbar className={`${className} pull-right`}>
{leftCol}
<Button type="button" onClick={onCancel} disabled={disableCancel}>Cancel</Button>
<Button bsStyle="success"
disabled={disabledSubmit}
title={submitButtonText}
type={submitButtonType}
onClick={onSubmit}>
{(submitIcon && !isSubmitting) && <><Icon name={submitIcon} /> </>}
{isSubmitting ? <Spinner text={submitLoadingText} delay={0} /> : submitButtonText}
</Button>
</ButtonToolbar>
);

FormSubmit.defaultProps = {
className: undefined,
disableCancel: false,
disabledSubmit: false,
isSubmitting: false,
leftCol: undefined,
onSubmit: undefined,
submitButtonType: 'submit',
submitIcon: undefined,
submitLoadingText: undefined,
};

export default FormSubmit;
48 changes: 48 additions & 0 deletions graylog2-web-interface/src/components/common/ModalSubmit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import * as React from 'react';

import FormSubmit from 'components/common/FormSubmit';

type Props = React.ComponentProps<typeof FormSubmit>

/* eslint-disable react/prop-types */
const ModalSubmit = ({
className,
disabledSubmit,
disableCancel,
isSubmitting,
leftCol,
onCancel,
onSubmit,
submitLoadingText,
submitIcon,
submitButtonText,
}: Props) => (
<FormSubmit disableCancel={disableCancel}
disabledSubmit={disabledSubmit}
isSubmitting={isSubmitting}
leftCol={leftCol}
onCancel={onCancel}
onSubmit={onSubmit}
submitButtonText={submitButtonText}
submitIcon={submitIcon}
submitLoadingText={submitLoadingText}
className={className} />
);

export default ModalSubmit;
2 changes: 2 additions & 0 deletions graylog2-web-interface/src/components/common/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export { default as ExternalLinkButton } from './ExternalLinkButton';
export { default as FlatContentRow } from './FlatContentRow';
export { default as FormikFormGroup } from './FormikFormGroup';
export { default as FormikInput } from './FormikInput';
export { default as FormSubmit } from './FormSubmit';
export { default as HasOwnership } from './HasOwnership';
export { default as HoverForHelp } from './HoverForHelp';
export { default as ISODurationInput } from './ISODurationInput';
Expand All @@ -70,6 +71,7 @@ export { default as LoadingIndicator } from './LoadingIndicator';
export { default as LocaleSelect } from './LocaleSelect';
export { default as Markdown } from './Markdown';
export { default as MessageDetailsDefinitionList } from './MessageDetailsDefinitionList';
export { default as ModalSubmit } from './ModalSubmit';
export { default as MultiSelect } from './MultiSelect';
export { default as OverlayElement } from './OverlayElement';
export { default as OverlayTrigger } from './OverlayTrigger';
Expand Down
Loading

0 comments on commit 377b5d8

Please sign in to comment.