Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: DIA-1794: [FE] Implement home page in LSO and LSE #6885

Merged
merged 143 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
86cc448
Adding tailwind (wip)
nick-skriabin Dec 6, 2024
b3ed266
Merge branch 'develop' into tailwind
nick-skriabin Dec 6, 2024
d220c4e
Adding Tailwind and shadcn UI
nick-skriabin Dec 12, 2024
4aa7085
Fix global styles
nick-skriabin Dec 12, 2024
a3ec3d6
setting up storybook
nick-skriabin Dec 27, 2024
f84e442
Merge branch 'develop' into tailwind
nick-skriabin Jan 7, 2025
93cb876
Move Tailwind config to UI lib
nick-skriabin Jan 7, 2025
6318bf6
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 7, 2025
0a03083
Tailwind and shadcn cross-repo setup
nick-skriabin Jan 8, 2025
9e063ea
Remove testing code
nick-skriabin Jan 8, 2025
2afc869
Rollback unnecessary changes
nick-skriabin Jan 8, 2025
3572a74
Remove dist changes
nick-skriabin Jan 8, 2025
0707aaf
Fix logo size
nick-skriabin Jan 8, 2025
2fdee5f
Ad root page
nick-skriabin Jan 8, 2025
541336d
Page layout, icons, styles
nick-skriabin Jan 9, 2025
c36d263
Create project
nick-skriabin Jan 9, 2025
606568d
Properly set up shadcn components installation, remove dist changes
nick-skriabin Jan 9, 2025
88190aa
Restore dist to develop state
nick-skriabin Jan 9, 2025
c705d0c
Remove dist changes
nick-skriabin Jan 9, 2025
d27fa52
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 9, 2025
6a5764f
Invite link
nick-skriabin Jan 9, 2025
9ffd009
Remove excess files
nick-skriabin Jan 9, 2025
8dca930
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 9, 2025
01ad5c8
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 9, 2025
ada01ba
More components
nick-skriabin Jan 10, 2025
e232d9d
Add folder icon
nick-skriabin Jan 10, 2025
326b498
Home page + new components
nick-skriabin Jan 13, 2025
c943cca
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 13, 2025
c9204a3
Update web/apps/labelstudio/src/pages/Settings/GeneralSettings.jsx
nick-skriabin Jan 13, 2025
3d385c4
Add folder icon
nick-skriabin Jan 13, 2025
92d627f
Remove and ignore dist
nick-skriabin Jan 13, 2025
fc943a4
Ignore dist
nick-skriabin Jan 13, 2025
3eb160f
fix icon
nick-skriabin Jan 13, 2025
30bff00
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 13, 2025
fcf9963
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 13, 2025
8ea21b4
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 13, 2025
233ec7a
Fix wave
nick-skriabin Jan 14, 2025
b599398
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 14, 2025
33a6e93
Remove excess code
nick-skriabin Jan 14, 2025
df8ba6e
Restore dist (to many changes)
nick-skriabin Jan 14, 2025
6ad56a3
Setup correct redirect after certain user actions
nick-skriabin Jan 14, 2025
5f148f6
Fix small issues
nick-skriabin Jan 15, 2025
a02f66b
Add collectstatic make action
nick-skriabin Jan 16, 2025
7c24fb4
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 16, 2025
1bea08b
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 17, 2025
9d5e25b
Update web/apps/labelstudio/src/components/Menubar/Menubar.jsx
nick-skriabin Jan 17, 2025
07a9bc7
Remove unnecessary files
nick-skriabin Jan 17, 2025
19b9df3
Keeping one location for stories (libs/storybook)
nick-skriabin Jan 17, 2025
87e49c2
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 17, 2025
eb54285
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 20, 2025
4e8fb29
Dist
nick-skriabin Jan 20, 2025
957e89a
Dist
nick-skriabin Jan 20, 2025
3e5f3ef
Add UI icons
nick-skriabin Jan 20, 2025
8b38fa5
Self-close
nick-skriabin Jan 20, 2025
60bff6b
Format file
nick-skriabin Jan 20, 2025
21c2a6c
Ignore shadcn components
nick-skriabin Jan 20, 2025
43f9365
Fix biome + stylelint
nick-skriabin Jan 20, 2025
e3813d8
Update stylelint and biome
nick-skriabin Jan 20, 2025
dc0360e
Allow unknown functions
nick-skriabin Jan 20, 2025
94ac7ae
Remove excess code
nick-skriabin Jan 20, 2025
16e3146
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 20, 2025
2e791a8
Feature flag
nick-skriabin Jan 20, 2025
451e1ea
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 22, 2025
b0d86e4
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 22, 2025
9f34cc7
Rollback unnecessary changes
nick-skriabin Jan 22, 2025
a07ab67
storybook
nick-skriabin Jan 22, 2025
2d045c5
Jest configs to address module import issues (WIP)
nick-skriabin Jan 22, 2025
f5de72f
Storybook setup
nick-skriabin Jan 22, 2025
3713d9c
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 23, 2025
8b90b71
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 23, 2025
dd5072a
Fix jest tests
nick-skriabin Jan 23, 2025
f4bc82e
Fix formatting
nick-skriabin Jan 23, 2025
6069474
Fix formatting for Blue
nick-skriabin Jan 23, 2025
b67c273
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 23, 2025
a1db901
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 23, 2025
5e4ba64
Remove traces
nick-skriabin Jan 23, 2025
6de0538
Fix formatting (blue)
nick-skriabin Jan 23, 2025
b41dec7
Fix formatting
nick-skriabin Jan 23, 2025
6a4a8a5
Fix formatting
nick-skriabin Jan 23, 2025
be6debb
Add docs references
nick-skriabin Jan 23, 2025
23d5e86
Upgrade to Tailwind 4
nick-skriabin Jan 23, 2025
a14a254
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 23, 2025
1cf3c55
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 23, 2025
49005bc
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 24, 2025
7ee5a92
Remove unused
nick-skriabin Jan 24, 2025
feeacbd
Use better naming
nick-skriabin Jan 24, 2025
bd7c6a1
Update web/apps/labelstudio/src/pages/Home/HomePage.tsx
nick-skriabin Jan 24, 2025
873a346
Use shared heading, add comment for invite link refetch
nick-skriabin Jan 24, 2025
2d396f4
Copy text
nick-skriabin Jan 24, 2025
86230f1
Remove unused
nick-skriabin Jan 24, 2025
56f41c0
Encode params into the query key
nick-skriabin Jan 24, 2025
317a5ab
Fix typo
nick-skriabin Jan 24, 2025
7d08b38
Consistent component naming
nick-skriabin Jan 24, 2025
b295608
Merge remote-tracking branch 'origin/develop' into fb-dia-1794/home-page
bmartel Jan 24, 2025
6ac248c
tailwind config must exist at the root of web to be part of assumed p…
bmartel Jan 24, 2025
1dbcf25
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 24, 2025
8a86566
Fix routing
nick-skriabin Jan 24, 2025
786edf7
Merge branch 'develop' into 'fb-dia-1794/home-page'
MihajloHoma Jan 27, 2025
7991e55
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 27, 2025
c157795
Fix blue issue
nick-skriabin Jan 27, 2025
8559727
Fix lint
nick-skriabin Jan 27, 2025
1b19c49
Files lowercase
nick-skriabin Jan 27, 2025
6898ea7
Fix casing
nick-skriabin Jan 27, 2025
9d2fdd8
Rename hack
nick-skriabin Jan 27, 2025
cad6eaa
Rename hack 2
nick-skriabin Jan 27, 2025
147b70f
Styled progress
nick-skriabin Jan 27, 2025
d97296f
Fix UI regressions
nick-skriabin Jan 27, 2025
9bd1db0
remove the development override for home page FF
bmartel Jan 27, 2025
209ee27
Move styles to css file
nick-skriabin Jan 27, 2025
2c58ae5
Remove postfix
nick-skriabin Jan 27, 2025
0591c02
Fix "Browse Templates"
nick-skriabin Jan 27, 2025
2060b16
Merge branch 'develop' into 'fb-1783/follow-up'
borisheartex Jan 28, 2025
22097dc
Merge branch 'develop' into 'fb-dia-1794/home-page'
MihajloHoma Jan 28, 2025
1251697
Fix dot
nick-skriabin Jan 28, 2025
cbfa379
Merge branch 'develop' into fb-1783/follow-up
nick-skriabin Jan 28, 2025
a2f146d
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 28, 2025
50e80a0
Fix footers
nick-skriabin Jan 28, 2025
0a50ee5
Fix heading tags font size
nick-skriabin Jan 28, 2025
2535f04
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 28, 2025
ecf39bb
Merge branch 'fb-1783/follow-up' into fb-dia-1783/tailwind
nick-skriabin Jan 28, 2025
d9b990d
Merge branch 'develop' into fb-1783/follow-up
nick-skriabin Jan 28, 2025
8c31840
Merge branch 'fb-1783/follow-up' into fb-dia-1783/tailwind
nick-skriabin Jan 28, 2025
b49dddf
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 28, 2025
8184f9d
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 28, 2025
b267fde
Fix info icon in templates
nick-skriabin Jan 28, 2025
955138e
Fix select border
nick-skriabin Jan 28, 2025
64523b1
Fix button
nick-skriabin Jan 28, 2025
981397e
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 29, 2025
d248814
feat: DIA-1783: [FE] Prep work - Tailwind + shadcn cross integration …
nick-skriabin Jan 23, 2025
89bd8b6
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 29, 2025
74f29bd
Fix visuals
nick-skriabin Jan 29, 2025
19f4d9e
Fix breadcrumbs
nick-skriabin Jan 29, 2025
e9b1098
Fix UI inconsistencies
nick-skriabin Jan 30, 2025
b967ebf
Fix security vulnerabilities
nick-skriabin Jan 30, 2025
d3a760f
Update lock file
nick-skriabin Jan 30, 2025
d0b617c
Update lock file
nick-skriabin Jan 30, 2025
dfcb71f
Merge branch 'develop' into fb-dia-1783/tailwind
nick-skriabin Jan 30, 2025
14830b2
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 30, 2025
b80f650
fix ws resolution
bmartel Jan 30, 2025
a26c8c4
fix ajv resolution
bmartel Jan 30, 2025
b76efc2
Merge branch 'fb-dia-1783/tailwind' into fb-dia-1794/home-page
nick-skriabin Jan 30, 2025
1c3c00a
Rollback ajv
nick-skriabin Jan 30, 2025
5202bfd
Merge branch 'develop' into fb-dia-1794/home-page
nick-skriabin Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile.development
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1
ARG NODE_VERSION=18
ARG PYTHON_VERSION=3.12
ARG POETRY_VERSION=1.8.4
ARG POETRY_VERSION=2.0.1
ARG VERSION_OVERRIDE
ARG BRANCH_OVERRIDE

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ docker-run-dev:
docker-migrate-dev:
docker compose run app python3 /label-studio/label_studio/manage.py migrate

