selectors.ts 668 B

12345678910111213141516171819
  1. import { AlertRule, AlertRulesState, NotificationChannelState, StoreState } from 'app/types';
  2. export const getSearchQuery = (state: AlertRulesState) => state.searchQuery;
  3. export const getAlertRuleItems = (state: StoreState): AlertRule[] => {
  4. const regex = new RegExp(state.alertRules.searchQuery, 'i');
  5. return state.alertRules.items.filter((item) => {
  6. return regex.test(item.name) || regex.test(item.stateText) || regex.test(item.info!);
  7. });
  8. };
  9. export const getNotificationChannel = (state: NotificationChannelState, channelId: number) => {
  10. if (state.notificationChannel.id === channelId) {
  11. return state.notificationChannel;
  12. }
  13. return null;
  14. };