grafana/pkg/api/dtos/frontend_settings.go
Marcus Andersson 1cfd3f81fb
Plugins: Support for link extensions (#61663)
* added extensions to plugin.json and exposing it via frontend settings.

* added extensions to the plugin.json schema.

* changing the extensions in frontend settings to a map instead of an array.

* wip

* feat(pluginregistry): begin wiring up registry

* feat(pluginextensions): prevent duplicate links and clean up

* added test case for link extensions.

* added tests and implemented the getPluginLink function.

* wip

* feat(pluginextensions): expose plugin extension registry

* fix(pluginextensions): appease the typescript gods post rename

* renamed file and will throw error if trying to call setExtensionsRegistry if trying to call it twice.

* added reafactorings.

* fixed failing test.

* minor refactorings to make sure we only include extensions if the app is enabled.

* fixed some nits.

* Update public/app/features/plugins/extensions/registry.test.ts

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* Update packages/grafana-runtime/src/services/pluginExtensions/registry.ts

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* Update packages/grafana-runtime/src/services/pluginExtensions/registry.ts

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* Update public/app/features/plugins/extensions/registry.test.ts

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* Moved types for extensions from data to runtime.

* added a small example on how you could consume link extensions.

* renamed after feedback from levi.

* updated the plugindef.cue.

* using the generated plugin def.

* added tests for apps and extensions.

* fixed linting issues.

* wip

* wip

* wip

* wip

* test(extensions): fix up failing tests

* feat(extensions): freeze registry extension arrays, include type in registry items

* added restrictions in the pugindef cue schema.

* wip

* added required fields.

* added key to uniquely identify each item.

* test(pluginextensions): align tests with implementation

* chore(schema): refresh reference.md

---------

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
2023-02-07 17:20:05 +01:00

229 lines
11 KiB
Go

package dtos
import (
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/setting"
)
type FrontendSettingsAuthDTO struct {
OAuthSkipOrgRoleUpdateSync bool `json:"OAuthSkipOrgRoleUpdateSync"`
SAMLSkipOrgRoleSync bool `json:"SAMLSkipOrgRoleSync"`
LDAPSkipOrgRoleSync bool `json:"LDAPSkipOrgRoleSync"`
GoogleSkipOrgRoleSync bool `json:"GoogleSkipOrgRoleSync"`
GenericOAuthSkipOrgRoleSync bool `json:"GenericOAuthSkipOrgRoleSync"`
JWTAuthSkipOrgRoleSync bool `json:"JWTAuthSkipOrgRoleSync"`
GrafanaComSkipOrgRoleSync bool `json:"GrafanaComSkipOrgRoleSync"`
AzureADSkipOrgRoleSync bool `json:"AzureADSkipOrgRoleSync"`
GithubSkipOrgRoleSync bool `json:"GithubSkipOrgRoleSync"`
GitLabSkipOrgRoleSync bool `json:"GitLabSkipOrgRoleSync"`
OktaSkipOrgRoleSync bool `json:"OktaSkipOrgRoleSync"`
DisableSyncLock bool `json:"DisableSyncLock"`
}
type FrontendSettingsBuildInfoDTO struct {
HideVersion bool `json:"hideVersion"`
Version string `json:"version"`
Commit string `json:"commit"`
Buildstamp int64 `json:"buildstamp"`
Edition string `json:"edition"`
LatestVersion string `json:"latestVersion"`
HasUpdate bool `json:"hasUpdate"`
Env string `json:"env"`
}
type FrontendSettingsLicenseInfoDTO struct {
Expiry int64 `json:"expiry"`
StateInfo string `json:"stateInfo"`
LicenseUrl string `json:"licenseUrl"`
Edition string `json:"edition"`
EnabledFeatures map[string]bool `json:"enabledFeatures"`
// Enterprise-only
TrialExpiry *int64 `json:"trialExpiry,omitempty"`
AppUrl *string `json:"appUrl,omitempty"`
}
type FrontendSettingsAzureDTO struct {
Cloud string `json:"cloud"`
ManagedIdentityEnabled bool `json:"managedIdentityEnabled"`
}
type FrontendSettingsCachingDTO struct {
Enabled bool `json:"enabled"`
}
type FrontendSettingsRecordedQueriesDTO struct {
Enabled bool `json:"enabled"`
}
type FrontendSettingsReportingDTO struct {
Enabled bool `json:"enabled"`
}
type FrontendSettingsUnifiedAlertingDTO struct {
MinInterval string `json:"minInterval"`
}
type DashboardPreviewsSystemRequirements struct {
Met bool `json:"met"`
RequiredImageRendererPluginVersion string `json:"requiredImageRendererPluginVersion"`
}
type DashboardPreviewsSetupConfig struct {
SystemRequirements DashboardPreviewsSystemRequirements `json:"systemRequirements"`
ThumbnailsExist bool `json:"thumbnailsExist"`
}
// Enterprise-only
type FrontendSettingsLicensingDTO struct {
Slug *string `json:"slug,omitempty"`
LimitBy *string `json:"limitBy,omitempty"`
IncludedUsers *int64 `json:"includedUsers,omitempty"`
LicenseExpiry *int64 `json:"licenseExpiry,omitempty"`
LicenseExpiryWarnDays *int64 `json:"licenseExpiryWarnDays,omitempty"`
TokenExpiry *int64 `json:"tokenExpiry,omitempty"`
IsTrial *bool `json:"isTrial,omitempty"`
TokenExpiryWarnDays *int64 `json:"tokenExpiryWarnDays,omitempty"`
UsageBilling *bool `json:"usageBilling,omitempty"`
ActiveAdminsAndEditors *int64 `json:"activeAdminsAndEditors,omitempty"`
ActiveViewers *int64 `json:"activeViewers,omitempty"`
ActiveUsers *int64 `json:"ActiveUsers,omitempty"`
}
// Enterprise-only
type FrontendSettingsFooterConfigItemDTO struct {
Text string `json:"text"`
Url string `json:"url"`
Icon string `json:"icon"`
Target string `json:"blank"`
}
// Enterprise-only
type FrontendSettingsPublicDashboardFooterConfigDTO struct {
Hide bool `json:"hide"`
Text string `json:"text"`
Logo string `json:"logo"`
Link string `json:"link"`
}
// Enterprise-only
type FrontendSettingsWhitelabelingDTO struct {
Links []FrontendSettingsFooterConfigItemDTO `json:"links"`
LoginTitle string `json:"loginTitle"`
AppTitle *string `json:"appTitle,omitempty"`
LoginLogo *string `json:"loginLogo,omitempty"`
MenuLogo *string `json:"menuLogo,omitempty"`
LoginBackground *string `json:"loginBackground,omitempty"`
LoginSubtitle *string `json:"loginSubtitle,omitempty"`
LoginBoxBackground *string `json:"loginBoxBackground,omitempty"`
LoadingLogo *string `json:"loadingLogo,omitempty"`
PublicDashboardFooter *FrontendSettingsPublicDashboardFooterConfigDTO `json:"publicDashboardFooter,omitempty"` // PR TODO: type this properly
}
type FrontendSettingsDTO struct {
DefaultDatasource string `json:"defaultDatasource"`
Datasources map[string]plugins.DataSourceDTO `json:"datasources"`
MinRefreshInterval string `json:"minRefreshInterval"`
Panels map[string]plugins.PanelDTO `json:"panels"`
Apps map[string]*plugins.AppDTO `json:"apps"`
AppUrl string `json:"appUrl"`
AppSubUrl string `json:"appSubUrl"`
AllowOrgCreate bool `json:"allowOrgCreate"`
AuthProxyEnabled bool `json:"authProxyEnabled"`
LdapEnabled bool `json:"ldapEnabled"`
JwtHeaderName string `json:"jwtHeaderName"`
JwtUrlLogin bool `json:"jwtUrlLogin"`
AlertingEnabled bool `json:"alertingEnabled"`
AlertingErrorOrTimeout string `json:"alertingErrorOrTimeout"`
AlertingNoDataOrNullValues string `json:"alertingNoDataOrNullValues"`
AlertingMinInterval int64 `json:"alertingMinInterval"`
LiveEnabled bool `json:"liveEnabled"`
AutoAssignOrg bool `json:"autoAssignOrg"`
VerifyEmailEnabled bool `json:"verifyEmailEnabled"`
SigV4AuthEnabled bool `json:"sigV4AuthEnabled"`
AzureAuthEnabled bool `json:"azureAuthEnabled"`
RbacEnabled bool `json:"rbacEnabled"`
ExploreEnabled bool `json:"exploreEnabled"`
HelpEnabled bool `json:"helpEnabled"`
ProfileEnabled bool `json:"profileEnabled"`
QueryHistoryEnabled bool `json:"queryHistoryEnabled"`
GoogleAnalyticsId string `json:"googleAnalyticsId"`
GoogleAnalytics4Id string `json:"googleAnalytics4Id"`
GoogleAnalytics4SendManualPageViews bool `json:"GoogleAnalytics4SendManualPageViews"`
RudderstackWriteKey string `json:"rudderstackWriteKey"`
RudderstackDataPlaneUrl string `json:"rudderstackDataPlaneUrl"`
RudderstackSdkUrl string `json:"rudderstackSdkUrl"`
RudderstackConfigUrl string `json:"rudderstackConfigUrl"`
FeedbackLinksEnabled bool `json:"feedbackLinksEnabled"`
ApplicationInsightsConnectionString string `json:"applicationInsightsConnectionString"`
ApplicationInsightsEndpointUrl string `json:"applicationInsightsEndpointUrl"`
DisableLoginForm bool `json:"disableLoginForm"`
DisableUserSignUp bool `json:"disableUserSignUp"`
LoginHint string `json:"loginHint"`
PasswordHint string `json:"passwordHint"`
ExternalUserMngInfo string `json:"externalUserMngInfo"`
ExternalUserMngLinkUrl string `json:"externalUserMngLinkUrl"`
ExternalUserMngLinkName string `json:"externalUserMngLinkName"`
ViewersCanEdit bool `json:"viewersCanEdit"`
AngularSupportEnabled bool `json:"angularSupportEnabled"`
EditorsCanAdmin bool `json:"editorsCanAdmin"`
DisableSanitizeHtml bool `json:"disableSanitizeHtml"`
Auth FrontendSettingsAuthDTO `json:"auth"`
BuildInfo FrontendSettingsBuildInfoDTO `json:"buildInfo"`
LicenseInfo FrontendSettingsLicenseInfoDTO `json:"licenseInfo"`
FeatureToggles map[string]bool `json:"featureToggles"`
RendererAvailable bool `json:"rendererAvailable"`
RendererVersion string `json:"rendererVersion"`
SecretsManagerPluginEnabled bool `json:"secretsManagerPluginEnabled"`
Http2Enabled bool `json:"http2Enabled"`
Sentry setting.Sentry `json:"sentry"`
GrafanaJavascriptAgent setting.GrafanaJavascriptAgent `json:"grafanaJavascriptAgent"`
PluginCatalogURL string `json:"pluginCatalogURL"`
PluginAdminEnabled bool `json:"pluginAdminEnabled"`
PluginAdminExternalManageEnabled bool `json:"pluginAdminExternalManageEnabled"`
PluginCatalogHiddenPlugins []string `json:"pluginCatalogHiddenPlugins"`
ExpressionsEnabled bool `json:"expressionsEnabled"`
AwsAllowedAuthProviders []string `json:"awsAllowedAuthProviders"`
AwsAssumeRoleEnabled bool `json:"awsAssumeRoleEnabled"`
SupportBundlesEnabled bool `json:"supportBundlesEnabled"`
SnapshotEnabled bool `json:"snapshotEnabled"`
Azure FrontendSettingsAzureDTO `json:"azure"`
Caching FrontendSettingsCachingDTO `json:"caching"`
RecordedQueries FrontendSettingsRecordedQueriesDTO `json:"recordedQueries"`
Reporting FrontendSettingsReportingDTO `json:"reporting"`
UnifiedAlertingEnabled bool `json:"unifiedAlertingEnabled"`
UnifiedAlerting FrontendSettingsUnifiedAlertingDTO `json:"unifiedAlerting"`
Oauth map[string]interface{} `json:"oauth"`
SamlEnabled bool `json:"samlEnabled"`
SamlName string `json:"samlName"`
TokenExpirationDayLimit int `json:"tokenExpirationDayLimit"`
DashboardPreviews DashboardPreviewsSetupConfig `json:"dashboardPreviews,omitempty"`
GeomapDefaultBaseLayerConfig *map[string]interface{} `json:"geomapDefaultBaseLayerConfig,omitempty"`
GeomapDisableCustomBaseLayer bool `json:"geomapDisableCustomBaseLayer"`
IsPublicDashboardView bool `json:"isPublicDashboardView"`
DateFormats setting.DateFormats `json:"dateFormats,omitempty"`
LoginError string `json:"loginError,omitempty"`
PluginsCDNBaseURL string `json:"pluginsCDNBaseURL,omitempty"`
// Enterprise
Licensing *FrontendSettingsLicensingDTO `json:"licensing,omitempty"`
Whitelabeling *FrontendSettingsWhitelabelingDTO `json:"whitelabeling,omitempty"`
}