docker-collectstatic-dev:
docker compose run app python3 /label-studio/label_studio/manage.py collectstatic

# Install modules
frontend-install:
cd web && yarn install --frozen-lockfile;
Expand Down
3 changes: 3 additions & 0 deletions label_studio/core/templates/home/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% extends 'base.html' %}
{% load i18n %}
{% load static %}
9 changes: 6 additions & 3 deletions label_studio/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pandas as pd
import requests
from core import utils
from core.feature_flags import all_flags, get_feature_file_path
from core.feature_flags import all_flags, flag_set, get_feature_file_path
from core.label_config import generate_time_series_json
from core.utils.common import collect_versions
from core.utils.io import find_file
Expand All @@ -27,7 +27,7 @@
HttpResponseServerError,
JsonResponse,
)
from django.shortcuts import redirect, reverse
from django.shortcuts import redirect, render, reverse
from django.template import loader
from django.utils._os import safe_join
from django.views.decorators.csrf import csrf_exempt
Expand Down Expand Up @@ -55,7 +55,10 @@
return redirect(reverse('user-login'))

# business mode access
return redirect(reverse('projects:project-index'))
if flag_set('fflag_all_feat_dia_1777_ls_homepage_short'):
return render(request, 'home/home.html')

Check warning on line 59 in label_studio/core/views.py

