Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { createReducer } from "redux-create-reducer";
import { combineReducers } from "redux";
import section from "./section";
import { repoDetails, view } from "./repoDetails";
import fileTree from "./fileTree";
import definition from "./definition";
import usages from "./usages";
import hoverResult from "./hoverResult";
import session from "./session";
import fileContents from "./fileContents";
import pjax from "./pjax";
const initialState = {};
const data = createReducer(initialState, {
UPDATE_DATA: (state, action: any) => ({
...state,
...action.payload
})
});
const dataReducer = combineReducers({
data,
repoDetails, // old repo details (for backward compatibility)
view, // new repo details
section,
session,
fileTree,
definition,
usages,
hoverResult,
public static create(this: (new () => IReducerClassConstraintComplete) & IReducerClassStatic): Reducer {
const instance = new this()
const keys = this.reducerClassHelpers.getClassInstanceMethodNames(instance)
const reducersWithActionTypes = this.reducerClassHelpers.getReducerClassMethodsWthActionTypes(
instance as IReducerClassConstraint,
keys,
)
const reducerMap = this.reducerClassHelpers.getReducerMap(reducersWithActionTypes)
// TODO: Remove as Handlers once https://github.com/kolodny/redux-create-reducer/pull/17 is merged
return createReducer((instance as ReducerClass).initialState, reducerMap as Handlers)
}
import { createReducer } from 'redux-create-reducer';
const loadingReducer = createReducer(false, {
START_LOADING: () => true,
STOP_LOADING: () => false,
});
export default loadingReducer;
import { createReducer } from "redux-create-reducer";
const initialState = {
base: {},
head: {}
};
export default createReducer(initialState, {
CALL_FILE_CONTENTS_FULFILLED: (state, action: any) => {
const { baseOrHead, filePath, result } = action.payload;
let newState = { ...state };
newState[baseOrHead][filePath] = result.contents;
return newState;
}
});
import {createReducer} from 'redux-create-reducer';
import * as types from './inbox-action-types';
export type InboxState = {
loading: boolean,
items: Array,
hasMore: boolean
};
const initialState: InboxState = {
loading: false,
hasMore: true,
items: []
};
export default createReducer(initialState, {
[types.SET_LOADING](state, {loading}): InboxState {
return {...state, loading};
},
[types.ADD_ITEMS](state, {items, hasMore}): InboxState {
return {...state, items: [...state.items, ...items], hasMore};
},
[types.RESET_ITEMS](state): InboxState {
return {...state, items: [], hasMore: true};
},
[types.LIST_END_REACHED](state): InboxState {
return {...state, hasMore: false};
}
});
const initialState: CreateIssueState = {
processing: false,
attachingImage: null,
predefinedDraftId: null,
issue: {
summary: '',
description: '',
attachments: [],
fields: [],
project: notSelectedProject
}
};
export default createReducer(initialState, {
[LOG_OUT](state: CreateIssueState, action: {draftId: string}): CreateIssueState {
return initialState;
},
[types.SET_ISSUE_PREDEFINED_DRAFT_ID](state: CreateIssueState, action: {draftId: string}): CreateIssueState {
return {...state, predefinedDraftId: action.draftId};
},
[types.SET_ISSUE_DRAFT](state: CreateIssueState, action: {issue: IssueFull}): CreateIssueState {
return {...state, issue: {...state.issue, ...action.issue}};
},
[types.RESET_ISSUE_DRAFT](state: CreateIssueState): CreateIssueState {
return {
...state,
issue: {
...state.issue,
id: null
}
const initialState: IssuesListState = {
query: '',
queryAssistSuggestions: [],
skip: 0,
isLoadingMore: false,
isListEndReached: false,
loadingError: null,
isInitialized: false,
isRefreshing: false,
issuesCount: null,
issues: []
};
export default createReducer(initialState, {
[LOG_OUT]: (state: IssuesListState): IssuesListState => {
return initialState;
},
[ISSUE_CREATED]: (state: IssuesListState, action: {issue: IssueFull}): IssuesListState => {
return {...state, issues: [action.issue, ...state.issues]};
},
[types.SET_ISSUES_QUERY]: (state: IssuesListState, action: Object) => {
return {...state, query: action.query};
},
[types.SUGGEST_QUERY]: (state: IssuesListState, action: Object) => {
return {...state, queryAssistSuggestions: action.suggestions};
},
[types.CLEAR_SUGGESTIONS]: (state: IssuesListState, action: Object) => {
return {...state, queryAssistSuggestions: []};
},
[types.START_ISSUES_LOADING]: (state: IssuesListState, action: Object) => {
);
export const getDebugger = (state) => {
if (!state.debugger) {
return {};
}
return {
...state.debugger,
events: state.debugger.events.filter((e) => (
matchLogLevel(state, e.logType) && (state.debugger.debugTypes || []).includes(e.type)
)).sort((a,b) => b.date - a.date),
};
};
export default createReducer(initialState, {
[INIT]: (state, { payload }) => ({
...state,
...payload,
}),
[DEBUG_EVENTS]: (state, { payload }) => ({
...state,
events: [
...payload,
...state.events.slice(0, 200),
],
}),
[CLOSE]: (state) => ({
...state,
isVisible: false,
}),
[SHOW]: (state) => ({
};
const initialPageState: AgilePageState = {
isLoading: false,
profile: null,
noBoardSelected: false,
isSprintSelectOpen: false,
isOutOfDate: false,
creatingIssueDraftId: null,
creatingIssueDraftCellId: null,
selectProps: null,
sprint: null,
serversideEvents: null
};
const boardReducer = createReducer({}, {
[types.RECEIVE_SWIMLANES](state: BoardState, action: Object): BoardState {
return {
...state,
trimmedSwimlanes: [...state.trimmedSwimlanes, ...action.swimlanes]
};
},
[types.ROW_COLLAPSE_TOGGLE](state: BoardState, action: {row: AgileBoardRow, newCollapsed: boolean}): BoardState {
return updateRowCollapsedState(state, action.row, action.newCollapsed);
},
[types.COLUMN_COLLAPSE_TOGGLE](state: BoardState, action: Object): BoardState {
return {
...state,
columns: (state.columns || []).map(it => {
return it === action.column ? {...action.column, collapsed: action.newCollapsed} : it;
})
};