Browse Source

ref(reflux): Remove MetricsMetaActions (#33404)

Evan Purkhiser 2 years ago
parent
commit
3bd522f42c

+ 1 - 2
static/app/actionCreators/metrics.tsx

@@ -1,5 +1,4 @@
 import {addErrorMessage} from 'sentry/actionCreators/indicator';
-import MetricsMetaActions from 'sentry/actions/metricsMetaActions';
 import MetricsTagActions from 'sentry/actions/metricTagActions';
 import {Client} from 'sentry/api';
 import {getInterval} from 'sentry/components/charts/utils';
@@ -112,7 +111,7 @@ export function fetchMetricsTags(
 }
 
 function metaFetchSuccess(metricsMeta: MetricsMeta[]) {
-  MetricsMetaActions.loadMetricsMetaSuccess(metricsMeta);
+  MetricsMetaStore.loadSuccess(metricsMeta);
 }
 
 export function fetchMetricsFields(

+ 0 - 5
static/app/actions/metricsMetaActions.tsx

@@ -1,5 +0,0 @@
-import {createActions} from 'reflux';
-
-const MetricsMetaActions = createActions(['loadMetricsMetaSuccess']);
-
-export default MetricsMetaActions;

+ 2 - 9
static/app/stores/metricsMetaStore.tsx

@@ -1,6 +1,5 @@
 import {createStore} from 'reflux';
 
-import MetricsMetaActions from 'sentry/actions/metricsMetaActions';
 import {MetricsMeta, MetricsMetaCollection} from 'sentry/types';
 import {makeSafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
 
@@ -15,7 +14,7 @@ type State = {
 };
 
 interface MetricsMetaStoreDefinition extends CommonStoreDefinition<State> {
-  onLoadSuccess(data: MetricsMeta[]): void;
+  loadSuccess(data: MetricsMeta[]): void;
   reset(): void;
 }
 
@@ -26,12 +25,6 @@ const storeConfig: MetricsMetaStoreDefinition = {
     loaded: false,
   },
 
-  init() {
-    this.unsubscribeListeners.push(
-      this.listenTo(MetricsMetaActions.loadMetricsMetaSuccess, this.onLoadSuccess)
-    );
-  },
-
   reset() {
     this.state = {
       metricsMeta: {},
@@ -44,7 +37,7 @@ const storeConfig: MetricsMetaStoreDefinition = {
     return this.state;
   },
 
-  onLoadSuccess(data) {
+  loadSuccess(data) {
     const newFields = data.reduce<MetricsMetaCollection>((acc, field) => {
       acc[field.name] = {
         ...field,

+ 3 - 4
tests/js/spec/actionCreators/metrics.spec.tsx

@@ -5,7 +5,6 @@ import {
   fetchMetricsFields,
   fetchMetricsTags,
 } from 'sentry/actionCreators/metrics';
-import MetricsMetaActions from 'sentry/actions/metricsMetaActions';
 import MetricsTagActions from 'sentry/actions/metricTagActions';
 import {Client} from 'sentry/api';
 import MetricsMetaStore from 'sentry/stores/metricsMetaStore';
@@ -162,7 +161,7 @@ describe('Metrics ActionCreator', function () {
         body: meta,
       });
       jest.restoreAllMocks();
-      jest.spyOn(MetricsMetaActions, 'loadMetricsMetaSuccess');
+      jest.spyOn(MetricsMetaStore, 'loadSuccess');
       jest.spyOn(MetricsMetaStore, 'reset');
     });
 
@@ -178,8 +177,8 @@ describe('Metrics ActionCreator', function () {
           query: {project: [1]},
         })
       );
-      expect(MetricsMetaActions.loadMetricsMetaSuccess).toHaveBeenCalledTimes(1);
-      expect(MetricsMetaActions.loadMetricsMetaSuccess).toHaveBeenCalledWith(meta);
+      expect(MetricsMetaStore.loadSuccess).toHaveBeenCalledTimes(1);
+      expect(MetricsMetaStore.loadSuccess).toHaveBeenCalledWith(meta);
     });
   });
 });

+ 1 - 1
tests/js/spec/components/modals/addDashboardWidgetModal.spec.jsx

@@ -132,7 +132,7 @@ describe('Modals -> AddDashboardWidgetModal', function () {
     act(() => {
       MetricsTagStore.onLoadSuccess(metricsTags);
     });
-    MetricsMetaStore.onLoadSuccess(metricsMeta);
+    MetricsMetaStore.loadSuccess(metricsMeta);
     MockApiClient.addMockResponse({
       url: '/organizations/org-slug/dashboards/widgets/',
       method: 'POST',

+ 1 - 1
tests/js/spec/stores/metricsMetaStore.spec.tsx

@@ -12,7 +12,7 @@ describe('MetricsMetaStore', function () {
       const {metricsMeta} = MetricsMetaStore.getState();
       expect(metricsMeta).toEqual({});
 
-      MetricsMetaStore.onLoadSuccess([
+      MetricsMetaStore.loadSuccess([
         {
           name: 'sentry.sessions.session',
           type: 'counter',

+ 1 - 1
tests/js/spec/utils/withMetricsMeta.spec.tsx

@@ -33,7 +33,7 @@ describe('withMetricsMeta HoC', function () {
     expect(screen.getByText('value')).toBeInTheDocument();
 
     act(() => {
-      MetricsMetaStore.onLoadSuccess([
+      MetricsMetaStore.loadSuccess([
         {
           name: 'sentry.sessions.session',
           type: 'counter',