Sha256: 6b7d5b4765f58a4f5fb1698ff0893783e486ff45f33c1cc81f1ae3c384ad47f1
Contents?: true
Size: 1.75 KB
Versions: 13
Compression:
Stored size: 1.75 KB
Contents
import { STATUS } from 'foremanReact/constants'; import { deepPropsToCamelCase } from 'foremanReact/common/helpers'; import { selectAPIStatus, selectAPIResponse, } from 'foremanReact/redux/API/APISelectors'; import { WEBHOOK_TEMPLATES_API_REQUEST_KEY, WEBHOOK_EVENTS_API_REQUEST_KEY, } from '../../constants'; // Webhook templates selectors const selectWebhookFormTemplatesResponse = state => deepPropsToCamelCase( selectAPIResponse(state, WEBHOOK_TEMPLATES_API_REQUEST_KEY) ); const selectWebhookFormTemplatesStatus = state => selectAPIStatus(state, WEBHOOK_TEMPLATES_API_REQUEST_KEY); export const selectTemplatesHasError = state => selectWebhookFormTemplatesStatus(state) === STATUS.ERROR; export const selectTemplatesIsLoading = state => { const status = selectWebhookFormTemplatesStatus(state); return !status || status === STATUS.PENDING; }; export const selectWebhookTemplates = state => { if (selectTemplatesHasError(state) || selectTemplatesIsLoading(state)) return []; return selectWebhookFormTemplatesResponse(state).results; }; // Webhook events selectors const selectWebhookFormEventsResponse = state => deepPropsToCamelCase( selectAPIResponse(state, WEBHOOK_EVENTS_API_REQUEST_KEY) ); const selectWebhookFormEventsStatus = state => selectAPIStatus(state, WEBHOOK_EVENTS_API_REQUEST_KEY); export const selectEventsHasError = state => selectWebhookFormEventsStatus(state) === STATUS.ERROR; export const selectEventsIsLoading = state => { const status = selectWebhookFormEventsStatus(state); return !status || status === STATUS.PENDING; }; export const selectWebhookEvents = state => { if (selectEventsHasError(state) || selectEventsIsLoading(state)) return []; return selectWebhookFormEventsResponse(state); };
Version data entries
13 entries across 13 versions & 1 rubygems