All files / src/apps/sources/redux selectors.ts

66.67% Statements 14/21
0% Branches 0/4
0% Functions 0/3
73.68% Lines 14/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77                                        1x   1x   1x     1x       1x       1x       1x             1x       1x     1x       1x       1x   1x             1x            
import {
  AppState,
  errorSelector,
  indexedAction,
  loadingSelector
} from "../../../redux";
import {
  ORG_SOURCES_ACTION_INDEX,
  PERSONAL_SOURCES_ACTION_INDEX,
  PUBLIC_SOURCES_ACTION_INDEX
} from "./constants";
import {
  CREATE_SOURCE_ACTION,
  EDIT_SOURCE_ACTION,
  RETRIEVE_SOURCE_ACTION,
  RETRIEVE_SOURCES_ACTION,
  RETRIEVE_SOURCE_VERSIONS_ACTION,
  CREATE_SOURCE_VERSION_ACTION
} from "./actionTypes";
 
export const createSourceErrorSelector = errorSelector(CREATE_SOURCE_ACTION);
 
export const editSourceErrorSelector = errorSelector(EDIT_SOURCE_ACTION);
 
export const retrievePersonalSourcesLoadingSelector = loadingSelector(
  indexedAction(RETRIEVE_SOURCES_ACTION, PERSONAL_SOURCES_ACTION_INDEX)
);
export const retrieveOrgSourcesLoadingSelector = loadingSelector(
  indexedAction(RETRIEVE_SOURCES_ACTION, ORG_SOURCES_ACTION_INDEX)
);
 
export const retrieveSourceVersionLoadingSelector = loadingSelector(
  RETRIEVE_SOURCE_VERSIONS_ACTION
);
 
export const createSourceVersionLoadingSelector = loadingSelector(
  CREATE_SOURCE_VERSION_ACTION
);
 
export const createSourceVersionErrorSelector = errorSelector(
  CREATE_SOURCE_VERSION_ACTION
);
export function sourceSelector(state: AppState) {
  return state.sources.source;
}
 
export const retrieveSourceErrorSelector = errorSelector(
  RETRIEVE_SOURCE_ACTION
);
 
export const retrieveSourceLoadingSelector = loadingSelector(
  RETRIEVE_SOURCE_ACTION
);
export const retrievePublicSourcesLoadingSelector = loadingSelector(
  indexedAction(RETRIEVE_SOURCES_ACTION, PUBLIC_SOURCES_ACTION_INDEX)
);
 
export const createSourceLoadingSelector = loadingSelector(
  CREATE_SOURCE_ACTION
);
 
export const editSourceLoadingSelector = loadingSelector(EDIT_SOURCE_ACTION);
 
export const createSourceErrorsSelector = (
  state: AppState
): { [key: string]: string[] | undefined } | undefined => {
  const createSourceErrors = createSourceErrorSelector(state);
  if (createSourceErrors) return createSourceErrors;
};
 
export const editSourceErrorsSelector = (
  state: AppState
): { [key: string]: string[] | undefined } | undefined => {
  const editSourceErrors = editSourceErrorSelector(state);
  if (editSourceErrors) return editSourceErrors;
};