{"size": 1889, "ext": "js", "max_stars_repo_path": "src/js/view/reducers/topPanelReducer.js", "max_stars_repo_name": "kits-ab/LogLady", "max_stars_repo_stars_event_min_datetime": "2019-03-01T08:44:25.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-26T19:04:33.000Z", "max_issues_repo_path": "src/js/view/reducers/topPanelReducer.js", "max_issues_repo_name": "kits-ab/logs-in-action", "max_issues_repo_issues_event_min_datetime": "2019-02-22T09:17:27.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T18:54:53.000Z", "max_forks_repo_path": "src/js/view/reducers/topPanelReducer.js", "max_forks_repo_name": "kits-ab/LogLady", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 6, "max_issues_count": 360, "max_forks_count": null, "avg_line_length": 24.5324675325, "max_line_length": 67, "alphanum_fraction": 0.4997353097}
const initialTabState = {
  tailSwitch: false,
  highlightInput: '',
  filterInput: ''
};

const initialState = {
  settings: {}
};

export const topPanelReducer = (state = initialState, action) => {
  switch (action.type) {
    case 'tailSwitch': {
      const { sourcePath } = action.data;
      return {
        settings: {
          ...state.settings,
          [sourcePath]: {
            ...state.settings[sourcePath],
            tailSwitch: !state.settings[sourcePath].tailSwitch
          }
        }
      };
    }
    case 'filterInput': {
      const { sourcePath } = action.data;

      return {
        settings: {
          ...state.settings,
          [sourcePath]: {
            ...state.settings[sourcePath],
            filterInput: action.data.text
          }
        }
      };
    }
    case 'highlightInput': {
      const { sourcePath } = action.data;

      return {
        settings: {
          ...state.settings,
          [sourcePath]: {
            ...state.settings[sourcePath],
            highlightInput: action.data.text
          }
        }
      };
    }
    case 'CREATE_SETTINGS_OBJECT': {
      const { sourcePath } = action.data;
      return {
        settings: {
          ...state.settings,
          [sourcePath]: initialTabState
        }
      };
    }
    case 'TOPPANEL_REMOVE_LOGSETTINGS': {
      const { sourcePath } = action.data;
      const settingsToKeep = {};
      Object.keys(state.settings).forEach(source => {
        let settings = state.settings[source];
        if (source !== sourcePath) {
          settingsToKeep[source] = settings;
        }
      });
      return { ...state, settings: { ...settingsToKeep } };
    }
    case 'TOP_PANEL_STATE_RESTORE':
      return { ...initialState, ...action.data };
    default:
      return state;
  }
};
