selectors.ts 870 B

12345678910111213141516171819202122232425262728
  1. import { DataSource } from '../../../types';
  2. export const getDataSources = state => {
  3. const regex = new RegExp(state.searchQuery, 'i');
  4. return state.dataSources.filter(dataSource => {
  5. return regex.test(dataSource.name) || regex.test(dataSource.database);
  6. });
  7. };
  8. export const getDataSourceTypes = state => {
  9. const regex = new RegExp(state.dataSourceTypeSearchQuery, 'i');
  10. return state.dataSourceTypes.filter(type => {
  11. return regex.test(type.name);
  12. });
  13. };
  14. export const getDataSource = (state, dataSourceId): DataSource | null => {
  15. if (state.dataSource.id === parseInt(dataSourceId, 10)) {
  16. return state.dataSource;
  17. }
  18. return null;
  19. };
  20. export const getDataSourcesSearchQuery = state => state.searchQuery;
  21. export const getDataSourcesLayoutMode = state => state.layoutMode;
  22. export const getDataSourcesCount = state => state.dataSourcesCount;