fix: save the updated connection on OAuth recon...
...nect
We need to save (invoke `PUT /api/v1/connections/{id}`) when
reconnecting the OAuth-capable connection.
Fixes
@@ -28,18 +28,22 @@ export interface IConnectionDetailsOauthProps {
connectorId: string;
connectionName: string;
configuredProperties: Pick<IConnectionOverview, 'configuredProperties'>;
+ onOAuthReconnect: () => void;
}
const ConnectionDetailsOAuth: React.FunctionComponent<
IConnectionDetailsOauthProps
-> = ({ connectorId, connectionName, configuredProperties }) => {
+> = ({
+ connectorId,
+ connectionName,
+ configuredProperties,
+ onOAuthReconnect,
+}) => {
const { t } = useTranslation(['connections', 'shared']);
const { pushNotification } = React.useContext(UIContext);
const { connectOAuth, isConnecting } = useOAuthFlow(
connectorId,
connectionName,
- () => {
- pushNotification(`Connection successful`, 'success');
- }
+ onOAuthReconnect
);
const { loading: isVerifying, read: verify } = useConnectorVerifier();
@@ -176,6 +180,11 @@ export const ConnectionDetailsPage: React.FunctionComponent<
setIsWorking(false);
};
+ const onOAuthReconnect = async () => {
+ await save(connection);
+ pushNotification(`Connection successful`, 'success');
+ };
+
/**
* Backend validation only occurs when save has been called.
* @param proposedName the name to validate
@@ -314,6 +323,7 @@ export const ConnectionDetailsPage: React.FunctionComponent<
connectorId={connection.connector!.id!}
connectionName={connection.name}
configuredProperties={connection.configuredProperties || {}}
+ onOAuthReconnect={onOAuthReconnect}
/>
)}
</>
