Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 KB | None | 0 0
  1. Index: src/components/RoleList.js
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. --- src/components/RoleList.js (date 1542022707035)
  7. +++ src/components/RoleList.js (date 1542022707035)
  8. @@ -0,0 +1,1 @@
  9. +import React from 'react';
  10. Index: src/components/UserForm.js
  11. IDEA additional info:
  12. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  13. <+>UTF-8
  14. ===================================================================
  15. --- src/components/UserForm.js (date 1542022707036)
  16. +++ src/components/UserForm.js (date 1542022707036)
  17. @@ -0,0 +1,1 @@
  18. +import React from 'react';
  19. Index: src/containers/UserFormContainer.js
  20. IDEA additional info:
  21. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  22. <+>UTF-8
  23. ===================================================================
  24. --- src/containers/UserFormContainer.js (date 1542026856188)
  25. +++ src/containers/UserFormContainer.js (date 1542026856188)
  26. @@ -0,0 +1,124 @@
  27. +import React from 'react';
  28. +import Paper from '@material-ui/core/Paper';
  29. +import Tab from '@material-ui/core/Tab';
  30. +import Tabs from '@material-ui/core/Tabs';
  31. +import Typography from '@material-ui/core/Typography';
  32. +import withStyles from '@material-ui/core/styles/withStyles';
  33. +
  34. +const styles = theme => ({
  35. + paper: {
  36. + width: 1024,
  37. + margin: '64px auto',
  38. + padding: `${theme.spacing.unit * 3}px`
  39. + },
  40. + tabs: {
  41. + marginTop: theme.spacing.unit * 7
  42. + }
  43. +});
  44. +
  45. +class UserFormContainer extends React.Component {
  46. +
  47. + constructor(props) {
  48. + super(props);
  49. +
  50. + this.state = {
  51. + form: {
  52. + client: '',
  53. + emailAddress: '',
  54. + password: '',
  55. + replicatedPassword: '',
  56. + firstName: '',
  57. + lastName: ''
  58. + },
  59. + modeConfiguration: {
  60. + cardTitle: '',
  61. + submitButtonText: ''
  62. + },
  63. + selectedTab: 0,
  64. + selectedUser: {
  65. + id: '',
  66. + client: '',
  67. + emailAddress: '',
  68. + password: '',
  69. + firstName: '',
  70. + lastName: '',
  71. + permissions: {
  72. + roleSet: [],
  73. + customPermissionSet: [],
  74. + isSuperAdmin: false
  75. + }
  76. + }
  77. + };
  78. + }
  79. +
  80. + componentDidMount() {
  81. + if (this.props.mode === 'create') {
  82. + const modeConfiguration = this.state.modeConfiguration;
  83. + modeConfiguration.paperTitle = 'Create user';
  84. + modeConfiguration.submitButtonText = 'Create';
  85. +
  86. + this.setState({
  87. + modeConfiguration: modeConfiguration
  88. + });
  89. + }
  90. +
  91. + if (this.props.mode === 'edit') {
  92. + const modeConfiguration = this.state.modeConfiguration;
  93. + modeConfiguration.paperTitle = 'Edit user';
  94. + modeConfiguration.submitButtonText = 'Edit';
  95. +
  96. + this.setState({
  97. + modeConfiguration: modeConfiguration
  98. + });
  99. + }
  100. + }
  101. +
  102. + handleInputChange = event => {
  103. + const name = event.target.name;
  104. + const value = event.target.value;
  105. +
  106. + const form = this.state.form;
  107. + form[ name ] = value;
  108. +
  109. + this.setState({
  110. + form: form
  111. + });
  112. + };
  113. +
  114. + handleTabChange = (event, value) => {
  115. + this.setState({ selectedTab: value });
  116. + };
  117. +
  118. + handleSubmit = event => {
  119. + event.preventDefault();
  120. +
  121. + if (this.props.mode === 'create') {
  122. + this.handleCreateModeSubmit();
  123. + }
  124. +
  125. + if (this.props.mode === 'edit') {
  126. + this.handleEditModeSubmit();
  127. + }
  128. + };
  129. +
  130. + handleCreateModeSubmit() {
  131. + }
  132. +
  133. + handleEditModeSubmit() {
  134. + }
  135. +
  136. + render = () => (
  137. + <Paper className={this.props.classes.paper}>
  138. + <Typography variant={"h5"} component={"h3"}>
  139. + {this.state.modeConfiguration.paperTitle}
  140. + </Typography>
  141. + <Tabs value={this.state.selectedTab} className={this.props.classes.tabs} onChange={this.handleTabChange}>
  142. + <Tab label={"General Information"} />
  143. + <Tab label={"Roles"} />
  144. + <Tab label={"Custom permissions"} />
  145. + </Tabs>
  146. + </Paper>
  147. + );
  148. +}
  149. +
  150. +export default withStyles(styles)(UserFormContainer);
  151. Index: src/components/PermissionList.js
  152. IDEA additional info:
  153. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  154. <+>UTF-8
  155. ===================================================================
  156. --- src/components/PermissionList.js (date 1542022707034)
  157. +++ src/components/PermissionList.js (date 1542022707034)
  158. @@ -0,0 +1,1 @@
  159. +import React from 'react';
  160. Index: src/routers/UserRouter.js
  161. IDEA additional info:
  162. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  163. <+>UTF-8
  164. ===================================================================
  165. --- src/routers/UserRouter.js (revision f96042b33a71505f37e535a4bfb9a0546e59ce3e)
  166. +++ src/routers/UserRouter.js (date 1542024456121)
  167. @@ -3,6 +3,7 @@
  168.  
  169. import NavigationBar from '../components/NavigationBar';
  170.  
  171. +import UserFormContainer from '../containers/UserFormContainer';
  172. import UserListContainer from '../containers/UserListContainer';
  173.  
  174. export default () => (
  175. @@ -10,7 +11,7 @@
  176. <NavigationBar title={"Users"} />
  177. <Switch>
  178. <Route exact path={"/users"} component={UserListContainer} />
  179. - <Route path={"/users/add"} render={{}} />
  180. + <Route path={"/users/add"} render={props => <UserFormContainer mode={"create"} {...props} />} />
  181. <Route path={"/users/detail/:id"} render={{}} />
  182. </Switch>
  183. </React.Fragment>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement