-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds supports for external Postgres for noobaa
Signed-off-by: vbadrina <[email protected]>
- Loading branch information
Showing
7 changed files
with
376 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
199 changes: 199 additions & 0 deletions
199
...ge-system/create-storage-system-steps/backing-storage-step/enable-noobaa-postgres-tls.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
import * as React from 'react'; | ||
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook'; | ||
import { | ||
FormGroup, | ||
Checkbox, | ||
TextInput, | ||
Form, | ||
GridItem, | ||
Grid, | ||
Text, | ||
TextVariants, | ||
Stack, | ||
} from '@patternfly/react-core'; | ||
import { WizardDispatch, WizardState } from '../../reducer'; | ||
import './backing-storage-step.scss'; | ||
|
||
export const PostgresConnectionDetails: React.FC<PostgresConnectionDetails> = ({ | ||
dispatch, | ||
username, | ||
password, | ||
serverName, | ||
port, | ||
databaseName, | ||
tlsEnabled, | ||
allowSelfSignedCerts, | ||
enableClientSideCerts, | ||
}) => { | ||
const { t } = useCustomTranslation(); | ||
|
||
return ( | ||
<Form> | ||
<Text component={TextVariants.h4}>Connection details</Text> | ||
<Grid hasGutter md={12}> | ||
<GridItem md={8} span={2}> | ||
<FormGroup label={t('Username')} fieldId="username-tls" isRequired> | ||
<TextInput | ||
id="username-input" | ||
type="text" | ||
value={username} | ||
onChange={(newUsername: string) => { | ||
dispatch({ | ||
type: 'backingStorage/externalPostgres/setUsername', | ||
payload: newUsername, | ||
}); | ||
}} | ||
isRequired | ||
/> | ||
</FormGroup> | ||
</GridItem> | ||
<GridItem md={8} span={2}> | ||
<FormGroup label={t('Password')} fieldId="password-tls" isRequired> | ||
<TextInput | ||
id="password-input" | ||
type="password" | ||
value={password} | ||
onChange={(newPassword: string) => { | ||
dispatch({ | ||
type: 'backingStorage/externalPostgres/setPassword', | ||
payload: newPassword, | ||
}); | ||
}} | ||
isRequired | ||
/> | ||
</FormGroup> | ||
</GridItem> | ||
<GridItem md={6} span={10}> | ||
<FormGroup label={t('Server')} fieldId="server-tls" isRequired> | ||
<TextInput | ||
id="server-input" | ||
type="text" | ||
value={serverName} | ||
onChange={(newServer: string) => { | ||
dispatch({ | ||
type: 'backingStorage/externalPostgres/setServerName', | ||
payload: newServer, | ||
}); | ||
}} | ||
isRequired | ||
/> | ||
</FormGroup> | ||
</GridItem> | ||
<GridItem md={6} span={2}> | ||
<FormGroup label={t('Port')} fieldId="port-tls" isRequired> | ||
<TextInput | ||
id="port-input" | ||
type="number" | ||
value={port} | ||
onChange={(newPort: string) => { | ||
dispatch({ | ||
type: 'backingStorage/externalPostgres/setPort', | ||
payload: newPort, | ||
}); | ||
}} | ||
isRequired | ||
/> | ||
</FormGroup> | ||
</GridItem> | ||
<GridItem md={8} span={2}> | ||
<FormGroup | ||
label={t('Database name')} | ||
fieldId="database-tls" | ||
isRequired | ||
> | ||
<TextInput | ||
id="database-input" | ||
type="text" | ||
value={databaseName} | ||
onChange={(newDatabase: string) => { | ||
dispatch({ | ||
type: 'backingStorage/externalPostgres/setDatabaseName', | ||
payload: newDatabase, | ||
}); | ||
}} | ||
isRequired | ||
/> | ||
</FormGroup> | ||
</GridItem> | ||
</Grid> | ||
<FormGroup fieldId="enable-tls"> | ||
<Checkbox | ||
id="enable-tls" | ||
label={t('Enable TLS/SSL')} | ||
description={t( | ||
'Enable this for encrytion on flight with the Postgres server' | ||
)} | ||
isChecked={tlsEnabled} | ||
onChange={() => { | ||
const isTLSEnabled = !tlsEnabled; | ||
dispatch({ | ||
type: 'backingStorage/externalPostgres/TLS/enableTLS', | ||
payload: !tlsEnabled, | ||
}); | ||
|
||
dispatch({ | ||
type: 'backingStorage/externalPostgres/TLS/allowSelfSignedCerts', | ||
payload: | ||
!isTLSEnabled && allowSelfSignedCerts | ||
? false | ||
: allowSelfSignedCerts, | ||
}); | ||
|
||
dispatch({ | ||
type: 'backingStorage/externalPostgres/TLS/enableClientSideCerts', | ||
payload: | ||
!isTLSEnabled && enableClientSideCerts | ||
? false | ||
: enableClientSideCerts, | ||
}); | ||
}} | ||
className="odf-backing-store__radio--margin-bottom" | ||
/> | ||
{tlsEnabled && ( | ||
<Stack hasGutter> | ||
<Checkbox | ||
id="allow-self-signed-certs" | ||
label={t('Allow self-signed certificates')} | ||
description={t( | ||
'Adding this option will allow the postgres server to use a self-signed certificates.' | ||
)} | ||
isChecked={allowSelfSignedCerts} | ||
onChange={() => | ||
dispatch({ | ||
type: 'backingStorage/externalPostgres/TLS/allowSelfSignedCerts', | ||
payload: !allowSelfSignedCerts, | ||
}) | ||
} | ||
/> | ||
<Checkbox | ||
id="enable-client-side-certs" | ||
label={t('Enable client-side certificates')} | ||
description={t( | ||
'Select this option to upload and use your client side certificates' | ||
)} | ||
isChecked={enableClientSideCerts} | ||
onChange={() => | ||
dispatch({ | ||
type: 'backingStorage/externalPostgres/TLS/enableClientSideCerts', | ||
payload: !enableClientSideCerts, | ||
}) | ||
} | ||
/> | ||
</Stack> | ||
)} | ||
</FormGroup> | ||
</Form> | ||
); | ||
}; | ||
|
||
type PostgresConnectionDetails = { | ||
dispatch: WizardDispatch; | ||
username: WizardState['backingStorage']['externalPostgres']['username']; | ||
password: WizardState['backingStorage']['externalPostgres']['password']; | ||
serverName: WizardState['backingStorage']['externalPostgres']['serverName']; | ||
port: WizardState['backingStorage']['externalPostgres']['port']; | ||
databaseName: WizardState['backingStorage']['externalPostgres']['databaseName']; | ||
tlsEnabled: WizardState['backingStorage']['externalPostgres']['TLS']['enabled']; | ||
allowSelfSignedCerts: WizardState['backingStorage']['externalPostgres']['TLS']['allowSelfSignedCerts']; | ||
enableClientSideCerts: WizardState['backingStorage']['externalPostgres']['TLS']['enableClientSideCerts']; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.