Skip to content

Commit cf7f601

Browse files
committed
Merge branch 'test' of github.com:apache/answer into test
2 parents c888188 + 462931a commit cf7f601

File tree

8 files changed

+24
-5
lines changed

8 files changed

+24
-5
lines changed

i18n/en_US.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,6 +2387,7 @@ ui:
23872387
user_normal: This user is already normal.
23882388
user_suspended: This user has been suspended.
23892389
user_deleted: This user has been deleted.
2390+
user_added: User has been added successfully.
23902391
badge_activated: This badge has been activated.
23912392
badge_inactivated: This badge has been inactivated.
23922393
users_deleted: These users have been deleted.

internal/base/constant/site_info.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ const (
4343
ColorSchemeLight = "light"
4444
ColorSchemeDark = "dark"
4545
ColorSchemeSystem = "system"
46+
47+
ThemeLayoutFullWidth = "Full-width"
48+
ThemeLayoutFixedWidth = "Fixed-width"
4649
)
4750

4851
const (

internal/migrations/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (m *Mentor) initSiteInfoLegalConfig() {
236236
}
237237

238238
func (m *Mentor) initSiteInfoThemeConfig() {
239-
themeConfig := `{"theme":"default","theme_config":{"default":{"navbar_style":"#0033ff","primary_color":"#0033ff"}}}`
239+
themeConfig := fmt.Sprintf(`{"theme":"default","theme_config":{"default":{"navbar_style":"#0033ff","primary_color":"#0033ff"}},"layout":"%s"}`, constant.ThemeLayoutFullWidth)
240240
_, m.err = m.engine.Context(m.ctx).Insert(&entity.SiteInfo{
241241
Type: "theme",
242242
Content: themeConfig,

internal/migrations/v5.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"encoding/json"
2525
"fmt"
2626

27+
"github.com/apache/answer/internal/base/constant"
2728
"github.com/apache/answer/internal/entity"
2829
"xorm.io/xorm"
2930
)
@@ -50,7 +51,7 @@ func addThemeAndPrivateMode(ctx context.Context, x *xorm.Engine) error {
5051
}
5152
}
5253

53-
themeConfig := `{"theme":"default","theme_config":{"default":{"navbar_style":"#0033ff","primary_color":"#0033ff"}}}`
54+
themeConfig := fmt.Sprintf(`{"theme":"default","theme_config":{"default":{"navbar_style":"#0033ff","primary_color":"#0033ff"}},"layout":"%s"}`, constant.ThemeLayoutFullWidth)
5455
themeSiteInfo := &entity.SiteInfo{
5556
Type: "theme",
5657
Content: themeConfig,

internal/schema/siteinfo_schema.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ type SiteThemeReq struct {
181181
Theme string `validate:"required,gt=0,lte=255" json:"theme"`
182182
ThemeConfig map[string]any `validate:"omitempty" json:"theme_config"`
183183
ColorScheme string `validate:"omitempty,gt=0,lte=100" json:"color_scheme"`
184+
Layout string `validate:"omitempty,oneof=Full-width Fixed-width" json:"layout"`
184185
}
185186

186187
type SiteSeoReq struct {
@@ -217,6 +218,7 @@ type SiteThemeResp struct {
217218
Theme string `json:"theme"`
218219
ThemeConfig map[string]any `json:"theme_config"`
219220
ColorScheme string `json:"color_scheme"`
221+
Layout string `json:"layout"`
220222
}
221223

222224
func (s *SiteThemeResp) TrTheme(ctx context.Context) {

internal/service/siteinfo/siteinfo_service.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ func (s *SiteInfoService) SaveSiteCustomCssHTML(ctx context.Context, req *schema
252252

253253
// SaveSiteTheme save site custom html configuration
254254
func (s *SiteInfoService) SaveSiteTheme(ctx context.Context, req *schema.SiteThemeReq) (err error) {
255+
if len(req.Layout) == 0 {
256+
req.Layout = constant.ThemeLayoutFullWidth
257+
}
255258
content, _ := json.Marshal(req)
256259
data := &entity.SiteInfo{
257260
Type: constant.SiteTypeTheme,

internal/service/siteinfo_common/siteinfo_service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,14 @@ func (s *siteInfoCommonService) GetSiteCustomCssHTML(ctx context.Context) (resp
198198
func (s *siteInfoCommonService) GetSiteTheme(ctx context.Context) (resp *schema.SiteThemeResp, err error) {
199199
resp = &schema.SiteThemeResp{
200200
ThemeOptions: schema.GetThemeOptions,
201+
Layout: constant.ThemeLayoutFullWidth,
201202
}
202203
if err = s.GetSiteInfoByType(ctx, constant.SiteTypeTheme, resp); err != nil {
203204
return nil, err
204205
}
206+
if resp.Layout == "" {
207+
resp.Layout = constant.ThemeLayoutFullWidth
208+
}
205209
resp.TrTheme(ctx)
206210
return resp, nil
207211
}

ui/src/pages/Admin/Users/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,14 @@ const Users: FC = () => {
109109
return new Promise((resolve, reject) => {
110110
addUsers(userModel)
111111
.then(() => {
112-
if (/all|staff/.test(curFilter) && curPage === 1) {
113-
refreshUsers();
114-
}
112+
toastStore.getState().show({
113+
msg: t('user_added', { keyPrefix: 'messages' }),
114+
variant: 'success',
115+
});
116+
urlSearchParams.set('filter', 'normal');
117+
urlSearchParams.delete('page');
118+
setUrlSearchParams(urlSearchParams);
119+
refreshUsers();
115120
resolve(true);
116121
})
117122
.catch((e) => {

0 commit comments

Comments
 (0)