Skip to content
Snippets Groups Projects
Select Git revision
  • 5a8605b80e27a30c4f3f3e10999ccaf0089b388e
  • main default
  • 35-cgu
  • 34-peertube-support
  • 27-add-autoplay-to-iframe
  • 33-bug-on-youtube-embed-urls
  • RC-Rekall-v1.1-fix_lpo
  • tuleap-140-go-back-to-my-capsules-page-when-i-m-on-capsule-preview-page
  • RC-Rekall-v1.2-fix10
  • RC-Rekall-v1.2-fix9
  • RC-Rekall-v1.2-fix8
  • RC-Rekall-v1.2-fix7
  • RC-Rekall-v1.2-fix6
  • RC-Rekall-v1.2-fix5
  • RC-Rekall-v1.2-fix4
  • RC-Rekall-v1.2-fix3
  • RC-Rekall-v1.2-fix2
  • RC-Rekall-v1.2-fix1
  • RC-Rekall-v1.1-fix-3
  • RC-Rekall-v1.1-fix-2
  • RC-Rekall-v1.1-fix-1
  • RC-Rekall-v1.1-delivered
  • preprod20220209-1535
23 results

webpack.config.js

Blame
  • windows.js 2.81 KiB
    import { createSelector } from 'reselect';
    import {
      getManifestTitle,
      getManifestBehaviors,
      getManifestViewingHint,
      getManifestoInstance,
    } from './manifests';
    import { getDefaultView } from './config';
    import { getWorkspaceType } from './workspace';
    
    /**
     * Return the manifest titles for all open windows
     * @param {object} state
     * @return {object}
     */
    export function getWindowTitles(state) {
      const result = {};
    
      Object.keys(getWindows(state)).forEach((windowId) => {
        result[windowId] = getManifestTitle(state, { windowId });
      });
    
      return result;
    }
    
    /**
     * Return the manifest titles for all open windows
     * @param {object} state
     * @return {object}
     */
    export function getWindowManifests(state) {
      return Object.values(state.windows).map(window => window.manifestId);
    }
    
    /** */
    export function getWindows(state) {
      return state.windows || {};
    }
    
    /** */
    export const getWindowIds = createSelector(
      [getWindows],
      windows => Object.keys(windows),
    );
    
    /** */
    export const getMaximizedWindowsIds = createSelector(
      [getWindows],
      windows => Object.values(windows)
        .filter(window => window.maximized === true)
        .map(window => window.id),
    );
    
    /** */
    export function getWindow(state, { windowId }) {
      return getWindows(state)[windowId];
    }
    
    /** Return the canvas index for a certain window.
    * @param {object} state
    * @param {String} windowId
    * @param {Number}
    */
    export const getCanvasIndex = createSelector(
      [
        getWindow,
        getManifestoInstance,
      ],
      (window, manifest) => (
        (manifest && window && window.canvasId
          && manifest.getSequences()[0].getCanvasById(window.canvasId))
        || {}).index || 0,
    );
    
    /** Return type of view in a certain window.
    * @param {object} state
    * @param {object} props
    * @param {string} props.manifestId
    * @param {string} props.windowId
    * @param {String}
    */
    export const getWindowViewType = createSelector(
      [
        getWindow,
        getManifestViewingHint,
        getManifestBehaviors,
        getDefaultView,
      ],
      (window, manifestViewingHint, manifestBehaviors, defaultView) => {
        const lookup = {
          individuals: 'single',
          paged: 'book',
        };
        return (window && window.view)
          || lookup[manifestBehaviors.find(b => lookup[b]) || manifestViewingHint]
          || defaultView;
      },
    );
    
    export const getViewer = createSelector(
      [
        state => state.viewers,
        (state, { windowId }) => windowId,
      ],
      (viewers, windowId) => viewers[windowId],
    );
    
    /**
     * Returns the draggability of a window
     * @param {object} state
     * @param {object} props
     * @return {Boolean}
     */
    export const getWindowDraggability = createSelector(
      [
        getWorkspaceType,
        getWindow,
        state => Object.keys(state.windows).length > 1,
      ],
      (workspaceType, window, manyWindows) => {
        if (workspaceType === 'elastic') return true;
        return manyWindows && window && window.maximized === false;
      },
    );