export default function sidebar()

in app/addons/documents/sidebar/reducers.js [158:252]


export default function sidebar(state = initialState, action) {
  const { options } = action;
  switch (action.type) {

    case ActionTypes.SIDEBAR_EXPAND_SELECTED_ITEM:
      return expandSelectedItem(state, options);

    case ActionTypes.SIDEBAR_NEW_OPTIONS:
      return setNewOptions(state, options);

    case ActionTypes.SIDEBAR_TOGGLE_CONTENT:
      return toggleContent(state, action.designDoc, action.indexGroup);

    case ActionTypes.SIDEBAR_FETCHING:
      return {
        ...state,
        loading: true
      };

    case ActionTypes.SIDEBAR_SHOW_DELETE_INDEX_MODAL:
      return {
        ...state,
        deleteIndexModalIndexName: options.indexName,
        deleteIndexModalDesignDocName: options.designDocName,
        deleteIndexModalVisible: true,
        deleteIndexModalText: (
          <div>
            Are you sure you want to delete the <code>{options.indexName}</code> {options.indexLabel}?
          </div>
        ),
        deleteIndexModalOnSubmit: options.onDelete
      };


    case ActionTypes.SIDEBAR_HIDE_DELETE_INDEX_MODAL:
      return {
        ...state,
        deleteIndexModalVisible: false
      };

    case ActionTypes.SIDEBAR_SHOW_CLONE_INDEX_MODAL:
      return {
        ...state,
        cloneIndexModalIndexLabel: options.indexLabel,
        cloneIndexModalTitle: options.cloneIndexModalTitle,
        cloneIndexModalSourceIndexName: options.sourceIndexName,
        cloneIndexModalSourceDesignDocName: options.sourceDesignDocName,
        cloneIndexModalSelectedDesignDoc: '_design/' + options.sourceDesignDocName,
        cloneIndexDesignDocProp: '',
        cloneIndexModalVisible: true,
        cloneIndexModalOnSubmit: options.onSubmit
      };

    case ActionTypes.SIDEBAR_HIDE_CLONE_INDEX_MODAL:
      return {
        ...state,
        cloneIndexModalVisible: false
      };

    case ActionTypes.SIDEBAR_CLONE_MODAL_DESIGN_DOC_CHANGE:
      return {
        ...state,
        cloneIndexModalSelectedDesignDoc: options.value
      };

    case ActionTypes.SIDEBAR_CLONE_MODAL_DESIGN_DOC_NEW_NAME_UPDATED:
      return {
        ...state,
        cloneIndexModalNewDesignDocName: options.value
      };

    case ActionTypes.SIDEBAR_CLONE_MODAL_DESIGN_DOC_NEW_PARTITIONED_UPDATED:
      return {
        ...state,
        cloneIndexModalNewDesignDocPartitioned: options.value
      };

    case ActionTypes.SIDEBAR_CLONE_MODAL_UPDATE_INDEX_NAME:
      return {
        ...state,
        cloneIndexModalNewIndexName: options.value
      };

    case ActionTypes.SIDEBAR_UPDATED_DESIGN_DOCS:
      return {
        ...state,
        designDocs: options.designDocs,
        designDocList: getDesignDocList(options.designDocs),
        loading: false
      };

    default:
      return state;
  }
}