Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Copyright (c) 2019 SafetyCulture Pty Ltd. All Rights Reserved.
import { createSlice } from "redux-starter-kit";
const toolbarSlice = createSlice({
slice: 'toolbar',
initialState: {
filterIsOpen: true,
filterIsEnabled: false,
filterValue: "",
},
reducers: {
toggleFilter(state) {
state.filterIsOpen = !state.filterIsOpen;
},
setFilterValue(state, action) {
const { payload } = action;
state.filterValue = payload;
state.filterIsEnabled = !!(state.filterValue && state.filterValue.length > 0);
}
},
import { createSlice } from 'redux-starter-kit';
// To handle webpack state
const webpack = createSlice({
slice: "webpack",
initialState: "",
reducers: {
update: (state, action) => action.payload,
}
});
export const { actions, reducer } = webpack;
const { update } = actions;
export const refresh = () => async (dispatch) => {
const webpack = await request('/api/init', {type: "refresh"});
dispatch(update(webpack.webpack));
}
/* eslint-disable no-param-reassign */
import { createSlice } from 'redux-starter-kit';
const usersSlice = createSlice({
name: 'users',
initialState: {
list: [],
fetching: false,
},
reducers: {
fetchUser: state => {
state.fetching = true;
state.list = [];
},
fetchUsers: state => {
state.fetching = true;
state.list = [];
},
fetchUserSuccess(state, { payload }) {
state.fetching = false;
import { createSlice } from "redux-starter-kit";
import Fuse from 'fuse.js';
import { setFilterValue } from "./toolbar";
var options = {
shouldSort: false,
threshold: 0.1,
distance: 10000,
keys: [
'method',
]
};
var fuse = new Fuse(null, options);
const networkSlice = createSlice({
slice: 'network',
initialState: {
preserveLog: false,
selectedIdx: null,
selectedEntry: null,
log: [
],
_filterValue: '',
_logBak: [],
},
reducers: {
networkLog(state, action) {
const { log, _filterValue, _logBak } = state;
const { payload, } = action;
if (payload.method) {
const parts = payload.method.split('/')
import { createSlice, PayloadAction, Action } from "redux-starter-kit";
import { ThunkAction } from "redux-thunk";
import { getRepoDetails, RepoDetails } from "api/githubAPI";
import { RootState } from "store";
interface RepoDetailsState {
openIssuesCount: number;
error: Error | null;
}
const repoDetails = createSlice({
slice: "repoDetails",
initialState: {
openIssuesCount: -1,
error: null,
} as RepoDetailsState,
reducers: {
getRepoDetailsSuccess(state, action: PayloadAction) {
state.openIssuesCount = action.payload.open_issues_count;
state.error = null;
},
getRepoDetailsFailed(state, action: PayloadAction) {
state.openIssuesCount = -1;
state.error = action.payload;
},
},
});
type CurrentDisplayState = {
page: number;
} & CurrentDisplay &
CurrentRepo;
let initialState: CurrentDisplayState = {
org: "rails",
repo: "rails",
page: 1,
displayType: "issues",
issueId: 0,
};
type IST = (typeof initialState)["displayType"];
const issuesDisplay = createSlice({
slice: "issuesDisplay",
initialState,
reducers: {
displayRepo(state, action: PayloadAction) {
const { org, repo } = action.payload;
state.org = org;
state.repo = repo;
},
setCurrentPage(state, action: PayloadAction) {
state.page = action.payload;
},
setCurrentDisplayType(state, action: PayloadAction) {
const { displayType, issueId } = action.payload;
state.displayType = displayType;
if (issueId !== undefined) {
state.issueId = issueId;
import { createSlice } from "redux-starter-kit";
import * as actions from "../actions";
const metadata = createSlice({
slice: "metadata",
initialState: {},
reducers: actions.metadataActions
});
const accounts = createSlice({
slice: "accounts",
initialState: {},
reducers: actions.accountActions
});
export { metadata, accounts };
import { createSlice } from "redux-starter-kit";
import * as actions from "../actions";
const metadata = createSlice({
slice: "metadata",
initialState: {},
reducers: actions.metadataActions
});
const accounts = createSlice({
slice: "accounts",
initialState: {},
reducers: actions.accountActions
});
export { metadata, accounts };
import {createSlice} from 'redux-starter-kit';
const userSlice = createSlice({
slice: 'users',
initialState: {loggedIn: false, onCheck: false},
reducers: {
login: state => ({...state, onCheck: true}),
loginSuccess(state) {
state.onCheck = false;
state.loggedIn = true;
},
logout: state => ({...state, onCheck: true}),
logoutSuccess(state) {
state.onCheck = false;
state.loggedIn = false;
},
},
});
state.map(todo =>
todo.id === action.payload.id
? { ...todo, completed: !todo.completed }
: todo
);
const completeAllTodos = state => {
const areAllMarked = state.every(todo => todo.completed);
return state.map(todo => ({
...todo,
completed: !areAllMarked
}));
};
const clearCompleted = state => state.filter(todo => todo.completed === false);
const todos = createSlice({
slice: "todos",
initialState: [],
reducers: {
add: addTodo,
delete: deleteTodo,
edit: editTodo,
complete: completeTodo,
completeAll: completeAllTodos,
clearCompleted: clearCompleted
}
});
todos.selectors.getVisibleTodos = createSelector(
[getVisibilityFilter, todos.selectors.getTodos],
(visibilityFilter, todos) => {
switch (visibilityFilter) {