From 6649f35f20a4df4417ce68fd18cd6a45cadddaed Mon Sep 17 00:00:00 2001 From: jkoberg Date: Fri, 28 Apr 2023 11:28:41 +0200 Subject: [PATCH 1/4] use custom struct for web options Signed-off-by: jkoberg --- changelog/unreleased/web-config.md | 5 ++ services/web/pkg/config/config.go | 20 +++--- .../web/pkg/config/defaults/defaultconfig.go | 4 +- services/web/pkg/config/options.go | 65 +++++++++++++++++++ 4 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 changelog/unreleased/web-config.md create mode 100644 services/web/pkg/config/options.go diff --git a/changelog/unreleased/web-config.md b/changelog/unreleased/web-config.md new file mode 100644 index 00000000000..8d277b477a8 --- /dev/null +++ b/changelog/unreleased/web-config.md @@ -0,0 +1,5 @@ +Enhancement: Web options configuration + +Hardcode web options instead of using a generic `map[string]interface{}` + +https://github.com/owncloud/ocis/pull/6188 diff --git a/services/web/pkg/config/config.go b/services/web/pkg/config/config.go index c27ab9d181f..d7aed85a87f 100644 --- a/services/web/pkg/config/config.go +++ b/services/web/pkg/config/config.go @@ -51,16 +51,16 @@ type CustomTranslation struct { // WebConfig defines the available web configuration for a dynamically rendered config.json. type WebConfig struct { - Server string `json:"server,omitempty" yaml:"server" env:"OCIS_URL;WEB_UI_CONFIG_SERVER" desc:"URL, where the oCIS APIs are reachable for ownCloud Web."` - Theme string `json:"theme,omitempty" yaml:"-"` - OpenIDConnect OIDC `json:"openIdConnect,omitempty" yaml:"oidc"` - Apps []string `json:"apps" yaml:"apps"` - Applications []Application `json:"applications,omitempty" yaml:"applications"` - ExternalApps []ExternalApp `json:"external_apps,omitempty" yaml:"external_apps"` - Options map[string]interface{} `json:"options,omitempty" yaml:"options"` - Styles []CustomStyle `json:"styles,omitempty" yaml:"styles"` - Scripts []CustomScript `json:"scripts,omitempty" yaml:"scripts"` - Translations []CustomTranslation `json:"customTranslations,omitempty" yaml:"custom_translations"` + Server string `json:"server,omitempty" yaml:"server" env:"OCIS_URL;WEB_UI_CONFIG_SERVER" desc:"URL, where the oCIS APIs are reachable for ownCloud Web."` + Theme string `json:"theme,omitempty" yaml:"-"` + OpenIDConnect OIDC `json:"openIdConnect,omitempty" yaml:"oidc"` + Apps []string `json:"apps" yaml:"apps"` + Applications []Application `json:"applications,omitempty" yaml:"applications"` + ExternalApps []ExternalApp `json:"external_apps,omitempty" yaml:"external_apps"` + Options Options `json:"options,omitempty" yaml:"options"` + Styles []CustomStyle `json:"styles,omitempty" yaml:"styles"` + Scripts []CustomScript `json:"scripts,omitempty" yaml:"scripts"` + Translations []CustomTranslation `json:"customTranslations,omitempty" yaml:"custom_translations"` } // OIDC defines the available oidc configuration diff --git a/services/web/pkg/config/defaults/defaultconfig.go b/services/web/pkg/config/defaults/defaultconfig.go index 1c1446320d9..e0575aa7f4f 100644 --- a/services/web/pkg/config/defaults/defaultconfig.go +++ b/services/web/pkg/config/defaults/defaultconfig.go @@ -66,8 +66,8 @@ func DefaultConfig() *config.Config { }, }, }, - Options: map[string]interface{}{ - "previewFileMimeTypes": []string{"image/gif", "image/png", "image/jpeg", "text/plain", "image/tiff", "image/bmp", "image/x-ms-bmp"}, + Options: config.Options{ + PreviewFileMimeTypes: []string{"image/gif", "image/png", "image/jpeg", "text/plain", "image/tiff", "image/bmp", "image/x-ms-bmp"}, }, }, }, diff --git a/services/web/pkg/config/options.go b/services/web/pkg/config/options.go new file mode 100644 index 00000000000..a8669049145 --- /dev/null +++ b/services/web/pkg/config/options.go @@ -0,0 +1,65 @@ +package config + +// Options are the option for the web +type Options struct { + HomeFolder string `json:"homeFolder" yaml:"homeFolder" env:"WEB_OPTION_HOME_FOLDER" desc:"You can specify a folder that is used when the user navigates 'home'. Navigating home gets triggered by clicking on the 'All files' menu item. The user will not be jailed in that directory. It simply serves as a default location. You can either provide a static location, or you can use variables of the user object to come up with a user specific home path. This uses twig template variable style and allows you to pick a value or a substring of a value of the authenticated user. Examples are '/Shares', '/{{.Id}}' and '/{{substr 0 3 .Id}}/{{.Id}'."` + OpenAppsInTab bool `json:"openAppsInTab" yaml:"openAppsInTab" env:"WEB_OPTION_OPEN_APPS_IN_TAB" desc:"Configures whether apps and extensions generally should open in a new tab. Defaults to false."` + DisablePreviews bool `json:"disablePreviews" yaml:"disablePreviews" env:"WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different file listing views. The only list view that is not affected by this is the trash bin, as that doesn't allow showing previews at all."` + PreviewFileMimeTypes []string `json:"previewFileMimeTypes" yaml:"previewFileMimeTypes" env:"WEB_OPTION_PREVIEW_FILE_MIMETYPES" desc:"Specifies which mimeTypes will be previewed in the ui. For example to only preview jpg and text files set this option to ['image/jpeg', 'text/plain']."` + AccountEditLink AccountEditLink `json:"accountEditLink" yaml:"accountEditLink"` + DisableFeedbackLink bool `json:"disableFeedbackLink" yaml:"disableFeedbackLink" env:"WEB_OPTION_DISABLE_FEEDBACK_LINK" desc:"Set this option to 'true' to disable the feedback link in the topbar. Keeping it enabled (value 'false' or absence of the option) allows ownCloud to get feedback from your user base through a dedicated survey website."` + FeedbackLink FeedbackLink `json:"feedbackLink" yaml:"feedbackLink"` + SharingRecipientsPerPage int `json:"sharingRecipientsPerPage" yaml:"sharingRecipientsPerPage" env:"WEB_OPTION_SHARING_RECIPIENTS_PER_PAGE" desc:"Sets the amount of users shown as recipients in the dropdown when sharing resources. Default amount is 200."` + Sidebar Sidebar `json:"sidebar" yaml:"sidebar"` + RunningOnEOS bool `json:"runningOnEos" yaml:"runningOnEos" env:"WEB_OPTION_RUNNING_ON_EOS" desc:"Set this option to 'true' if running on an [EOS storage backend](https://eos-web.web.cern.ch/eos-web/) to enable its specific features. Defaults to 'false'."` + CernFeatures bool `json:"cernFeatures" yaml:"cernFeatures" env:"WEB_OPTION_CERN_FEATURES" desc:"Enabling this will activate CERN-specific features. Defaults to 'false'."` + HoverableQuickActions bool `json:"hoverableQuickActions" yaml:"hoverableQuickActions" env:"WEB_OPTION_HOVERABLE_QUICK_ACTIONS" desc:"Set this option to 'true' to hide the quick actions (buttons appearing on file rows), and only show them when the user hovers the row with his mouse. Defaults to 'false'."` + Routing Routing `json:"routing" yaml:"routing"` + Upload Upload `json:"upload" yaml:"upload"` + Editor Editor `json:"editor" yaml:"editor"` + ContextHelpersReadMore bool `json:"contextHelpersReadMore" yaml:"contextHelpersReadMore" env:"WEB_OPTION_CONTEXTHELPERS_READ_MORE" desc:"Specifies whether the 'Read more' link should be displayed or not."` + LogoutURL string `json:"logoutURL" yaml:"logoutURL" env:"WEB_OPTION_LOGOUT_URL" desc:"The logout url"` +} + +// AccountEditLink are the AccountEditLink options +type AccountEditLink struct { + Href string `json:"href" yaml:"href" env:"WEB_OPTION_ACCOUNT_EDIT_LINK_HREF" desc:"Set a different target URL for the edit link. Make sure to prepend it with 'http(s)://'."` +} + +// FeedbackLink are the feedback link options +type FeedbackLink struct { + Href string `json:"href" yaml:"href" env:"WEB_OPTION_FEEDBACKLINK_HREF" desc:"Set a different target URL for the feedback link. Make sure to prepend it with 'http(s)://'. Defaults to 'https://owncloud.com/web-design-feedback'.` + AriaLabel string `json:"ariaLabel" yaml:"ariaLabel" env:"WEB_OPTION_ARIALABEL" desc:"Since the link only has an icon, you can set an e.g. screen reader accessible label. Defaults to 'ownCloud feedback survey'.` + Description string `json:"description" yaml:"description" env:"WEB_OPTION_DESCRIPTION" desc:"Provide any description you want to see as tooltip and as accessible description. Defaults to 'Provide your feedback: We'd like to improve the web design and would be happy to hear your feedback. Thank you! Your ownCloud team'.` +} + +// Sidebar are the side bar option +type Sidebar struct { + Shares SidebarShares `json:"shares" yaml:"shares"` +} + +// SidebarShares are the options for the shares side bar +type SidebarShares struct { + ShowAllOnLoad bool `json:"showAllOnLoad" yaml:"showAllOnLoad" env:"WEB_OPTION_SIDEBAR_SHARES_SHOW_ALL_ON_LOAD" desc:"Sets the list of (link) shares list in the sidebar to be initially expanded (default is a collapsed state, only showing the first three shares)."` +} + +// Routing are the routing options +type Routing struct { + IDBased bool `json:"idBased" yaml:"idBased" env:"WEB_OPTION_ROUTING_ID_BASED" desc:"Enable or disable fileIds being added to the URL. Defaults to 'true' because otherwise e.g. spaces with name clashes can't be resolved correctly. Only disable this if you can guarantee server side that spaces of the same namespace can't have name clashes."` +} + +// Upload are the upload options +type Upload struct { + XHR XHR `json:"xhr" yaml:"xhr"` +} + +// XHR are the XHR options +type XHR struct { + Timeout int `json:"timeout" yaml:"timeout" desc:"Specifies the timeout for XHR uploads in milliseconds."` +} + +// Editor are the web editor options +type Editor struct { + AutosaveEnabled bool `json:"autosaveEnabled" yaml:"autosaveEnabled" env:"WEB_OPTION_EDITOR_AUTOSAVE_ENABLED" desc:"Specifies if the autosave for the editor apps is enabled."` + AutosaveInterval int `json:"autosaveInterval" yaml:"autosaveInterval" env:"WEB_OPTION_EDITOR_AUTOSAVE_INTERVAL" desc:"Specifies the time interval for the autosave of editor apps in seconds."` +} From 6cb5be4e658424b7dd03b1a8db20a664ee230de0 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Fri, 28 Apr 2023 13:42:29 +0200 Subject: [PATCH 2/4] update envvar descriptions Co-authored-by: Martin --- services/web/pkg/config/options.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/services/web/pkg/config/options.go b/services/web/pkg/config/options.go index a8669049145..8ca035e04d7 100644 --- a/services/web/pkg/config/options.go +++ b/services/web/pkg/config/options.go @@ -2,23 +2,23 @@ package config // Options are the option for the web type Options struct { - HomeFolder string `json:"homeFolder" yaml:"homeFolder" env:"WEB_OPTION_HOME_FOLDER" desc:"You can specify a folder that is used when the user navigates 'home'. Navigating home gets triggered by clicking on the 'All files' menu item. The user will not be jailed in that directory. It simply serves as a default location. You can either provide a static location, or you can use variables of the user object to come up with a user specific home path. This uses twig template variable style and allows you to pick a value or a substring of a value of the authenticated user. Examples are '/Shares', '/{{.Id}}' and '/{{substr 0 3 .Id}}/{{.Id}'."` - OpenAppsInTab bool `json:"openAppsInTab" yaml:"openAppsInTab" env:"WEB_OPTION_OPEN_APPS_IN_TAB" desc:"Configures whether apps and extensions generally should open in a new tab. Defaults to false."` - DisablePreviews bool `json:"disablePreviews" yaml:"disablePreviews" env:"WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different file listing views. The only list view that is not affected by this is the trash bin, as that doesn't allow showing previews at all."` - PreviewFileMimeTypes []string `json:"previewFileMimeTypes" yaml:"previewFileMimeTypes" env:"WEB_OPTION_PREVIEW_FILE_MIMETYPES" desc:"Specifies which mimeTypes will be previewed in the ui. For example to only preview jpg and text files set this option to ['image/jpeg', 'text/plain']."` + HomeFolder string `json:"homeFolder" yaml:"homeFolder" env:"WEB_OPTION_HOME_FOLDER" desc:"Specifies a folder that is used when the user navigates 'home'. Navigating home gets triggered by clicking on the 'All files' menu item. The user will not be jailed in that directory, it simply serves as a default location. A static location can be provided, or variables of the user object to come up with a user specific home path can be used. This uses the twig template variable style and allows to pick a value or a substring of a value of the authenticated user. Examples are '/Shares', '/{{.Id}}' and '/{{substr 0 3 .Id}}/{{.Id}'."` + OpenAppsInTab bool `json:"openAppsInTab" yaml:"openAppsInTab" env:"WEB_OPTION_OPEN_APPS_IN_TAB" desc:"Configures whether apps and extensions should generally open in a new tab. Defaults to false."` + DisablePreviews bool `json:"disablePreviews" yaml:"disablePreviews" env:"WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different file listing views. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all."` + PreviewFileMimeTypes []string `json:"previewFileMimeTypes" yaml:"previewFileMimeTypes" env:"WEB_OPTION_PREVIEW_FILE_MIMETYPES" desc:"Specifies which mimeTypes will be previewed in the UI. For example to only preview jpg and text files, set this option to ['image/jpeg', 'text/plain']."` AccountEditLink AccountEditLink `json:"accountEditLink" yaml:"accountEditLink"` - DisableFeedbackLink bool `json:"disableFeedbackLink" yaml:"disableFeedbackLink" env:"WEB_OPTION_DISABLE_FEEDBACK_LINK" desc:"Set this option to 'true' to disable the feedback link in the topbar. Keeping it enabled (value 'false' or absence of the option) allows ownCloud to get feedback from your user base through a dedicated survey website."` + DisableFeedbackLink bool `json:"disableFeedbackLink" yaml:"disableFeedbackLink" env:"WEB_OPTION_DISABLE_FEEDBACK_LINK" desc:"Set this option to 'true' to disable the feedback link in the topbar. Keeping it enabled by setting the value to 'false' or with the absence of the option, allows ownCloud to get feedback from your user base through a dedicated survey website."` FeedbackLink FeedbackLink `json:"feedbackLink" yaml:"feedbackLink"` - SharingRecipientsPerPage int `json:"sharingRecipientsPerPage" yaml:"sharingRecipientsPerPage" env:"WEB_OPTION_SHARING_RECIPIENTS_PER_PAGE" desc:"Sets the amount of users shown as recipients in the dropdown when sharing resources. Default amount is 200."` + SharingRecipientsPerPage int `json:"sharingRecipientsPerPage" yaml:"sharingRecipientsPerPage" env:"WEB_OPTION_SHARING_RECIPIENTS_PER_PAGE" desc:"Sets the amount of users shown as recipients in the dropdown menu when sharing resources. Default amount is 200."` Sidebar Sidebar `json:"sidebar" yaml:"sidebar"` - RunningOnEOS bool `json:"runningOnEos" yaml:"runningOnEos" env:"WEB_OPTION_RUNNING_ON_EOS" desc:"Set this option to 'true' if running on an [EOS storage backend](https://eos-web.web.cern.ch/eos-web/) to enable its specific features. Defaults to 'false'."` - CernFeatures bool `json:"cernFeatures" yaml:"cernFeatures" env:"WEB_OPTION_CERN_FEATURES" desc:"Enabling this will activate CERN-specific features. Defaults to 'false'."` - HoverableQuickActions bool `json:"hoverableQuickActions" yaml:"hoverableQuickActions" env:"WEB_OPTION_HOVERABLE_QUICK_ACTIONS" desc:"Set this option to 'true' to hide the quick actions (buttons appearing on file rows), and only show them when the user hovers the row with his mouse. Defaults to 'false'."` + RunningOnEOS bool `json:"runningOnEos" yaml:"runningOnEos" env:"WEB_OPTION_RUNNING_ON_EOS" desc:"Set this option to 'true' if running on an EOS storage backend (https://eos-web.web.cern.ch/eos-web/) to enable its specific features. Defaults to 'false'."` + CernFeatures bool `json:"cernFeatures" yaml:"cernFeatures"` + HoverableQuickActions bool `json:"hoverableQuickActions" yaml:"hoverableQuickActions" env:"WEB_OPTION_HOVERABLE_QUICK_ACTIONS" desc:"Set this option to 'true' to hide quick actions (buttons appearing on file rows) and only show them when the user hovers over the row with his mouse. Defaults to 'false'."` Routing Routing `json:"routing" yaml:"routing"` Upload Upload `json:"upload" yaml:"upload"` Editor Editor `json:"editor" yaml:"editor"` ContextHelpersReadMore bool `json:"contextHelpersReadMore" yaml:"contextHelpersReadMore" env:"WEB_OPTION_CONTEXTHELPERS_READ_MORE" desc:"Specifies whether the 'Read more' link should be displayed or not."` - LogoutURL string `json:"logoutURL" yaml:"logoutURL" env:"WEB_OPTION_LOGOUT_URL" desc:"The logout url"` + LogoutURL string `json:"logoutURL" yaml:"logoutURL" env:"WEB_OPTION_LOGOUT_URL" desc:"Adds a link to the user's profile page to point him to an external page, where he can manage his session and devices. This is helpful when an external IdP is used. This option is disabled by default."` } // AccountEditLink are the AccountEditLink options @@ -28,9 +28,9 @@ type AccountEditLink struct { // FeedbackLink are the feedback link options type FeedbackLink struct { - Href string `json:"href" yaml:"href" env:"WEB_OPTION_FEEDBACKLINK_HREF" desc:"Set a different target URL for the feedback link. Make sure to prepend it with 'http(s)://'. Defaults to 'https://owncloud.com/web-design-feedback'.` - AriaLabel string `json:"ariaLabel" yaml:"ariaLabel" env:"WEB_OPTION_ARIALABEL" desc:"Since the link only has an icon, you can set an e.g. screen reader accessible label. Defaults to 'ownCloud feedback survey'.` - Description string `json:"description" yaml:"description" env:"WEB_OPTION_DESCRIPTION" desc:"Provide any description you want to see as tooltip and as accessible description. Defaults to 'Provide your feedback: We'd like to improve the web design and would be happy to hear your feedback. Thank you! Your ownCloud team'.` + Href string `json:"href" yaml:"href" env:"WEB_OPTION_FEEDBACKLINK_HREF" desc:"Set a target URL for the feedback link. Make sure to prepend it with 'http(s)://'. Defaults to 'https://owncloud.com/web-design-feedback'."` + AriaLabel string `json:"ariaLabel" yaml:"ariaLabel" env:"WEB_OPTION_FEEDBACKLINK_ARIALABEL" desc:"Since the feedback link only has an icon, a screen reader accessible label can be set. The text defaults to 'ownCloud feedback survey'."` + Description string `json:"description" yaml:"description" env:"WEB_OPTION_FEEDBACKLINK_DESCRIPTION" desc:"For feedbacks, provide any description you want to see as tooltip and as accessible description. Defaults to 'Provide your feedback: We'd like to improve the web design and would be happy to hear your feedback. Thank you! Your ownCloud team'."` } // Sidebar are the side bar option @@ -40,12 +40,12 @@ type Sidebar struct { // SidebarShares are the options for the shares side bar type SidebarShares struct { - ShowAllOnLoad bool `json:"showAllOnLoad" yaml:"showAllOnLoad" env:"WEB_OPTION_SIDEBAR_SHARES_SHOW_ALL_ON_LOAD" desc:"Sets the list of (link) shares list in the sidebar to be initially expanded (default is a collapsed state, only showing the first three shares)."` + ShowAllOnLoad bool `json:"showAllOnLoad" yaml:"showAllOnLoad" env:"WEB_OPTION_SIDEBAR_SHARES_SHOW_ALL_ON_LOAD" desc:"Sets the list of the (link) shares list in the sidebar to be initially expanded. Default is a collapsed state, only showing the first three shares."` } // Routing are the routing options type Routing struct { - IDBased bool `json:"idBased" yaml:"idBased" env:"WEB_OPTION_ROUTING_ID_BASED" desc:"Enable or disable fileIds being added to the URL. Defaults to 'true' because otherwise e.g. spaces with name clashes can't be resolved correctly. Only disable this if you can guarantee server side that spaces of the same namespace can't have name clashes."` + IDBased bool `json:"idBased" yaml:"idBased" env:"WEB_OPTION_ROUTING_ID_BASED" desc:"Enable or disable fileIds being added to the URL. Defaults to 'true', because otherwise spaces with name clashes cannot be resolved correctly. Note: Only disable this if you can guarantee on the server side, that spaces of the same namespace cannot have name clashes."` } // Upload are the upload options From ef5ca7de309f63a3929a1b8ad0e04a08747ee216 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Fri, 28 Apr 2023 22:19:02 +0200 Subject: [PATCH 3/4] Use correct defaults --- .../web/pkg/config/defaults/defaultconfig.go | 32 ++++++++++- services/web/pkg/config/options.go | 54 +++++++++---------- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/services/web/pkg/config/defaults/defaultconfig.go b/services/web/pkg/config/defaults/defaultconfig.go index e0575aa7f4f..d725885d544 100644 --- a/services/web/pkg/config/defaults/defaultconfig.go +++ b/services/web/pkg/config/defaults/defaultconfig.go @@ -67,7 +67,19 @@ func DefaultConfig() *config.Config { }, }, Options: config.Options{ - PreviewFileMimeTypes: []string{"image/gif", "image/png", "image/jpeg", "text/plain", "image/tiff", "image/bmp", "image/x-ms-bmp"}, + ContextHelpersReadMore: true, + PreviewFileMimeTypes: []string{"image/gif", "image/png", "image/jpeg", "text/plain", "image/tiff", "image/bmp", "image/x-ms-bmp"}, + SharingRecipientsPerPage: 200, + AccountEditLink: &config.AccountEditLink{}, + Editor: &config.Editor{}, + FeedbackLink: &config.FeedbackLink{}, + Routing: config.Routing{ + IDBased: true, + }, + Sidebar: config.Sidebar{ + Shares: config.SidebarShares{}, + }, + Upload: &config.Upload{}, }, }, }, @@ -121,4 +133,22 @@ func Sanitize(cfg *config.Config) { if cfg.Web.Config.OpenIDConnect.MetadataURL == "" { cfg.Web.Config.OpenIDConnect.MetadataURL = strings.TrimRight(cfg.Web.Config.OpenIDConnect.Authority, "/") + "/.well-known/openid-configuration" } + // remove AccountEdit parent if no value is set + if cfg.Web.Config.Options.AccountEditLink.Href == "" { + cfg.Web.Config.Options.AccountEditLink = nil + } + // remove Editor parent if no value is set + if cfg.Web.Config.Options.Editor.AutosaveEnabled == false { + cfg.Web.Config.Options.Editor = nil + } + // remove FeedbackLink parent if no value is set + if cfg.Web.Config.Options.FeedbackLink.Href == "" && + cfg.Web.Config.Options.FeedbackLink.AriaLabel == "" && + cfg.Web.Config.Options.FeedbackLink.Description == "" { + cfg.Web.Config.Options.FeedbackLink = nil + } + // remove Upload parent if no value is set + if cfg.Web.Config.Options.Upload.XHR.Timeout == 0 { + cfg.Web.Config.Options.Upload = nil + } } diff --git a/services/web/pkg/config/options.go b/services/web/pkg/config/options.go index 8ca035e04d7..98a27842f02 100644 --- a/services/web/pkg/config/options.go +++ b/services/web/pkg/config/options.go @@ -2,43 +2,43 @@ package config // Options are the option for the web type Options struct { - HomeFolder string `json:"homeFolder" yaml:"homeFolder" env:"WEB_OPTION_HOME_FOLDER" desc:"Specifies a folder that is used when the user navigates 'home'. Navigating home gets triggered by clicking on the 'All files' menu item. The user will not be jailed in that directory, it simply serves as a default location. A static location can be provided, or variables of the user object to come up with a user specific home path can be used. This uses the twig template variable style and allows to pick a value or a substring of a value of the authenticated user. Examples are '/Shares', '/{{.Id}}' and '/{{substr 0 3 .Id}}/{{.Id}'."` - OpenAppsInTab bool `json:"openAppsInTab" yaml:"openAppsInTab" env:"WEB_OPTION_OPEN_APPS_IN_TAB" desc:"Configures whether apps and extensions should generally open in a new tab. Defaults to false."` - DisablePreviews bool `json:"disablePreviews" yaml:"disablePreviews" env:"WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different file listing views. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all."` - PreviewFileMimeTypes []string `json:"previewFileMimeTypes" yaml:"previewFileMimeTypes" env:"WEB_OPTION_PREVIEW_FILE_MIMETYPES" desc:"Specifies which mimeTypes will be previewed in the UI. For example to only preview jpg and text files, set this option to ['image/jpeg', 'text/plain']."` - AccountEditLink AccountEditLink `json:"accountEditLink" yaml:"accountEditLink"` - DisableFeedbackLink bool `json:"disableFeedbackLink" yaml:"disableFeedbackLink" env:"WEB_OPTION_DISABLE_FEEDBACK_LINK" desc:"Set this option to 'true' to disable the feedback link in the topbar. Keeping it enabled by setting the value to 'false' or with the absence of the option, allows ownCloud to get feedback from your user base through a dedicated survey website."` - FeedbackLink FeedbackLink `json:"feedbackLink" yaml:"feedbackLink"` - SharingRecipientsPerPage int `json:"sharingRecipientsPerPage" yaml:"sharingRecipientsPerPage" env:"WEB_OPTION_SHARING_RECIPIENTS_PER_PAGE" desc:"Sets the amount of users shown as recipients in the dropdown menu when sharing resources. Default amount is 200."` - Sidebar Sidebar `json:"sidebar" yaml:"sidebar"` - RunningOnEOS bool `json:"runningOnEos" yaml:"runningOnEos" env:"WEB_OPTION_RUNNING_ON_EOS" desc:"Set this option to 'true' if running on an EOS storage backend (https://eos-web.web.cern.ch/eos-web/) to enable its specific features. Defaults to 'false'."` - CernFeatures bool `json:"cernFeatures" yaml:"cernFeatures"` - HoverableQuickActions bool `json:"hoverableQuickActions" yaml:"hoverableQuickActions" env:"WEB_OPTION_HOVERABLE_QUICK_ACTIONS" desc:"Set this option to 'true' to hide quick actions (buttons appearing on file rows) and only show them when the user hovers over the row with his mouse. Defaults to 'false'."` - Routing Routing `json:"routing" yaml:"routing"` - Upload Upload `json:"upload" yaml:"upload"` - Editor Editor `json:"editor" yaml:"editor"` - ContextHelpersReadMore bool `json:"contextHelpersReadMore" yaml:"contextHelpersReadMore" env:"WEB_OPTION_CONTEXTHELPERS_READ_MORE" desc:"Specifies whether the 'Read more' link should be displayed or not."` - LogoutURL string `json:"logoutURL" yaml:"logoutURL" env:"WEB_OPTION_LOGOUT_URL" desc:"Adds a link to the user's profile page to point him to an external page, where he can manage his session and devices. This is helpful when an external IdP is used. This option is disabled by default."` + HomeFolder string `json:"homeFolder,omitempty" yaml:"homeFolder" env:"WEB_OPTION_HOME_FOLDER" desc:"Specifies a folder that is used when the user navigates 'home'. Navigating home gets triggered by clicking on the 'All files' menu item. The user will not be jailed in that directory, it simply serves as a default location. A static location can be provided, or variables of the user object to come up with a user specific home path can be used. This uses the twig template variable style and allows to pick a value or a substring of a value of the authenticated user. Examples are '/Shares', '/{{.Id}}' and '/{{substr 0 3 .Id}}/{{.Id}'."` + OpenAppsInTab bool `json:"openAppsInTab,omitempty" yaml:"openAppsInTab" env:"WEB_OPTION_OPEN_APPS_IN_TAB" desc:"Configures whether apps and extensions should generally open in a new tab. Defaults to false."` + DisablePreviews bool `json:"disablePreviews,omitempty" yaml:"disablePreviews" env:"WEB_OPTION_DISABLE_PREVIEWS" desc:"Set this option to 'true' to disable previews in all the different file listing views. The only list view that is not affected by this setting is the trash bin, as it does not allow previewing at all."` + PreviewFileMimeTypes []string `json:"previewFileMimeTypes,omitempty" yaml:"previewFileMimeTypes" env:"WEB_OPTION_PREVIEW_FILE_MIMETYPES" desc:"Specifies which mimeTypes will be previewed in the UI. For example to only preview jpg and text files, set this option to ['image/jpeg', 'text/plain']."` + AccountEditLink *AccountEditLink `json:"accountEditLink,omitempty" yaml:"accountEditLink"` + DisableFeedbackLink bool `json:"disableFeedbackLink,omitempty" yaml:"disableFeedbackLink" env:"WEB_OPTION_DISABLE_FEEDBACK_LINK" desc:"Set this option to 'true' to disable the feedback link in the topbar. Keeping it enabled by setting the value to 'false' or with the absence of the option, allows ownCloud to get feedback from your user base through a dedicated survey website."` + FeedbackLink *FeedbackLink `json:"feedbackLink,omitempty" yaml:"feedbackLink"` + SharingRecipientsPerPage int `json:"sharingRecipientsPerPage,omitempty" yaml:"sharingRecipientsPerPage" env:"WEB_OPTION_SHARING_RECIPIENTS_PER_PAGE" desc:"Sets the amount of users shown as recipients in the dropdown menu when sharing resources. Default amount is 200."` + Sidebar Sidebar `json:"sidebar" yaml:"sidebar"` + RunningOnEOS bool `json:"runningOnEos,omitempty" yaml:"runningOnEos" env:"WEB_OPTION_RUNNING_ON_EOS" desc:"Set this option to 'true' if running on an EOS storage backend (https://eos-web.web.cern.ch/eos-web/) to enable its specific features. Defaults to 'false'."` + CernFeatures bool `json:"cernFeatures,omitempty" yaml:"cernFeatures"` + HoverableQuickActions bool `json:"hoverableQuickActions,omitempty" yaml:"hoverableQuickActions" env:"WEB_OPTION_HOVERABLE_QUICK_ACTIONS" desc:"Set this option to 'true' to hide quick actions (buttons appearing on file rows) and only show them when the user hovers over the row with his mouse. Defaults to 'false'."` + Routing Routing `json:"routing" yaml:"routing"` + Upload *Upload `json:"upload,omitempty" yaml:"upload"` + Editor *Editor `json:"editor,omitempty" yaml:"editor"` + ContextHelpersReadMore bool `json:"contextHelpersReadMore,omitempty" yaml:"contextHelpersReadMore" env:"WEB_OPTION_CONTEXTHELPERS_READ_MORE" desc:"Specifies whether the 'Read more' link should be displayed or not."` + LogoutURL string `json:"logoutURL,omitempty" yaml:"logoutURL" env:"WEB_OPTION_LOGOUT_URL" desc:"Adds a link to the user's profile page to point him to an external page, where he can manage his session and devices. This is helpful when an external IdP is used. This option is disabled by default."` } // AccountEditLink are the AccountEditLink options type AccountEditLink struct { - Href string `json:"href" yaml:"href" env:"WEB_OPTION_ACCOUNT_EDIT_LINK_HREF" desc:"Set a different target URL for the edit link. Make sure to prepend it with 'http(s)://'."` + Href string `json:"href,omitempty" yaml:"href" env:"WEB_OPTION_ACCOUNT_EDIT_LINK_HREF" desc:"Set a different target URL for the edit link. Make sure to prepend it with 'http(s)://'."` } // FeedbackLink are the feedback link options type FeedbackLink struct { - Href string `json:"href" yaml:"href" env:"WEB_OPTION_FEEDBACKLINK_HREF" desc:"Set a target URL for the feedback link. Make sure to prepend it with 'http(s)://'. Defaults to 'https://owncloud.com/web-design-feedback'."` - AriaLabel string `json:"ariaLabel" yaml:"ariaLabel" env:"WEB_OPTION_FEEDBACKLINK_ARIALABEL" desc:"Since the feedback link only has an icon, a screen reader accessible label can be set. The text defaults to 'ownCloud feedback survey'."` - Description string `json:"description" yaml:"description" env:"WEB_OPTION_FEEDBACKLINK_DESCRIPTION" desc:"For feedbacks, provide any description you want to see as tooltip and as accessible description. Defaults to 'Provide your feedback: We'd like to improve the web design and would be happy to hear your feedback. Thank you! Your ownCloud team'."` + Href string `json:"href,omitempty" yaml:"href" env:"WEB_OPTION_FEEDBACKLINK_HREF" desc:"Set a target URL for the feedback link. Make sure to prepend it with 'http(s)://'. Defaults to 'https://owncloud.com/web-design-feedback'."` + AriaLabel string `json:"ariaLabel,omitempty" yaml:"ariaLabel" env:"WEB_OPTION_FEEDBACKLINK_ARIALABEL" desc:"Since the feedback link only has an icon, a screen reader accessible label can be set. The text defaults to 'ownCloud feedback survey'."` + Description string `json:"description,omitempty" yaml:"description" env:"WEB_OPTION_FEEDBACKLINK_DESCRIPTION" desc:"For feedbacks, provide any description you want to see as tooltip and as accessible description. Defaults to 'Provide your feedback: We'd like to improve the web design and would be happy to hear your feedback. Thank you! Your ownCloud team'."` } -// Sidebar are the side bar option +// Sidebar are the sidebar option type Sidebar struct { Shares SidebarShares `json:"shares" yaml:"shares"` } -// SidebarShares are the options for the shares side bar +// SidebarShares are the options for the shares sidebar type SidebarShares struct { ShowAllOnLoad bool `json:"showAllOnLoad" yaml:"showAllOnLoad" env:"WEB_OPTION_SIDEBAR_SHARES_SHOW_ALL_ON_LOAD" desc:"Sets the list of the (link) shares list in the sidebar to be initially expanded. Default is a collapsed state, only showing the first three shares."` } @@ -50,16 +50,16 @@ type Routing struct { // Upload are the upload options type Upload struct { - XHR XHR `json:"xhr" yaml:"xhr"` + XHR XHR `json:"xhr,omitempty" yaml:"xhr"` } // XHR are the XHR options type XHR struct { - Timeout int `json:"timeout" yaml:"timeout" desc:"Specifies the timeout for XHR uploads in milliseconds."` + Timeout int `json:"timeout,omitempty" yaml:"timeout" env:"WEB_OPTION_UPLOAD_XHR_TIMEOUT" desc:"Specifies the timeout for XHR uploads in milliseconds."` } // Editor are the web editor options type Editor struct { - AutosaveEnabled bool `json:"autosaveEnabled" yaml:"autosaveEnabled" env:"WEB_OPTION_EDITOR_AUTOSAVE_ENABLED" desc:"Specifies if the autosave for the editor apps is enabled."` - AutosaveInterval int `json:"autosaveInterval" yaml:"autosaveInterval" env:"WEB_OPTION_EDITOR_AUTOSAVE_INTERVAL" desc:"Specifies the time interval for the autosave of editor apps in seconds."` + AutosaveEnabled bool `json:"autosaveEnabled,omitempty" yaml:"autosaveEnabled" env:"WEB_OPTION_EDITOR_AUTOSAVE_ENABLED" desc:"Specifies if the autosave for the editor apps is enabled."` + AutosaveInterval int `json:"autosaveInterval,omitempty" yaml:"autosaveInterval" env:"WEB_OPTION_EDITOR_AUTOSAVE_INTERVAL" desc:"Specifies the time interval for the autosave of editor apps in seconds. Has no effect when WEB_OPTION_EDITOR_AUTOSAVE_ENABLED is set to 'false'."` } From a62e53932877826d5e00aff513aac8c3ecc10d35 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Fri, 28 Apr 2023 23:40:10 +0200 Subject: [PATCH 4/4] fix code style --- services/web/pkg/config/defaults/defaultconfig.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/pkg/config/defaults/defaultconfig.go b/services/web/pkg/config/defaults/defaultconfig.go index d725885d544..4138919939f 100644 --- a/services/web/pkg/config/defaults/defaultconfig.go +++ b/services/web/pkg/config/defaults/defaultconfig.go @@ -138,7 +138,7 @@ func Sanitize(cfg *config.Config) { cfg.Web.Config.Options.AccountEditLink = nil } // remove Editor parent if no value is set - if cfg.Web.Config.Options.Editor.AutosaveEnabled == false { + if !cfg.Web.Config.Options.Editor.AutosaveEnabled { cfg.Web.Config.Options.Editor = nil } // remove FeedbackLink parent if no value is set