From 4ea33a29a8f8978ad9e413f22f4fcc791a2ff0c1 Mon Sep 17 00:00:00 2001 From: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com> Date: Tue, 2 Jul 2024 07:21:04 +1200 Subject: [PATCH] refactor(ui): blank page content when no organizations are available (#41) * refactor(ui): blank page content when no organizations are available * ci: simply the ci process --- .github/workflows/pr.yml | 41 ++++-------------------- src/routers/app/ui/components/button.tsx | 9 ++++-- src/routers/app/ui/index.tsx | 6 ++-- src/routers/app/ui/pages/app.index.tsx | 9 ++++-- 4 files changed, 22 insertions(+), 43 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 55b93bc..32b42d4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -7,42 +7,9 @@ on: branches: [master] jobs: - test: - name: test + pr-check: + name: pr-check runs-on: ubuntu-latest - steps: - # This step uses the actions/checkout action to download a copy of your repository on the runner. - - name: Checkout repo - uses: actions/checkout@v4 - - # This step uses the pnpm/action-setup action to set up pnpm on the runner. - - name: Install pnpm - uses: pnpm/action-setup@v3 - with: - version: 9 - - # This step uses the actions/setup-node action to set up a Node.js environment on the runner. - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: pnpm - - # This step runs the install script for the selected node package manager. - - name: Install dependencies - run: pnpm install - - # This step runs the test script if there is one specified under the scripts key in your package.json file. - - name: Test - run: pnpm test:ci - - build: - name: build - needs: [test] - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20] steps: # This step uses the actions/checkout action to download a copy of your repository on the runner. - name: Checkout repo @@ -68,3 +35,7 @@ jobs: # This step runs the build script if there is one specified under the scripts key in your package.json file. - name: Build run: pnpm build + + # This step runs the test script if there is one specified under the scripts key in your package.json file. + - name: Test + run: pnpm test:ci diff --git a/src/routers/app/ui/components/button.tsx b/src/routers/app/ui/components/button.tsx index ea6677d..5dd6ab2 100644 --- a/src/routers/app/ui/components/button.tsx +++ b/src/routers/app/ui/components/button.tsx @@ -1,4 +1,4 @@ -import type { PropsWithChildren } from "hono/jsx"; +import type { JSX, PropsWithChildren } from "hono/jsx"; const buttonStyles = { primary: @@ -21,10 +21,13 @@ export function Button({ children, variant = "primary", size = "md", + class: className, ...props -}: PropsWithChildren<{ variant?: keyof typeof buttonStyles; size?: keyof typeof buttonSize }>) { +}: PropsWithChildren< + { variant?: keyof typeof buttonStyles; size?: keyof typeof buttonSize } & JSX.IntrinsicElements["button"] +>) { return ( - ); diff --git a/src/routers/app/ui/index.tsx b/src/routers/app/ui/index.tsx index 9b81b2e..0d0d9c0 100644 --- a/src/routers/app/ui/index.tsx +++ b/src/routers/app/ui/index.tsx @@ -2,7 +2,7 @@ import { Hono } from "hono"; import { db } from "@/config/db/index.mjs"; -import { DashboardLandingPage } from "./pages/app.index.js"; +import { NoOrganizationPage } from "./pages/app.index.js"; import { LoginPage } from "./pages/app.login.js"; import { WorkspaceLandingPage } from "./pages/app.$workspace.index.js"; import { WorkspaceEditPage } from "./pages/app.$workspace.edit.js"; @@ -26,12 +26,12 @@ app.get("/", checkUserAuthed, async (c) => { const tenants = relationships.map((r) => r.tenant); - if (tenants.length === 1 && view_all !== "true") { + if (tenants.length >= 1 && view_all !== "true") { const tenant = tenants[0]; return c.redirect(`/app/${tenant.workspace}`); } - return c.html(); + return c.html(); }); app.get("/login", async (c) => { diff --git a/src/routers/app/ui/pages/app.index.tsx b/src/routers/app/ui/pages/app.index.tsx index a0c2592..65fac50 100644 --- a/src/routers/app/ui/pages/app.index.tsx +++ b/src/routers/app/ui/pages/app.index.tsx @@ -2,12 +2,17 @@ import type { FC } from "hono/jsx"; import { RootDocument } from "../layouts/root-document.js"; import { AppContainer, type AppContainerProps } from "../layouts/app-container.js"; +import { Button } from "../components/button.js"; -export const DashboardLandingPage: FC<{} & Omit> = ({ user, tenants }) => { +export const NoOrganizationPage: FC<{} & Omit> = ({ user, tenants }) => { return ( -

There is no content on this page

+
+

You are not a part of any active organizations.

+

Create your own organization!.

+ +
);