Moved navigation to the left-side panel.
This commit is contained in:
parent
eafde27809
commit
0239f46247
6 changed files with 59 additions and 20 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"goweb/context"
|
||||
"goweb/ent"
|
||||
"goweb/htmx"
|
||||
"goweb/msg"
|
||||
|
||||
|
|
@ -68,6 +69,9 @@ type Page struct {
|
|||
// IsAuth stores whether or not the user is authenticated
|
||||
IsAuth bool
|
||||
|
||||
// AuthUser stores the authenticated user
|
||||
AuthUser *ent.User
|
||||
|
||||
// StatusCode stores the HTTP status code that will be returned
|
||||
StatusCode int
|
||||
|
||||
|
|
@ -137,6 +141,7 @@ func NewPage(ctx echo.Context) Page {
|
|||
|
||||
if u := ctx.Get(context.AuthenticatedUserKey); u != nil {
|
||||
p.IsAuth = true
|
||||
p.AuthUser = u.(*ent.User)
|
||||
}
|
||||
|
||||
p.HTMX.Request = htmx.GetRequest(ctx)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
echomw "github.com/labstack/echo/v4/middleware"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewPage(t *testing.T) {
|
||||
|
|
@ -29,13 +30,16 @@ func TestNewPage(t *testing.T) {
|
|||
assert.False(t, p.Cache.Enabled)
|
||||
|
||||
ctx, _ = tests.NewContext(c.Web, "/abc?def=123")
|
||||
ctx.Set(context.AuthenticatedUserKey, 1)
|
||||
usr, err := tests.CreateUser(c.ORM)
|
||||
require.NoError(t, err)
|
||||
ctx.Set(context.AuthenticatedUserKey, usr)
|
||||
ctx.Set(echomw.DefaultCSRFConfig.ContextKey, "csrf")
|
||||
p = NewPage(ctx)
|
||||
assert.Equal(t, "/abc", p.Path)
|
||||
assert.Equal(t, "/abc?def=123", p.URL)
|
||||
assert.False(t, p.IsHome)
|
||||
assert.True(t, p.IsAuth)
|
||||
assert.Equal(t, usr, p.AuthUser)
|
||||
assert.Equal(t, "csrf", p.CSRF)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue