mirror of
https://github.com/bendtherules/github-delete-unused-repos.git
synced 2026-08-18 13:52:59 +00:00
@@ -57,6 +57,9 @@ export class App extends React.Component<AppPropTypes, { username: string | unde
|
|||||||
}, {
|
}, {
|
||||||
Header: FilterSteps.noCommits,
|
Header: FilterSteps.noCommits,
|
||||||
accessor: `filterState.${FilterSteps.noCommits}.status`
|
accessor: `filterState.${FilterSteps.noCommits}.status`
|
||||||
|
}, {
|
||||||
|
Header: FilterSteps.aggregated,
|
||||||
|
accessor: `filterState.${FilterSteps.aggregated}.status`
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export enum FilterSteps {
|
|||||||
notForkContributor = 'notForkContributor',
|
notForkContributor = 'notForkContributor',
|
||||||
notParentContributor = 'notParentContributor',
|
notParentContributor = 'notParentContributor',
|
||||||
noCommits = 'noCommits',
|
noCommits = 'noCommits',
|
||||||
|
aggregated = 'aggregated',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum FilterStatus {
|
export enum FilterStatus {
|
||||||
@@ -52,6 +53,10 @@ export interface RepoFilterState {
|
|||||||
status: FilterStatus;
|
status: FilterStatus;
|
||||||
// failReason?: FailReasons.NoCommits;
|
// failReason?: FailReasons.NoCommits;
|
||||||
};
|
};
|
||||||
|
[FilterSteps.aggregated]: {
|
||||||
|
status: FilterStatus;
|
||||||
|
// failReason?: FailReasons.NoCommits;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RepoFilterStateMap = Map<
|
export type RepoFilterStateMap = Map<
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Reducer, createStore, Store } from 'redux';
|
import { Reducer, createStore, Store } from 'redux';
|
||||||
import { devToolsEnhancer } from 'redux-devtools-extension';
|
import { devToolsEnhancer } from 'redux-devtools-extension';
|
||||||
|
|
||||||
import { ApplicationState, FilterStatus, RepoFilterState } from './model';
|
import { ApplicationState, FilterStatus, RepoFilterState, FilterSteps } from './model';
|
||||||
import {
|
import {
|
||||||
ActionNames,
|
ActionNames,
|
||||||
InitUserNameArgs,
|
InitUserNameArgs,
|
||||||
@@ -10,6 +10,26 @@ import {
|
|||||||
ActionsType,
|
ActionsType,
|
||||||
} from './actions';
|
} from './actions';
|
||||||
|
|
||||||
|
|
||||||
|
function calculateAggregateStatus(repoFilterState: RepoFilterState) {
|
||||||
|
let aggregatedStatus = FilterStatus.pass;
|
||||||
|
|
||||||
|
const filterStepValues = Object.values(FilterSteps) as FilterSteps[];
|
||||||
|
|
||||||
|
|
||||||
|
for (const stepName of filterStepValues) {
|
||||||
|
const stepStatus = repoFilterState[stepName].status;
|
||||||
|
if (stepStatus === FilterStatus.fail) {
|
||||||
|
aggregatedStatus = FilterStatus.fail;
|
||||||
|
break;
|
||||||
|
} else if (stepStatus === FilterStatus.waiting) {
|
||||||
|
aggregatedStatus = FilterStatus.waiting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return aggregatedStatus;
|
||||||
|
}
|
||||||
|
|
||||||
export const initialState: ApplicationState = {
|
export const initialState: ApplicationState = {
|
||||||
username: '',
|
username: '',
|
||||||
repoStateMap: new Map(),
|
repoStateMap: new Map(),
|
||||||
@@ -23,7 +43,7 @@ export const reducer: Reducer<ApplicationState, ActionsType> = (
|
|||||||
// all the cases handled.
|
// all the cases handled.
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ActionNames.InitUserName:
|
case ActionNames.InitUserName:
|
||||||
return { ...state, username: action.payload.userName };
|
return { ...initialState, username: action.payload.userName };
|
||||||
|
|
||||||
case ActionNames.InitRepo: {
|
case ActionNames.InitRepo: {
|
||||||
const clonedAppState = new Map(state.repoStateMap);
|
const clonedAppState = new Map(state.repoStateMap);
|
||||||
@@ -44,6 +64,9 @@ export const reducer: Reducer<ApplicationState, ActionsType> = (
|
|||||||
noCommits: {
|
noCommits: {
|
||||||
status: FilterStatus.waiting,
|
status: FilterStatus.waiting,
|
||||||
},
|
},
|
||||||
|
aggregated: {
|
||||||
|
status: FilterStatus.waiting,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return { ...state, repoStateMap: clonedAppState };
|
return { ...state, repoStateMap: clonedAppState };
|
||||||
@@ -62,6 +85,9 @@ export const reducer: Reducer<ApplicationState, ActionsType> = (
|
|||||||
clonedRepoState.filterState[action.payload.filterStep] =
|
clonedRepoState.filterState[action.payload.filterStep] =
|
||||||
action.payload.filterState;
|
action.payload.filterState;
|
||||||
|
|
||||||
|
clonedRepoState.filterState[FilterSteps.aggregated].status =
|
||||||
|
calculateAggregateStatus(clonedRepoState.filterState);
|
||||||
|
|
||||||
clonedAppState.set(action.payload.repoName, clonedRepoState);
|
clonedAppState.set(action.payload.repoName, clonedRepoState);
|
||||||
return { ...state, repoStateMap: clonedAppState };
|
return { ...state, repoStateMap: clonedAppState };
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user