Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataSourceSettings: add support for expandable details #33189

Merged
merged 1 commit into from Apr 23, 2021

Conversation

vickyyyyyyy
Copy link
Member

What this PR does / why we need it:

In our enterprise plugins, in the ConfigEditor, we would like to be able to display more detailed error messages that are expandable. This would be helpful for stack traces or more technical errors (that can be collapsed by users).

Before

The alert component only looks at the message from the details payload:

{testingStatus.details?.message ?? null}

Screenshot 2021-04-20 at 18 57 32

After

In the plugin's CheckHealth, we can additionally pass in a verbose error message in the details:

response, err := datasource.API.TestDatasource(ctx)
if err != nil {
    jsonDetails := `{"message":"Could not connect to AppDynamics. This usually happens when the URL is incorrect.", "verboseMessage":"More error details here when expanded."}`

    return &backend.CheckHealthResult{
        Status:  backend.HealthStatusError,
        Message: "Authentication error (401)",
        JSONDetails: []byte(jsonDetails),
    }, nil
}

And this will be picked up by the page:

Screenshot 2021-04-20 at 18 41 23

Screenshot 2021-04-20 at 19 03 21

Which issue(s) this PR fixes:

Fixes https://github.com/grafana/integrations-team/issues/146

Special notes for your reviewer:

TIA 馃檹

@vickyyyyyyy vickyyyyyyy requested review from a team, jackw, natellium and Clarity-89 and removed request for a team April 20, 2021 18:10
@CLAassistant
Copy link

CLAassistant commented Apr 20, 2021

CLA assistant check
All committers have signed the CLA.

@@ -45,6 +45,7 @@ export enum HealthStatus {
* plugin.
*
* If the 'message' key exists, this will be displayed in the error message in DataSourceSettingsPage
* If the 'verboseMessage' key exists, this will be displayed in the expandable details in the error message in DataSourceSettingsPage
Copy link
Member

Choose a reason for hiding this comment

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

can we also add a go struct to the SDK with this same shape?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean replace the []byte type for JSONDetails https://github.com/grafana/grafana-plugin-sdk-go/blob/master/backend/diagnostics.go#L63 with something like this

type CheckHealthResultsJSONDetails struct {
	Message string `json:"message,omitempty"`
	VerboseMessage   string `json:"verboseMessage,omitempty"`
}

so we are able to define the specific fields we are expecting and be more strict with the keys or do you mean something else?

@ryantxu ryantxu self-requested a review April 20, 2021 19:24
@vickyyyyyyy vickyyyyyyy merged commit 99a04ed into master Apr 23, 2021
@vickyyyyyyy vickyyyyyyy deleted the add-verbose-message-datasource-settings-alert branch April 23, 2021 09:37
mortenaa pushed a commit to mortenaa/grafana that referenced this pull request May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants