cleanup. remove comments, not used files etc

This commit is contained in:
Erik Sundell
2019-01-02 15:35:36 +01:00
parent 0e49225d1d
commit 1ab9fc871c
10 changed files with 25 additions and 180 deletions

View File

@@ -1,8 +1,8 @@
import React from 'react';
import _ from 'lodash';
import { getAggregationOptionsByMetric } from '../functions';
import { MetricSelect } from 'app/core/components/Select/MetricSelect';
import { getAggregationOptionsByMetric } from '../functions';
export interface Props {
onChange: (metricDescriptor) => void;

View File

@@ -109,7 +109,6 @@ export class AnnotationQueryEditor extends React.Component<Props, State> {
</div>
<AnnotationsHelp />
{/* <Help datasource={datasource} rawQuery={lastQuery} lastQueryError={lastQueryError} /> */}
</React.Fragment>
);
}

View File

@@ -1,6 +1,7 @@
import React from 'react';
import _ from 'lodash';
import appEvents from 'app/core/app_events';
import { MetricSelect } from 'app/core/components/Select/MetricSelect';
export interface Props {
@@ -54,7 +55,7 @@ export class Metrics extends React.Component<Props, State> {
}
resolve(this.state.defaultProject);
} catch (error) {
// appEvents.emit('ds-request-error', error);
appEvents.emit('ds-request-error', error);
reject();
}
});

View File

@@ -1,44 +0,0 @@
import React, { PureComponent } from 'react';
import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader';
import 'app/core/directives/metric_segment';
interface QueryEditorProps {
segment: any;
getOptions: () => Promise<any[]>;
onChange: (segment, index) => void;
key: number;
}
export default class Segment extends PureComponent<QueryEditorProps, any> {
element: any;
component: AngularComponent;
async componentDidMount() {
if (!this.element) {
return;
}
const { segment, getOptions, onChange } = this.props;
const loader = getAngularLoader();
const template = '<metric-segment> </metric-segment>';
const scopeProps = {
segment,
onChange,
getOptions,
debounce: false,
};
this.component = loader.load(this.element, scopeProps, template);
}
componentWillUnmount() {
if (this.component) {
this.component.destroy();
}
}
render() {
return <div ref={element => (this.element = element)} style={{ width: '100%' }} />;
}
}

View File

@@ -1,97 +0,0 @@
import React from 'react';
import _ from 'lodash';
import Select from 'app/core/components/Select/Select';
export interface Props {
onChange: (value: string) => void;
options: any[];
searchable: boolean;
selected: string;
placeholder?: string;
className?: string;
groupName?: string;
templateVariables?: any[];
}
interface State {
options: any[];
}
export class StackdriverPicker extends React.Component<Props, State> {
static defaultProps = {
templateVariables: [],
options: [],
groupName: 'Options',
};
constructor(props) {
super(props);
this.state = { options: [] };
}
componentDidMount() {
this.setState({ options: this.buildOptions(this.props) });
}
componentWillReceiveProps(nextProps: Props) {
if (nextProps.options.length > 0 || nextProps.templateVariables.length) {
this.setState({ options: this.buildOptions(nextProps) });
}
}
shouldComponentUpdate(nextProps: Props) {
const nextOptions = this.buildOptions(nextProps);
return nextProps.selected !== this.props.selected || !_.isEqual(nextOptions, this.state.options);
}
buildOptions({ templateVariables = [], groupName = '', options }) {
return templateVariables.length > 0
? [
this.getTemplateVariablesGroup(),
{
label: groupName,
expanded: true,
options,
},
]
: options;
}
getTemplateVariablesGroup() {
return {
label: 'Template Variables',
options: this.props.templateVariables.map(v => ({
label: `$${v.name}`,
value: `$${v.name}`,
})),
};
}
getSelectedOption() {
const { options } = this.state;
const allOptions = options.every(o => o.options) ? _.flatten(options.map(o => o.options)) : options;
return allOptions.find(option => option.value === this.props.selected);
}
render() {
const { placeholder, className, searchable, onChange } = this.props;
const { options } = this.state;
const selectedOption = this.getSelectedOption();
return (
<Select
className={className}
isMulti={false}
isClearable={false}
backspaceRemovesValue={false}
onChange={item => onChange(item.value)}
options={options}
isSearchable={searchable}
maxMenuHeight={500}
placeholder={placeholder}
noOptionsMessage={() => 'No options found'}
value={selectedOption}
/>
);
}
}