ChangeRoleForm.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import React from 'react'
  2. import { Form, Input, Radio, Button } from 'antd'
  3. import { FormComponentProps } from 'antd/lib/form/Form'
  4. import { IOrganizationMember } from '../types'
  5. const FormItem = Form.Item
  6. const RadioGroup = Radio.Group
  7. const styles = require('../Organization.less')
  8. const utilStyles = require('assets/less/util.less')
  9. interface IChangeRoleProps {
  10. category: string
  11. member: IOrganizationMember
  12. organizationOrTeam: { name?: string }
  13. submitLoading: boolean
  14. changeHandler: () => any
  15. }
  16. export class ChangeRoleForm extends React.PureComponent<IChangeRoleProps & FormComponentProps, {}> {
  17. private tips = (type: string) => {
  18. switch (type) {
  19. case 'orgMember':
  20. return '选择一个新成员类型'
  21. case 'teamMember':
  22. return ''
  23. }
  24. }
  25. private selectOptions = (type: string) => {
  26. switch (type) {
  27. case 'orgMember':
  28. return (
  29. <RadioGroup>
  30. <div className={styles.radioWrapper}>
  31. <Radio key={`radio${1}`} value={1} />
  32. <div className={styles.labelWrapper}>
  33. <div className={styles.label}>拥有者</div>
  34. <div className={styles.labelDesc}>组织的管理者,可以添加和删除组织成员并创建团队</div>
  35. </div>
  36. </div>
  37. <div className={styles.radioWrapper}>
  38. <Radio key={`radio${2}`} value={0} />
  39. <div className={styles.labelWrapper}>
  40. <div className={styles.label}>成员</div>
  41. <div className={styles.labelDesc}>组织内的普通成员,进入团队后,由团队的 Maintainer 分配项目模块权限</div>
  42. </div>
  43. </div>
  44. </RadioGroup>
  45. )
  46. case 'teamMember':
  47. return (
  48. <RadioGroup>
  49. <div className={styles.radioWrapper}>
  50. <Radio key={`radio${1}`} value={1} />
  51. <div className={styles.labelWrapper}>
  52. <div className={styles.label}>Maintainer</div>
  53. <div className={styles.labelDesc}>团队的管理者,可以指定该团队在项目中的模块权限</div>
  54. </div>
  55. </div>
  56. <div className={styles.radioWrapper}>
  57. <Radio key={`radio${2}`} value={0} />
  58. <div className={styles.labelWrapper}>
  59. <div className={styles.label}>Member</div>
  60. <div className={styles.labelDesc}>组织内的普通成员,进入团队后,由团队的 Maintainer 分配项目模块权限</div>
  61. </div>
  62. </div>
  63. </RadioGroup>
  64. )
  65. default:
  66. return ''
  67. }
  68. }
  69. public render () {
  70. const { category, organizationOrTeam, member, submitLoading } = this.props
  71. const orgOrTeamName = organizationOrTeam ? organizationOrTeam.name : ''
  72. const { getFieldDecorator } = this.props.form
  73. const modalButtons = [(
  74. <Button
  75. key="submit"
  76. type="primary"
  77. loading={submitLoading}
  78. disabled={submitLoading}
  79. onClick={this.props.changeHandler}
  80. >
  81. 保 存
  82. </Button>
  83. )]
  84. return (
  85. <div className={styles.formWrapper}>
  86. <div className={styles.header}>
  87. <div className={styles.title}>
  88. 改变 {member.user.username} 在 <span className={styles.orgName}>{orgOrTeamName}</span> 的成员类型
  89. </div>
  90. <div className={styles.desc}>
  91. <b>{this.tips(category)}</b>
  92. </div>
  93. </div>
  94. <div className={styles.body}>
  95. <Form style={{marginTop: '12px'}}>
  96. <FormItem className={utilStyles.hide}>
  97. {getFieldDecorator('id', {
  98. })(
  99. <Input />
  100. )}
  101. </FormItem>
  102. <FormItem
  103. >
  104. {getFieldDecorator('role', {
  105. })(
  106. this.selectOptions(category)
  107. )}
  108. </FormItem>
  109. </Form>
  110. </div>
  111. <div className={styles.footer}>
  112. {modalButtons}
  113. </div>
  114. </div>
  115. )
  116. }
  117. }
  118. export default Form.create<IChangeRoleProps & FormComponentProps>()(ChangeRoleForm)