View check run for this annotation

Codecov / codecov/patch

label_studio/core/views.py#L58-L59

Added lines #L58 - L59 were not covered by tests
else:
return redirect(reverse('projects:project-index'))

Check warning on line 61 in label_studio/core/views.py

View check run for this annotation

Codecov / codecov/patch

label_studio/core/views.py#L61

Added line #L61 was not covered by tests

# not authenticated
return redirect(reverse('user-login'))
Expand Down
12 changes: 9 additions & 3 deletions label_studio/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from users.functions import login, proceed_registration

logger = logging.getLogger()

main_redirect = 'projects:project-index'
nick-skriabin marked this conversation as resolved.
Show resolved Hide resolved

@login_required
def logout(request):
Expand All @@ -41,7 +41,10 @@

# checks if the URL is a safe redirection.
if not next_page or not url_has_allowed_host_and_scheme(url=next_page, allowed_hosts=request.get_host()):
next_page = reverse('projects:project-index')
if flag_set('fflag_all_feat_dia_1777_ls_homepage_short'):
next_page = reverse('main')

Check warning on line 45 in label_studio/users/views.py

View check run for this annotation

Codecov / codecov/patch

label_studio/users/views.py#L45

Added line #L45 was not covered by tests
else:
next_page = reverse('projects:project-index')

user_form = forms.UserSignupForm()
organization_form = OrganizationSignupForm()
Expand Down Expand Up @@ -101,7 +104,10 @@

# checks if the URL is a safe redirection.
if not next_page or not url_has_allowed_host_and_scheme(url=next_page, allowed_hosts=request.get_host()):
next_page = reverse('projects:project-index')
if flag_set('fflag_all_feat_dia_1777_ls_homepage_short'):
next_page = reverse('main')

Check warning on line 108 in label_studio/users/views.py

View check run for this annotation

Codecov / codecov/patch

label_studio/users/views.py#L108

Added line #L108 was not covered by tests
else:
next_page = reverse('projects:project-index')

login_form = load_func(settings.USER_LOGIN_FORM)
form = login_form()
Expand Down
1 change: 1 addition & 0 deletions web/.stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"selector-class-pattern": null,
"custom-property-pattern": null,
"no-descending-specificity": null,
"function-no-unknown": null,
"scss/no-global-function-names": null,
"scss/function-no-unknown": null,
"selector-pseudo-class-no-unknown": [
Expand Down
9 changes: 9 additions & 0 deletions web/apps/labelstudio/src/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ import { FF_OPTIC_2, FF_UNSAVED_CHANGES, FF_PRODUCT_TOUR, isFF } from "../utils/
import { TourProvider } from "@humansignal/core";
import { ToastProvider, ToastViewport } from "@humansignal/ui";
import "@humansignal/ui/src/tailwind.css";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const baseURL = new URL(APP_SETTINGS.hostname || location.origin);
export const UNBLOCK_HISTORY_MESSAGE = "UNBLOCK_HISTORY";
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
},
},
});

