@@ -6,10 +6,10 @@ import PropTypes from 'prop-types';
6
6
import Typography from '@material-ui/core/Typography' ;
7
7
import { withTranslation } from 'react-i18next' ;
8
8
import { withStyles } from '@material-ui/core' ;
9
- import { getDatabase , setDatabase } from '../../actions' ;
9
+ import { getDatabase } from '../../actions' ;
10
10
import Loader from '../common/Loader' ;
11
11
import Styles from '../../Styles' ;
12
- import SampleDatabase from '../../data/sample.json ' ;
12
+ import { FILTER_ALL_SPACE_ID } from '../../config/constants ' ;
13
13
14
14
export class ActionEditor extends Component {
15
15
static propTypes = {
@@ -18,44 +18,40 @@ export class ActionEditor extends Component {
18
18
button : PropTypes . string . isRequired ,
19
19
} ) . isRequired ,
20
20
dispatchGetDatabase : PropTypes . func . isRequired ,
21
- dispatchSetDatabase : PropTypes . func . isRequired ,
22
21
database : PropTypes . shape ( {
23
22
user : PropTypes . object ,
24
- spaces : PropTypes . array ,
25
- actions : PropTypes . array ,
23
+ spaces : PropTypes . arrayOf ( PropTypes . object ) ,
24
+ actions : PropTypes . arrayOf ( PropTypes . object ) ,
26
25
} ) ,
26
+ spaceId : PropTypes . string ,
27
27
} ;
28
28
29
29
static defaultProps = {
30
30
database : { } ,
31
+ spaceId : FILTER_ALL_SPACE_ID ,
31
32
} ;
32
33
33
34
componentDidMount ( ) {
34
35
const { dispatchGetDatabase } = this . props ;
35
36
dispatchGetDatabase ( ) ;
36
37
}
37
38
38
- handleEdit = ( { updated_src : updatedSrc } ) => {
39
- const { dispatchSetDatabase } = this . props ;
40
- dispatchSetDatabase ( updatedSrc ) ;
41
- } ;
42
-
43
- handleUseSampleDatabase = ( ) => {
44
- const { dispatchSetDatabase } = this . props ;
45
- dispatchSetDatabase ( SampleDatabase ) ;
46
- } ;
47
-
48
39
render ( ) {
49
- const { database, t } = this . props ;
40
+ const { database, t, spaceId } = this . props ;
50
41
51
42
if ( ! database || _ . isEmpty ( database ) ) {
52
43
return < Loader /> ;
53
44
}
54
45
46
+ let { actions } = database ;
47
+ if ( spaceId !== FILTER_ALL_SPACE_ID ) {
48
+ actions = actions . filter ( ( { spaceId : id } ) => id === spaceId ) ;
49
+ }
50
+
55
51
return (
56
52
< div >
57
53
< Typography variant = "h6" > { t ( 'View Action Database' ) } </ Typography >
58
- < ReactJson name = "actions" collapsed src = { database . actions } />
54
+ < ReactJson name = "actions" collapsed src = { actions } />
59
55
</ div >
60
56
) ;
61
57
}
@@ -67,7 +63,6 @@ const mapStateToProps = ({ Developer }) => ({
67
63
68
64
const mapDispatchToProps = {
69
65
dispatchGetDatabase : getDatabase ,
70
- dispatchSetDatabase : setDatabase ,
71
66
} ;
72
67
73
68
const StyledComponent = withStyles ( Styles , { withTheme : true } ) ( ActionEditor ) ;
0 commit comments