|
| 1 | +import React from 'react'; |
| 2 | +import { useIntl } from '@umijs/max'; |
| 3 | +import { Checkbox, Col, Row } from 'antd'; |
| 4 | +import { ProForm, ProFormText } from '@ant-design/pro-components'; |
| 5 | + |
| 6 | +import CallbackURL from './CallbackURL'; |
| 7 | + |
| 8 | +const INTL = { |
| 9 | + CLIENT_ID: { |
| 10 | + id: 'idp.form.clientID', |
| 11 | + }, |
| 12 | + SCOPES: { |
| 13 | + id: 'idp.form.scopes', |
| 14 | + }, |
| 15 | + CLIENT_SECRET: { |
| 16 | + id: 'idp.form.clientSecret', |
| 17 | + }, |
| 18 | + CALLBACK_URL: { |
| 19 | + id: 'idp.form.callbackURL', |
| 20 | + }, |
| 21 | + CALLBACK_URL_PLACEHOLDER: { |
| 22 | + id: 'idp.form.callbackURL.placeholder', |
| 23 | + }, |
| 24 | + CODING_TEAM: { |
| 25 | + id: 'idp.form.codingTeam', |
| 26 | + }, |
| 27 | + CODING_TEAM_PLACEHOLDER: { |
| 28 | + id: 'idp.form.codingTeam.placeholder', |
| 29 | + }, |
| 30 | + CLIENT_ID_PLACEHOLDER: { |
| 31 | + id: 'idp.form.clientID.placeholder', |
| 32 | + }, |
| 33 | + CLIENT_SECRET_PLACEHOLDER: { |
| 34 | + id: 'idp.form.clientSecret.placeholder', |
| 35 | + }, |
| 36 | +}; |
| 37 | + |
| 38 | +export const Coding: React.FC = () => { |
| 39 | + const intl = useIntl(); |
| 40 | + |
| 41 | + const scopes = [ |
| 42 | + { name: 'user', desc: '' }, |
| 43 | + { name: 'user:email', desc: '' }, |
| 44 | + { name: 'notification', desc: '' }, |
| 45 | + { name: 'project', desc: '' }, |
| 46 | + { name: 'project:api_doc', desc: '' }, |
| 47 | + { name: 'project:artifacts', desc: '' }, |
| 48 | + { name: 'project:depot', desc: '' }, |
| 49 | + { name: 'project:file', desc: '' }, |
| 50 | + { name: 'project:issue', desc: '' }, |
| 51 | + { name: 'project:key', desc: '' }, |
| 52 | + { name: 'project:members', desc: '' }, |
| 53 | + { name: 'project:notice', desc: '' }, |
| 54 | + ]; |
| 55 | + |
| 56 | + return ( |
| 57 | + <> |
| 58 | + <ProForm.Group align="center"> |
| 59 | + <ProFormText |
| 60 | + width="lg" |
| 61 | + required |
| 62 | + name={['config', 'clientID']} |
| 63 | + fieldProps={{ autoComplete: 'off' }} |
| 64 | + label={intl.formatMessage(INTL.CLIENT_ID)} |
| 65 | + placeholder={intl.formatMessage(INTL.CLIENT_ID_PLACEHOLDER)} |
| 66 | + rules={[{ required: true }]} |
| 67 | + /> |
| 68 | + <ProFormText.Password |
| 69 | + width="lg" |
| 70 | + name={['config', 'clientSecret']} |
| 71 | + fieldProps={{ autoComplete: 'off' }} |
| 72 | + label={intl.formatMessage(INTL.CLIENT_SECRET)} |
| 73 | + placeholder={intl.formatMessage(INTL.CLIENT_SECRET_PLACEHOLDER)} |
| 74 | + rules={[{ required: true }]} |
| 75 | + /> |
| 76 | + </ProForm.Group> |
| 77 | + <ProForm.Group align="center"> |
| 78 | + <ProFormText |
| 79 | + width="lg" |
| 80 | + name={['config', 'team']} |
| 81 | + fieldProps={{ autoComplete: 'off' }} |
| 82 | + label={intl.formatMessage(INTL.CODING_TEAM)} |
| 83 | + placeholder={intl.formatMessage(INTL.CODING_TEAM_PLACEHOLDER)} |
| 84 | + rules={[{ required: true }]} |
| 85 | + /> |
| 86 | + <ProFormText |
| 87 | + width="lg" |
| 88 | + name="callbackURL" |
| 89 | + fieldProps={{ autoComplete: 'off' }} |
| 90 | + label={intl.formatMessage(INTL.CALLBACK_URL)} |
| 91 | + placeholder={intl.formatMessage(INTL.CALLBACK_URL_PLACEHOLDER)} |
| 92 | + /> |
| 93 | + </ProForm.Group> |
| 94 | + <ProForm.Group align="center"> |
| 95 | + <ProForm.Item name={['config', 'scopes']} label={intl.formatMessage(INTL.SCOPES)}> |
| 96 | + <Checkbox.Group style={{ maxWidth: 912 }}> |
| 97 | + <Row gutter={[4, 8]}> |
| 98 | + {scopes.map((act) => { |
| 99 | + return ( |
| 100 | + <Col span={6} key={`${act.name}-scope`}> |
| 101 | + <Checkbox value={act.name}> |
| 102 | + {act.name} |
| 103 | + {act.desc ? `(${act.desc})` : ''} |
| 104 | + </Checkbox> |
| 105 | + </Col> |
| 106 | + ); |
| 107 | + })} |
| 108 | + </Row> |
| 109 | + </Checkbox.Group> |
| 110 | + </ProForm.Item> |
| 111 | + </ProForm.Group> |
| 112 | + <ProForm.Group align="center"> |
| 113 | + <CallbackURL /> |
| 114 | + </ProForm.Group> |
| 115 | + </> |
| 116 | + ); |
| 117 | +}; |
0 commit comments