Skip to content

Commit

Permalink
Merge branch 'master' into less-less
Browse files Browse the repository at this point in the history
  • Loading branch information
ranbena committed Aug 6, 2019
2 parents b5a8f6e + 8e23f93 commit eaf17cb
Show file tree
Hide file tree
Showing 65 changed files with 1,503 additions and 992 deletions.
8 changes: 7 additions & 1 deletion client/app/assets/less/inc/ant-variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
@font-size-base: 13px;


/* --------------------------------------------------------
Borders
-----------------------------------------------------------*/
@border-color-split: #f0f0f0;


/* --------------------------------------------------------
Typograpgy
-----------------------------------------------------------*/
Expand Down Expand Up @@ -77,4 +83,4 @@
Notification
-----------------------------------------------------------*/
@notification-padding: @notification-padding-vertical 48px @notification-padding-vertical 17px;
@notification-width: auto;
@notification-width: auto;
14 changes: 5 additions & 9 deletions client/app/components/DateInput.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import DatePicker from 'antd/lib/date-picker';
import { clientConfig } from '@/services/auth';
import { Moment } from '@/components/proptypes';

export function DateInput({
const DateInput = React.forwardRef(({
defaultValue,
value,
onSelect,
className,
...props
}) {
}, ref) => {
const format = clientConfig.dateFormat || 'YYYY-MM-DD';
const additionalAttributes = {};
if (defaultValue && defaultValue.isValid()) {
Expand All @@ -22,6 +21,7 @@ export function DateInput({
}
return (
<DatePicker
ref={ref}
className={className}
{...additionalAttributes}
format={format}
Expand All @@ -30,7 +30,7 @@ export function DateInput({
{...props}
/>
);
}
});

DateInput.propTypes = {
defaultValue: Moment,
Expand All @@ -46,8 +46,4 @@ DateInput.defaultProps = {
className: '',
};

export default function init(ngModule) {
ngModule.component('dateInput', react2angular(DateInput));
}

init.init = true;
export default DateInput;
14 changes: 5 additions & 9 deletions client/app/components/DateRangeInput.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { isArray } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import DatePicker from 'antd/lib/date-picker';
import { clientConfig } from '@/services/auth';
import { Moment } from '@/components/proptypes';

const { RangePicker } = DatePicker;

export function DateRangeInput({
const DateRangeInput = React.forwardRef(({
defaultValue,
value,
onSelect,
className,
...props
}) {
}, ref) => {
const format = clientConfig.dateFormat || 'YYYY-MM-DD';
const additionalAttributes = {};
if (isArray(defaultValue) && defaultValue[0].isValid() && defaultValue[1].isValid()) {
Expand All @@ -25,14 +24,15 @@ export function DateRangeInput({
}
return (
<RangePicker
ref={ref}
className={className}
{...additionalAttributes}
format={format}
onChange={onSelect}
{...props}
/>
);
}
});

DateRangeInput.propTypes = {
defaultValue: PropTypes.arrayOf(Moment),
Expand All @@ -48,8 +48,4 @@ DateRangeInput.defaultProps = {
className: '',
};

export default function init(ngModule) {
ngModule.component('dateRangeInput', react2angular(DateRangeInput));
}

init.init = true;
export default DateRangeInput;
14 changes: 5 additions & 9 deletions client/app/components/DateTimeInput.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import DatePicker from 'antd/lib/date-picker';
import { clientConfig } from '@/services/auth';
import { Moment } from '@/components/proptypes';

export function DateTimeInput({
const DateTimeInput = React.forwardRef(({
defaultValue,
value,
withSeconds,
onSelect,
className,
...props
}) {
}, ref) => {
const format = (clientConfig.dateFormat || 'YYYY-MM-DD') +
(withSeconds ? ' HH:mm:ss' : ' HH:mm');
const additionalAttributes = {};
Expand All @@ -24,6 +23,7 @@ export function DateTimeInput({
}
return (
<DatePicker
ref={ref}
className={className}
showTime
{...additionalAttributes}
Expand All @@ -33,7 +33,7 @@ export function DateTimeInput({
{...props}
/>
);
}
});

DateTimeInput.propTypes = {
defaultValue: Moment,
Expand All @@ -51,8 +51,4 @@ DateTimeInput.defaultProps = {
className: '',
};

export default function init(ngModule) {
ngModule.component('dateTimeInput', react2angular(DateTimeInput));
}

init.init = true;
export default DateTimeInput;
14 changes: 5 additions & 9 deletions client/app/components/DateTimeRangeInput.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { isArray } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
import DatePicker from 'antd/lib/date-picker';
import { clientConfig } from '@/services/auth';
import { Moment } from '@/components/proptypes';

const { RangePicker } = DatePicker;

export function DateTimeRangeInput({
const DateTimeRangeInput = React.forwardRef(({
defaultValue,
value,
withSeconds,
onSelect,
className,
...props
}) {
}, ref) => {
const format = (clientConfig.dateFormat || 'YYYY-MM-DD') +
(withSeconds ? ' HH:mm:ss' : ' HH:mm');
const additionalAttributes = {};
Expand All @@ -27,6 +26,7 @@ export function DateTimeRangeInput({
}
return (
<RangePicker
ref={ref}
className={className}
showTime
{...additionalAttributes}
Expand All @@ -35,7 +35,7 @@ export function DateTimeRangeInput({
{...props}
/>
);
}
});

DateTimeRangeInput.propTypes = {
defaultValue: PropTypes.arrayOf(Moment),
Expand All @@ -53,8 +53,4 @@ DateTimeRangeInput.defaultProps = {
className: '',
};

export default function init(ngModule) {
ngModule.component('dateTimeRangeInput', react2angular(DateTimeRangeInput));
}

init.init = true;
export default DateTimeRangeInput;
50 changes: 50 additions & 0 deletions client/app/components/EditParameterSettingsDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { includes, words, capitalize, clone, isNull } from 'lodash';
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import Checkbox from 'antd/lib/checkbox';
import Modal from 'antd/lib/modal';
import Form from 'antd/lib/form';
import Button from 'antd/lib/button';
Expand All @@ -23,6 +24,13 @@ function isTypeDateRange(type) {
return /-range/.test(type);
}

function joinExampleList(multiValuesOptions) {
const { prefix, suffix } = multiValuesOptions;
return ['value1', 'value2', 'value3']
.map(value => `${prefix}${value}${suffix}`)
.join(',');
}

function NameInput({ name, type, onChange, existingNames, setValidation }) {
let helpText = '';
let validateStatus = '';
Expand Down Expand Up @@ -185,6 +193,48 @@ function EditParameterSettingsDialog(props) {
/>
</Form.Item>
)}
{(param.type === 'enum' || param.type === 'query') && (
<Form.Item className="m-b-0" label=" " colon={false} {...formItemProps}>
<Checkbox
defaultChecked={!!param.multiValuesOptions}
onChange={e => setParam({ ...param,
multiValuesOptions: e.target.checked ? {
prefix: '',
suffix: '',
separator: ',',
} : null })}
data-test="AllowMultipleValuesCheckbox"
>
Allow multiple values
</Checkbox>
</Form.Item>
)}
{(param.type === 'enum' || param.type === 'query') && param.multiValuesOptions && (
<Form.Item
label="Quotation"
help={(
<React.Fragment>
Placed in query as: <code>{joinExampleList(param.multiValuesOptions)}</code>
</React.Fragment>
)}
{...formItemProps}
>
<Select
value={param.multiValuesOptions.prefix}
onChange={quoteOption => setParam({ ...param,
multiValuesOptions: {
...param.multiValuesOptions,
prefix: quoteOption,
suffix: quoteOption,
} })}
data-test="QuotationSelect"
>
<Option value="">None (default)</Option>
<Option value="'">Single Quotation Mark</Option>
<Option value={'"'} data-test="DoubleQuotationMarkOption">Double Quotation Mark</Option>
</Select>
</Form.Item>
)}
</Form>
</Modal>
);
Expand Down
20 changes: 20 additions & 0 deletions client/app/components/HtmlContent.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import PropTypes from 'prop-types';
import { $sanitize } from '@/services/ng';

export default function HtmlContent({ children, ...props }) {
return (
<div
{...props}
dangerouslySetInnerHTML={{ __html: $sanitize(children) }} // eslint-disable-line react/no-danger
/>
);
}

HtmlContent.propTypes = {
children: PropTypes.string,
};

HtmlContent.defaultProps = {
children: '',
};
26 changes: 21 additions & 5 deletions client/app/components/ParameterValueInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ import './ParameterValueInput.less';

const { Option } = Select;

const multipleValuesProps = {
maxTagCount: 3,
maxTagTextLength: 10,
maxTagPlaceholder: num => `+${num.length} more`,
};

export class ParameterValueInput extends React.Component {
static propTypes = {
type: PropTypes.string,
value: PropTypes.any, // eslint-disable-line react/forbid-prop-types
enumOptions: PropTypes.string,
queryId: PropTypes.number,
parameter: PropTypes.any, // eslint-disable-line react/forbid-prop-types
allowMultipleValues: PropTypes.bool,
onSelect: PropTypes.func,
className: PropTypes.string,
};
Expand All @@ -30,6 +37,7 @@ export class ParameterValueInput extends React.Component {
enumOptions: '',
queryId: null,
parameter: null,
allowMultipleValues: false,
onSelect: () => {},
className: '',
};
Expand Down Expand Up @@ -88,36 +96,43 @@ export class ParameterValueInput extends React.Component {
}

renderEnumInput() {
const { value, enumOptions } = this.props;
const { enumOptions, allowMultipleValues } = this.props;
const { value } = this.state;
const enumOptionsArray = enumOptions.split('\n').filter(v => v !== '');
return (
<Select
className={this.props.className}
mode={allowMultipleValues ? 'multiple' : 'default'}
optionFilterProp="children"
disabled={enumOptionsArray.length === 0}
defaultValue={value}
value={value}
onChange={this.onSelect}
dropdownMatchSelectWidth={false}
dropdownClassName="ant-dropdown-in-bootstrap-modal"
showSearch
style={{ minWidth: 60 }}
optionFilterProp="children"
style={{ minWidth: allowMultipleValues ? 195 : 60 }}
notFoundContent={null}
{...multipleValuesProps}
>
{enumOptionsArray.map(option => (<Option key={option} value={option}>{ option }</Option>))}
</Select>
);
}

renderQueryBasedInput() {
const { queryId, parameter } = this.props;
const { queryId, parameter, allowMultipleValues } = this.props;
const { value } = this.state;
return (
<QueryBasedParameterInput
className={this.props.className}
mode={allowMultipleValues ? 'multiple' : 'default'}
optionFilterProp="children"
parameter={parameter}
value={value}
queryId={queryId}
onSelect={this.onSelect}
style={{ minWidth: allowMultipleValues ? 195 : 60 }}
{...multipleValuesProps}
/>
);
}
Expand Down Expand Up @@ -187,6 +202,7 @@ export default function init(ngModule) {
parameter="$ctrl.param"
enum-options="$ctrl.param.enumOptions"
query-id="$ctrl.param.queryId"
allow-multiple-values="!!$ctrl.param.multiValuesOptions"
on-select="$ctrl.setValue"
></parameter-value-input-impl>
`,
Expand Down
Loading

0 comments on commit eaf17cb

Please sign in to comment.