* wip getting started checklist page * lint * add new ui skeleton for new home page/checklist * make legacy home page appearance setting * dynamic checklist rendering/close checklist * make home page functional + update cta buttons in ws settings * lint * remove unneeded routes * wip fixing checklist items (create ws and embed doc broken) + news section updates * lint * FINALLY fix all functionality & remove hook to simplify logic * lint * hide/show options based on user role/mum enabled * add hover states and redo checklist ui * remove welcome checklist page * add validation to task completion * polish behavior of checklist/fix roles on checklist items * lint * light mode/use tailwind color classes * remove tutorials link * Modify how legacy page works * small UI updates * remove unused paths cleanup explore features * revert save button changes * conditionally render legacy default chat page when in multiuser * remove role checks in checklist * remove role checks in quick links * remove unused hook * dark mode new home page checklist ui updates * Add news logging to repo for record keeping update new module to pull from CDN * simplify landing markup * light mode styles * remove border in light mode from merge conflict * Update ignores * slide up dismiss * prevent checklist popin * confetti? * fix url hash on navigate * watch for event changes for updating checklist * useMemo and callback memory optimization * move handlers to constants via params fwd * dev * update github text --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
163 lines
4.4 KiB
JavaScript
163 lines
4.4 KiB
JavaScript
import {
|
|
SquaresFour,
|
|
ChatDots,
|
|
Files,
|
|
ChatCenteredText,
|
|
UsersThree,
|
|
} from "@phosphor-icons/react";
|
|
import SlashCommandIcon from "./ChecklistItem/icons/SlashCommand";
|
|
import paths from "@/utils/paths";
|
|
const noop = () => {};
|
|
|
|
export const CHECKLIST_UPDATED_EVENT = "anythingllm_checklist_updated";
|
|
export const CHECKLIST_STORAGE_KEY = "anythingllm_checklist_completed";
|
|
export const CHECKLIST_HIDDEN = "anythingllm_checklist_dismissed";
|
|
|
|
/**
|
|
* @typedef {Object} ChecklistItemHandlerParams
|
|
* @property {Object[]} workspaces - Array of workspaces
|
|
* @property {Function} navigate - Function to navigate to a path
|
|
* @property {Function} setSelectedWorkspace - Function to set the selected workspace
|
|
* @property {Function} showManageWsModal - Function to show the manage workspace modal
|
|
* @property {Function} showToast - Function to show a toast
|
|
* @property {Function} showNewWsModal - Function to show the new workspace modal
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Object} ChecklistItem
|
|
* @property {string} id
|
|
* @property {string} title
|
|
* @property {string} description
|
|
* @property {string} action
|
|
* @property {(params: ChecklistItemHandlerParams) => boolean} handler
|
|
* @property {string} icon
|
|
* @property {boolean} completed
|
|
*/
|
|
|
|
/** @type {ChecklistItem[]} */
|
|
export const CHECKLIST_ITEMS = [
|
|
{
|
|
id: "create_workspace",
|
|
title: "Create a workspace",
|
|
description: "Create your first workspace to get started",
|
|
action: "Create",
|
|
handler: ({ showNewWsModal = noop }) => {
|
|
showNewWsModal();
|
|
return true;
|
|
},
|
|
icon: SquaresFour,
|
|
},
|
|
{
|
|
id: "send_chat",
|
|
title: "Send a chat",
|
|
description: "Start a conversation with your AI assistant",
|
|
action: "Chat",
|
|
handler: ({
|
|
workspaces = [],
|
|
navigate = noop,
|
|
showToast = noop,
|
|
showNewWsModal = noop,
|
|
}) => {
|
|
if (workspaces.length === 0) {
|
|
showToast(
|
|
"Please create a workspace before starting a chat.",
|
|
"warning",
|
|
{ clear: true }
|
|
);
|
|
showNewWsModal();
|
|
return false;
|
|
}
|
|
navigate(paths.workspace.chat(workspaces[0].slug));
|
|
return true;
|
|
},
|
|
icon: ChatDots,
|
|
},
|
|
{
|
|
id: "embed_document",
|
|
title: "Embed a document",
|
|
description: "Add your first document to your workspace",
|
|
action: "Embed",
|
|
handler: ({
|
|
workspaces = [],
|
|
setSelectedWorkspace = noop,
|
|
showManageWsModal = noop,
|
|
showToast = noop,
|
|
showNewWsModal = noop,
|
|
}) => {
|
|
if (workspaces.length === 0) {
|
|
showToast(
|
|
"Please create a workspace before embedding documents.",
|
|
"warning",
|
|
{ clear: true }
|
|
);
|
|
showNewWsModal();
|
|
return false;
|
|
}
|
|
setSelectedWorkspace(workspaces[0]);
|
|
showManageWsModal();
|
|
return true;
|
|
},
|
|
icon: Files,
|
|
},
|
|
{
|
|
id: "setup_system_prompt",
|
|
title: "Set up a system prompt",
|
|
description: "Configure your AI assistant's behavior",
|
|
action: "Set Up",
|
|
handler: ({
|
|
workspaces = [],
|
|
navigate = noop,
|
|
showNewWsModal = noop,
|
|
showToast = noop,
|
|
}) => {
|
|
if (workspaces.length === 0) {
|
|
showToast(
|
|
"Please create a workspace before setting up system prompts.",
|
|
"warning",
|
|
{ clear: true }
|
|
);
|
|
showNewWsModal();
|
|
return false;
|
|
}
|
|
navigate(paths.workspace.settings.chatSettings(workspaces[0].slug));
|
|
window.location.hash = "#system-prompts";
|
|
return true;
|
|
},
|
|
icon: ChatCenteredText,
|
|
},
|
|
{
|
|
id: "define_slash_command",
|
|
title: "Define a slash command",
|
|
description: "Create custom commands for your assistant",
|
|
action: "Define",
|
|
handler: ({
|
|
workspaces = [],
|
|
navigate = noop,
|
|
showNewWsModal = noop,
|
|
showToast = noop,
|
|
}) => {
|
|
if (workspaces.length === 0) {
|
|
showToast(
|
|
"Please create a workspace before setting up slash commands.",
|
|
"warning",
|
|
{ clear: true }
|
|
);
|
|
showNewWsModal();
|
|
return false;
|
|
}
|
|
navigate(paths.workspace.chat(workspaces[0].slug));
|
|
window.location.hash = "#slash-commands";
|
|
return true;
|
|
},
|
|
icon: SlashCommandIcon,
|
|
},
|
|
{
|
|
id: "visit_community",
|
|
title: "Visit Community Hub",
|
|
description: "Explore community resources and templates",
|
|
action: "Browse",
|
|
handler: () => window.open(paths.communityHub.website(), "_blank"),
|
|
icon: UsersThree,
|
|
},
|
|
];
|