projects
/
arvados-workbench2.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '14602_admin_compute_node_paginations'
[arvados-workbench2.git]
/
src
/
store
/
dialog
/
with-dialog.ts
diff --git
a/src/store/dialog/with-dialog.ts
b/src/store/dialog/with-dialog.ts
index 42ae73e4a46ddabfe3959bd6b7db99ce725969de..41dcd559c6a47033d779a339bd82f5953d05835e 100644
(file)
--- a/
src/store/dialog/with-dialog.ts
+++ b/
src/store/dialog/with-dialog.ts
@@
-8,26
+8,28
@@
import { DialogState } from './dialog-reducer';
import { Dispatch } from 'redux';
import { dialogActions } from './dialog-actions';
import { Dispatch } from 'redux';
import { dialogActions } from './dialog-actions';
-export type WithDialog<T> = {
+export type WithDialog
StateProps
<T> = {
open: boolean;
open: boolean;
- data
?
: T;
+ data: T;
};
};
-export type WithDialog
Action
s = {
+export type WithDialog
DispatchProp
s = {
closeDialog: () => void;
};
closeDialog: () => void;
};
+export type WithDialogProps<T> = WithDialogStateProps<T> & WithDialogDispatchProps;
export const withDialog = (id: string) =>
export const withDialog = (id: string) =>
- <T>(component: React.ComponentType<WithDialog<T> & WithDialogActions>) =>
+ // TODO: How to make compiler happy with & P instead of & any?
+ <T, P>(component: React.ComponentType<WithDialogProps<T> & any>) =>
connect(mapStateToProps(id), mapDispatchToProps(id))(component);
connect(mapStateToProps(id), mapDispatchToProps(id))(component);
-export const mapStateToProps = (id: string) => <T>(state: { dialog: DialogState }): WithDialog<T> => {
+export const mapStateToProps = (id: string) => <T>(state: { dialog: DialogState }): WithDialog
StateProps
<T> => {
const dialog = state.dialog[id];
const dialog = state.dialog[id];
- return dialog ? dialog : { open: false };
+ return dialog ? dialog : { open: false
, data: {}
};
};
};
-export const mapDispatchToProps = (id: string) => (dispatch: Dispatch): WithDialog
Action
s => ({
+export const mapDispatchToProps = (id: string) => (dispatch: Dispatch): WithDialog
DispatchProp
s => ({
closeDialog: () => {
dispatch(dialogActions.CLOSE_DIALOG({ id }));
}
closeDialog: () => {
dispatch(dialogActions.CLOSE_DIALOG({ id }));
}
-});
\ No newline at end of file
+});