Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(demo): add demo mode indicator with storage reset (#44)

Corentin THOMASSETb789ae9cfae2
diff --git a/README.md b/README.md
index 4f16368c..742bcbc9 100644
--- a/README.md
+++ b/README.md
@@ -13,15 +13,15 @@
Minimalistic document management and archiving platform.
</p>
-<!-- <p align="center">
+<p align="center">
<a href="https://demo.papra.app">Demo</a>
+ <!-- <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
+ <a href="https://docs.papra.app">Docs</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
- <a href="https://demo.papra.app">Docs</a>
- <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
- <a href="https://docs.papra.app/self-hosting/docker">Self-hosting</a>
+ <a href="https://docs.papra.app/self-hosting/docker">Self-hosting</a> -->
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
- <a href="https://dashboard.papra.app">Production app</a>
-</p> -->
+ <a href="https://dashboard.papra.app">Prod app</a>
+</p>
## Introduction
@@ -32,7 +32,7 @@
Forget about that receipt of that gift you bought for your friend last year, or that warranty for your new phone. With Papra, you can easily store, forget, and retrieve your documents whenever you need them.
-A live demo of the platform is available at [demo.papra.cc](https://demo.papra.cc) (*coming soon*).
+A live demo of the platform is available at [demo.papra.cc](https://demo.papra.cc) (no backend, client-side local storage only).
## Features
diff --git a/apps/papra-client/src/index.tsx b/apps/papra-client/src/index.tsx
index 76700b78..ee0b9bbd 100644
--- a/apps/papra-client/src/index.tsx
+++ b/apps/papra-client/src/index.tsx
@@ -7,6 +7,7 @@ import { QueryClientProvider } from '@tanstack/solid-query';
import { render, Suspense } from 'solid-js/web';
import { CommandPaletteProvider } from './modules/command-palette/command-palette.provider';
+import { DemoIndicator } from './modules/demo/demo.provider';
import { ConfirmModalProvider } from './modules/shared/confirm';
import { queryClient } from './modules/shared/query/query-client';
import { Toaster } from './modules/ui/components/sonner';
@@ -37,6 +38,7 @@ render(
<div class="min-h-screen font-sans text-sm font-400">{props.children}</div>
<Toaster />
+ <DemoIndicator />
</CommandPaletteProvider>
</ColorModeProvider>
diff --git a/apps/papra-client/src/modules/demo/demo.provider.tsx b/apps/papra-client/src/modules/demo/demo.provider.tsx
new file mode 100644
index 00000000..bb64f7db
--- /dev/null
+++ b/apps/papra-client/src/modules/demo/demo.provider.tsx
@@ -0,0 +1,50 @@
+import { useNavigate } from '@solidjs/router';
+import { type Component, createSignal } from 'solid-js';
+import { Portal } from 'solid-js/web';
+import { config } from '../config/config';
+import { Button } from '../ui/components/button';
+import { clearDemoStorage } from './demo.storage';
+
+export const DemoIndicator: Component = () => {
+ const [getIsMinified, setIsMinified] = createSignal(false);
+ const navigate = useNavigate();
+
+ const clearDemo = async () => {
+ await clearDemoStorage();
+ navigate('/');
+ };
+
+ return (
+ <>
+ {config.isDemoMode && (
+ <Portal>
+ {getIsMinified()
+ ? (
+ <div class="fixed bottom-4 right-4 z-50 rounded-xl max-w-280px">
+ <Button onClick={() => setIsMinified(false)} size="icon">
+ <div class="i-tabler-info-circle size-5.5"></div>
+ </Button>
+ </div>
+ )
+ : (
+ <div class="fixed bottom-4 right-4 z-50 bg-primary text-primary-foreground p-5 py-4 rounded-xl shadow-md max-w-300px">
+ <p class="text-sm">
+ This is a demo environment, all data is save to your browser local storage.
+ </p>
+ <div class="flex justify-end mt-4 gap-2">
+ <Button variant="secondary" onClick={clearDemo} size="sm" class="text-primary shadow-none">
+ Reset demo data
+ </Button>
+
+ <Button onClick={() => setIsMinified(true)} class="bg-transparent hover:text-primary" variant="outline" size="sm">
+ Hide
+ </Button>
+ </div>
+ </div>
+ )}
+
+ </Portal>
+ )}
+ </>
+ );
+};
diff --git a/apps/papra-client/src/modules/demo/demo.storage.ts b/apps/papra-client/src/modules/demo/demo.storage.ts
index 5390490e..4d111415 100644
--- a/apps/papra-client/src/modules/demo/demo.storage.ts
+++ b/apps/papra-client/src/modules/demo/demo.storage.ts
@@ -10,3 +10,7 @@ const storage = createStorage<any>({
export const organizationStorage = prefixStorage<Organization>(storage, 'organizations');
export const documentStorage = prefixStorage<Document>(storage, 'documents');
export const documentFileStorage = prefixStorage(storage, 'documentFiles');
+
+export async function clearDemoStorage() {
+ await storage.clear();
+}
diff --git a/apps/papra-client/src/modules/organizations/pages/create-first-organization.page.tsx b/apps/papra-client/src/modules/organizations/pages/create-first-organization.page.tsx
index 20814dea..576f106e 100644
--- a/apps/papra-client/src/modules/organizations/pages/create-first-organization.page.tsx
+++ b/apps/papra-client/src/modules/organizations/pages/create-first-organization.page.tsx
@@ -1,11 +1,15 @@
-import type { Component } from 'solid-js';
import { useCurrentUser } from '@/modules/users/composables/useCurrentUser';
+import { useNavigate } from '@solidjs/router';
+import { createQuery } from '@tanstack/solid-query';
+import { type Component, createEffect, on } from 'solid-js';
import { CreateOrganizationForm } from '../components/create-organization-form.component';
import { useCreateOrganization } from '../organizations.composables';
+import { fetchOrganizations } from '../organizations.services';
export const CreateFirstOrganizationPage: Component = () => {
const { createOrganization } = useCreateOrganization();
const { user } = useCurrentUser();
+ const navigate = useNavigate();
const getOrganizationName = () => {
const fullName = user.fullName;
@@ -17,15 +21,29 @@ export const CreateFirstOrganizationPage: Component = () => {
return `My organization`;
};
+ const queries = createQuery(() => ({
+ queryKey: ['organizations'],
+ queryFn: fetchOrganizations,
+ }));
+
+ createEffect(on(
+ () => queries.data?.organizations,
+ (orgs) => {
+ if (orgs && orgs.length > 0) {
+ navigate('/organizations/create');
+ }
+ },
+ ));
+
return (
<div>
- <div class="max-w-md mx-auto sm:mt-16 p-6">
+ <div class="max-w-md mx-auto pt-12 sm:pt-24 px-6">
<h1 class="text-xl font-bold">
Create your organization
</h1>
<p class="text-muted-foreground mb-6">
- Your documents will be grouped by organization. You can create multiple organizations to separate your documents, for your personal use or to collaborate with others.
+ Your documents will be grouped by organization. You can create multiple organizations to separate your documents, for example, for personal and work documents.
</p>
<CreateOrganizationForm onSubmit={createOrganization} initialOrganizationName={getOrganizationName()} />
diff --git a/apps/papra-client/src/modules/organizations/pages/create-organization.page.tsx b/apps/papra-client/src/modules/organizations/pages/create-organization.page.tsx
index 597850f6..0c77b10a 100644
--- a/apps/papra-client/src/modules/organizations/pages/create-organization.page.tsx
+++ b/apps/papra-client/src/modules/organizations/pages/create-organization.page.tsx
@@ -9,7 +9,7 @@ export const CreateOrganizationPage: Component = () => {
return (
<div>
- <div class="max-w-md mx-auto sm:mt-16 p-6">
+ <div class="max-w-md mx-auto pt-12 sm:pt-24 px-6">
<Button as={A} href="/" class="mb-4" variant="outline">
<div class="i-tabler-arrow-left mr-2"></div>
@@ -21,7 +21,7 @@ export const CreateOrganizationPage: Component = () => {
</h1>
<p class="text-muted-foreground mb-6">
- Your documents will be grouped by organization. You can create multiple organizations to separate your documents.
+ Your documents will be grouped by organization. You can create multiple organizations to separate your documents, for example, for personal and work documents.
</p>
<CreateOrganizationForm onSubmit={createOrganization} />