This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new a27bf451 feat(frontend): change jira basicauthencode to
username/password (#2002)
a27bf451 is described below
commit a27bf45143a4e2be5691fe61a29195ddba341490
Author: Warren Chen <[email protected]>
AuthorDate: Mon Jun 6 23:39:17 2022 +0800
feat(frontend): change jira basicauthencode to username/password (#2002)
---
config-ui/cypress/integration/0-api/api.spec.js | 3 +-
config-ui/src/hooks/useConnectionManager.jsx | 5 +-
config-ui/src/hooks/useConnectionValidation.jsx | 2 +-
config-ui/src/hooks/useSettingsManager.jsx | 3 +-
.../pages/configure/connections/AddConnection.jsx | 2 +-
.../configure/connections/ConfigureConnection.jsx | 2 +-
.../pages/configure/connections/ConnectionForm.jsx | 120 ++++++++++-----------
.../pages/configure/connections/EditConnection.jsx | 4 +-
8 files changed, 66 insertions(+), 75 deletions(-)
diff --git a/config-ui/cypress/integration/0-api/api.spec.js
b/config-ui/cypress/integration/0-api/api.spec.js
index 72934c24..d934b365 100644
--- a/config-ui/cypress/integration/0-api/api.spec.js
+++ b/config-ui/cypress/integration/0-api/api.spec.js
@@ -40,7 +40,8 @@ context('API Network Requests', () => {
expect(response.body[0]).to.have.property('id')
expect(response.body[0]).to.have.property('name')
expect(response.body[0]).to.have.property('endpoint')
- expect(response.body[0]).to.have.property('basicAuthEncoded')
+ expect(response.body[0]).to.have.property('username')
+ expect(response.body[0]).to.have.property('password')
expect(response.body[0]).to.have.property('epicKeyField')
expect(response.body[0]).to.have.property('storyPointField')
expect(response.body[0]).to.have.property('remotelinkCommitShaPattern')
diff --git a/config-ui/src/hooks/useConnectionManager.jsx
b/config-ui/src/hooks/useConnectionManager.jsx
index 56e992d3..a3558df0 100644
--- a/config-ui/src/hooks/useConnectionManager.jsx
+++ b/config-ui/src/hooks/useConnectionManager.jsx
@@ -125,7 +125,7 @@ function useConnectionManager ({
let connectionPayload = { ...configurationSettings }
switch (activeProvider.id) {
case Providers.JIRA:
- connectionPayload = { name: name, endpoint: endpointUrl,
basicAuthEncoded: token, proxy: proxy, ...connectionPayload }
+ connectionPayload = { name: name, endpoint: endpointUrl, username:
username, password: password, proxy: proxy, ...connectionPayload }
break
case Providers.GITHUB:
connectionPayload = { name: name, endpoint: endpointUrl, auth: token,
proxy: proxy, ...connectionPayload }
@@ -384,7 +384,8 @@ function useConnectionManager ({
setProxy(activeConnection.Proxy || activeConnection.proxy)
break
case Providers.JIRA:
- setToken(activeConnection.basicAuthEncoded || activeConnection.auth)
+ setUsername(activeConnection.username)
+ setPassword(activeConnection.password)
setProxy(activeConnection.Proxy || activeConnection.proxy)
break
}
diff --git a/config-ui/src/hooks/useConnectionValidation.jsx
b/config-ui/src/hooks/useConnectionValidation.jsx
index be5b77c5..8b168e62 100644
--- a/config-ui/src/hooks/useConnectionValidation.jsx
+++ b/config-ui/src/hooks/useConnectionValidation.jsx
@@ -79,12 +79,12 @@ function useConnectionValidation ({
switch (activeProvider.id) {
case Providers.GITHUB:
- case Providers.JIRA:
case Providers.GITLAB:
if (!token || token.length <= 2) {
errs.push('Authentication token(s) are required')
}
break
+ case Providers.JIRA:
case Providers.JENKINS:
if (!username || username.length <= 2) {
errs.push('Username is required')
diff --git a/config-ui/src/hooks/useSettingsManager.jsx
b/config-ui/src/hooks/useSettingsManager.jsx
index 29e1d218..bdfb635d 100644
--- a/config-ui/src/hooks/useSettingsManager.jsx
+++ b/config-ui/src/hooks/useSettingsManager.jsx
@@ -39,7 +39,8 @@ function useSettingsManager ({
...connectionPayload,
name: connection.name,
endpoint: connection.endpoint,
- basicAuthEncoded: connection.basicAuthEncoded,
+ username: connection.username,
+ password: connection.password,
proxy: connection.proxy || connection.Proxy
}
break
diff --git a/config-ui/src/pages/configure/connections/AddConnection.jsx
b/config-ui/src/pages/configure/connections/AddConnection.jsx
index f7e87a5e..7e81106d 100644
--- a/config-ui/src/pages/configure/connections/AddConnection.jsx
+++ b/config-ui/src/pages/configure/connections/AddConnection.jsx
@@ -180,7 +180,7 @@ export default function AddConnection () {
testStatus={testStatus}
errors={errors}
showError={showError}
- authType={activeProvider.id === Providers.JENKINS ? 'plain'
: 'token'}
+ authType={[Providers.JENKINS,
Providers.JIRA].includes(activeProvider.id) ? 'plain' : 'token'}
sourceLimits={ProviderConnectionLimits}
labels={ProviderFormLabels[activeProvider.id]}
placeholders={ProviderFormPlaceholders[activeProvider.id]}
diff --git a/config-ui/src/pages/configure/connections/ConfigureConnection.jsx
b/config-ui/src/pages/configure/connections/ConfigureConnection.jsx
index 6387a4fa..82ec07a0 100644
--- a/config-ui/src/pages/configure/connections/ConfigureConnection.jsx
+++ b/config-ui/src/pages/configure/connections/ConfigureConnection.jsx
@@ -265,7 +265,7 @@ export default function ConfigureConnection () {
testStatus={testStatus}
errors={errors}
showError={showConnectionError}
- authType={activeProvider.id === Providers.JENKINS
? 'plain' : 'token'}
+ authType={[Providers.JENKINS,
Providers.JIRA].includes(activeProvider.id) ? 'plain' : 'token'}
showLimitWarning={false}
sourceLimits={ProviderConnectionLimits}
labels={ProviderFormLabels[activeProvider.id]}
diff --git a/config-ui/src/pages/configure/connections/ConnectionForm.jsx
b/config-ui/src/pages/configure/connections/ConnectionForm.jsx
index 6dc32fd8..e5fe71d2 100644
--- a/config-ui/src/pages/configure/connections/ConnectionForm.jsx
+++ b/config-ui/src/pages/configure/connections/ConnectionForm.jsx
@@ -75,6 +75,8 @@ export default function ConnectionForm (props) {
const connectionNameRef = useRef()
const connectionEndpointRef = useRef()
const connectionTokenRef = useRef()
+ const connectionUsernameRef = useRef()
+ const connectionPasswordRef = useRef()
// const [isValidForm, setIsValidForm] = useState(true)
const [allowedAuthTypes, setAllowedAuthTypes] = useState(['token', 'plain'])
@@ -353,39 +355,42 @@ export default function ConnectionForm (props) {
)}
/>
)}
- {
- activeProvider.id === Providers.JIRA &&
- <Popover
- className='popover-generate-token'
- position={Position.RIGHT}
- autoFocus={false}
- enforceFocus={false}
- isOpen={showTokenCreator}
- onInteraction={handleTokenInteraction}
- onClosed={() => setShowTokenCreator(false)}
- usePortal={false}
- >
- <Button
- disabled={isTesting || isSaving || isLocked}
- type='button' icon='key' intent={Intent.PRIMARY}
style={{ marginLeft: '5px' }}
- />
- <>
- <div style={{ padding: '15px 20px 15px 15px' }}>
- <GenerateTokenForm
- isTesting={isTesting}
- isSaving={isSaving}
- isLocked={isLocked}
- onTokenChange={onTokenChange}
- setShowTokenCreator={setShowTokenCreator}
- />
- </div>
- </>
- </Popover>
- }
{/* <a href='#' style={{ margin: '5px 0 5px 5px' }}><Icon
icon='info-sign' size='16' /></a> */}
</FormGroup>
</div>
)}
+ {[Providers.GITHUB, Providers.GITLAB,
Providers.JIRA].includes(activeProvider.id) && (
+ <div className='formContainer'>
+ <FormGroup
+ disabled={isTesting || isSaving || isLocked}
+ inline={true}
+ labelFor='connection-proxy'
+ className='formGroup'
+ contentClassName='formGroupContent'
+ >
+ <Label>
+ {labels
+ ? labels.proxy
+ : (
+ <>Proxy URL</>
+ )}
+ </Label>
+ <InputGroup
+ id='connection-proxy'
+ placeholder={placeholders.proxy ? placeholders.proxy :
'http://proxy.localhost:8080'}
+ defaultValue={proxy}
+ onChange={(e) => onProxyChange(e.target.value)}
+ disabled={isTesting || isSaving || isLocked}
+ className={`input input-proxy ${fieldHasError('Proxy') ?
'invalid-field' : ''}`}
+ rightElement={(
+ <InputValidationError
+ error={getFieldError('Proxy')}
+ />
+ )}
+ />
+ </FormGroup>
+ </div>
+ )}
{authType === 'plain' && (
<>
<div style={{ marginTop: '20px', marginBottom: '20px' }}>
@@ -408,20 +413,30 @@ export default function ConnectionForm (props) {
? labels.username
: (
<>Username</>
- )}
+ )}
<span className='requiredStar'>*</span>
</Label>
<InputGroup
id='connection-username'
+ inputRef={connectionUsernameRef}
disabled={isTesting || isSaving || isLocked}
placeholder='Enter Username'
defaultValue={username}
onChange={(e) => onUsernameChange(e.target.value)}
- className={`input username-input ${fieldHasError('Username')
? 'invalid-field' : ''}`}
+ className={`input username-input ${stateErrored ===
'Username' ? 'invalid-field' : ''}`}
// style={{ maxWidth: '300px' }}
+ // rightElement={(
+ // <InputValidationError
+ // error={getFieldError('Username')}
+ // />
+ // )}
rightElement={(
<InputValidationError
error={getFieldError('Username')}
+ elementRef={connectionUsernameRef}
+ onError={activateErrorStates}
+ onSuccess={() => setStateErrored(null)}
+ validateOnFocus
/>
)}
/>
@@ -441,60 +456,33 @@ export default function ConnectionForm (props) {
? labels.password
: (
<>Password</>
- )}
+ )}
<span className='requiredStar'>*</span>
</Label>
<InputGroup
id='connection-password'
+ inputRef={connectionPasswordRef}
type='password'
disabled={isTesting || isSaving || isLocked}
placeholder='Enter Password'
defaultValue={password}
onChange={(e) => onPasswordChange(e.target.value)}
- className={`input password-input ${fieldHasError('Password')
? 'invalid-field' : ''}`}
+ className={`input password-input ${stateErrored ===
'Password' ? 'invalid-field' : ''}`}
// style={{ maxWidth: '300px' }}
rightElement={(
<InputValidationError
error={getFieldError('Password')}
+ elementRef={connectionPasswordRef}
+ onError={activateErrorStates}
+ onSuccess={() => setStateErrored(null)}
+ validateOnFocus
/>
- )}
+ )}
/>
</FormGroup>
</div>
</>
)}
- {[Providers.GITHUB, Providers.GITLAB,
Providers.JIRA].includes(activeProvider.id) && (
- <div className='formContainer'>
- <FormGroup
- disabled={isTesting || isSaving || isLocked}
- inline={true}
- labelFor='connection-proxy'
- className='formGroup'
- contentClassName='formGroupContent'
- >
- <Label>
- {labels
- ? labels.proxy
- : (
- <>Proxy URL</>
- )}
- </Label>
- <InputGroup
- id='connection-proxy'
- placeholder={placeholders.proxy ? placeholders.proxy :
'http://proxy.localhost:8080'}
- defaultValue={proxy}
- onChange={(e) => onProxyChange(e.target.value)}
- disabled={isTesting || isSaving || isLocked}
- className={`input input-proxy ${fieldHasError('Proxy') ?
'invalid-field' : ''}`}
- rightElement={(
- <InputValidationError
- error={getFieldError('Proxy')}
- />
- )}
- />
- </FormGroup>
- </div>
- )}
<div
className='form-actions-block'
style={{ display: 'flex', marginTop: '30px', justifyContent:
'space-between' }}
diff --git a/config-ui/src/pages/configure/connections/EditConnection.jsx
b/config-ui/src/pages/configure/connections/EditConnection.jsx
index 5df1143a..bb6e9fdd 100644
--- a/config-ui/src/pages/configure/connections/EditConnection.jsx
+++ b/config-ui/src/pages/configure/connections/EditConnection.jsx
@@ -76,11 +76,11 @@ export default function EditConnection () {
setEndpointUrl(activeConnection.endpoint)
switch (activeProvider.id) {
case Providers.JENKINS:
+ case Providers.JIRA:
setUsername(activeConnection.username)
setPassword(activeConnection.password)
break
case Providers.GITLAB:
- case Providers.JIRA:
setToken(activeConnection.basicAuthEncoded || activeConnection.Auth)
break
}
@@ -147,7 +147,7 @@ export default function EditConnection () {
testStatus={testStatus}
errors={errors}
showError={showError}
- authType={activeProvider.id === Providers.JENKINS ? 'plain'
: 'token'}
+ authType={[Providers.JENKINS,
Providers.JIRA].includes(activeProvider.id) ? 'plain' : 'token'}
sourceLimits={ProviderConnectionLimits}
labels={ProviderFormLabels[activeProvider.id]}
placeholders={ProviderFormPlaceholders[activeProvider.id]}