فهرست منبع

typing changes

Peter Holmberg 7 سال پیش
والد
کامیت
3e0a34ceca

+ 1 - 8
public/app/core/components/AppNotifications/AppNotificationList.tsx

@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
 import appEvents from 'app/core/app_events';
 import { addAppNotification, clearAppNotification } from './state/actions';
 import { connectWithStore } from 'app/core/utils/connectWithReduxStore';
-import { AppNotification, StoreState } from '../../../types';
+import { AppNotification, AppNotificationSeverity, StoreState } from 'app/types';
 
 export interface Props {
   appNotifications: AppNotification[];
@@ -10,13 +10,6 @@ export interface Props {
   clearAppNotification: typeof clearAppNotification;
 }
 
-enum AppNotificationSeverity {
-  Success = 'success',
-  Warning = 'warning',
-  Error = 'error',
-  Info = 'info',
-}
-
 export class AppNotificationList extends PureComponent<Props> {
   componentDidMount() {
     appEvents.on('alert-warning', options => this.addAppNotification(options[0], options[1], 'warning', 5000));

+ 4 - 3
public/app/core/components/AppNotifications/state/reducers.test.ts

@@ -1,5 +1,6 @@
 import { appNotificationsReducer } from './reducers';
 import { ActionTypes } from './actions';
+import { AppNotificationSeverity } from 'app/types';
 
 describe('clear alert', () => {
   it('should filter alert', () => {
@@ -10,14 +11,14 @@ describe('clear alert', () => {
       appNotifications: [
         {
           id: id1,
-          severity: 'success',
+          severity: AppNotificationSeverity.Success,
           icon: 'success',
           title: 'test',
           text: 'test alert',
         },
         {
           id: id2,
-          severity: 'fail',
+          severity: AppNotificationSeverity.Warning,
           icon: 'warning',
           title: 'test2',
           text: 'test alert fail 2',
@@ -34,7 +35,7 @@ describe('clear alert', () => {
       appNotifications: [
         {
           id: id1,
-          severity: 'success',
+          severity: AppNotificationSeverity.Success,
           icon: 'success',
           title: 'test',
           text: 'test alert',

+ 0 - 11
public/app/types/alerts.ts

@@ -1,11 +0,0 @@
-export interface AppNotification {
-  id: number;
-  severity: string;
-  icon: string;
-  title: string;
-  text: string;
-}
-
-export interface AppNotificationsState {
-  appNotifications: AppNotification[];
-}

+ 18 - 0
public/app/types/appNotifications.ts

@@ -0,0 +1,18 @@
+export interface AppNotification {
+  id?: number;
+  severity: AppNotificationSeverity;
+  icon: string;
+  title: string;
+  text: string;
+}
+
+export enum AppNotificationSeverity {
+  Success = 'success',
+  Warning = 'warning',
+  Error = 'error',
+  Info = 'info',
+}
+
+export interface AppNotificationsState {
+  appNotifications: AppNotification[];
+}

+ 2 - 1
public/app/types/index.ts

@@ -9,7 +9,7 @@ import { ApiKey, ApiKeysState, NewApiKey } from './apiKeys';
 import { Invitee, OrgUser, User, UsersState } from './user';
 import { DataSource, DataSourcesState } from './datasources';
 import { PluginDashboard, PluginMeta, Plugin, PluginsState } from './plugins';
-import { AppNotification, AppNotificationsState } from './alerts';
+import { AppNotification, AppNotificationSeverity, AppNotificationsState } from './appNotifications';
 
 export {
   Team,
@@ -49,6 +49,7 @@ export {
   PluginDashboard,
   AppNotification,
   AppNotificationsState,
+  AppNotificationSeverity,
 };
 
 export interface StoreState {