Skip to content

[FEATURE] Add test datasource connection button - #99

Open
adrianSepiol wants to merge 1 commit into
perses:mainfrom
adrianSepiol:add-test-connection-button
Open

[FEATURE] Add test datasource connection button#99
adrianSepiol wants to merge 1 commit into
perses:mainfrom
adrianSepiol:add-test-connection-button

Conversation

@adrianSepiol

@adrianSepiol adrianSepiol commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

…Button for testing datasource connections

Related pull requests (in order):

  1. [BUGFIX] set correct ContentLength for request body perses#4007
  2. This one
  3. [FEATURE] integrate test datasource connection button into DatasourceDrawer perses#4008
  4. [BREAKINGCHANGE] Replace local buildProxyUrl with shared implementation from @perses-dev/client perses#4302
  5. [FEATURE] add test connection button to prometheus plugin plugins#620

Related issue:
perses/perses#1542

Description

Adds a Test Connection button to the datasource editor that validates connectivity before saving. The button is wired through the editor component chain (DatasourceEditorForm → PluginEditor → PluginSpecEditor) where the connection logic is bound to the plugin's healthCheckPath and the current project/dashboard context. As part of this, buildProxyUrl is also migrated to @perses-dev/client, replacing the local implementation in perses/ui/app that will be removed in a companion PR.

Screenshots

In perses/plugins#620

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.
  • E2E tests are stable and unlikely to be flaky.
    See e2e docs for more details. Common issues include:
    • Is the data inconsistent? You need to mock API requests.
    • Does the time change? You need to use consistent time values or mock time utilities.
    • Does it have loading states? You need to wait for loading to complete.

Signed-off-by: Adrian Sepiół <a.sepiol@sap.com>
@adrianSepiol
adrianSepiol force-pushed the add-test-connection-button branch from 6e06d51 to bcda582 Compare July 27, 2026 14:31
@adrianSepiol adrianSepiol changed the title [ENHANCEMENT] Add UnsavedDatasourceStore and DatasourceTestConnection… [FEATURE] Add test datasource connection button Jul 27, 2026
const existing = draft.proxy.spec.allowedEndpoints ?? [];
const alreadyAllowed = existing.some((e) => e.endpointPattern === healthCheckPath && e.method === 'GET');
if (!alreadyAllowed) {
draft.proxy.spec.allowedEndpoints = [...existing, { endpointPattern: healthCheckPath, method: 'GET' }];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inserted as a regex, would it fail it the dots or other reserved characters are not escaped?

}, [testConnection, successSnackbar, exceptionSnackbar]);

return (
<Button onClick={handleClick} color="info" variant="outlined" {...buttonProps}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should have a testing... state and block the button while is testing, otherwise rapid clicks can cause multiple snackbars.

const pluginSpec = spec.plugin.spec;

if (hasDirectUrl(pluginSpec)) {
await fetch(`${pluginSpec.directUrl}${normalizedPath}`, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we sanitize this url?, it seems it might contain double slash // if directUrl ends with slash

value: Spec;
onChange: (next: Spec) => void;
isReadonly?: boolean;
testConnection?: () => Promise<void>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to apply for all plugins, is there a more concrete interface for the datasources editors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants