PLT-7 client side infra
Этот коммит содержится в:
@@ -31,6 +31,7 @@ type Context struct {
|
||||
siteURL string
|
||||
SessionTokenIndex int64
|
||||
T goi18n.TranslateFunc
|
||||
Locale string
|
||||
}
|
||||
|
||||
type Page struct {
|
||||
@@ -87,7 +88,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
l4g.Debug("%v", r.URL.Path)
|
||||
|
||||
c := &Context{}
|
||||
c.T = utils.GetTranslations(w, r)
|
||||
c.T, c.Locale = utils.GetTranslationsAndLocale(w, r)
|
||||
c.RequestId = model.NewId()
|
||||
c.IpAddress = GetIpAddress(r)
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ func handleWebhookEventsAndForget(c *Context, post *model.Post, team *model.Team
|
||||
|
||||
// copy the context and create a mock session for posting the message
|
||||
mockSession := model.Session{UserId: hook.CreatorId, TeamId: hook.TeamId, IsOAuth: false}
|
||||
newContext := &Context{mockSession, model.NewId(), "", c.Path, nil, c.teamURLValid, c.teamURL, c.siteURL, 0, c.T}
|
||||
newContext := &Context{mockSession, model.NewId(), "", c.Path, nil, c.teamURLValid, c.teamURL, c.siteURL, 0, c.T, c.Locale}
|
||||
|
||||
if text, ok := respProps["text"]; ok {
|
||||
if _, err := CreateWebhookPost(newContext, post.ChannelId, text, respProps["username"], respProps["icon_url"], post.Props, post.Type); err != nil {
|
||||
|
||||
@@ -44,7 +44,7 @@ func GetTranslationsBySystemLocale() i18n.TranslateFunc {
|
||||
}
|
||||
}
|
||||
|
||||
if locales[model.DEFAULT_LOCALE] == "" {
|
||||
if locales[locale] == "" {
|
||||
panic("Failed to load system translations for '" + model.DEFAULT_LOCALE + "'")
|
||||
}
|
||||
|
||||
@@ -62,14 +62,14 @@ func SetTranslations(locale string) i18n.TranslateFunc {
|
||||
return translations
|
||||
}
|
||||
|
||||
func GetTranslations(w http.ResponseWriter, r *http.Request) i18n.TranslateFunc {
|
||||
translations, _ := getTranslationsAndLocale(w, r)
|
||||
return translations
|
||||
}
|
||||
// func GetTranslations(w http.ResponseWriter, r *http.Request) i18n.TranslateFunc {
|
||||
// translations, _ := getTranslationsAndLocale(w, r)
|
||||
// return translations
|
||||
// }
|
||||
|
||||
func GetTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string) {
|
||||
return getTranslationsAndLocale(w, r)
|
||||
}
|
||||
// func GetTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string) {
|
||||
// return getTranslationsAndLocale(w, r)
|
||||
// }
|
||||
|
||||
func SetLocaleCookie(w http.ResponseWriter, lang string, sessionCacheInMinutes int) {
|
||||
maxAge := (sessionCacheInMinutes * 60)
|
||||
@@ -116,7 +116,7 @@ func SetLocaleCookie(w http.ResponseWriter, lang string, sessionCacheInMinutes i
|
||||
// })
|
||||
// }
|
||||
|
||||
func getTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string) {
|
||||
func GetTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string) {
|
||||
var translations i18n.TranslateFunc
|
||||
var _ error
|
||||
localeCookie := ""
|
||||
|
||||
@@ -7,6 +7,8 @@ import LoginLdap from './login_ldap.jsx';
|
||||
import * as Utils from '../utils/utils.jsx';
|
||||
import Constants from '../utils/constants.jsx';
|
||||
|
||||
var FormattedMessage = ReactIntl.FormattedMessage;
|
||||
|
||||
export default class Login extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -86,7 +88,12 @@ export default class Login extends React.Component {
|
||||
if (emailSignup) {
|
||||
forgotPassword = (
|
||||
<div className='form-group'>
|
||||
<a href={'/' + teamName + '/reset_password'}>{'I forgot my password'}</a>
|
||||
<a href={'/' + teamName + '/reset_password'}>
|
||||
<FormattedMessage
|
||||
id='login.forgot_password'
|
||||
defaultMessage='I forgot my password'
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -141,7 +148,13 @@ export default class Login extends React.Component {
|
||||
{ldapLogin}
|
||||
{userSignUp}
|
||||
<div className='form-group margin--extra form-group--small'>
|
||||
<span><a href='/find_team'>{'Find your other teams'}</a></span>
|
||||
<span>
|
||||
<a href='/find_team'>
|
||||
<FormattedMessage
|
||||
id='login.find_teams'
|
||||
defaultMessage='Find your other teams'
|
||||
/>
|
||||
</a></span>
|
||||
</div>
|
||||
{forgotPassword}
|
||||
{teamSignUp}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"about.close": "Close",
|
||||
"about.date": "Build Date:"
|
||||
"login.find_teams": "Find your other teams",
|
||||
"login.forgot_password": "I forgot my password"
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"about.close": "Close",
|
||||
"about.date": "Build Date:"
|
||||
"login.find_teams": "Find your other teams (spanish!)",
|
||||
"login.forgot_password": "I forgot my password (spanish!)"
|
||||
}
|
||||
34
web/web.go
34
web/web.go
@@ -24,7 +24,7 @@ var Templates *template.Template
|
||||
|
||||
type HtmlTemplatePage api.Page
|
||||
|
||||
func NewHtmlTemplatePage(templateName string, title string) *HtmlTemplatePage {
|
||||
func NewHtmlTemplatePage(templateName string, title string, locale string) *HtmlTemplatePage {
|
||||
|
||||
if len(title) > 0 {
|
||||
title = utils.Cfg.TeamSettings.SiteName + " - " + title
|
||||
@@ -37,7 +37,7 @@ func NewHtmlTemplatePage(templateName string, title string) *HtmlTemplatePage {
|
||||
Props: props,
|
||||
ClientCfg: utils.ClientCfg,
|
||||
ClientLicense: utils.ClientLicense,
|
||||
Locale: model.DEFAULT_LOCALE,
|
||||
Locale: locale,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ func root(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if len(c.Session.UserId) == 0 {
|
||||
page := NewHtmlTemplatePage("signup_team", "Signup")
|
||||
page := NewHtmlTemplatePage("signup_team", "Signup", c.Locale)
|
||||
|
||||
if result := <-api.Srv.Store.Team().GetAllTeamListing(); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
@@ -210,7 +210,7 @@ func root(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
user = ur.Data.(*model.User)
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("home", "Home")
|
||||
page := NewHtmlTemplatePage("home", "Home", c.Locale)
|
||||
page.Team = team
|
||||
page.User = user
|
||||
page.Render(c, w)
|
||||
@@ -223,7 +223,7 @@ func signup(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("signup_team", "Signup")
|
||||
page := NewHtmlTemplatePage("signup_team", "Signup", c.Locale)
|
||||
page.Render(c, w)
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ func login(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("login", "Login")
|
||||
page := NewHtmlTemplatePage("login", "Login", c.Locale)
|
||||
page.Props["TeamDisplayName"] = team.DisplayName
|
||||
page.Props["TeamName"] = team.Name
|
||||
|
||||
@@ -272,7 +272,7 @@ func login(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
func signupTeamConfirm(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
email := r.FormValue("email")
|
||||
|
||||
page := NewHtmlTemplatePage("signup_team_confirm", "Signup Email Sent")
|
||||
page := NewHtmlTemplatePage("signup_team_confirm", "Signup Email Sent", c.Locale)
|
||||
page.Props["Email"] = email
|
||||
page.Render(c, w)
|
||||
}
|
||||
@@ -294,7 +294,7 @@ func signupTeamComplete(c *api.Context, w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("signup_team_complete", "Complete Team Sign Up")
|
||||
page := NewHtmlTemplatePage("signup_team_complete", "Complete Team Sign Up", c.Locale)
|
||||
page.Props["Email"] = props["email"]
|
||||
page.Props["Data"] = data
|
||||
page.Props["Hash"] = hash
|
||||
@@ -344,7 +344,7 @@ func signupUserComplete(c *api.Context, w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("signup_user_complete", "Complete User Sign Up")
|
||||
page := NewHtmlTemplatePage("signup_user_complete", "Complete User Sign Up", c.Locale)
|
||||
page.Props["Email"] = props["email"]
|
||||
page.Props["TeamDisplayName"] = props["display_name"]
|
||||
page.Props["TeamName"] = props["name"]
|
||||
@@ -528,7 +528,7 @@ func doLoadChannel(c *api.Context, w http.ResponseWriter, r *http.Request, team
|
||||
user = ur.Data.(*model.User)
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("channel", "")
|
||||
page := NewHtmlTemplatePage("channel", "", c.Locale)
|
||||
page.Props["Title"] = channel.DisplayName + " - " + team.DisplayName + " " + page.ClientCfg["SiteName"]
|
||||
page.Props["TeamDisplayName"] = team.DisplayName
|
||||
page.Props["ChannelName"] = channel.Name
|
||||
@@ -585,7 +585,7 @@ func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("verify", "Email Verified")
|
||||
page := NewHtmlTemplatePage("verify", "Email Verified", c.Locale)
|
||||
page.Props["TeamURL"] = c.GetTeamURLFromTeam(team)
|
||||
page.Props["UserEmail"] = email
|
||||
page.Props["ResendSuccess"] = resendSuccess
|
||||
@@ -593,7 +593,7 @@ func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func findTeam(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
page := NewHtmlTemplatePage("find_team", "Find Team")
|
||||
page := NewHtmlTemplatePage("find_team", "Find Team", c.Locale)
|
||||
page.Render(c, w)
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@ func docs(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
doc := params["doc"]
|
||||
|
||||
page := NewHtmlTemplatePage("docs", "Documentation")
|
||||
page := NewHtmlTemplatePage("docs", "Documentation", c.Locale)
|
||||
page.Props["Site"] = doc
|
||||
page.Render(c, w)
|
||||
}
|
||||
@@ -643,7 +643,7 @@ func resetPassword(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
teamDisplayName = team.DisplayName
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("password_reset", "")
|
||||
page := NewHtmlTemplatePage("password_reset", "", c.Locale)
|
||||
page.Props["Title"] = "Reset Password " + page.ClientCfg["SiteName"]
|
||||
page.Props["TeamDisplayName"] = teamDisplayName
|
||||
page.Props["TeamName"] = teamName
|
||||
@@ -821,7 +821,7 @@ func adminConsole(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
activeTab := params["tab"]
|
||||
teamId := params["team"]
|
||||
|
||||
page := NewHtmlTemplatePage("admin_console", "Admin Console")
|
||||
page := NewHtmlTemplatePage("admin_console", "Admin Console", c.Locale)
|
||||
page.User = user
|
||||
page.Team = team
|
||||
page.Props["ActiveTab"] = activeTab
|
||||
@@ -867,7 +867,7 @@ func authorizeOAuth(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
team = result.Data.(*model.Team)
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("authorize", "Authorize Application")
|
||||
page := NewHtmlTemplatePage("authorize", "Authorize Application", c.Locale)
|
||||
page.Props["TeamName"] = team.Name
|
||||
page.Props["AppName"] = app.Name
|
||||
page.Props["ResponseType"] = responseType
|
||||
@@ -1165,7 +1165,7 @@ func claimAccount(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
page := NewHtmlTemplatePage("claim_account", "Claim Account")
|
||||
page := NewHtmlTemplatePage("claim_account", "Claim Account", c.Locale)
|
||||
page.Props["Email"] = email
|
||||
page.Props["CurrentType"] = authType
|
||||
page.Props["NewType"] = newType
|
||||
|
||||
Ссылка в новой задаче
Block a user