Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM node:18-alpine3.18 as ui-builder
RUN apk add --no-cache make
WORKDIR /app

COPY ui ./ui
COPY web/apps/admin-ui ./web/apps/admin-ui
COPY Makefile .
RUN make ui

Expand All @@ -16,7 +16,7 @@ COPY go.mod go.sum ./
RUN go mod download

COPY . .
COPY --from=ui-builder /app/ui/dist /app/ui/dist
COPY --from=ui-builder /app/web/apps/admin-ui/dist /app/web/apps/admin-ui/dist

RUN make build

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PROTON_COMMIT := "4144445eb0f9cbd1a801a3d0aa5cfce4cc0ea551"

ui:
@echo " > generating ui build"
@cd ui && $(MAKE) build
@cd web/apps/admin-ui && $(MAKE) build

install:
@echo "Clean up imports..."
Expand All @@ -31,7 +31,7 @@ lint-fix:
golangci-lint run --fix

test: ## Run tests
@go test -race $(shell go list ./... | grep -v /ui | grep -v /vendor/ | grep -v /test/ | grep -v /mocks | grep -v postgres/migrations | grep -v /proto) -coverprofile=coverage.out -count 2 -timeout 150s
@go test -race $(shell go list ./... | grep -v /web/apps/admin-ui | grep -v /vendor/ | grep -v /test/ | grep -v /mocks | grep -v postgres/migrations | grep -v /proto) -coverprofile=coverage.out -count 2 -timeout 150s

test-all: lint test e2e-test ## Run all tests

Expand All @@ -52,7 +52,7 @@ coverage: ## print code coverage
go test -race -coverprofile coverage.out -covermode=atomic ./... -tags=unit_test && go tool cover -html=coverage.out

clean :
rm -rf ui/dist/ui
rm -rf web/apps/admin-ui/dist/admin-ui

proto: ## Generate the protobuf files
@echo " > generating protobuf from raystack/proton"
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

"github.com/raystack/frontier/pkg/server/consts"
"github.com/raystack/frontier/pkg/server/health"
"github.com/raystack/frontier/ui"
"github.com/raystack/frontier/web/apps/admin-ui"

connectinterceptors "github.com/raystack/frontier/pkg/server/connect_interceptors"
"github.com/raystack/frontier/pkg/server/interceptors"
Expand Down Expand Up @@ -93,7 +93,7 @@ func ServeUI(ctx context.Context, logger log.Logger, uiConfig UIConfig, apiServe
return
}

spaHandler, err := spa.Handler(ui.Assets, "dist/ui", "index.html", false)
spaHandler, err := spa.Handler(adminui.Assets, "dist/admin-ui", "index.html", false)
if err != nil {
logger.Warn("failed to load ui", "err", err)
return
Expand Down
12 changes: 0 additions & 12 deletions ui/Makefile

This file was deleted.

Empty file removed ui/dist/.gitkeep
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions web/apps/admin-ui/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.PHONY: dist test

build: dep dist

dist:
@pnpm run build

test:
@pnpm run test

dep:
@pnpm install
File renamed without changes.
2 changes: 1 addition & 1 deletion ui/embed.go → web/apps/admin-ui/embed.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ui
package adminui

import (
"embed"
)

//go:embed all:dist

Check failure on line 7 in web/apps/admin-ui/embed.go

View workflow job for this annotation

GitHub Actions / smoke

pattern all:dist: no matching files found

Check failure on line 7 in web/apps/admin-ui/embed.go

View workflow job for this annotation

GitHub Actions / golangci

pattern all:dist: no matching files found (typecheck)

Check failure on line 7 in web/apps/admin-ui/embed.go

View workflow job for this annotation

GitHub Actions / regression

pattern all:dist: no matching files found

Check failure on line 7 in web/apps/admin-ui/embed.go

View workflow job for this annotation

GitHub Actions / unit

pattern all:dist: no matching files found

Check failure on line 7 in web/apps/admin-ui/embed.go

View workflow job for this annotation

GitHub Actions / unit

pattern all:dist: no matching files found
var Assets embed.FS
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ui/vite.config.ts → web/apps/admin-ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig(() => {
return {
base: "/",
build: {
outDir: "dist/ui",
outDir: "dist/admin-ui",
},
server: {
proxy: {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions web/packages/core/admin/components/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useEffect } from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dummy file just to test the new Admin folder. This will contain the exportable frontier admin files coming from ui folder.

import type { AdminConfig } from '../types';

export function AdminPageTitle({
title,
appName,
config
}: {
title?: string;
appName?: string;
config?: AdminConfig;
}) {
const titleAppName = appName || config?.title || 'Frontier Admin';
const fullTitle = title ? `${title} | ${titleAppName}` : titleAppName;

useEffect(() => {
document.title = fullTitle;
return () => {
document.title = titleAppName;
};
}, [fullTitle, titleAppName]);

return null;
}

6 changes: 6 additions & 0 deletions web/packages/core/admin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '@raystack/apsara/style.css';

export type { AdminConfig, AdminLoginProps } from './types';
export { AdminPageTitle } from './components/PageTitle';
export { AdminLogin } from './pages/auth/Login';

48 changes: 48 additions & 0 deletions web/packages/core/admin/pages/auth/Login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"use client";

import { Box, Flex, Image } from '@raystack/apsara';
import { Header } from '../../../react/components/Header';
import { MagicLink } from '../../../react/components/onboarding/magiclink';
import { AdminPageTitle } from '../../components/PageTitle';
import type { AdminLoginProps } from '../../types';

export function AdminLogin({ config, logoIcon }: AdminLoginProps) {
return (
<Flex>
<AdminPageTitle title="Login" config={config} />
<Box style={{ width: '100%' }}>
<Flex
direction="column"
justify="center"
align="center"
style={{
margin: 'auto',
height: '100vh',
width: '280px'
}}
>
<Flex direction="column" gap={5} style={{ width: '100%' }}>
<Header
logo={
config?.logo ? (
<Image
alt="logo"
src={config.logo}
width={80}
height={80}
style={{ borderRadius: 'var(--rs-space-3)' }}
/>
) : (
logoIcon
)
}
title={`Login to ${config?.title || 'Frontier Admin'}`}
/>
<MagicLink open />
</Flex>
</Flex>
</Box>
</Flex>
);
}

12 changes: 12 additions & 0 deletions web/packages/core/admin/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type React from 'react';

export type AdminConfig = {
title?: string;
logo?: string;
};

export type AdminLoginProps = {
config?: AdminConfig;
logoIcon?: React.ReactNode;
};

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"files": [
"dist/**/*",
"react/dist/**/*",
"admin/dist/**/*",
"hooks/dist/**/*",
"README.md"
],
Expand Down Expand Up @@ -50,6 +51,12 @@
"module": "./react/dist/index.mjs",
"require": "./react/dist/index.js"
},
"./admin": {
"types": "./admin/dist/index.d.ts",
"import": "./admin/dist/index.mjs",
"module": "./admin/dist/index.mjs",
"require": "./admin/dist/index.js"
},
"./hooks": {
"types": "./hooks/dist/index.d.ts",
"import": "./hooks/dist/index.mjs",
Expand Down
Loading
Loading