Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2e53fb5

Browse files
authored
feat: Enable custom support links (#6313)
* backend: support links* frontend: Support links* fmt* test: CODER_SUPPORT_LINKS_0_NAME* Go tests* Use UpdateAppearanceConfig* ui: UpdateAppearanceConfig* fix: fmt* Fix: site* Fix: site tests* fix: fmt* fix* test: check default support links
1 parent16364db commit2e53fb5

File tree

20 files changed

+642
-91
lines changed

20 files changed

+642
-91
lines changed

‎cli/deployment/config.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,15 @@ func newConfig() *codersdk.DeploymentConfig {
570570
Flag:"disable-password-auth",
571571
Default:false,
572572
},
573+
Support:&codersdk.SupportConfig{
574+
Links:&codersdk.DeploymentConfigField[[]codersdk.LinkConfig]{
575+
Name:"Support links",
576+
Usage:"Use custom support links",
577+
Flag:"support-links",
578+
Default: []codersdk.LinkConfig{},
579+
Enterprise:true,
580+
},
581+
},
573582
}
574583
}
575584

@@ -649,6 +658,10 @@ func setConfig(prefix string, vip *viper.Viper, target interface{}) {
649658
// Do not bind to CODER_GITAUTH, instead bind to CODER_GITAUTH_0_*, etc.
650659
values:=readSliceFromViper[codersdk.GitAuthConfig](vip,prefix,value)
651660
val.FieldByName("Value").Set(reflect.ValueOf(values))
661+
case []codersdk.LinkConfig:
662+
// Do not bind to CODER_SUPPORT_LINKS, instead bind to CODER_SUPPORT_LINKS_0_*, etc.
663+
values:=readSliceFromViper[codersdk.LinkConfig](vip,prefix,value)
664+
val.FieldByName("Value").Set(reflect.ValueOf(values))
652665
default:
653666
panic(fmt.Sprintf("unsupported type %T",value))
654667
}
@@ -824,6 +837,8 @@ func setFlags(prefix string, flagset *pflag.FlagSet, vip *viper.Viper, target in
824837
_=flagset.DurationP(flg,shorthand,vip.GetDuration(prefix),usage)
825838
case []string:
826839
_=flagset.StringSliceP(flg,shorthand,vip.GetStringSlice(prefix),usage)
840+
case []codersdk.LinkConfig:
841+
// Ignore this one!
827842
case []codersdk.GitAuthConfig:
828843
// Ignore this one!
829844
default:

‎cli/deployment/config_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,29 @@ func TestConfig(t *testing.T) {
222222
Regex:"gitlab.com",
223223
}},config.GitAuth.Value)
224224
},
225+
}, {
226+
Name:"Support links",
227+
Env:map[string]string{
228+
"CODER_SUPPORT_LINKS_0_NAME":"First link",
229+
"CODER_SUPPORT_LINKS_0_TARGET":"http://target-link-1",
230+
"CODER_SUPPORT_LINKS_0_ICON":"bug",
231+
232+
"CODER_SUPPORT_LINKS_1_NAME":"Second link",
233+
"CODER_SUPPORT_LINKS_1_TARGET":"http://target-link-2",
234+
"CODER_SUPPORT_LINKS_1_ICON":"chat",
235+
},
236+
Valid:func(config*codersdk.DeploymentConfig) {
237+
require.Len(t,config.Support.Links.Value,2)
238+
require.Equal(t, []codersdk.LinkConfig{{
239+
Name:"First link",
240+
Target:"http://target-link-1",
241+
Icon:"bug",
242+
}, {
243+
Name:"Second link",
244+
Target:"http://target-link-2",
245+
Icon:"chat",
246+
}},config.Support.Links.Value)
247+
},
225248
}, {
226249
Name:"Wrong env must not break default values",
227250
Env:map[string]string{

‎coderd/apidoc/docs.go

Lines changed: 82 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 82 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎codersdk/deployment.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ type DeploymentConfig struct {
153153
Address*DeploymentConfigField[string]`json:"address" typescript:",notnull"`
154154
// DEPRECATED: Use Experiments instead.
155155
Experimental*DeploymentConfigField[bool]`json:"experimental" typescript:",notnull"`
156+
157+
Support*SupportConfig`json:"support" typescript:",notnull"`
156158
}
157159

158160
typeDERPstruct {
@@ -276,8 +278,18 @@ type DangerousConfig struct {
276278
AllowPathAppSiteOwnerAccess*DeploymentConfigField[bool]`json:"allow_path_app_site_owner_access" typescript:",notnull"`
277279
}
278280

281+
typeSupportConfigstruct {
282+
Links*DeploymentConfigField[[]LinkConfig]`json:"links" typescript:",notnull"`
283+
}
284+
285+
typeLinkConfigstruct {
286+
Namestring`json:"name"`
287+
Targetstring`json:"target"`
288+
Iconstring`json:"icon"`
289+
}
290+
279291
typeFlaggableinterface {
280-
string| time.Duration|bool|int| []string| []GitAuthConfig
292+
string| time.Duration|bool|int| []string| []GitAuthConfig| []LinkConfig
281293
}
282294

283295
typeDeploymentConfigField[TFlaggable]struct {
@@ -348,6 +360,12 @@ func (c *Client) DeploymentConfig(ctx context.Context) (DeploymentConfig, error)
348360
typeAppearanceConfigstruct {
349361
LogoURLstring`json:"logo_url"`
350362
ServiceBannerServiceBannerConfig`json:"service_banner"`
363+
SupportLinks []LinkConfig`json:"support_links,omitempty"`
364+
}
365+
366+
typeUpdateAppearanceConfigstruct {
367+
LogoURLstring`json:"logo_url"`
368+
ServiceBannerServiceBannerConfig`json:"service_banner"`
351369
}
352370

353371
typeServiceBannerConfigstruct {
@@ -371,7 +389,7 @@ func (c *Client) Appearance(ctx context.Context) (AppearanceConfig, error) {
371389
returncfg,json.NewDecoder(res.Body).Decode(&cfg)
372390
}
373391

374-
func (c*Client)UpdateAppearance(ctx context.Context,appearanceAppearanceConfig)error {
392+
func (c*Client)UpdateAppearance(ctx context.Context,appearanceUpdateAppearanceConfig)error {
375393
res,err:=c.Request(ctx,http.MethodPut,"/api/v2/appearance",appearance)
376394
iferr!=nil {
377395
returnerr

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp