projects
/
arvados-workbench2.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make use of ahell-quote lib in command window, add copy command button
[arvados-workbench2.git]
/
src
/
store
/
progress-indicator
/
progress-indicator-reducer.ts
diff --git
a/src/store/progress-indicator/progress-indicator-reducer.ts
b/src/store/progress-indicator/progress-indicator-reducer.ts
index 4889bace06edba27da76ca1c15a4ea8088a91d55..89885afb526ee7b904855e2bfab15c2f8ea8b5fe 100644
(file)
--- a/
src/store/progress-indicator/progress-indicator-reducer.ts
+++ b/
src/store/progress-indicator/progress-indicator-reducer.ts
@@
-9,17
+9,17
@@
export type ProgressIndicatorState = { id: string, working: boolean }[];
const initialState: ProgressIndicatorState = [];
export const progressIndicatorReducer = (state: ProgressIndicatorState = initialState, action: ProgressIndicatorAction) => {
const initialState: ProgressIndicatorState = [];
export const progressIndicatorReducer = (state: ProgressIndicatorState = initialState, action: ProgressIndicatorAction) => {
- const startWorking = (id: string) => state.find(p => p.
working
) ? state : state.concat({ id, working: true });
+ const startWorking = (id: string) => state.find(p => p.
id === id
) ? state : state.concat({ id, working: true });
const stopWorking = (id: string) => state.filter(p => p.id !== id);
return progressIndicatorActions.match(action, {
const stopWorking = (id: string) => state.filter(p => p.id !== id);
return progressIndicatorActions.match(action, {
- START: id => startWorking(id),
- STOP: id => stopWorking(id),
- PERSIST_STOP: id => state.map(p => ({
-
id
,
+ START
_WORKING
: id => startWorking(id),
+ STOP
_WORKING
: id => stopWorking(id),
+ PERSIST_STOP
_WORKING
: id => state.map(p => ({
+
...p
,
working: p.id === id ? false : p.working
})),
working: p.id === id ? false : p.working
})),
- TOGGLE: ({ id, working }) => working ? startWorking(id) : stopWorking(id),
+ TOGGLE
_WORKING
: ({ id, working }) => working ? startWorking(id) : stopWorking(id),
default: () => state,
});
};
default: () => state,
});
};
@@
-27,3
+27,7
@@
export const progressIndicatorReducer = (state: ProgressIndicatorState = initial
export function isSystemWorking(state: ProgressIndicatorState): boolean {
return state.length > 0 && state.reduce((working, p) => working ? true : p.working, false);
}
export function isSystemWorking(state: ProgressIndicatorState): boolean {
return state.length > 0 && state.reduce((working, p) => working ? true : p.working, false);
}
+
+export const getProgressIndicator = (id: string) =>
+ (state: ProgressIndicatorState) =>
+ state.find(state => state.id === id);