Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

refactor: remove client side routing

goenningc4ae20a03679
diff --git a/app/cmd/routes.go b/app/cmd/routes.go
index ab474805d..6fa427b4f 100644
--- a/app/cmd/routes.go
+++ b/app/cmd/routes.go
@@ -85,7 +85,7 @@ func routes(r *web.Engine) *web.Engine {
})
}
- r.Get("/_design", handlers.Page("Design System", "A preview of Fider UI elements", "DesignSystem.page"))
+ r.Get("/_design", handlers.Page("Design System", "A preview of Fider UI elements", "DesignSystem/DesignSystem.page"))
r.Get("/signup/verify", handlers.VerifySignUpKey())
r.Get("/signout", handlers.SignOut())
r.Get("/oauth/:provider/token", handlers.OAuthToken())
@@ -94,7 +94,7 @@ func routes(r *web.Engine) *web.Engine {
//If tenant is pending, block it from using any other route
r.Use(middlewares.BlockPendingTenants())
- r.Get("/signin", handlers.SignInPage())
+ r.Get("/signin", handlers.SignInPage("SignIn/SignIn.page"))
r.Get("/not-invited", handlers.NotInvitedPage())
r.Get("/signin/verify", handlers.VerifySignInKey(enum.EmailVerificationKindSignIn))
r.Get("/invite/verify", handlers.VerifySignInKey(enum.EmailVerificationKindUserInvitation))
@@ -104,7 +104,7 @@ func routes(r *web.Engine) *web.Engine {
//Block if it's private tenant with unauthenticated user
r.Use(middlewares.CheckTenantPrivacy())
- r.Get("/", handlers.Index())
+ r.Get("/", handlers.Index("Home/Home.page"))
r.Get("/posts/:number", handlers.PostDetails())
r.Get("/posts/:number/:slug", handlers.PostDetails())
@@ -134,8 +134,8 @@ func routes(r *web.Engine) *web.Engine {
ui.Get("/admin", handlers.GeneralSettingsPage())
ui.Get("/admin/advanced", handlers.AdvancedSettingsPage())
- ui.Get("/admin/privacy", handlers.Page("Privacy · Site Settings", "", "PrivacySettings.page"))
- ui.Get("/admin/invitations", handlers.Page("Invitations · Site Settings", "", "Invitations.page"))
+ ui.Get("/admin/privacy", handlers.Page("Privacy · Site Settings", "", "Administration/pages/PrivacySettings.page"))
+ ui.Get("/admin/invitations", handlers.Page("Invitations · Site Settings", "", "Administration/pages/Invitations.page"))
ui.Get("/admin/members", handlers.ManageMembers())
ui.Get("/admin/tags", handlers.ManageTags())
ui.Get("/admin/authentication", handlers.ManageAuthentication())
@@ -144,7 +144,7 @@ func routes(r *web.Engine) *web.Engine {
//From this step, only Administrators are allowed
ui.Use(middlewares.IsAuthorized(enum.RoleAdministrator))
- ui.Get("/admin/export", handlers.Page("Export · Site Settings", "", "Export.page"))
+ ui.Get("/admin/export", handlers.Page("Export · Site Settings", "", "Administration/pages/Export.page"))
ui.Get("/admin/export/posts.csv", handlers.ExportPostsToCSV())
ui.Get("/admin/export/backup.zip", handlers.ExportBackupZip())
ui.Get("/admin/webhooks", handlers.ManageWebhooks())
diff --git a/app/handlers/admin.go b/app/handlers/admin.go
index c0e2bd614..755006f52 100644
--- a/app/handlers/admin.go
+++ b/app/handlers/admin.go
@@ -12,8 +12,8 @@ import (
func GeneralSettingsPage() web.HandlerFunc {
return func(c *web.Context) error {
return c.Page(web.Props{
- Title: "General · Site Settings",
- ChunkName: "GeneralSettings.page",
+ Page: "Administration/pages/GeneralSettings.page",
+ Title: "General · Site Settings",
})
}
}
@@ -22,8 +22,8 @@ func GeneralSettingsPage() web.HandlerFunc {
func AdvancedSettingsPage() web.HandlerFunc {
return func(c *web.Context) error {
return c.Page(web.Props{
- Title: "Advanced · Site Settings",
- ChunkName: "AdvancedSettings.page",
+ Page: "Administration/pages/AdvancedSettings.page",
+ Title: "Advanced · Site Settings",
Data: web.Map{
"customCSS": c.Tenant().CustomCSS,
},
@@ -125,8 +125,8 @@ func ManageMembers() web.HandlerFunc {
}
return c.Page(web.Props{
- Title: "Manage Members · Site Settings",
- ChunkName: "ManageMembers.page",
+ Page: "Administration/pages/ManageMembers.page",
+ Title: "Manage Members · Site Settings",
Data: web.Map{
"users": allUsers.Result,
},
@@ -143,8 +143,8 @@ func ManageAuthentication() web.HandlerFunc {
}
return c.Page(web.Props{
- Title: "Authentication · Site Settings",
- ChunkName: "ManageAuthentication.page",
+ Page: "Administration/pages/ManageAuthentication.page",
+ Title: "Authentication · Site Settings",
Data: web.Map{
"providers": listProviders.Result,
},
diff --git a/app/handlers/billing.go b/app/handlers/billing.go
index 7685b4b0c..188d0f521 100644
--- a/app/handlers/billing.go
+++ b/app/handlers/billing.go
@@ -25,8 +25,8 @@ func ManageBilling() web.HandlerFunc {
}
return c.Page(web.Props{
- Title: "Manage Billing · Site Settings",
- ChunkName: "ManageBilling.page",
+ Page: "Administration/pages/ManageBilling.page",
+ Title: "Manage Billing · Site Settings",
Data: web.Map{
"status": billingState.Result.Status,
"trialEndsAt": billingState.Result.TrialEndsAt,
diff --git a/app/handlers/common.go b/app/handlers/common.go
index 461d9d72c..5f54ad577 100644
--- a/app/handlers/common.go
+++ b/app/handlers/common.go
@@ -43,8 +43,8 @@ func LegalPage(title, file string) web.HandlerFunc {
}
return c.Page(web.Props{
- Title: title,
- ChunkName: "Legal.page",
+ Page: "Legal/Legal.page",
+ Title: title,
Data: web.Map{
"content": string(bytes),
},
@@ -93,12 +93,12 @@ func RobotsTXT() web.HandlerFunc {
}
//Page returns a page without properties
-func Page(title, description, chunkName string) web.HandlerFunc {
+func Page(title, description, page string) web.HandlerFunc {
return func(c *web.Context) error {
return c.Page(web.Props{
+ Page: page,
Title: title,
Description: description,
- ChunkName: chunkName,
})
}
}
diff --git a/app/handlers/notification.go b/app/handlers/notification.go
index ce3bb0122..1dc83b4c6 100644
--- a/app/handlers/notification.go
+++ b/app/handlers/notification.go
@@ -30,8 +30,8 @@ func Notifications() web.HandlerFunc {
}
return c.Page(web.Props{
- Title: "Notifications",
- ChunkName: "MyNotifications.page",
+ Page: "MyNotifications/MyNotifications.page",
+ Title: "Notifications",
Data: web.Map{
"notifications": q.Result,
},
diff --git a/app/handlers/oauth.go b/app/handlers/oauth.go
index 7ece52ae0..e620947a7 100644
--- a/app/handlers/oauth.go
+++ b/app/handlers/oauth.go
@@ -41,8 +41,8 @@ func OAuthEcho() web.HandlerFunc {
err := bus.Dispatch(c, rawProfile)
if err != nil {
return c.Page(web.Props{
- Title: "OAuth Test Page",
- ChunkName: "OAuthEcho.page",
+ Page: "OAuthEcho/OAuthEcho.page",
+ Title: "OAuth Test Page",
Data: web.Map{
"err": errors.Cause(err).Error(),
},
@@ -53,8 +53,8 @@ func OAuthEcho() web.HandlerFunc {
_ = bus.Dispatch(c, parseRawProfile)
return c.Page(web.Props{
- Title: "OAuth Test Page",
- ChunkName: "OAuthEcho.page",
+ Page: "OAuthEcho/OAuthEcho.page",
+ Title: "OAuth Test Page",
Data: web.Map{
"body": rawProfile.Result,
"profile": parseRawProfile.Result,
diff --git a/app/handlers/post.go b/app/handlers/post.go
index 21fad5c00..47f30b574 100644
--- a/app/handlers/post.go
+++ b/app/handlers/post.go
@@ -11,7 +11,7 @@ import (
)
// Index is the default home page
-func Index() web.HandlerFunc {
+func Index(page string) web.HandlerFunc {
return func(c *web.Context) error {
c.SetCanonicalURL("")
@@ -37,7 +37,7 @@ func Index() web.HandlerFunc {
return c.Page(web.Props{
Description: description,
- ChunkName: "Home.page",
+ Page: page,
Data: web.Map{
"posts": searchPosts.Result,
"tags": getAllTags.Result,
@@ -74,9 +74,9 @@ func PostDetails() web.HandlerFunc {
}
return c.Page(web.Props{
+ Page: "ShowPost/ShowPost.page",
Title: getPost.Result.Title,
Description: markdown.PlainText(getPost.Result.Description),
- ChunkName: "ShowPost.page",
Data: web.Map{
"comments": getComments.Result,
"subscribed": isSubscribed.Result,
diff --git a/app/handlers/post_test.go b/app/handlers/post_test.go
index 59733b1a4..af6f1a10e 100644
--- a/app/handlers/post_test.go
+++ b/app/handlers/post_test.go
@@ -34,7 +34,7 @@ func TestIndexHandler(t *testing.T) {
server := mock.NewServer()
code, _ := server.OnTenant(mock.DemoTenant).
AsUser(mock.JonSnow).
- Execute(handlers.Index())
+ Execute(handlers.Index("Home/Home.page"))
Expect(code).Equals(http.StatusOK)
}
diff --git a/app/handlers/settings.go b/app/handlers/settings.go
index 73d46d4b2..07ee53708 100644
--- a/app/handlers/settings.go
+++ b/app/handlers/settings.go
@@ -75,8 +75,8 @@ func UserSettings() web.HandlerFunc {
}
return c.Page(web.Props{
- Title: "Settings",
- ChunkName: "MySettings.page",
+ Page: "MySettings/MySettings.page",
+ Title: "Settings",
Data: web.Map{
"userSettings": settings.Result,
},
diff --git a/app/handlers/signin.go b/app/handlers/signin.go
index 48e1b7dab..eaa79efb5 100644
--- a/app/handlers/signin.go
+++ b/app/handlers/signin.go
@@ -19,13 +19,13 @@ import (
)
// SignInPage renders the sign in page
-func SignInPage() web.HandlerFunc {
+func SignInPage(page string) web.HandlerFunc {
return func(c *web.Context) error {
if c.Tenant().IsPrivate {
return c.Page(web.Props{
- Title: "Sign in",
- ChunkName: "SignIn.page",
+ Page: page,
+ Title: "Sign in",
})
}
@@ -99,7 +99,7 @@ func VerifySignInKey(kind enum.EmailVerificationKind) web.HandlerFunc {
if c.Tenant().IsPrivate {
return NotInvitedPage()(c)
}
- return Index()(c)
+ return Index("CompleteSignInProfile/CompleteSignInProfile.page")(c)
}
return c.Failure(err)
}
@@ -110,9 +110,9 @@ func VerifySignInKey(kind enum.EmailVerificationKind) web.HandlerFunc {
if err != nil {
if errors.Cause(err) == app.ErrNotFound {
if c.Tenant().IsPrivate {
- return SignInPage()(c)
+ return SignInPage("CompleteSignInProfile/CompleteSignInProfile.page")(c)
}
- return Index()(c)
+ return Index("CompleteSignInProfile/CompleteSignInProfile.page")(c)
}
return c.Failure(err)
}
diff --git a/app/handlers/signin_test.go b/app/handlers/signin_test.go
index ed045cc1e..22fd6756d 100644
--- a/app/handlers/signin_test.go
+++ b/app/handlers/signin_test.go
@@ -562,7 +562,7 @@ func TestSignInPageHandler_AuthenticatedUser(t *testing.T) {
OnTenant(mock.DemoTenant).
AsUser(mock.AryaStark).
WithURL("http://demo.test.fider.io/signin").
- Execute(handlers.SignInPage())
+ Execute(handlers.SignInPage("SignIn/SignIn.page"))
Expect(code).Equals(http.StatusTemporaryRedirect)
Expect(response.Header().Get("Location")).Equals("http://demo.test.fider.io")
@@ -575,7 +575,7 @@ func TestSignInPageHandler_NonPrivateTenant(t *testing.T) {
code, response := server.
OnTenant(mock.DemoTenant).
WithURL("http://demo.test.fider.io/signin").
- Execute(handlers.SignInPage())
+ Execute(handlers.SignInPage("SignIn/SignIn.page"))
Expect(code).Equals(http.StatusTemporaryRedirect)
Expect(response.Header().Get("Location")).Equals("http://demo.test.fider.io")
@@ -590,7 +590,7 @@ func TestSignInPageHandler_PrivateTenant_UnauthenticatedUser(t *testing.T) {
code, _ := server.
OnTenant(mock.DemoTenant).
WithURL("http://demo.test.fider.io/signin").
- Execute(handlers.SignInPage())
+ Execute(handlers.SignInPage("SignIn/SignIn.page"))
Expect(code).Equals(http.StatusOK)
}
diff --git a/app/handlers/signup.go b/app/handlers/signup.go
index 142515a3c..2d20e349f 100644
--- a/app/handlers/signup.go
+++ b/app/handlers/signup.go
@@ -143,9 +143,9 @@ func SignUp() web.HandlerFunc {
}
return c.Page(web.Props{
+ Page: "SignUp/SignUp.page",
Title: "Sign up",
Description: "Sign up for Fider and let your customers share, vote and discuss on suggestions they have to make your product even better.",
- ChunkName: "SignUp.page",
})
}
}
diff --git a/app/handlers/tag.go b/app/handlers/tag.go
index 7fc69d573..4d8603c49 100644
--- a/app/handlers/tag.go
+++ b/app/handlers/tag.go
@@ -15,8 +15,8 @@ func ManageTags() web.HandlerFunc {
}
return c.Page(web.Props{
- Title: "Manage Tags · Site Settings",
- ChunkName: "ManageTags.page",
+ Page: "Administration/pages/ManageTags.page",
+ Title: "Manage Tags · Site Settings",
Data: web.Map{
"tags": getAllTags.Result,
},
diff --git a/app/handlers/webhook.go b/app/handlers/webhook.go
index 9f950a5d0..31dd9c46d 100644
--- a/app/handlers/webhook.go
+++ b/app/handlers/webhook.go
@@ -1,13 +1,14 @@
package handlers
import (
+ "strconv"
+
"github.com/getfider/fider/app/actions"
"github.com/getfider/fider/app/models/cmd"
"github.com/getfider/fider/app/models/enum"
"github.com/getfider/fider/app/models/query"
"github.com/getfider/fider/app/pkg/bus"
"github.com/getfider/fider/app/pkg/web"
- "strconv"
)
// ManageWebhooks is the page used by administrators to configure webhooks
@@ -19,8 +20,8 @@ func ManageWebhooks() web.HandlerFunc {
}
return c.Page(web.Props{
- Title: "Manage Webhooks · Site Settings",
- ChunkName: "ManageWebhooks.page",
+ Page: "Administration/pages/ManageWebhooks.page",
+ Title: "Manage Webhooks · Site Settings",
Data: web.Map{
"webhooks": allWebhooks.Result,
},
diff --git a/app/pkg/web/context.go b/app/pkg/web/context.go
index 6490c3cf9..da108a030 100644
--- a/app/pkg/web/context.go
+++ b/app/pkg/web/context.go
@@ -38,7 +38,7 @@ type StringMap map[string]string
type Props struct {
Title string
Description string
- ChunkName string
+ Page string
Data Map
}
diff --git a/app/pkg/web/react.go b/app/pkg/web/react.go
index df7a33e9a..0b09a6fa6 100644
--- a/app/pkg/web/react.go
+++ b/app/pkg/web/react.go
@@ -76,7 +76,7 @@ func (r *ReactRenderer) Render(u *url.URL, props Map) (string, error) {
return "", errors.Wrap(err, "failed to marshal props")
}
- renderCmd := fmt.Sprintf(`ssrRender("%s", "%s", %s)`, u.String(), u.Path, string(jsonArg))
+ renderCmd := fmt.Sprintf(`ssrRender("%s", %s)`, u.String(), string(jsonArg))
val, err := v8ctx.RunScript(renderCmd, r.scriptPath)
if err != nil {
if jsErr, ok := err.(*v8go.JSError); ok {
diff --git a/app/pkg/web/react_test.go b/app/pkg/web/react_test.go
index 4cbf2e5ad..ddddfcdf1 100644
--- a/app/pkg/web/react_test.go
+++ b/app/pkg/web/react_test.go
@@ -38,6 +38,7 @@ func TestReactRenderer_RenderEmptyHomeHTML(t *testing.T) {
u, _ := url.Parse("https://demo.test.fider.io")
html, err := r.Render(u, web.Map{
+ "page": "Home/Home.page",
"tenant": &entity.Tenant{
Locale: "en",
},
@@ -66,6 +67,7 @@ func TestReactRenderer_RenderEmptyHomeHTML_Portuguese(t *testing.T) {
u, _ := url.Parse("https://demo.test.fider.io")
html, err := r.Render(u, web.Map{
+ "page": "Home/Home.page",
"tenant": &entity.Tenant{
Locale: "pt-BR",
},
diff --git a/app/pkg/web/renderer.go b/app/pkg/web/renderer.go
index 18325622c..488621eea 100644
--- a/app/pkg/web/renderer.go
+++ b/app/pkg/web/renderer.go
@@ -170,9 +170,12 @@ func (r *Renderer) Render(w io.Writer, statusCode int, templateName string, prop
locale := i18n.GetLocale(ctx)
localeChunkName := fmt.Sprintf("locale-%s-client-json", locale)
+
+ // webpack replaces "/" and "." with "-", so we do the same here
+ pageChunkName := strings.ReplaceAll(strings.ReplaceAll(props.Page, ".", "-"), "/", "-")
private["preloadAssets"] = []*clientAssets{
r.chunkedAssets[localeChunkName],
- r.chunkedAssets[props.ChunkName],
+ r.chunkedAssets[pageChunkName],
}
if tenant == nil || tenant.LogoBlobKey == "" {
@@ -196,6 +199,7 @@ func (r *Renderer) Render(w io.Writer, statusCode int, templateName string, prop
}
}
+ public["page"] = props.Page
public["contextID"] = ctx.ContextID()
public["sessionID"] = ctx.SessionID()
public["tenant"] = tenant
diff --git a/app/pkg/web/renderer_test.go b/app/pkg/web/renderer_test.go
index 42b3c3f9c..bef579746 100644
--- a/app/pkg/web/renderer_test.go
+++ b/app/pkg/web/renderer_test.go
@@ -51,7 +51,7 @@ func TestRenderer_WithChunkPreload(t *testing.T) {
buf := new(bytes.Buffer)
ctx := newGetContext("https://demo.test.fider.io:3000/", nil)
renderer := web.NewRenderer()
- renderer.Render(buf, http.StatusOK, "index.html", web.Props{ChunkName: "Test.page"}, ctx)
+ renderer.Render(buf, http.StatusOK, "index.html", web.Props{Page: "Test.page"}, ctx)
compareRendererResponse(buf, "/app/pkg/web/testdata/chunk.html", ctx)
}
@@ -124,9 +124,9 @@ func TestRenderer_Home_SSR(t *testing.T) {
})
renderer := web.NewRenderer()
renderer.Render(buf, http.StatusOK, "index.html", web.Props{
+ Page: "Test.page",
Title: "My Page Title",
Description: "My Page Description",
- ChunkName: "Test.page",
Data: web.Map{
"posts": make([]web.Map, 0),
"tags": make([]web.Map, 0),
diff --git a/app/pkg/web/testdata/basic.html b/app/pkg/web/testdata/basic.html
index 63010efbd..13ab09ce4 100755
--- a/app/pkg/web/testdata/basic.html
+++ b/app/pkg/web/testdata/basic.html
@@ -44,7 +44,7 @@
<script id="server-data" type="application/json">
- {"contextID":"CONTEXT_ID","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":null,"title":"Fider"}
+ {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":null,"title":"Fider"}
</script>
diff --git a/app/pkg/web/testdata/canonical.html b/app/pkg/web/testdata/canonical.html
index b4182e4ff..361d71489 100755
--- a/app/pkg/web/testdata/canonical.html
+++ b/app/pkg/web/testdata/canonical.html
@@ -46,7 +46,7 @@
<script id="server-data" type="application/json">
- {"contextID":"CONTEXT_ID","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":null,"title":"Fider"}
+ {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":null,"title":"Fider"}
</script>
diff --git a/app/pkg/web/testdata/chunk.html b/app/pkg/web/testdata/chunk.html
index 8f30bfd4d..32c0a09ed 100644
--- a/app/pkg/web/testdata/chunk.html
+++ b/app/pkg/web/testdata/chunk.html
@@ -20,9 +20,6 @@
- <link rel="preload" href="https://demo.test.fider.io:3000/assets/css/Test.page.css" as="style" />
- <link rel="preload" href="https://demo.test.fider.io:3000/assets/js/Test.page.js" as="script" />
-
<title>Fider</title>
@@ -47,7 +44,7 @@
<script id="server-data" type="application/json">
- {"contextID":"CONTEXT_ID","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":null,"title":"Fider"}
+ {"contextID":"CONTEXT_ID","page":"Test.page","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":null,"title":"Fider"}
</script>
diff --git a/app/pkg/web/testdata/home.html b/app/pkg/web/testdata/home.html
index 8dffa5ae2..16aa88e30 100755
--- a/app/pkg/web/testdata/home.html
+++ b/app/pkg/web/testdata/home.html
@@ -44,7 +44,7 @@
<script id="server-data" type="application/json">
- {"contextID":"CONTEXT_ID","description":"My Page Description","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":null,"title":"My Page Title · Fider"}
+ {"contextID":"CONTEXT_ID","description":"My Page Description","page":"","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":null,"title":"My Page Title · Fider"}
</script>
diff --git a/app/pkg/web/testdata/home_ssr.html b/app/pkg/web/testdata/home_ssr.html
index 8e9679d6b..d8291cc10 100755
--- a/app/pkg/web/testdata/home_ssr.html
+++ b/app/pkg/web/testdata/home_ssr.html
@@ -16,11 +16,10 @@
+ <link rel="preload" href="https://demo.test.fider.io:3000/assets/locale-en.js" as="script" />
- <link href="https://demo.test.fider.io:3000/assets/css/Test.page.css" rel="stylesheet" />
-
<title>My Page Title · </title>
@@ -33,19 +32,33 @@
</head>
<body>
+<noscript class="container page">
+ <div class="mt-8">
+ <h2 class="text-display2">Please enable JavaScript</h2>
+ <p>This website requires JavaScript, please enable and reload the page.</p>
+ </div>
+</noscript>
-
-<div id="root"><div class="c-dev-banner">DEV</div><div id="c-header"><div class="c-menu shadow p-2 w-full flex flex-x flex--spacing-1 flex-items-center"><div class="container"><div class="flex flex-x flex--spacing-1 flex-items-center justify-between"><a href="/" class="flex flex-x flex-items-center flex--spacing-2 h-8"><h1 class="text-title"></h1></a><a href="#" class="uppercase text-sm">Sign in</a></div></div></div></div><div id="p-home" class="page container"><div class="p-home__welcome-col"><div class="flex flex-y flex--spacing-2"><div class="c-markdown "><p>We&#39;d love to hear what you&#39;re thinking about.</p>
-<p>What can we do better? This is the place for you to vote, discuss and share ideas.</p></div><form autoComplete="off" class="c-form"><div class="c-form-field"><div class="relative flex flex-x"><input type="text" class="c-input" id="input-title" tabindex="-1" maxLength="100" value="" placeholder="Enter your suggestion here..."/></div></div></form><div class="c-powered sm:hidden md:hidden lg:block"><a rel="noopener" href="https://getfider.com" target="_blank">Powered by Fider</a></div></div></div><div class="p-home__posts-col"><div class="text-center"><img style="height:120px" height="120" class="mt-6 mb-2" src="data:image/svg+xml;base64,PHN2ZyBpZD0iYjIxNjEzYzktMmJmMC00ZDM3LWJlZjAtM2IxOTNkMzRmYzVkIiBkYXRhLW5hbWU9IkxheWVyIDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjY0Ny42MzYyNiIgaGVpZ2h0PSI2MzIuMTczODMiIHZpZXdCb3g9IjAgMCA2NDcuNjM2MjYgNjMyLjE3MzgzIj48cGF0aCBkPSJNNjg3LjMyNzksMjc2LjA4NjkxSDUxMi44MTgxM2ExNS4wMTgyOCwxNS4wMTgyOCwwLDAsMC0xNSwxNXYzODcuODVsLTIsLjYxMDA1LTQyLjgxMDA2LDEzLjExYTguMDA2NzYsOC4wMDY3NiwwLDAsMS05Ljk4OTc0LTUuMzFMMzE1LjY3OCwyNzEuMzk2OTFhOC4wMDMxMyw4LjAwMzEzLDAsMCwxLDUuMzEwMDYtOS45OWw2NS45NzAyMi0yMC4yLDE5MS4yNS01OC41NCw2NS45Njk3Mi0yMC4yYTcuOTg5MjcsNy45ODkyNywwLDAsMSw5Ljk5MDI0LDUuM2wzMi41NDk4LDEwNi4zMloiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yNzYuMTgxODcgLTEzMy45MTMwOSkiIGZpbGw9IiNmMmYyZjIiLz48cGF0aCBkPSJNNzI1LjQwOCwyNzQuMDg2OTFsLTM5LjIzLTEyOC4xNGExNi45OTM2OCwxNi45OTM2OCwwLDAsMC0yMS4yMy0xMS4yOGwtOTIuNzUsMjguMzlMMzgwLjk1ODI3LDIyMS42MDY5M2wtOTIuNzUsMjguNGExNy4wMTUyLDE3LjAxNTIsMCwwLDAtMTEuMjgwMjgsMjEuMjNsMTM0LjA4MDA4LDQzNy45M2ExNy4wMjY2MSwxNy4wMjY2MSwwLDAsMCwxNi4yNjAyNiwxMi4wMywxNi43ODkyNiwxNi43ODkyNiwwLDAsMCw0Ljk2OTcyLS43NWw2My41ODAwOC0xOS40NiwyLS42MnYtMi4wOWwtMiwuNjEtNjQuMTY5OTIsMTkuNjVhMTUuMDE0ODksMTUuMDE0ODksMCwwLDEtMTguNzMtOS45NWwtMTM0LjA2OTgzLTQzNy45NGExNC45NzkzNSwxNC45NzkzNSwwLDAsMSw5Ljk0OTcxLTE4LjczbDkyLjc1LTI4LjQsMTkxLjI0MDI0LTU4LjU0LDkyLjc1LTI4LjRhMTUuMTU1NTEsMTUuMTU1NTEsMCwwLDEsNC40MDk2Ni0uNjYsMTUuMDE0NjEsMTUuMDE0NjEsMCwwLDEsMTQuMzIwMzIsMTAuNjFsMzkuMDQ5OCwxMjcuNTYuNjIwMTIsMmgyLjA4MDA4WiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTI3Ni4xODE4NyAtMTMzLjkxMzA5KSIgZmlsbD0iIzNmM2Q1NiIvPjxwYXRoIGQ9Ik0zOTguODYyNzksMjYxLjczMzg5YTkuMDE1Nyw5LjAxNTcsMCwwLDEtOC42MTEzMy02LjM2NjdsLTEyLjg4MDM3LTQyLjA3MTc4YTguOTk4ODQsOC45OTg4NCwwLDAsMSw1Ljk3MTItMTEuMjQwMjNsMTc1LjkzOS01My44NjM3N2E5LjAwODY3LDkuMDA4NjcsMCwwLDEsMTEuMjQwNzIsNS45NzA3bDEyLjg4MDM3LDQyLjA3MjI3YTkuMDEwMjksOS4wMTAyOSwwLDAsMS01Ljk3MDcsMTEuMjQwNzJMNDAxLjQ5MjE5LDI2MS4zMzg4N0E4Ljk3Niw4Ljk3NiwwLDAsMSwzOTguODYyNzksMjYxLjczMzg5WiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTI3Ni4xODE4NyAtMTMzLjkxMzA5KSIgZmlsbD0iIzQzMzhjYSIvPjxjaXJjbGUgY3g9IjE5MC4xNTM1MSIgY3k9IjI0Ljk1NDY1IiByPSIyMCIgZmlsbD0iIzQzMzhjYSIvPjxjaXJjbGUgY3g9IjE5MC4xNTM1MSIgY3k9IjI0Ljk1NDY1IiByPSIxMi42NjQ2MiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik04NzguODE4MzYsNzE2LjA4NjkxaC0zMzhhOC41MDk4MSw4LjUwOTgxLDAsMCwxLTguNS04LjV2LTQwNWE4LjUwOTUxLDguNTA5NTEsMCwwLDEsOC41LTguNWgzMzhhOC41MDk4Miw4LjUwOTgyLDAsMCwxLDguNSw4LjV2NDA1QTguNTEwMTMsOC41MTAxMywwLDAsMSw4NzguODE4MzYsNzE2LjA4NjkxWiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTI3Ni4xODE4NyAtMTMzLjkxMzA5KSIgZmlsbD0iI2U2ZTZlNiIvPjxwYXRoIGQ9Ik03MjMuMzE4MTMsMjc0LjA4NjkxaC0yMTAuNWExNy4wMjQxMSwxNy4wMjQxMSwwLDAsMC0xNywxN3Y0MDcuOGwyLS42MXYtNDA3LjE5YTE1LjAxODI4LDE1LjAxODI4LDAsMCwxLDE1LTE1SDcyMy45MzgyNVptMTgzLjUsMGgtMzk0YTE3LjAyNDExLDE3LjAyNDExLDAsMCwwLTE3LDE3djQ1OGExNy4wMjQxLDE3LjAyNDEsMCwwLDAsMTcsMTdoMzk0YTE3LjAyNDEsMTcuMDI0MSwwLDAsMCwxNy0xN3YtNDU4QTE3LjAyNDExLDE3LjAyNDExLDAsMCwwLDkwNi44MTgxMywyNzQuMDg2OTFabTE1LDQ3NWExNS4wMTgyOCwxNS4wMTgyOCwwLDAsMS0xNSwxNWgtMzk0YTE1LjAxODI4LDE1LjAxODI4LDAsMCwxLTE1LTE1di00NThhMTUuMDE4MjgsMTUuMDE4MjgsMCwwLDEsMTUtMTVoMzk0YTE1LjAxODI4LDE1LjAxODI4LDAsMCwxLDE1LDE1WiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTI3Ni4xODE4NyAtMTMzLjkxMzA5KSIgZmlsbD0iIzNmM2Q1NiIvPjxwYXRoIGQ9Ik04MDEuODE4MzYsMzE4LjA4NjkxaC0xODRhOS4wMTAxNSw5LjAxMDE1LDAsMCwxLTktOXYtNDRhOS4wMTAxNiw5LjAxMDE2LDAsMCwxLDktOWgxODRhOS4wMTAxNiw5LjAxMDE2LDAsMCwxLDksOXY0NEE5LjAxMDE1LDkuMDEwMTUsMCwwLDEsODAxLjgxODM2LDMxOC4wODY5MVoiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yNzYuMTgxODcgLTEzMy45MTMwOSkiIGZpbGw9IiM0MzM4Y2EiLz48Y2lyY2xlIGN4PSI0MzMuNjM2MjYiIGN5PSIxMDUuMTczODMiIHI9IjIwIiBmaWxsPSIjNDMzOGNhIi8+PGNpcmNsZSBjeD0iNDMzLjYzNjI2IiBjeT0iMTA1LjE3MzgzIiByPSIxMi4xODE4NyIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg=="/><p class="text-muted">No posts have been created yet.</p></div><div class="c-powered lg:hidden xl:hidden mt-8"><a rel="noopener" href="https://getfider.com" target="_blank">Powered by Fider</a></div></div></div></div>
+ <div id="root"></div><div id="root-modal"></div><div id="root-toastify"></div>
<script id="server-data" type="application/json">
-
+
+ {"contextID":"CONTEXT_ID","description":"My Page Description","page":"Test.page","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":{"id":0,"name":"","subdomain":"","invitation":"","welcomeMessage":"","cname":"","status":0,"locale":"en","isPrivate":false,"logoBlobKey":"","isEmailAuthAllowed":false},"title":"My Page Title · "}
+
</script>
+
+
+ <script src="https://demo.test.fider.io:3000/assets/js/file1.js" crossorigin="anonymous"></script>
+
+ <script src="https://demo.test.fider.io:3000/assets/js/file2.js" crossorigin="anonymous"></script>
+
+
+
diff --git a/app/pkg/web/testdata/oauth.html b/app/pkg/web/testdata/oauth.html
index ab65359df..3bf54adde 100755
--- a/app/pkg/web/testdata/oauth.html
+++ b/app/pkg/web/testdata/oauth.html
@@ -44,7 +44,7 @@
<script id="server-data" type="application/json">
- {"contextID":"CONTEXT_ID","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[{"provider":"google","displayName":"Google","clientID":"1234","url":"https://demo.test.fider.io:3000/oauth/google","callbackURL":"https://demo.test.fider.io:3000/oauth/google/callback","logoBlobKey":"google.png","isCustomProvider":false,"isEnabled":true}]},"tenant":null,"title":"Fider"}
+ {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[{"provider":"google","displayName":"Google","clientID":"1234","url":"https://demo.test.fider.io:3000/oauth/google","callbackURL":"https://demo.test.fider.io:3000/oauth/google/callback","logoBlobKey":"google.png","isCustomProvider":false,"isEnabled":true}]},"tenant":null,"title":"Fider"}
</script>
diff --git a/app/pkg/web/testdata/tenant.html b/app/pkg/web/testdata/tenant.html
index 4d24f477f..15521d18a 100755
--- a/app/pkg/web/testdata/tenant.html
+++ b/app/pkg/web/testdata/tenant.html
@@ -44,7 +44,7 @@
<script id="server-data" type="application/json">
- {"contextID":"CONTEXT_ID","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":{"id":0,"name":"Game of Thrones","subdomain":"","invitation":"","welcomeMessage":"","cname":"","status":0,"locale":"","isPrivate":false,"logoBlobKey":"","isEmailAuthAllowed":false},"title":"Game of Thrones"}
+ {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":{"id":0,"name":"Game of Thrones","subdomain":"","invitation":"","welcomeMessage":"","cname":"","status":0,"locale":"","isPrivate":false,"logoBlobKey":"","isEmailAuthAllowed":false},"title":"Game of Thrones"}
</script>
diff --git a/app/pkg/web/testdata/user.html b/app/pkg/web/testdata/user.html
index 280d566a8..5005636b7 100755
--- a/app/pkg/web/testdata/user.html
+++ b/app/pkg/web/testdata/user.html
@@ -44,7 +44,7 @@
<script id="server-data" type="application/json">
- {"contextID":"CONTEXT_ID","description":"My Page Description","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":null,"title":"My Page Title · Fider","user":{"avatarBlobKey":"","avatarType":"gravatar","avatarURL":"https://demo.test.fider.io:3000/static/avatars/gravatar/5/Jon%20Snow","email":"[email protected]","id":5,"isAdministrator":true,"isCollaborator":true,"name":"Jon Snow","role":"administrator","status":"active"}}
+ {"contextID":"CONTEXT_ID","description":"My Page Description","page":"","props":{},"sessionID":"","settings":{"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","mode":"multi","oauth":[]},"tenant":null,"title":"My Page Title · Fider","user":{"avatarBlobKey":"","avatarType":"gravatar","avatarURL":"https://demo.test.fider.io:3000/static/avatars/gravatar/5/Jon%20Snow","email":"[email protected]","id":5,"isAdministrator":true,"isCollaborator":true,"name":"Jon Snow","role":"administrator","status":"active"}}
</script>
diff --git a/public/AsyncPages.tsx b/public/AsyncPages.tsx
index 6d53a5557..227655b84 100644
--- a/public/AsyncPages.tsx
+++ b/public/AsyncPages.tsx
@@ -23,162 +23,12 @@ const retry = (fn: LazyImport, retriesLeft = MAX_RETRIES): Promise<{ default: Co
const load = (fn: LazyImport) => lazy(() => retry(() => fn()))
-export const AsyncHomePage = load(
- () =>
- import(
- /* webpackChunkName: "Home.page" */
- "@fider/pages/Home/Home.page"
- )
-)
-
-export const AsyncShowPostPage = load(
- () =>
- import(
- /* webpackChunkName: "ShowPost.page" */
- "@fider/pages/ShowPost/ShowPost.page"
- )
-)
-
-export const AsyncManageMembersPage = load(
- () =>
- import(
- /* webpackChunkName: "ManageMembers.page" */
- "@fider/pages/Administration/pages/ManageMembers.page"
- )
-)
-
-export const AsyncManageTagsPage = load(
- () =>
- import(
- /* webpackChunkName: "ManageTags.page" */
- "@fider/pages/Administration/pages/ManageTags.page"
- )
-)
-
-export const AsyncPrivacySettingsPage = load(
- () =>
- import(
- /* webpackChunkName: "PrivacySettings.page" */
- "@fider/pages/Administration/pages/PrivacySettings.page"
- )
-)
-
-export const AsyncExportPage = load(
- () =>
- import(
- /* webpackChunkName: "Export.page" */
- "@fider/pages/Administration/pages/Export.page"
- )
-)
-
-export const AsyncInvitationsPage = load(
- () =>
- import(
- /* webpackChunkName: "Invitations.page" */
- "@fider/pages/Administration/pages/Invitations.page"
- )
-)
-
-export const AsyncManageAuthenticationPage = load(
- () =>
- import(
- /* webpackChunkName: "ManageAuthentication.page" */
- "@fider/pages/Administration/pages/ManageAuthentication.page"
- )
-)
-
-export const AsyncAdvancedSettingsPage = load(
- () =>
- import(
- /* webpackChunkName: "AdvancedSettings.page" */
- "@fider/pages/Administration/pages/AdvancedSettings.page"
- )
-)
-
-export const AsyncManageBillingPage = load(
- () =>
- import(
- /* webpackChunkName: "ManageBilling.page" */
- "@fider/pages/Administration/pages/ManageBilling.page"
- )
-)
-
-export const AsyncManageWebhooksPage = load(
- () =>
- import(
- /* webpackChunkName: "ManageWebhooks.page" */
- "@fider/pages/Administration/pages/ManageWebhooks.page"
- )
-)
-
-export const AsyncGeneralSettingsPage = load(
- () =>
- import(
- /* webpackChunkName: "GeneralSettings.page" */
- "@fider/pages/Administration/pages/GeneralSettings.page"
- )
-)
-
-export const AsyncSignInPage = load(
- () =>
- import(
- /* webpackChunkName: "SignIn.page" */
- "@fider/pages/SignIn/SignIn.page"
- )
-)
-
-export const AsyncSignUpPage = load(
- () =>
- import(
- /* webpackChunkName: "SignUp.page" */
- "@fider/pages/SignUp/SignUp.page"
- )
-)
-
-export const AsyncCompleteSignInProfilePage = load(
- () =>
- import(
- /* webpackChunkName: "CompleteSignInProfile.page" */
- "@fider/pages/CompleteSignInProfile/CompleteSignInProfile.page"
- )
-)
-
-export const AsyncMyNotificationsPage = load(
- () =>
- import(
- /* webpackChunkName: "MyNotifications.page" */
- "@fider/pages/MyNotifications/MyNotifications.page"
- )
-)
-
-export const AsyncMySettingsPage = load(
- () =>
- import(
- /* webpackChunkName: "MySettings.page" */
- "@fider/pages/MySettings/MySettings.page"
- )
-)
-
-export const AsyncOAuthEchoPage = load(
- () =>
- import(
- /* webpackChunkName: "OAuthEcho.page" */
- "@fider/pages/OAuthEcho/OAuthEcho.page"
- )
-)
-
-export const AsyncDesignSystemPage = load(
- () =>
- import(
- /* webpackChunkName: "DesignSystem.page" */
- "@fider/pages/DesignSystem/DesignSystem.page"
- )
-)
-
-export const AsyncLegalPage = load(
- () =>
- import(
- /* webpackChunkName: "Legal.page" */
- "@fider/pages/Legal/Legal.page"
- )
-)
+export const AsyncPage = (pageName: string) =>
+ load(
+ () =>
+ import(
+ /* webpackInclude: /\.page.tsx$/ */
+ /* webpackChunkName: "[request]" */
+ `@fider/pages/${pageName}`
+ )
+ )
diff --git a/public/index.tsx b/public/index.tsx
index 546dc59cb..6ea33e474 100644
--- a/public/index.tsx
+++ b/public/index.tsx
@@ -2,12 +2,12 @@ import "@fider/assets/styles/index.scss"
import React, { Suspense } from "react"
import ReactDOM from "react-dom"
-import { resolveRootComponent } from "@fider/router"
-import { Header, ErrorBoundary, Loader, ReadOnlyNotice, DevBanner } from "@fider/components"
+import { ErrorBoundary, Loader, ReadOnlyNotice, DevBanner } from "@fider/components"
import { classSet, Fider, FiderContext, actions, activateI18N } from "@fider/services"
import { I18n } from "@lingui/core"
import { I18nProvider } from "@lingui/react"
+import { AsyncPage } from "./AsyncPages"
const Loading = () => (
<div className="page">
@@ -37,20 +37,20 @@ window.addEventListener("error", (evt: ErrorEvent) => {
})
const bootstrapApp = (i18n: I18n) => {
- const config = resolveRootComponent(location.pathname)
+ const component = AsyncPage(fider.session.page)
document.body.className = classSet({
"is-authenticated": fider.session.isAuthenticated,
"is-staff": fider.session.isAuthenticated && fider.session.user.isCollaborator,
})
+
ReactDOM.render(
<React.StrictMode>
<ErrorBoundary onError={logProductionError}>
<I18nProvider i18n={i18n}>
<FiderContext.Provider value={fider}>
<DevBanner />
- {config.showHeader && <Header />}
<ReadOnlyNotice />
- <Suspense fallback={<Loading />}>{React.createElement(config.component, fider.session.props)}</Suspense>
+ <Suspense fallback={<Loading />}>{React.createElement(component, fider.session.props)}</Suspense>
</FiderContext.Provider>
</I18nProvider>
</ErrorBoundary>
diff --git a/public/pages/Administration/components/AdminBasePage.tsx b/public/pages/Administration/components/AdminBasePage.tsx
index cc943c14d..10ad7fc55 100644
--- a/public/pages/Administration/components/AdminBasePage.tsx
+++ b/public/pages/Administration/components/AdminBasePage.tsx
@@ -1,7 +1,7 @@
import "./AdminBasePage.scss"
import React from "react"
-import { PageTitle } from "@fider/components"
+import { Header, PageTitle } from "@fider/components"
import { SideMenu, SideMenuToggler } from "./SideMenu"
import { HStack } from "@fider/components/layout"
@@ -15,17 +15,20 @@ interface AdminPageContainerProps {
export const AdminPageContainer = (props: AdminPageContainerProps) => {
return (
- <div id={props.id} className="page container">
- <HStack justify="between">
- <PageTitle title={props.title} subtitle={props.subtitle} />
- <SideMenuToggler />
- </HStack>
+ <>
+ <Header />
+ <div id={props.id} className="page container">
+ <HStack justify="between">
+ <PageTitle title={props.title} subtitle={props.subtitle} />
+ <SideMenuToggler />
+ </HStack>
- <div className="c-admin-basepage">
- <SideMenu activeItem={props.name} />
- <div>{props.children}</div>
+ <div className="c-admin-basepage">
+ <SideMenu activeItem={props.name} />
+ <div>{props.children}</div>
+ </div>
</div>
- </div>
+ </>
)
}
diff --git a/public/pages/DesignSystem/DesignSystem.page.tsx b/public/pages/DesignSystem/DesignSystem.page.tsx
index d6ddebfb4..cac109102 100644
--- a/public/pages/DesignSystem/DesignSystem.page.tsx
+++ b/public/pages/DesignSystem/DesignSystem.page.tsx
@@ -27,6 +27,7 @@ import {
Icon,
Checkbox,
ImageUploader,
+ Header,
} from "@fider/components"
import { User, UserRole, Tag } from "@fider/models"
import { notify, Failure } from "@fider/services"
@@ -108,358 +109,361 @@ const DesignSystemPage = () => {
}
return (
- <div id="p-ui-toolkit" className="page container">
- <h2 className="text-display2 mb-2">1. Colors</h2>
-
- <div className="color-scale">
- <div className="color gray-900" />
- <div className="color gray-800" />
- <div className="color gray-700" />
- <div className="color gray-600" />
- <div className="color gray-500" />
- <div className="color gray-400" />
- <div className="color gray-300" />
- <div className="color gray-200" />
- <div className="color gray-100" />
- <div className="color gray-50" />
- </div>
- <div className="color-scale">
- <div className="color green-900" />
- <div className="color green-800" />
- <div className="color green-700" />
- <div className="color green-600" />
- <div className="color green-500" />
- <div className="color green-400" />
- <div className="color green-300" />
- <div className="color green-200" />
- <div className="color green-100" />
- <div className="color green-50" />
- </div>
- <div className="color-scale">
- <div className="color red-900" />
- <div className="color red-800" />
- <div className="color red-700" />
- <div className="color red-600" />
- <div className="color red-500" />
- <div className="color red-400" />
- <div className="color red-300" />
- <div className="color red-200" />
- <div className="color red-100" />
- <div className="color red-50" />
- </div>
- <div className="color-scale">
- <div className="color blue-900" />
- <div className="color blue-800" />
- <div className="color blue-700" />
- <div className="color blue-600" />
- <div className="color blue-500" />
- <div className="color blue-400" />
- <div className="color blue-300" />
- <div className="color blue-200" />
- <div className="color blue-100" />
- <div className="color blue-50" />
- </div>
- <div className="color-scale">
- <div className="color yellow-900" />
- <div className="color yellow-800" />
- <div className="color yellow-700" />
- <div className="color yellow-600" />
- <div className="color yellow-500" />
- <div className="color yellow-400" />
- <div className="color yellow-300" />
- <div className="color yellow-200" />
- <div className="color yellow-full" />
- <div className="color yellow-50" />
- </div>
- <div className="color-scale">
- <div className="color bg-primary-dark" />
- <div className="color bg-primary-base" />
- <div className="color bg-primary-light" />
- </div>
-
- <h2 className="text-display2 mb-3 mt-6">2. Text</h2>
-
- <VStack>
- <span className="text-display2">text-display2</span>
- <span className="text-display">text-display</span>
- <span className="text-title">text-title</span>
- <span className="text-body">text-body</span>
- <span className="text-sm">text-sm</span>
- <span className="text-xs">text-xs</span>
- <span className="text-2xs">text-2xs</span>
- <span className="text-muted">text-muted</span>
- <span className="text-category">text-category</span>
- </VStack>
-
- <h2 className="text-display2 mb-3 mt-6">3. Avatars</h2>
-
- <VStack>
- <HStack>
- <Avatar user={jonSnow} /> <UserName user={jonSnow} />
- </HStack>
- <HStack>
- <Avatar user={aryaStark} /> <UserName user={aryaStark} />
- </HStack>
- <HStack>
- <AvatarStack users={[jonSnow, aryaStark, robStark]} />
- </HStack>
- </VStack>
-
- <h2 className="text-display2 mb-3 mt-6">4. Page Title</h2>
-
- <PageTitle title="Page Title" subtitle="This is a page subtitle" />
-
- <h2 className="text-display2 mb-3 mt-6">5. Buttons</h2>
-
- <VStack>
- <HStack>
- <Button variant="primary" size="large">
- Primary
- </Button>
- <Button size="large">
- <Icon sprite={IconLightBulb} /> <span>Secondary</span>
- </Button>
- <Button size="large">
- <Icon sprite={IconLightBulb} />
- </Button>
- <Button size="large">Secondary</Button>
- <Button variant="tertiary" size="large">
- Tertiary
- </Button>
- <Button variant="danger" size="large">
- Danger
- </Button>
- </HStack>
-
- <HStack>
- <Button variant="primary">Primary</Button>
- <Button>
- <Icon sprite={IconLightBulb} /> <span>Secondary</span>
- </Button>
- <Button>
- <Icon sprite={IconLightBulb} />
- </Button>
- <Button>Secondary</Button>
- <Button variant="tertiary">Tertiary</Button>
- <Button variant="danger">Danger</Button>
- </HStack>
-
- <HStack>
- <Button variant="primary" size="small">
- Primary
- </Button>
- <Button size="small">
- <Icon sprite={IconLightBulb} /> <span>Secondary</span>
- </Button>
- <Button size="small">
- <Icon sprite={IconLightBulb} />
- </Button>
- <Button size="small">Secondary</Button>
- <Button variant="tertiary" size="small">
- Tertiary
- </Button>
- <Button variant="danger" size="small">
- Danger
- </Button>
- </HStack>
-
- <HStack>
- <Button href="#" variant="primary">
- Link
- </Button>
- <Button href="#">
- <Icon sprite={IconLightBulb} /> <span>Link</span>
- </Button>
- <Button href="#">
- <Icon sprite={IconLightBulb} />
- </Button>
- <Button>Link</Button>
- <Button variant="tertiary" href="#">
- Link
- </Button>
- <Button href="#" variant="danger">
- Link
- </Button>
- </HStack>
-
- <HStack>
- <Button disabled={true} variant="primary">
- Primary
- </Button>
- <Button disabled={true}>
- <Icon sprite={IconLightBulb} /> <span>Secondary</span>
- </Button>
- <Button disabled={true}>
- <Icon sprite={IconLightBulb} />
- </Button>
- <Button disabled={true}>Secondary</Button>
- <Button disabled={true} variant="tertiary">
- Tertiary
- </Button>
- <Button disabled={true} variant="danger">
- Danger
- </Button>
- </HStack>
-
- <HStack>
- <Button variant="primary" onClick={showLoading}>
- Loading
- </Button>
- <Button onClick={showLoading}>
- <Icon sprite={IconLightBulb} /> <span>Loading</span>
- </Button>
- <Button onClick={showLoading}>
- <Icon sprite={IconLightBulb} />
- </Button>
- <Button onClick={showLoading}>Loading</Button>
- <Button variant="tertiary" onClick={showLoading}>
- Loading
- </Button>
- <Button variant="danger" onClick={showLoading}>
- Loading
- </Button>
- </HStack>
-
- <HStack>
- <SocialSignInButton option={{ displayName: "GitHub", provider: "github" }} />
- <SocialSignInButton option={{ displayName: "Facebook", provider: "facebook" }} />
- <SocialSignInButton option={{ displayName: "Google", provider: "google" }} />
- </HStack>
- </VStack>
-
- <h2 className="text-display2 mb-3 mt-6">6. Toggle</h2>
-
- <VStack>
- <Toggle active={true} label="Active" />
- <Toggle active={false} label="Inactive" />
- <Toggle active={true} disabled={true} label="Disabled" />
- </VStack>
-
- <h2 className="text-display2 mb-3 mt-6">7. Statuses</h2>
-
- <VStack>
- <ShowPostStatus status={PostStatus.Open} />
- <ShowPostStatus status={PostStatus.Planned} />
- <ShowPostStatus status={PostStatus.Started} />
- <ShowPostStatus status={PostStatus.Duplicate} />
- <ShowPostStatus status={PostStatus.Completed} />
- <ShowPostStatus status={PostStatus.Declined} />
- </VStack>
-
- <h2 className="text-display2 mb-3 mt-6">8. Tags</h2>
-
- <VStack>
- <HStack>
- <ShowTag tag={easyTag} />
- <ShowTag tag={normalTag} />
- <ShowTag tag={hardTag} />
- <ShowTag tag={linkTag} link />
- </HStack>
- <HStack>
- <ShowTag tag={easyTag} circular />
- <ShowTag tag={normalTag} circular />
- <ShowTag tag={hardTag} circular />
- <ShowTag tag={linkTag} circular link />
- </HStack>
- </VStack>
-
- <h2 className="text-display2 mb-3 mt-6">9. Notification</h2>
-
- <HStack>
- <Button onClick={notifySuccess}>Success</Button>
- <Button onClick={notifyError}>Error</Button>
- </HStack>
-
- <h2 className="text-display2 mb-3 mt-6">10. Moment</h2>
-
- <VStack>
- <div>
- Relative: <Moment locale={fider.currentLocale} date={threeHoursAgo} format="relative" />
+ <>
+ <Header />
+ <div id="p-ui-toolkit" className="page container">
+ <h2 className="text-display2 mb-2">1. Colors</h2>
+
+ <div className="color-scale">
+ <div className="color gray-900" />
+ <div className="color gray-800" />
+ <div className="color gray-700" />
+ <div className="color gray-600" />
+ <div className="color gray-500" />
+ <div className="color gray-400" />
+ <div className="color gray-300" />
+ <div className="color gray-200" />
+ <div className="color gray-100" />
+ <div className="color gray-50" />
</div>
- <div>
- Short: <Moment locale={fider.currentLocale} date="2017-06-03T16:55:06.815042Z" format="short" />
+ <div className="color-scale">
+ <div className="color green-900" />
+ <div className="color green-800" />
+ <div className="color green-700" />
+ <div className="color green-600" />
+ <div className="color green-500" />
+ <div className="color green-400" />
+ <div className="color green-300" />
+ <div className="color green-200" />
+ <div className="color green-100" />
+ <div className="color green-50" />
</div>
- <div>
- Full: <Moment locale={fider.currentLocale} date="2017-06-03T16:55:06.815042Z" format="full" />
+ <div className="color-scale">
+ <div className="color red-900" />
+ <div className="color red-800" />
+ <div className="color red-700" />
+ <div className="color red-600" />
+ <div className="color red-500" />
+ <div className="color red-400" />
+ <div className="color red-300" />
+ <div className="color red-200" />
+ <div className="color red-100" />
+ <div className="color red-50" />
</div>
- </VStack>
-
- <h2 className="text-display2 mb-3 mt-6">11. Loader</h2>
-
- <Loader />
- <Loader text="Loader with text" />
-
- <h2 className="text-display2 mb-3 mt-6">12. Message</h2>
-
- <Message showIcon={true} type="error">
- Something went wrong.
- </Message>
- <Message showIcon={true} type="warning">
- Be careful!
- </Message>
- <Message showIcon={true} type="success">
- Your order has been confirmed.
- </Message>
-
- <h2 className="text-display2 mb-3 mt-6">13. Hints</h2>
-
- <Hint permanentCloseKey="ui-toolkip-example">Did you know that you can close this permanently?</Hint>
- <Hint>You can&apos;t close this one :)</Hint>
-
- <h2 className="text-display2 mb-3 mt-6">14. Form</h2>
-
- <Form error={error}>
- <Input label="Title" field="title">
- <p className="text-muted">This is the explanation for the field above.</p>
- </Input>
- <Input label="Disabled!" field="unamed" disabled={true} value={"you can't change this!"} />
- <Input label="Name" field="name" placeholder={"Your name goes here..."} />
- <Input label="Subdomain" field="subdomain" suffix=".fider.io" />
- <Input label="Email" field="email" suffix={<Button variant="primary">Sign in</Button>} />
- <TextArea label="Description" field="description" minRows={5}>
- <p className="text-muted">This textarea resizes as you type.</p>
- </TextArea>
- <Input field="age" placeholder="This field doesn't have a label" />
-
- <div className="grid gap-4 grid-cols-4">
- <Input label="Title1" field="title1" />
- <Input label="Title2" field="title2" />
- <Input label="Title3" field="title3" />
- <RadioButton label="Visibility" field="visibility" defaultOption={visibilityPublic} options={[visibilityPrivate, visibilityPublic]} />
+ <div className="color-scale">
+ <div className="color blue-900" />
+ <div className="color blue-800" />
+ <div className="color blue-700" />
+ <div className="color blue-600" />
+ <div className="color blue-500" />
+ <div className="color blue-400" />
+ <div className="color blue-300" />
+ <div className="color blue-200" />
+ <div className="color blue-100" />
+ <div className="color blue-50" />
+ </div>
+ <div className="color-scale">
+ <div className="color yellow-900" />
+ <div className="color yellow-800" />
+ <div className="color yellow-700" />
+ <div className="color yellow-600" />
+ <div className="color yellow-500" />
+ <div className="color yellow-400" />
+ <div className="color yellow-300" />
+ <div className="color yellow-200" />
+ <div className="color yellow-full" />
+ <div className="color yellow-50" />
+ </div>
+ <div className="color-scale">
+ <div className="color bg-primary-dark" />
+ <div className="color bg-primary-base" />
+ <div className="color bg-primary-light" />
</div>
- <Select
- label="Status"
- field="status"
- options={[
- { value: "open", label: "Open" },
- { value: "started", label: "Started" },
- { value: "planned", label: "Planned" },
- ]}
- onChange={notifyStatusChange}
- />
-
- <ImageUploader label="Logo" field="logo" onChange={console.log} />
-
- <Checkbox field="gdpr">I agree with this policy.</Checkbox>
-
- <Button onClick={forceError}>Save</Button>
- </Form>
-
- <h2 className="text-display2 mb-3 mt-6">15. Dropdown</h2>
-
- <Dropdown renderHandle={<Avatar user={aryaStark} />}>
- <div className="p-2 text-bold uppercase">Arya Stark</div>
- <Dropdown.ListItem>Account Settings</Dropdown.ListItem>
- <Dropdown.ListItem>My Profile</Dropdown.ListItem>
- <Dropdown.Divider />
- <Dropdown.ListItem>Sign Out</Dropdown.ListItem>
- </Dropdown>
+ <h2 className="text-display2 mb-3 mt-6">2. Text</h2>
+
+ <VStack>
+ <span className="text-display2">text-display2</span>
+ <span className="text-display">text-display</span>
+ <span className="text-title">text-title</span>
+ <span className="text-body">text-body</span>
+ <span className="text-sm">text-sm</span>
+ <span className="text-xs">text-xs</span>
+ <span className="text-2xs">text-2xs</span>
+ <span className="text-muted">text-muted</span>
+ <span className="text-category">text-category</span>
+ </VStack>
+
+ <h2 className="text-display2 mb-3 mt-6">3. Avatars</h2>
+
+ <VStack>
+ <HStack>
+ <Avatar user={jonSnow} /> <UserName user={jonSnow} />
+ </HStack>
+ <HStack>
+ <Avatar user={aryaStark} /> <UserName user={aryaStark} />
+ </HStack>
+ <HStack>
+ <AvatarStack users={[jonSnow, aryaStark, robStark]} />
+ </HStack>
+ </VStack>
+
+ <h2 className="text-display2 mb-3 mt-6">4. Page Title</h2>
+
+ <PageTitle title="Page Title" subtitle="This is a page subtitle" />
+
+ <h2 className="text-display2 mb-3 mt-6">5. Buttons</h2>
+
+ <VStack>
+ <HStack>
+ <Button variant="primary" size="large">
+ Primary
+ </Button>
+ <Button size="large">
+ <Icon sprite={IconLightBulb} /> <span>Secondary</span>
+ </Button>
+ <Button size="large">
+ <Icon sprite={IconLightBulb} />
+ </Button>
+ <Button size="large">Secondary</Button>
+ <Button variant="tertiary" size="large">
+ Tertiary
+ </Button>
+ <Button variant="danger" size="large">
+ Danger
+ </Button>
+ </HStack>
+
+ <HStack>
+ <Button variant="primary">Primary</Button>
+ <Button>
+ <Icon sprite={IconLightBulb} /> <span>Secondary</span>
+ </Button>
+ <Button>
+ <Icon sprite={IconLightBulb} />
+ </Button>
+ <Button>Secondary</Button>
+ <Button variant="tertiary">Tertiary</Button>
+ <Button variant="danger">Danger</Button>
+ </HStack>
+
+ <HStack>
+ <Button variant="primary" size="small">
+ Primary
+ </Button>
+ <Button size="small">
+ <Icon sprite={IconLightBulb} /> <span>Secondary</span>
+ </Button>
+ <Button size="small">
+ <Icon sprite={IconLightBulb} />
+ </Button>
+ <Button size="small">Secondary</Button>
+ <Button variant="tertiary" size="small">
+ Tertiary
+ </Button>
+ <Button variant="danger" size="small">
+ Danger
+ </Button>
+ </HStack>
+
+ <HStack>
+ <Button href="#" variant="primary">
+ Link
+ </Button>
+ <Button href="#">
+ <Icon sprite={IconLightBulb} /> <span>Link</span>
+ </Button>
+ <Button href="#">
+ <Icon sprite={IconLightBulb} />
+ </Button>
+ <Button>Link</Button>
+ <Button variant="tertiary" href="#">
+ Link
+ </Button>
+ <Button href="#" variant="danger">
+ Link
+ </Button>
+ </HStack>
+
+ <HStack>
+ <Button disabled={true} variant="primary">
+ Primary
+ </Button>
+ <Button disabled={true}>
+ <Icon sprite={IconLightBulb} /> <span>Secondary</span>
+ </Button>
+ <Button disabled={true}>
+ <Icon sprite={IconLightBulb} />
+ </Button>
+ <Button disabled={true}>Secondary</Button>
+ <Button disabled={true} variant="tertiary">
+ Tertiary
+ </Button>
+ <Button disabled={true} variant="danger">
+ Danger
+ </Button>
+ </HStack>
+
+ <HStack>
+ <Button variant="primary" onClick={showLoading}>
+ Loading
+ </Button>
+ <Button onClick={showLoading}>
+ <Icon sprite={IconLightBulb} /> <span>Loading</span>
+ </Button>
+ <Button onClick={showLoading}>
+ <Icon sprite={IconLightBulb} />
+ </Button>
+ <Button onClick={showLoading}>Loading</Button>
+ <Button variant="tertiary" onClick={showLoading}>
+ Loading
+ </Button>
+ <Button variant="danger" onClick={showLoading}>
+ Loading
+ </Button>
+ </HStack>
+
+ <HStack>
+ <SocialSignInButton option={{ displayName: "GitHub", provider: "github" }} />
+ <SocialSignInButton option={{ displayName: "Facebook", provider: "facebook" }} />
+ <SocialSignInButton option={{ displayName: "Google", provider: "google" }} />
+ </HStack>
+ </VStack>
+
+ <h2 className="text-display2 mb-3 mt-6">6. Toggle</h2>
+
+ <VStack>
+ <Toggle active={true} label="Active" />
+ <Toggle active={false} label="Inactive" />
+ <Toggle active={true} disabled={true} label="Disabled" />
+ </VStack>
+
+ <h2 className="text-display2 mb-3 mt-6">7. Statuses</h2>
+
+ <VStack>
+ <ShowPostStatus status={PostStatus.Open} />
+ <ShowPostStatus status={PostStatus.Planned} />
+ <ShowPostStatus status={PostStatus.Started} />
+ <ShowPostStatus status={PostStatus.Duplicate} />
+ <ShowPostStatus status={PostStatus.Completed} />
+ <ShowPostStatus status={PostStatus.Declined} />
+ </VStack>
+
+ <h2 className="text-display2 mb-3 mt-6">8. Tags</h2>
+
+ <VStack>
+ <HStack>
+ <ShowTag tag={easyTag} />
+ <ShowTag tag={normalTag} />
+ <ShowTag tag={hardTag} />
+ <ShowTag tag={linkTag} link />
+ </HStack>
+ <HStack>
+ <ShowTag tag={easyTag} circular />
+ <ShowTag tag={normalTag} circular />
+ <ShowTag tag={hardTag} circular />
+ <ShowTag tag={linkTag} circular link />
+ </HStack>
+ </VStack>
+
+ <h2 className="text-display2 mb-3 mt-6">9. Notification</h2>
- <h2 className="text-display2 mb-3 mt-6">16. Search</h2>
+ <HStack>
+ <Button onClick={notifySuccess}>Success</Button>
+ <Button onClick={notifyError}>Error</Button>
+ </HStack>
- <Input field="search" placeholder="Search..." icon={IconSearch} />
- </div>
+ <h2 className="text-display2 mb-3 mt-6">10. Moment</h2>
+
+ <VStack>
+ <div>
+ Relative: <Moment locale={fider.currentLocale} date={threeHoursAgo} format="relative" />
+ </div>
+ <div>
+ Short: <Moment locale={fider.currentLocale} date="2017-06-03T16:55:06.815042Z" format="short" />
+ </div>
+ <div>
+ Full: <Moment locale={fider.currentLocale} date="2017-06-03T16:55:06.815042Z" format="full" />
+ </div>
+ </VStack>
+
+ <h2 className="text-display2 mb-3 mt-6">11. Loader</h2>
+
+ <Loader />
+ <Loader text="Loader with text" />
+
+ <h2 className="text-display2 mb-3 mt-6">12. Message</h2>
+
+ <Message showIcon={true} type="error">
+ Something went wrong.
+ </Message>
+ <Message showIcon={true} type="warning">
+ Be careful!
+ </Message>
+ <Message showIcon={true} type="success">
+ Your order has been confirmed.
+ </Message>
+
+ <h2 className="text-display2 mb-3 mt-6">13. Hints</h2>
+
+ <Hint permanentCloseKey="ui-toolkip-example">Did you know that you can close this permanently?</Hint>
+ <Hint>You can&apos;t close this one :)</Hint>
+
+ <h2 className="text-display2 mb-3 mt-6">14. Form</h2>
+
+ <Form error={error}>
+ <Input label="Title" field="title">
+ <p className="text-muted">This is the explanation for the field above.</p>
+ </Input>
+ <Input label="Disabled!" field="unamed" disabled={true} value={"you can't change this!"} />
+ <Input label="Name" field="name" placeholder={"Your name goes here..."} />
+ <Input label="Subdomain" field="subdomain" suffix=".fider.io" />
+ <Input label="Email" field="email" suffix={<Button variant="primary">Sign in</Button>} />
+ <TextArea label="Description" field="description" minRows={5}>
+ <p className="text-muted">This textarea resizes as you type.</p>
+ </TextArea>
+ <Input field="age" placeholder="This field doesn't have a label" />
+
+ <div className="grid gap-4 grid-cols-4">
+ <Input label="Title1" field="title1" />
+ <Input label="Title2" field="title2" />
+ <Input label="Title3" field="title3" />
+ <RadioButton label="Visibility" field="visibility" defaultOption={visibilityPublic} options={[visibilityPrivate, visibilityPublic]} />
+ </div>
+
+ <Select
+ label="Status"
+ field="status"
+ options={[
+ { value: "open", label: "Open" },
+ { value: "started", label: "Started" },
+ { value: "planned", label: "Planned" },
+ ]}
+ onChange={notifyStatusChange}
+ />
+
+ <ImageUploader label="Logo" field="logo" onChange={console.log} />
+
+ <Checkbox field="gdpr">I agree with this policy.</Checkbox>
+
+ <Button onClick={forceError}>Save</Button>
+ </Form>
+
+ <h2 className="text-display2 mb-3 mt-6">15. Dropdown</h2>
+
+ <Dropdown renderHandle={<Avatar user={aryaStark} />}>
+ <div className="p-2 text-bold uppercase">Arya Stark</div>
+ <Dropdown.ListItem>Account Settings</Dropdown.ListItem>
+ <Dropdown.ListItem>My Profile</Dropdown.ListItem>
+ <Dropdown.Divider />
+ <Dropdown.ListItem>Sign Out</Dropdown.ListItem>
+ </Dropdown>
+
+ <h2 className="text-display2 mb-3 mt-6">16. Search</h2>
+
+ <Input field="search" placeholder="Search..." icon={IconSearch} />
+ </div>
+ </>
)
}
diff --git a/public/pages/Home/Home.page.tsx b/public/pages/Home/Home.page.tsx
index 0d32f7d7f..8f2ea733d 100644
--- a/public/pages/Home/Home.page.tsx
+++ b/public/pages/Home/Home.page.tsx
@@ -3,7 +3,7 @@ import NoDataIllustration from "@fider/assets/images/undraw-no-data.svg"
import React, { useState } from "react"
import { Post, Tag, PostStatus } from "@fider/models"
-import { Markdown, Hint, PoweredByFider, Icon } from "@fider/components"
+import { Markdown, Hint, PoweredByFider, Icon, Header } from "@fider/components"
import { SimilarPosts } from "./components/SimilarPosts"
import { PostInput } from "./components/PostInput"
import { PostsContainer } from "./components/PostsContainer"
@@ -73,25 +73,28 @@ What can we do better? This is the place for you to vote, discuss and share idea
}
return (
- <div id="p-home" className="page container">
- <div className="p-home__welcome-col">
- <VStack spacing={2}>
- <Markdown text={fider.session.tenant.welcomeMessage || defaultWelcomeMessage} style="full" />
- <PostInput placeholder={fider.session.tenant.invitation || defaultInvitation} onTitleChanged={setTitle} />
- <PoweredByFider className="sm:hidden md:hidden lg:block" />
- </VStack>
+ <>
+ <Header />
+ <div id="p-home" className="page container">
+ <div className="p-home__welcome-col">
+ <VStack spacing={2}>
+ <Markdown text={fider.session.tenant.welcomeMessage || defaultWelcomeMessage} style="full" />
+ <PostInput placeholder={fider.session.tenant.invitation || defaultInvitation} onTitleChanged={setTitle} />
+ <PoweredByFider className="sm:hidden md:hidden lg:block" />
+ </VStack>
+ </div>
+ <div className="p-home__posts-col">
+ {isLonely() ? (
+ <Lonely />
+ ) : title ? (
+ <SimilarPosts title={title} tags={props.tags} />
+ ) : (
+ <PostsContainer posts={props.posts} tags={props.tags} countPerStatus={props.countPerStatus} />
+ )}
+ <PoweredByFider className="lg:hidden xl:hidden mt-8" />
+ </div>
</div>
- <div className="p-home__posts-col">
- {isLonely() ? (
- <Lonely />
- ) : title ? (
- <SimilarPosts title={title} tags={props.tags} />
- ) : (
- <PostsContainer posts={props.posts} tags={props.tags} countPerStatus={props.countPerStatus} />
- )}
- <PoweredByFider className="lg:hidden xl:hidden mt-8" />
- </div>
- </div>
+ </>
)
}
diff --git a/public/pages/MyNotifications/MyNotifications.page.tsx b/public/pages/MyNotifications/MyNotifications.page.tsx
index f5f9ffc68..c7d8f383f 100644
--- a/public/pages/MyNotifications/MyNotifications.page.tsx
+++ b/public/pages/MyNotifications/MyNotifications.page.tsx
@@ -1,7 +1,7 @@
import React from "react"
import { Notification } from "@fider/models"
-import { Markdown, Moment, PageTitle } from "@fider/components"
+import { Header, Markdown, Moment, PageTitle } from "@fider/components"
import { actions, Fider } from "@fider/services"
import { HStack, VStack } from "@fider/components/layout"
import { t, Trans } from "@lingui/macro"
@@ -59,41 +59,44 @@ export default class MyNotificationsPage extends React.Component<MyNotifications
public render() {
return (
- <div id="p-my-notifications" className="page container">
- <PageTitle
- title={t({ id: "mynotifications.page.title", message: "Notifications" })}
- subtitle={t({ id: "mynotifications.page.subtitle", message: "Stay up to date with what's happening" })}
- />
+ <>
+ <Header />
+ <div id="p-my-notifications" className="page container">
+ <PageTitle
+ title={t({ id: "mynotifications.page.title", message: "Notifications" })}
+ subtitle={t({ id: "mynotifications.page.subtitle", message: "Stay up to date with what's happening" })}
+ />
- <HStack spacing={4} className="mt-8 mb-2">
- <h4 className="text-title">
- <Trans id="label.unread">Unread</Trans>
- </h4>
- {this.state.unread.length > 0 && (
- <a href="#" className="text-link text-xs" onClick={this.markAllAsRead}>
- <Trans id="action.markallasread">Mark All as Read</Trans>
- </a>
- )}
- </HStack>
+ <HStack spacing={4} className="mt-8 mb-2">
+ <h4 className="text-title">
+ <Trans id="label.unread">Unread</Trans>
+ </h4>
+ {this.state.unread.length > 0 && (
+ <a href="#" className="text-link text-xs" onClick={this.markAllAsRead}>
+ <Trans id="action.markallasread">Mark All as Read</Trans>
+ </a>
+ )}
+ </HStack>
- <VStack spacing={4}>
- {this.state.unread.length > 0 && this.items(this.state.unread)}
- {this.state.unread.length === 0 && (
- <span className="text-muted">
- <Trans id="mynotifications.message.nounread">No unread notifications.</Trans>
- </span>
- )}
- </VStack>
+ <VStack spacing={4}>
+ {this.state.unread.length > 0 && this.items(this.state.unread)}
+ {this.state.unread.length === 0 && (
+ <span className="text-muted">
+ <Trans id="mynotifications.message.nounread">No unread notifications.</Trans>
+ </span>
+ )}
+ </VStack>
- {this.state.recent.length > 0 && (
- <>
- <h4 className="text-title mt-8 mb-2">
- <Trans id="mynotifications.label.readrecently">Read on last 30 days.</Trans>
- </h4>
- <VStack spacing={4}>{this.items(this.state.recent)}</VStack>
- </>
- )}
- </div>
+ {this.state.recent.length > 0 && (
+ <>
+ <h4 className="text-title mt-8 mb-2">
+ <Trans id="mynotifications.label.readrecently">Read on last 30 days.</Trans>
+ </h4>
+ <VStack spacing={4}>{this.items(this.state.recent)}</VStack>
+ </>
+ )}
+ </div>
+ </>
)
}
}
diff --git a/public/pages/MySettings/MySettings.page.tsx b/public/pages/MySettings/MySettings.page.tsx
index ba95e0768..248cc1127 100644
--- a/public/pages/MySettings/MySettings.page.tsx
+++ b/public/pages/MySettings/MySettings.page.tsx
@@ -1,6 +1,6 @@
import React from "react"
-import { Modal, Form, Button, PageTitle, Input, Select, SelectOption, ImageUploader } from "@fider/components"
+import { Modal, Form, Button, PageTitle, Input, Select, SelectOption, ImageUploader, Header } from "@fider/components"
import { UserSettings, UserAvatarType, ImageUpload } from "@fider/models"
import { Failure, actions, Fider } from "@fider/services"
@@ -110,115 +110,118 @@ export default class MySettingsPage extends React.Component<MySettingsPageProps,
)
return (
- <div id="p-my-settings" className="page container">
- <Modal.Window isOpen={this.state.showModal} onClose={this.closeModal}>
- <Modal.Header>
- <Trans id="modal.changeemail.header">Confirm your new email</Trans>
- </Modal.Header>
- <Modal.Content>
- <div>
- <p>
- <Trans id="modal.changeemail.text">
- We have just sent a confirmation link to <b>{this.state.newEmail}</b>. <br /> Click the link to update your email.
- </Trans>
- </p>
- <p>
- <a href="#" onClick={this.closeModal}>
- <Trans id="action.ok">OK</Trans>
- </a>
- </p>
- </div>
- </Modal.Content>
- </Modal.Window>
-
- <PageTitle
- title={t({ id: "mysettings.page.title", message: "Settings" })}
- subtitle={t({ id: "mysettings.page.subtitle", message: "Manage your profile settings" })}
- />
-
- <div className="w-max-7xl">
- <Form error={this.state.error}>
- <Input
- label={t({ id: "label.email", message: "Email" })}
- field="email"
- value={this.state.changingEmail ? this.state.newEmail : Fider.session.user.email}
- maxLength={200}
- disabled={!this.state.changingEmail}
- afterLabel={this.state.changingEmail ? undefined : changeEmail}
- onChange={this.setNewEmail}
- >
- <p className="text-muted">
- {Fider.session.user.email || this.state.changingEmail ? (
- <Trans id="mysettings.message.privateemail">Your email is private and will never be publicly displayed.</Trans>
- ) : (
- <Trans id="mysettings.message.noemail">Your account doesn&apos;t have an email.</Trans>
- )}
- </p>
- {this.state.changingEmail && (
- <>
- <Button variant="primary" size="small" onClick={this.submitNewEmail}>
- <Trans id="action.confirm">Confirm</Trans>
- </Button>
- <Button variant="tertiary" size="small" onClick={this.cancelChangeEmail}>
- <Trans id="action.cancel">Cancel</Trans>
- </Button>
- </>
- )}
- </Input>
-
- <Input label={t({ id: "label.name", message: "Name" })} field="name" value={this.state.name} maxLength={100} onChange={this.setName} />
-
- <Select
- label={t({ id: "label.avatar", message: "Avatar" })}
- field="avatarType"
- defaultValue={this.state.avatarType}
- options={[
- { label: t({ id: "label.letter", message: "Letter" }), value: UserAvatarType.Letter },
- { label: t({ id: "label.gravatar", message: "Gravatar" }), value: UserAvatarType.Gravatar },
- { label: t({ id: "label.custom", message: "Custom" }), value: UserAvatarType.Custom },
- ]}
- onChange={this.avatarTypeChanged}
- >
- {this.state.avatarType === UserAvatarType.Gravatar && (
- <p className="text-muted mt-1">
- <Trans id="mysettings.message.avatar.gravatar">
- A{" "}
- <a className="text-link" rel="noopener" href="https://en.gravatar.com" target="_blank">
- Gravatar
- </a>{" "}
- will be used based on your email. If you don&apos;t have a Gravatar, a letter avatar based on your initials is generated for you.
+ <>
+ <Header />
+ <div id="p-my-settings" className="page container">
+ <Modal.Window isOpen={this.state.showModal} onClose={this.closeModal}>
+ <Modal.Header>
+ <Trans id="modal.changeemail.header">Confirm your new email</Trans>
+ </Modal.Header>
+ <Modal.Content>
+ <div>
+ <p>
+ <Trans id="modal.changeemail.text">
+ We have just sent a confirmation link to <b>{this.state.newEmail}</b>. <br /> Click the link to update your email.
</Trans>
</p>
- )}
- {this.state.avatarType === UserAvatarType.Letter && (
+ <p>
+ <a href="#" onClick={this.closeModal}>
+ <Trans id="action.ok">OK</Trans>
+ </a>
+ </p>
+ </div>
+ </Modal.Content>
+ </Modal.Window>
+
+ <PageTitle
+ title={t({ id: "mysettings.page.title", message: "Settings" })}
+ subtitle={t({ id: "mysettings.page.subtitle", message: "Manage your profile settings" })}
+ />
+
+ <div className="w-max-7xl">
+ <Form error={this.state.error}>
+ <Input
+ label={t({ id: "label.email", message: "Email" })}
+ field="email"
+ value={this.state.changingEmail ? this.state.newEmail : Fider.session.user.email}
+ maxLength={200}
+ disabled={!this.state.changingEmail}
+ afterLabel={this.state.changingEmail ? undefined : changeEmail}
+ onChange={this.setNewEmail}
+ >
<p className="text-muted">
- <Trans id="mysettings.message.avatar.letter">A letter avatar based on your initials is generated for you.</Trans>
+ {Fider.session.user.email || this.state.changingEmail ? (
+ <Trans id="mysettings.message.privateemail">Your email is private and will never be publicly displayed.</Trans>
+ ) : (
+ <Trans id="mysettings.message.noemail">Your account doesn&apos;t have an email.</Trans>
+ )}
</p>
- )}
- {this.state.avatarType === UserAvatarType.Custom && (
- <ImageUploader field="avatar" onChange={this.setAvatar} bkey={Fider.session.user.avatarBlobKey}>
- <p className="text-muted">
- <Trans id="mysettings.message.avatar.custom">
- We accept JPG, GIF and PNG images, smaller than 100KB and with an aspect ratio of 1:1 with minimum dimensions of 50x50 pixels.
+ {this.state.changingEmail && (
+ <>
+ <Button variant="primary" size="small" onClick={this.submitNewEmail}>
+ <Trans id="action.confirm">Confirm</Trans>
+ </Button>
+ <Button variant="tertiary" size="small" onClick={this.cancelChangeEmail}>
+ <Trans id="action.cancel">Cancel</Trans>
+ </Button>
+ </>
+ )}
+ </Input>
+
+ <Input label={t({ id: "label.name", message: "Name" })} field="name" value={this.state.name} maxLength={100} onChange={this.setName} />
+
+ <Select
+ label={t({ id: "label.avatar", message: "Avatar" })}
+ field="avatarType"
+ defaultValue={this.state.avatarType}
+ options={[
+ { label: t({ id: "label.letter", message: "Letter" }), value: UserAvatarType.Letter },
+ { label: t({ id: "label.gravatar", message: "Gravatar" }), value: UserAvatarType.Gravatar },
+ { label: t({ id: "label.custom", message: "Custom" }), value: UserAvatarType.Custom },
+ ]}
+ onChange={this.avatarTypeChanged}
+ >
+ {this.state.avatarType === UserAvatarType.Gravatar && (
+ <p className="text-muted mt-1">
+ <Trans id="mysettings.message.avatar.gravatar">
+ A{" "}
+ <a className="text-link" rel="noopener" href="https://en.gravatar.com" target="_blank">
+ Gravatar
+ </a>{" "}
+ will be used based on your email. If you don&apos;t have a Gravatar, a letter avatar based on your initials is generated for you.
</Trans>
</p>
- </ImageUploader>
- )}
- </Select>
+ )}
+ {this.state.avatarType === UserAvatarType.Letter && (
+ <p className="text-muted">
+ <Trans id="mysettings.message.avatar.letter">A letter avatar based on your initials is generated for you.</Trans>
+ </p>
+ )}
+ {this.state.avatarType === UserAvatarType.Custom && (
+ <ImageUploader field="avatar" onChange={this.setAvatar} bkey={Fider.session.user.avatarBlobKey}>
+ <p className="text-muted">
+ <Trans id="mysettings.message.avatar.custom">
+ We accept JPG, GIF and PNG images, smaller than 100KB and with an aspect ratio of 1:1 with minimum dimensions of 50x50 pixels.
+ </Trans>
+ </p>
+ </ImageUploader>
+ )}
+ </Select>
- <NotificationSettings userSettings={this.props.userSettings} settingsChanged={this.setNotificationSettings} />
+ <NotificationSettings userSettings={this.props.userSettings} settingsChanged={this.setNotificationSettings} />
- <Button variant="primary" onClick={this.confirm}>
- <Trans id="action.save">Save</Trans>
- </Button>
- </Form>
+ <Button variant="primary" onClick={this.confirm}>
+ <Trans id="action.save">Save</Trans>
+ </Button>
+ </Form>
- <div className="mt-8">{Fider.session.user.isCollaborator && <APIKeyForm />}</div>
- <div className="mt-8">
- <DangerZone />
+ <div className="mt-8">{Fider.session.user.isCollaborator && <APIKeyForm />}</div>
+ <div className="mt-8">
+ <DangerZone />
+ </div>
</div>
</div>
- </div>
+ </>
)
}
}
diff --git a/public/pages/ShowPost/ShowPost.page.tsx b/public/pages/ShowPost/ShowPost.page.tsx
index 99ffea4d9..0e0d12a36 100644
--- a/public/pages/ShowPost/ShowPost.page.tsx
+++ b/public/pages/ShowPost/ShowPost.page.tsx
@@ -18,6 +18,7 @@ import {
MultiImageUploader,
ImageViewer,
Icon,
+ Header,
} from "@fider/components"
import { ResponseForm } from "./components/ResponseForm"
import { TagsPanel } from "./components/TagsPanel"
@@ -103,103 +104,106 @@ export default class ShowPostPage extends React.Component<ShowPostPageProps, Sho
public render() {
return (
- <div id="p-show-post" className="page container">
- <VStack className="p-show-post" spacing={4}>
- <div className="p-show-post__header-col">
- <VStack spacing={4}>
- <HStack>
- <VoteCounter post={this.props.post} />
-
- <div className="flex-grow">
+ <>
+ <Header />
+ <div id="p-show-post" className="page container">
+ <VStack className="p-show-post" spacing={4}>
+ <div className="p-show-post__header-col">
+ <VStack spacing={4}>
+ <HStack>
+ <VoteCounter post={this.props.post} />
+
+ <div className="flex-grow">
+ {this.state.editMode ? (
+ <Form error={this.state.error}>
+ <Input field="title" maxLength={100} value={this.state.newTitle} onChange={this.setNewTitle} />
+ </Form>
+ ) : (
+ <h1 className="text-display2">{this.props.post.title}</h1>
+ )}
+
+ <span className="text-muted">
+ <Trans id="showpost.label.author">
+ Posted by <UserName user={this.props.post.user} /> &middot; <Moment locale={Fider.currentLocale} date={this.props.post.createdAt} />
+ </Trans>
+ </span>
+ </div>
+ </HStack>
+ <VStack>
+ <span className="text-category">
+ <Trans id="label.description">Description</Trans>
+ </span>
{this.state.editMode ? (
<Form error={this.state.error}>
- <Input field="title" maxLength={100} value={this.state.newTitle} onChange={this.setNewTitle} />
+ <TextArea field="description" value={this.state.newDescription} onChange={this.setNewDescription} />
+ <MultiImageUploader field="attachments" bkeys={this.props.attachments} maxUploads={3} onChange={this.setAttachments} />
</Form>
) : (
- <h1 className="text-display2">{this.props.post.title}</h1>
+ <>
+ {this.props.post.description && <Markdown className="description" text={this.props.post.description} style="full" />}
+ {!this.props.post.description && (
+ <em className="text-muted">
+ <Trans id="showpost.message.nodescription">No description provided.</Trans>
+ </em>
+ )}
+ {this.props.attachments.map((x) => (
+ <ImageViewer key={x} bkey={x} />
+ ))}
+ </>
)}
+ </VStack>
+ <ShowPostResponse status={this.props.post.status} response={this.props.post.response} />
+ </VStack>
+ </div>
- <span className="text-muted">
- <Trans id="showpost.label.author">
- Posted by <UserName user={this.props.post.user} /> &middot; <Moment locale={Fider.currentLocale} date={this.props.post.createdAt} />
- </Trans>
+ <VStack spacing={4} className="p-show-post__action-col">
+ <VotesPanel post={this.props.post} votes={this.props.votes} />
+
+ {Fider.session.isAuthenticated && canEditPost(Fider.session.user, this.props.post) && (
+ <VStack>
+ <span key={0} className="text-category">
+ <Trans id="label.actions">Actions</Trans>
</span>
- </div>
- </HStack>
- <VStack>
- <span className="text-category">
- <Trans id="label.description">Description</Trans>
- </span>
- {this.state.editMode ? (
- <Form error={this.state.error}>
- <TextArea field="description" value={this.state.newDescription} onChange={this.setNewDescription} />
- <MultiImageUploader field="attachments" bkeys={this.props.attachments} maxUploads={3} onChange={this.setAttachments} />
- </Form>
- ) : (
- <>
- {this.props.post.description && <Markdown className="description" text={this.props.post.description} style="full" />}
- {!this.props.post.description && (
- <em className="text-muted">
- <Trans id="showpost.message.nodescription">No description provided.</Trans>
- </em>
- )}
- {this.props.attachments.map((x) => (
- <ImageViewer key={x} bkey={x} />
- ))}
- </>
- )}
- </VStack>
- <ShowPostResponse status={this.props.post.status} response={this.props.post.response} />
+ {this.state.editMode ? (
+ <VStack>
+ <Button variant="primary" onClick={this.saveChanges} disabled={Fider.isReadOnly}>
+ <Icon sprite={IconCheck} />{" "}
+ <span>
+ <Trans id="action.save">Save</Trans>
+ </span>
+ </Button>
+ <Button onClick={this.cancelEdit} disabled={Fider.isReadOnly}>
+ <Icon sprite={IconX} />
+ <span>
+ <Trans id="action.cancel">Cancel</Trans>
+ </span>
+ </Button>
+ </VStack>
+ ) : (
+ <VStack>
+ <Button onClick={this.startEdit} disabled={Fider.isReadOnly}>
+ <Icon sprite={IconPencilAlt} />
+ <span>
+ <Trans id="action.edit">Edit</Trans>
+ </span>
+ </Button>
+ {Fider.session.user.isCollaborator && <ResponseForm post={this.props.post} />}
+ </VStack>
+ )}
+ </VStack>
+ )}
+
+ <TagsPanel post={this.props.post} tags={this.props.tags} />
+ <NotificationsPanel post={this.props.post} subscribed={this.props.subscribed} />
+ <ModerationPanel post={this.props.post} />
</VStack>
- </div>
-
- <VStack spacing={4} className="p-show-post__action-col">
- <VotesPanel post={this.props.post} votes={this.props.votes} />
-
- {Fider.session.isAuthenticated && canEditPost(Fider.session.user, this.props.post) && (
- <VStack>
- <span key={0} className="text-category">
- <Trans id="label.actions">Actions</Trans>
- </span>
- {this.state.editMode ? (
- <VStack>
- <Button variant="primary" onClick={this.saveChanges} disabled={Fider.isReadOnly}>
- <Icon sprite={IconCheck} />{" "}
- <span>
- <Trans id="action.save">Save</Trans>
- </span>
- </Button>
- <Button onClick={this.cancelEdit} disabled={Fider.isReadOnly}>
- <Icon sprite={IconX} />
- <span>
- <Trans id="action.cancel">Cancel</Trans>
- </span>
- </Button>
- </VStack>
- ) : (
- <VStack>
- <Button onClick={this.startEdit} disabled={Fider.isReadOnly}>
- <Icon sprite={IconPencilAlt} />
- <span>
- <Trans id="action.edit">Edit</Trans>
- </span>
- </Button>
- {Fider.session.user.isCollaborator && <ResponseForm post={this.props.post} />}
- </VStack>
- )}
- </VStack>
- )}
- <TagsPanel post={this.props.post} tags={this.props.tags} />
- <NotificationsPanel post={this.props.post} subscribed={this.props.subscribed} />
- <ModerationPanel post={this.props.post} />
+ <div className="p-show-post__discussion_col">
+ <DiscussionPanel post={this.props.post} comments={this.props.comments} />
+ </div>
</VStack>
-
- <div className="p-show-post__discussion_col">
- <DiscussionPanel post={this.props.post} comments={this.props.comments} />
- </div>
- </VStack>
- </div>
+ </div>
+ </>
)
}
}
diff --git a/public/router.spec.tsx b/public/router.spec.tsx
deleted file mode 100644
index ebd00ac8c..000000000
--- a/public/router.spec.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { resolveRootComponent } from "./router"
-import * as Pages from "@fider/AsyncPages"
-;[
- { path: "", expected: Pages.AsyncHomePage },
- { path: "/posts/123", expected: Pages.AsyncShowPostPage },
- { path: "/posts/123/the-slug", expected: Pages.AsyncShowPostPage },
- { path: "/posts" },
- { path: "/admin", expected: Pages.AsyncGeneralSettingsPage },
- { path: "/admin/invitations", expected: Pages.AsyncInvitationsPage },
- { path: "/oauth/_name/echo", expected: Pages.AsyncOAuthEchoPage },
-].forEach((x) => {
- test(`Router should resolve correct component for path '${x.path}'`, () => {
- if (x.expected) {
- const page = resolveRootComponent(x.path)
- expect(page.component).toEqual(x.expected)
- } else {
- expect(() => resolveRootComponent(x.path)).toThrowError()
- }
- })
-})
diff --git a/public/router.tsx b/public/router.tsx
deleted file mode 100644
index ce35763c9..000000000
--- a/public/router.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import * as Pages from "@fider/AsyncPages"
-
-interface PageConfiguration {
- regex: RegExp
- component: any
- showHeader: boolean
-}
-
-export const route = (path: string, component: any, showHeader = true): PageConfiguration => {
- path = path.replace("/", "/").replace(":number", "\\d+").replace(":string", ".+").replace("*", "/?.*")
-
- const regex = new RegExp(`^${path}$`)
- return { regex, component, showHeader }
-}
-
-const defaultRoutes = [
- route("", Pages.AsyncHomePage),
- route("/posts/:number*", Pages.AsyncShowPostPage),
- route("/admin/members", Pages.AsyncManageMembersPage),
- route("/admin/tags", Pages.AsyncManageTagsPage),
- route("/admin/privacy", Pages.AsyncPrivacySettingsPage),
- route("/admin/export", Pages.AsyncExportPage),
- route("/admin/invitations", Pages.AsyncInvitationsPage),
- route("/admin/authentication", Pages.AsyncManageAuthenticationPage),
- route("/admin/advanced", Pages.AsyncAdvancedSettingsPage),
- route("/admin/billing", Pages.AsyncManageBillingPage),
- route("/admin/webhooks", Pages.AsyncManageWebhooksPage),
- route("/admin", Pages.AsyncGeneralSettingsPage),
- route("/terms", Pages.AsyncLegalPage, false),
- route("/privacy", Pages.AsyncLegalPage, false),
- route("/signin", Pages.AsyncSignInPage, false),
- route("/signup", Pages.AsyncSignUpPage, false),
- route("/signin/verify", Pages.AsyncCompleteSignInProfilePage),
- route("/invite/verify", Pages.AsyncCompleteSignInProfilePage),
- route("/notifications", Pages.AsyncMyNotificationsPage),
- route("/settings", Pages.AsyncMySettingsPage),
- route("/oauth/:string/echo", Pages.AsyncOAuthEchoPage, false),
- route("/_design", Pages.AsyncDesignSystemPage),
-]
-
-export const resolveRootComponent = (path: string, routes: PageConfiguration[] = defaultRoutes): PageConfiguration => {
- if (path.length > 0 && path.charAt(path.length - 1) === "/") {
- path = path.substring(0, path.length - 1)
- }
- for (const entry of routes) {
- if (entry && entry.regex.test(path)) {
- return entry
- }
- }
- throw new Error(`Component not found for route ${path}.`)
-}
diff --git a/public/services/fider.ts b/public/services/fider.ts
index 315e5dd9a..5db8cd1b6 100644
--- a/public/services/fider.ts
+++ b/public/services/fider.ts
@@ -2,18 +2,24 @@ import { createContext } from "react"
import { CurrentUser, SystemSettings, Tenant, TenantStatus } from "@fider/models"
export class FiderSession {
+ private pPage: string
private pContextID: string
private pTenant: Tenant
private pUser: CurrentUser | undefined
private pProps: { [key: string]: any } = {}
constructor(data: any) {
+ this.pPage = data.page
this.pContextID = data.contextID
this.pProps = data.props
this.pUser = data.user
this.pTenant = data.tenant
}
+ public get page(): string {
+ return this.pPage
+ }
+
public get contextID(): string {
return this.pContextID
}
diff --git a/public/ssr.tsx b/public/ssr.tsx
index 674620151..7fa91ed39 100644
--- a/public/ssr.tsx
+++ b/public/ssr.tsx
@@ -1,15 +1,8 @@
+/* eslint-disable @typescript-eslint/no-var-requires */
import React from "react"
import { renderToStaticMarkup } from "react-dom/server"
import { Fider, FiderContext } from "./services/fider"
-import { DevBanner, Header, ReadOnlyNotice } from "./components"
-import { resolveRootComponent, route } from "./router"
-
-import HomePage from "./pages/Home/Home.page"
-import ShowPostPage from "./pages/ShowPost/ShowPost.page"
-import SignInPage from "./pages/SignIn/SignIn.page"
-import SignUpPage from "./pages/SignUp/SignUp.page"
-import DesignSystemPage from "./pages/DesignSystem/DesignSystem.page"
-import LegalPage from "./pages/Legal/Legal.page"
+import { DevBanner, ReadOnlyNotice } from "./components"
import { activateI18NSync } from "./services"
import { I18nProvider } from "@lingui/react"
@@ -26,31 +19,33 @@ const messages: { [key: string]: any } = {
sk: require(`../locale/sk/client`),
}
-// Only public routes should be here
-// Routes behind authentication are not crawled
-const routes = [
- route("", HomePage),
- route("/posts/:number*", ShowPostPage),
- route("/signin", SignInPage, false),
- route("/signup", SignUpPage, false),
- route("/terms", LegalPage, false),
- route("/privacy", LegalPage, false),
- route("/_design", DesignSystemPage),
-]
+// ESBuild doesn't support Dynamic Imports, so we need to map them statically
+// But at least only public routes will be here, as routes behind authentication won't be crawled anyway
+const pages: { [key: string]: any } = {
+ "Home/Home.page": require(`./pages/Home/Home.page`),
+ "ShowPost/ShowPost.page": require(`./pages/ShowPost/ShowPost.page`),
+ "SignIn/SignIn.page": require(`./pages/SignIn/SignIn.page`),
+ "SignUp/SignUp.page": require(`./pages/SignUp/SignUp.page`),
+ "Legal/Legal.page": require(`./pages/Legal/Legal.page`),
+ "DesignSystem/DesignSystem.page": require(`./pages/DesignSystem/DesignSystem.page`),
+}
-function ssrRender(url: string, pathname: string, args: any) {
+function ssrRender(url: string, args: any) {
const fider = Fider.initialize({ ...args })
const i18n = activateI18NSync(fider.currentLocale, messages[fider.currentLocale].messages)
- const config = resolveRootComponent(pathname, routes)
+ const component = pages[fider.session.page]?.default
+ if (!component) {
+ throw new Error(`Page not found: ${fider.session.page}`)
+ }
+
window.location.href = url
return renderToStaticMarkup(
<I18nProvider i18n={i18n}>
<FiderContext.Provider value={fider}>
<DevBanner />
- {config.showHeader && <Header />}
<ReadOnlyNotice />
- {React.createElement(config.component, args.props)}
+ {React.createElement(component, args.props)}
</FiderContext.Provider>
</I18nProvider>
)