const browserHistory = createBrowserHistory({
basename: baseURL.pathname || "/",
Expand Down Expand Up @@ -57,6 +65,7 @@ const App = ({ content }) => {
<Router history={browserHistory}>
<MultiProvider
providers={[
<QueryClientProvider key="query" client={queryClient} />,
<AppStoreProvider key="app-store" />,
<ApiProvider key="api" />,
<ConfigProvider key="config" />,
Expand Down
4 changes: 3 additions & 1 deletion web/apps/labelstudio/src/components/Menubar/Menubar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import "./Menubar.scss";
import "./MenuContent.scss";
import "./MenuSidebar.scss";
import { ModelsPage } from "../../pages/Organization/Models/ModelsPage";
import { FF_DIA_835, isFF } from "../../utils/feature-flags";
import { FF_DIA_835, FF_HOMEPAGE, isFF } from "../../utils/feature-flags";
import { IconHome } from "@humansignal/ui";

export const MenubarContext = createContext();

Expand Down Expand Up @@ -183,6 +184,7 @@ export const Menubar = ({ enabled, defaultOpened, defaultPinned, children, onSid
style={{ width: 240 }}
>
<Menu>
{isFF(FF_HOMEPAGE) && <Menu.Item label="Home" to="/" icon={<IconHome />} data-external exact />}
<Menu.Item label="Projects" to="/projects" icon={<IconFolder />} data-external exact />
<Menu.Item label="Organization" to="/organization" icon={<IconPersonInCircle />} data-external exact />
{isFF(FF_DIA_835) && <Menu.Item label="Models" to={ModelsPage.path} icon={<IconModel />} exact />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ProjectName = ({ name, setName, onSaveName, onSubmit, error, description,
</form>
);

export const CreateProject = ({ onClose }) => {
export const CreateProject = ({ onClose, redirect = true }) => {
const [step, _setStep] = React.useState("name"); // name | import | config
const [waiting, setWaitingStatus] = React.useState(false);

Expand Down Expand Up @@ -172,9 +172,9 @@ export const CreateProject = ({ onClose }) => {
},
});
setWaitingStatus(false);
history.replace("/projects");
redirect && history.replace("/projects");
onClose?.();
}, [project]);
}, [project, redirect]);

return (
<Modal onHide={onDelete} closeOnClickOutside={false} allowToInterceptEscape fullscreen visible bare>
Expand Down
196 changes: 196 additions & 0 deletions web/apps/labelstudio/src/pages/Home/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import type { Page } from "../types/Page";
import { Button } from "@humansignal/shad/components/ui/button";
import { IconFolder, SimpleCard, Spinner } from "@humansignal/ui";
import { IconExternal, IconFolderAdd, IconUserAdd } from "@humansignal/icons";
import { HeidiTips } from "../../components/HeidiTips/HeidiTips";
import { useQuery } from "@tanstack/react-query";
import { useAPI } from "../../providers/ApiProvider";
import { useState } from "react";
import { CreateProject } from "../CreateProject/CreateProject";
import { InviteLink } from "../Organization/PeoplePage/InviteLink";
import { Heading, Sub } from "@humansignal/typography";

const resources = [
{
title: "Documentation",
url: "https://labelstud.io/guide/",
},
{
title: "API Documentation",
url: "https://api.labelstud.io/api-reference/introduction/getting-started",
},
{
title: "LabelStud.io Blog",
url: "https://labelstud.io/blog/",
},
{
title: "Slack Community",
url: "https://slack.labelstud.io",
},
];

const actions = [
{
title: "Create Project",
icon: IconFolderAdd,
type: "createProject",
},
{
title: "Invite People",
icon: IconUserAdd,
type: "invitePeople",
},
] as const;

type Action = (typeof actions)[number]["type"];

export const HomePage: Page = () => {
const api = useAPI();
const [creationDialogOpen, setCreationDialogOpen] = useState(false);
const [invitationOpen, setInvitationOpen] = useState(false);
const { data, isFetching, isSuccess, isError } = useQuery({
nick-skriabin marked this conversation as resolved.
Show resolved Hide resolved
queryKey: ["projects"],
nick-skriabin marked this conversation as resolved.
Show resolved Hide resolved
async queryFn() {
return api.callApi<{ results: APIProject[] }>("projects", {
params: { page_size: 10 },
});
},
});
const handleActions = (action: Action) => {
return () => {
switch (action) {
case "createProject":
setCreationDialogOpen(true);
break;
case "invitePeople":
setInvitationOpen(true);
break;
}
};
};

return (
<main className="p-8">
<div className="grid grid-cols-[minmax(0,1fr)_450px] gap-6">
<section className="flex flex-col gap-4">
<div className="flex flex-col gap-1">
<Heading size={1}>Welcome 👋</Heading>
<Sub>Let's get you started.</Sub>
</div>
<div className="flex justify-between 2xl:justify-start gap-4">
{actions.map((action) => {
return (
<Button
key={action.title}
className="flex-1 2xl:flex-grow-0 text-lsLabelMedium text-lsPrimaryContent [&_svg]:w-6 [&_svg]:h-6"
variant="lsOutline"
onClick={handleActions(action.type)}
>
<action.icon className="text-lsPrimaryIcon" />
{action.title}
</Button>
);
})}
</div>

<SimpleCard
title={
<>
Recent Projects{" "}
<a href="/projects" className="text-lg">
View All
</a>
</>
}
>
{isFetching ? (
<div className="h-64 flex justify-center items-center">
<Spinner />
</div>
) : isError ? (
<div className="h-64 flex justify-center items-center">can't load projects</div>
) : isSuccess && data.results.length === 0 ? (
<div className="flex flex-col justify-center items-center border border-lsBorderSubtle bg-lsPrimaryEmphasisSubtle rounded-lg h-64">
<div
className={
"rounded-full w-12 h-12 flex justify-center items-center bg-lsAccentMangoSubtle text-lsPrimaryIcon"
}
>
<IconFolder />
</div>
<h2 className="text-2xl">Create your first project</h2>
<sub className="text-sm text-lsSubtitle">
Import your data and set up the labeling interface to start annotating
</sub>
<Button className="mt-4" onClick={() => setCreationDialogOpen(true)}>
Create Project
</Button>
</div>
) : isSuccess && data.results.length > 0 ? (
<div className="flex flex-col gap-1">
{data.results.map((project) => {
return <ProjectSimpleCard key={project.id} project={project} />;
})}
</div>
) : null}
</SimpleCard>
</section>
<section className="flex flex-col gap-6">
<HeidiTips collection="projectSettings" />
<SimpleCard title="Resources" description="Learn, explore and get help">
<ul>
{resources.map((link) => {
return (
<li key={link.title}>
<a
href={link.url}
className="py-2 px-1 flex justify-between items-center text-lsNeutralContent"
target="_blank"
rel="noreferrer"
>
{link.title}
<IconExternal className="text-lsPrimaryIcon" />
</a>
</li>
);
})}
</ul>
</SimpleCard>
</section>
</div>
{creationDialogOpen && <CreateProject redirect={false} onClose={() => setCreationDialogOpen(false)} />}
<InviteLink opened={invitationOpen} onClosed={() => setInvitationOpen(false)} />
</main>
);
};

HomePage.title = "Home";
HomePage.path = "/";
HomePage.exact = true;

function ProjectSimpleCard({
project,
}: {
project: APIProject;
}) {
const finished = project.finished_task_number ?? 0;
const total = project.task_number ?? 0;
const progress = (total > 0 ? finished / total : 0) * 100;
return (
<div className=" even:bg-lsNeutralSurface rounded-sm overflow-hidden">
<div className="grid grid-cols-[minmax(0,1fr)_150px] p-4 items-center border-l-2 border-lsNeutralBorderSubtle">
<div className="flex flex-col gap-1">
<a href={`/projects/${project.id}`} className="text-lsNeutralContent">
{project.title}
</a>
<div className="text-lsNeutralContentSubtler">
{finished} / {total}
</div>
</div>
<div className="bg-lsPrimaryEmphasisSubtle rounded-full overflow-hidden w-full h-2 shadow-lsNeutralBorderSubtle shadow-border-1">
<div className="bg-lsPositiveSurfaceHover h-full min-w-1" style={{ maxWidth: `${progress}%` }} />
</div>
</div>
</div>
);
}
Loading
Loading