Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/client/cypress/fixtures/saveAction.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
}
],
"authentication": {
"authenticationType": "dbAuth",
"authenticationType": "dbAuth",
"authType": "SCRAM_SHA_1",
"username": "cypress-test",
Expand Down
1 change: 1 addition & 0 deletions app/client/src/entities/Datasource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface DatasourceAuthentication {
value?: string;
addTo?: string;
bearerToken?: string;
authenticationStatus?: string;
}

export interface DatasourceColumns {
Expand Down
34 changes: 32 additions & 2 deletions app/client/src/pages/Editor/SaaSEditor/DatasourceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ type DatasourceSaaSEditorProps = StateProps &
type Props = DatasourceSaaSEditorProps &
InjectedFormProps<Datasource, DatasourceSaaSEditorProps>;

enum AuthenticationStatus {
NONE = "NONE",
IN_PROGRESS = "IN_PROGRESS",
SUCCESS = "SUCCESS",
}

const StyledButton = styled(Button)`
&&&& {
width: 180px;
Expand All @@ -91,6 +97,15 @@ const EditDatasourceButton = styled(AdsButton)`
}
`;

const StyledAuthMessage = styled.div`
color: ${(props) => props.theme.colors.error};
margin-top: 15px;
&:after {
content: " *";
color: inherit;
}
`;

class DatasourceSaaSEditor extends JSONtoForm<Props> {
componentDidMount() {
super.componentDidMount();
Expand Down Expand Up @@ -131,6 +146,7 @@ class DatasourceSaaSEditor extends JSONtoForm<Props> {

renderDataSourceConfigForm = (sections: any) => {
const {
datasource,
deleteDatasource,
isDeleting,
isSaving,
Expand All @@ -141,6 +157,10 @@ class DatasourceSaaSEditor extends JSONtoForm<Props> {

const params: string = location.search;
const viewMode = new URLSearchParams(params).get("viewMode");
const isAuthorized =
datasource?.datasourceConfiguration.authentication
?.authenticationStatus === AuthenticationStatus.SUCCESS;

return (
<form
onSubmit={(e) => {
Expand All @@ -152,6 +172,7 @@ class DatasourceSaaSEditor extends JSONtoForm<Props> {
<PluginImage alt="Datasource" src={this.props.pluginImage} />
<FormTitle focusOnMount={this.props.isNewDatasource} />
</FormTitleContainer>

{viewMode && (
<EditDatasourceButton
category={Category.tertiary}
Expand All @@ -178,6 +199,9 @@ class DatasourceSaaSEditor extends JSONtoForm<Props> {
{!_.isNil(sections)
? _.map(sections, this.renderMainSection)
: null}
{!isAuthorized && (
<StyledAuthMessage>Datasource not authorized</StyledAuthMessage>
)}
<SaveButtonContainer>
<ActionButton
accent="error"
Expand All @@ -194,6 +218,7 @@ class DatasourceSaaSEditor extends JSONtoForm<Props> {
}
text="Delete"
/>

<StyledButton
className="t--save-datasource"
disabled={this.validate()}
Expand All @@ -215,12 +240,17 @@ class DatasourceSaaSEditor extends JSONtoForm<Props> {
);
}}
size="small"
text="Continue"
text={isAuthorized ? "Re-authorize" : "Authorize"}
/>
</SaveButtonContainer>
</>
) : (
<Connected />
<>
<Connected />
{!isAuthorized && (
<StyledAuthMessage>Datasource not authorized</StyledAuthMessage>
)}
</>
)}
</form>
);
Expand Down