|
@@ -9,7 +9,6 @@ import set from 'lodash/set';
|
|
|
|
|
|
import {validateWidget} from 'sentry/actionCreators/dashboards';
|
|
|
import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
|
|
|
-import {fetchMetricsFields} from 'sentry/actionCreators/metrics';
|
|
|
import {ModalRenderProps} from 'sentry/actionCreators/modal';
|
|
|
import {Client} from 'sentry/api';
|
|
|
import Button from 'sentry/components/button';
|
|
@@ -26,7 +25,7 @@ import {t, tct} from 'sentry/locale';
|
|
|
import space from 'sentry/styles/space';
|
|
|
import {
|
|
|
DateString,
|
|
|
- MetricMeta,
|
|
|
+ MetricsMetaCollection,
|
|
|
MetricTagCollection,
|
|
|
Organization,
|
|
|
PageFilters,
|
|
@@ -38,6 +37,7 @@ import Measurements from 'sentry/utils/measurements/measurements';
|
|
|
import {SessionMetric} from 'sentry/utils/metrics/fields';
|
|
|
import {SPAN_OP_BREAKDOWN_FIELDS} from 'sentry/utils/performance/spanOperationBreakdowns/constants';
|
|
|
import withApi from 'sentry/utils/withApi';
|
|
|
+import withMetricsMeta from 'sentry/utils/withMetricsMeta';
|
|
|
import withMetricsTags from 'sentry/utils/withMetricsTags';
|
|
|
import withPageFilters from 'sentry/utils/withPageFilters';
|
|
|
import withTags from 'sentry/utils/withTags';
|
|
@@ -91,6 +91,7 @@ export type DashboardWidgetModalOptions = {
|
|
|
type Props = ModalRenderProps &
|
|
|
DashboardWidgetModalOptions & {
|
|
|
api: Client;
|
|
|
+ metricsMeta: MetricsMetaCollection;
|
|
|
metricsTags: MetricTagCollection;
|
|
|
organization: Organization;
|
|
|
selection: PageFilters;
|
|
@@ -106,7 +107,6 @@ type State = {
|
|
|
displayType: Widget['displayType'];
|
|
|
interval: Widget['interval'];
|
|
|
loading: boolean;
|
|
|
- metricFields: MetricMeta[];
|
|
|
queries: Widget['queries'];
|
|
|
title: string;
|
|
|
userHasModified: boolean;
|
|
@@ -163,7 +163,6 @@ class AddDashboardWidgetModal extends React.Component<Props, State> {
|
|
|
errors: undefined,
|
|
|
loading: !!this.omitDashboardProp,
|
|
|
dashboards: [],
|
|
|
- metricFields: [],
|
|
|
userHasModified: false,
|
|
|
widgetType: WidgetType.DISCOVER,
|
|
|
};
|
|
@@ -178,7 +177,6 @@ class AddDashboardWidgetModal extends React.Component<Props, State> {
|
|
|
errors: undefined,
|
|
|
loading: false,
|
|
|
dashboards: [],
|
|
|
- metricFields: [],
|
|
|
userHasModified: false,
|
|
|
widgetType: widget.widgetType ?? WidgetType.DISCOVER,
|
|
|
};
|
|
@@ -188,9 +186,6 @@ class AddDashboardWidgetModal extends React.Component<Props, State> {
|
|
|
if (this.omitDashboardProp) {
|
|
|
this.fetchDashboards();
|
|
|
}
|
|
|
- if (this.props.organization.features.includes('dashboards-metrics')) {
|
|
|
- this.fetchMetricsFields();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
get omitDashboardProp() {
|
|
@@ -525,19 +520,6 @@ class AddDashboardWidgetModal extends React.Component<Props, State> {
|
|
|
this.setState({loading: false});
|
|
|
}
|
|
|
|
|
|
- async fetchMetricsFields() {
|
|
|
- const {api, organization, selection} = this.props;
|
|
|
- const projects = !selection.projects.length ? undefined : selection.projects;
|
|
|
-
|
|
|
- const metricFields = await fetchMetricsFields(api, organization.slug, projects);
|
|
|
- const filteredFields = metricFields.filter(field =>
|
|
|
- METRICS_FIELDS_ALLOW_LIST.includes(field.name)
|
|
|
- );
|
|
|
- this.setState({
|
|
|
- metricFields: filteredFields,
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
handleDashboardChange(option: SelectValue<string>) {
|
|
|
this.setState({selectedDashboard: option});
|
|
|
}
|
|
@@ -596,8 +578,16 @@ class AddDashboardWidgetModal extends React.Component<Props, State> {
|
|
|
}
|
|
|
|
|
|
renderWidgetQueryForm() {
|
|
|
- const {organization, selection, tags, metricsTags, start, end, statsPeriod} =
|
|
|
- this.props;
|
|
|
+ const {
|
|
|
+ organization,
|
|
|
+ selection,
|
|
|
+ tags,
|
|
|
+ metricsTags,
|
|
|
+ metricsMeta,
|
|
|
+ start,
|
|
|
+ end,
|
|
|
+ statsPeriod,
|
|
|
+ } = this.props;
|
|
|
const state = this.state;
|
|
|
const errors = state.errors;
|
|
|
|
|
@@ -609,9 +599,12 @@ class AddDashboardWidgetModal extends React.Component<Props, State> {
|
|
|
? {...selection, datetime: {start, end, period: null, utc: null}}
|
|
|
: selection;
|
|
|
|
|
|
+ const filteredMeta = Object.values(metricsMeta).filter(field =>
|
|
|
+ METRICS_FIELDS_ALLOW_LIST.includes(field.name)
|
|
|
+ );
|
|
|
const issueWidgetFieldOptions = generateIssueWidgetFieldOptions();
|
|
|
const metricsWidgetFieldOptions = generateMetricsWidgetFieldOptions(
|
|
|
- state.metricFields.length ? state.metricFields : DEFAULT_METRICS_FIELDS,
|
|
|
+ filteredMeta.length ? filteredMeta : DEFAULT_METRICS_FIELDS,
|
|
|
Object.values(metricsTags).map(({key}) => key)
|
|
|
);
|
|
|
const fieldOptions = (measurementKeys: string[]) =>
|
|
@@ -921,5 +914,5 @@ const StyledFieldLabel = styled(FieldLabel)`
|
|
|
`;
|
|
|
|
|
|
export default withApi(
|
|
|
- withPageFilters(withTags(withMetricsTags(AddDashboardWidgetModal)))
|
|
|
+ withPageFilters(withTags(withMetricsMeta(withMetricsTags(AddDashboardWidgetModal))))
|
|
|
);
|