示例#1
0
 */

const selectRemote = (state: State) => state.remote;

export const logEntriesSelectors = globalizeSelectors(selectRemote, remoteLogEntriesSelectors);
export const logSummarySelectors = globalizeSelectors(selectRemote, remoteLogSummarySelectors);
export const sourceSelectors = globalizeSelectors(selectRemote, remoteSourceSelectors);

/**
 * shared selectors
 */

export const sharedSelectors = {
  selectFirstVisibleLogEntry: createSelector(
    logEntriesSelectors.selectEntries,
    logPositionSelectors.selectFirstVisiblePosition,
    (entries, firstVisiblePosition) =>
      firstVisiblePosition ? getLogEntryAtTime(entries, firstVisiblePosition) : null
  ),
  selectMiddleVisibleLogEntry: createSelector(
    logEntriesSelectors.selectEntries,
    logPositionSelectors.selectMiddleVisiblePosition,
    (entries, middleVisiblePosition) =>
      middleVisiblePosition ? getLogEntryAtTime(entries, middleVisiblePosition) : null
  ),
  selectLastVisibleLogEntry: createSelector(
    logEntriesSelectors.selectEntries,
    logPositionSelectors.selectLastVisiblePosition,
    (entries, lastVisiblePosition) =>
      lastVisiblePosition ? getLogEntryAtTime(entries, lastVisiblePosition) : null
  ),
  selectLogFilterQueryAsJson: createSelector(
export const makeIsApplyDisabledSelector = (nodeTypesRegistry: NodeTypesRegistry, validatorRegistry: ValidatorRegistry) => createSelector(
    [
        isDirty,
        makeValidationErrorsSelector(nodeTypesRegistry, validatorRegistry)
    ],
    (
        isDirty,
        validationErrors
    ) => {
        return !isDirty || (isDirty && validationErrors !== null);
    }
);
示例#3
0
/* eslint import/prefer-default-export: 0 */
import { AppState } from 'AppState';
import { createSelector } from 'reselect';
import { filter } from 'lodash';

const device = (state: AppState) => state.device;
const devicesSelector = createSelector(
  device,
  d => d.devices
);
const layerSelector = createSelector(
  device,
  d => d.layer
);

export const filteredDevices = createSelector(
  devicesSelector,
  layerSelector,
  (devices, layer) => filter(devices, d => d.layer === layer)
);
示例#4
0
);

export const WithStreamItems = asChildFunctionRenderer(withStreamItems, {
  onInitialize: props => {
    if (!props.isReloading && !props.isLoadingMore) {
      props.reloadEntries();
    }
  },
});

const selectItems = createSelector(
  logEntriesSelectors.selectEntries,
  logEntriesSelectors.selectIsReloadingEntries,
  logPositionSelectors.selectIsAutoReloading,
  // searchResultsSelectors.selectSearchResultsById,
  (logEntries, isReloading, isAutoReloading /* , searchResults */) =>
    isReloading && !isAutoReloading
      ? []
      : logEntries.map(logEntry =>
          createLogEntryStreamItem(logEntry /* , searchResults[logEntry.gid] || null */)
        )
);

const createLogEntryStreamItem = (logEntry: LogEntry, searchResult?: SearchResult) => ({
  kind: 'logEntry' as 'logEntry',
  logEntry: {
    gid: logEntry.gid,
    origin: {
      id: logEntry.gid,
      index: '',
      type: '',
    },
import validate from '@neos-project/neos-ui-validators';
import {selectors as nodes} from '@neos-project/neos-ui-redux-store/src/CR/Nodes';
import {GlobalState} from '@neos-project/neos-ui-redux-store/src/System';
import {NodeTypesRegistry, ValidatorRegistry} from '@neos-project/neos-ts-interfaces';

/**
 * Transient values and everything which depends on this
 *
 * - transientValues
 * - propertiesForValidation (merges transientValues + selectors.CR.Nodes.focusedSelector)
 * - makeValidationErrorsSelector (contains the full validation errors)
 */
export const transientValues = createSelector(
    [
        nodes.focusedNodePathSelector,
        (state: GlobalState) => $get(['ui', 'inspector', 'valuesByNodePath'], state)
    ],
    (focusedNodeContextPath, valuesByNodePath) => focusedNodeContextPath ? valuesByNodePath[focusedNodeContextPath] : {}
);

export const isDirty = createSelector(
    [
        transientValues
    ],
    transientValues => Boolean(transientValues && (Object.keys(transientValues).length > 0))
);

export const shouldPromptToHandleUnappliedChanges = (state: GlobalState) => $get(['ui', 'inspector', 'shouldPromptToHandleUnappliedChanges'], state);

export const shouldShowSecondaryInspector = (state: GlobalState) => $get(['ui', 'inspector', 'secondaryInspectorIsOpen'], state);
import {ApplicationState} from "../store/application-state";
import {MessageVM} from "./message.vm";
import {Message} from "../../../shared/model/message";
import * as _ from 'lodash';
import {Participant} from "../../../shared/model/participant";
import { createSelector } from 'reselect';


// createSelector will rerender the ui only if participants or messages have been changed and the outcome will be
// mapMessagesToMessagesVM, this a pure function implements memoization (results stored in the cache)
export const messagesSelector = createSelector(getParticipants, getMessagesForCurrentThread, mapMessagesToMessagesVM);



function getMessagesForCurrentThread(state: ApplicationState): Message[] {
  const currentThread = state.storeData.threads[state.uiState.currentThreadId];
  // if the messageIds array is empty map will return an empty array
  return currentThread? currentThread.messageIds.map(messageId => state.storeData.messages[messageId]):
    [];
}

function getParticipants(state: ApplicationState) {
  return state.storeData.participants;
}

function mapMessagesToMessagesVM(participants: {[key: number]: Participant}, messages:Message[]){
  return messages.map(message=> {
    const participantName = participants[message.participantId].name;
    return mapMessageToMessageVM(participantName, message)
  });
}
示例#7
0
      .value();
  }

  function buildGraph(rootId) {
    var typeIds = [rootId];
    var nodes = [];
    var types = _.keyBy(schema.types, 'id');

    for (var i = 0; i < typeIds.length; ++i) {
      var id = typeIds[i];
      if (typeIds.indexOf(id) < i)
        continue;

      var type = types[id];

      nodes.push(type);
      typeIds.push(...getEdgeTargets(type));
    }
    return {
      rootId,
      nodes: _.keyBy(nodes, 'id'),
    };
  }
}

export const getTypeGraphSelector = createSelector(
  getSchemaSelector,
  state => state.displayOptions.rootTypeId,
  getTypeGraph
);
示例#8
0
import { PathAnimationBlock } from 'app/model/timeline';
import { createDeepEqualSelector, getAppState } from 'app/store/selectors';
import * as _ from 'lodash';
import { createSelector } from 'reselect';

const getTimelineState = createSelector(getAppState, s => s.timeline);
export const getAnimation = createSelector(getTimelineState, t => t.animation);
export const isAnimationSelected = createSelector(getTimelineState, t => t.isAnimationSelected);
export const getSelectedBlockIds = createDeepEqualSelector(
  getTimelineState,
  t => t.selectedBlockIds,
);
export const getSingleSelectedBlockId = createSelector(
  getSelectedBlockIds,
  blockIds => (blockIds.size === 1 ? blockIds.values().next().value : undefined),
);
export const getSingleSelectedPathBlock = createSelector(
  [getAnimation, getSingleSelectedBlockId],
  (anim, blockId) => {
    if (!blockId) {
      return undefined;
    }
    return _.find(
      anim.blocks,
      b => b.id === blockId && b instanceof PathAnimationBlock,
    ) as PathAnimationBlock;
  },
);
export const getSelectedBlockLayerIds = createDeepEqualSelector(
  [getAnimation, getSelectedBlockIds],
  (anim, blockIds) => {
示例#9
0
import { BLACK, WHITE } from './consts'

import { State } from './reducer'
import { createSelector } from 'reselect'

const selectBoard = (state: State) => state.board
const selectPlayer = (state: State) => state.player

export const createScoreSelector = () =>
  createSelector([selectBoard], board => {
    var black = 0
    var white = 0
    board.forEach(row => {
      row.forEach(col => {
        if (col === BLACK) {
          black += 1
        } else if (col === WHITE) {
          white += 1
        }
      })
    })
    return { black, white }
  })

export const startedSelector = createSelector([selectPlayer], player => !!player)
示例#10
0
        // case StatActions.REMOVE_ALL_NETWORK_ERROR:
        // case StatActions.REMOVE_ALL_NETWORK_SUCCESS:
        // case StatActions.UPDATE_ERROR:
        // case StatActions.UPDATE_NETWORK:
        // case StatActions.UPDATE_NETWORK_ERROR:
        // case StatActions.UPDATE_NETWORK_SUCCESS:
        // case StatActions.SELECT_ERROR:
        default:
            return state;
    }
}

export const getIds        = (s: StatState) => s.ids;
export const getEntities   = (s: StatState) => s.entities;
export const getSelectedId = (s: StatState) => s.selectedStatId;
export const getLastAdded  = (s: StatState) => {    
    const lastElement = s.ids.length - 1;
    return s.entities[s.ids[lastElement]];  
};

export const getStat       = createSelector(getSelectedId, getEntities, (id, stats) => stats[id]);
export const getStats      = createSelector(getIds, getEntities, (ids, entities) => {
    return ids.map(id => entities[id]);
});
export const getMeta       = createSelector(getIds, getSelectedId, (ids, selectedId) => {
    return {ids, selectedId};
});
export const getAddedMeta = createSelector(getLastAdded, getMeta, (stat, meta) => {
    return {stat, meta};
});