add block buttons
This commit is contained in:
parent
4be325eb16
commit
d0339ecdf5
5 changed files with 64 additions and 68 deletions
|
|
@ -0,0 +1,54 @@
|
|||
import { PlusIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext } from "react";
|
||||
import { useAuth } from "../../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../../context/IdeMessenger";
|
||||
import { useAppDispatch } from "../../../../redux/hooks";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../../../redux/slices/uiSlice";
|
||||
import { fontSize } from "../../../../util";
|
||||
import AddDocsDialog from "../../../dialogs/AddDocsDialog";
|
||||
|
||||
export function AddBlockButton(props: { blockType: string }) {
|
||||
const { selectedProfile } = useAuth();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const handleClick = () => {
|
||||
if (selectedProfile?.profileType === "local") {
|
||||
switch (props.blockType) {
|
||||
case "docs":
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<AddDocsDialog />));
|
||||
break;
|
||||
default:
|
||||
ideMessenger.request("config/openProfile", {
|
||||
profileId: selectedProfile.id,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
ideMessenger.request("controlPlane/openUrl", {
|
||||
path: `new?type=block&blockType=${props.blockType}`,
|
||||
orgSlug: undefined,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className="cursor-pointer rounded px-2 pb-1 text-center text-gray-400 hover:text-gray-300"
|
||||
style={{
|
||||
fontSize: fontSize(-3),
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
handleClick();
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-center gap-1">
|
||||
<PlusIcon className="h-3 w-3" /> Add
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import {
|
|||
import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid";
|
||||
import { fontSize } from "../../../../util";
|
||||
import { useBookmarkedSlashCommands } from "../../../ConversationStarters/useBookmarkedSlashCommands";
|
||||
import { AddBlockButton } from "./AddBlockButton";
|
||||
|
||||
interface PromptRowProps {
|
||||
command: string;
|
||||
|
|
@ -62,7 +63,7 @@ export function PromptsSection() {
|
|||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1 pr-2">
|
||||
<div className="flex flex-col gap-1">
|
||||
{cmdsSortedByBookmark?.map((prompt, i) => (
|
||||
<PromptRow
|
||||
key={prompt.name}
|
||||
|
|
@ -73,6 +74,7 @@ export function PromptsSection() {
|
|||
onEdit={() => handleEdit(prompt)}
|
||||
/>
|
||||
))}
|
||||
<AddBlockButton blockType="prompts" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { IdeMessengerContext } from "../../../../context/IdeMessenger";
|
|||
import { RootState } from "../../../../redux/store";
|
||||
import { fontSize } from "../../../../util";
|
||||
import HeaderButtonWithToolTip from "../../../gui/HeaderButtonWithToolTip";
|
||||
import { AddBlockButton } from "./AddBlockButton";
|
||||
|
||||
interface RuleCardProps {
|
||||
index: number;
|
||||
|
|
@ -141,6 +142,7 @@ export function RulesSection() {
|
|||
})}
|
||||
</div>
|
||||
)}
|
||||
<AddBlockButton blockType="rules" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,10 @@
|
|||
import { parseConfigYaml } from "@continuedev/config-yaml";
|
||||
import { PlusIcon } from "@heroicons/react/24/outline";
|
||||
import { IndexingStatus } from "core";
|
||||
import { useContext, useMemo } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useAuth } from "../../../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../../../context/IdeMessenger";
|
||||
import { useAppSelector } from "../../../../../redux/hooks";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../../../../redux/slices/uiSlice";
|
||||
import { fontSize } from "../../../../../util";
|
||||
import AddDocsDialog from "../../../../dialogs/AddDocsDialog";
|
||||
import { AddBlockButton } from "../AddBlockButton";
|
||||
import DocsIndexingStatus from "./DocsIndexingStatus";
|
||||
|
||||
function DocsIndexingStatuses() {
|
||||
|
|
@ -21,7 +14,6 @@ function DocsIndexingStatuses() {
|
|||
(store) => store.indexing.indexing.statuses,
|
||||
);
|
||||
const { selectedProfile } = useAuth();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const mergedDocs = useMemo(() => {
|
||||
const parsed = selectedProfile?.rawYaml
|
||||
|
|
@ -33,18 +25,6 @@ function DocsIndexingStatuses() {
|
|||
}));
|
||||
}, [config.docs, selectedProfile?.rawYaml]);
|
||||
|
||||
const handleAddDocs = () => {
|
||||
if (selectedProfile?.profileType === "local") {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<AddDocsDialog />));
|
||||
} else {
|
||||
ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "new?type=block&blockType=docs",
|
||||
orgSlug: undefined,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const sortedConfigDocs = useMemo(() => {
|
||||
const sorter = (status: IndexingStatus["status"]) => {
|
||||
if (status === "complete") return 0;
|
||||
|
|
@ -74,20 +54,6 @@ function DocsIndexingStatuses() {
|
|||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex flex-col gap-1 overflow-y-auto overflow-x-hidden pr-2">
|
||||
<div>
|
||||
{sortedConfigDocs.length === 0 && (
|
||||
<a
|
||||
href="#"
|
||||
className="cursor-pointer text-blue-500 hover:text-blue-600 hover:underline"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
handleAddDocs();
|
||||
}}
|
||||
>
|
||||
Add Docs
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
{sortedConfigDocs.map((docConfig) => {
|
||||
return (
|
||||
<div
|
||||
|
|
@ -104,22 +70,7 @@ function DocsIndexingStatuses() {
|
|||
);
|
||||
})}
|
||||
</div>
|
||||
{sortedConfigDocs.length > 0 && (
|
||||
<div
|
||||
className="cursor-pointer rounded px-2 pb-1 text-center text-gray-400 hover:text-gray-300"
|
||||
style={{
|
||||
fontSize: fontSize(-3),
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
handleAddDocs();
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-center gap-1">
|
||||
<PlusIcon className="h-3 w-3" /> Add
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<AddBlockButton blockType="docs" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import {
|
|||
} from "@heroicons/react/24/outline";
|
||||
import { MCPServerStatus } from "core";
|
||||
import { useContext } from "react";
|
||||
import { SecondaryButton } from "../../components";
|
||||
import { ToolTip } from "../../components/gui/Tooltip";
|
||||
import { AddBlockButton } from "../../components/mainInput/Lump/sections/AddBlockButton";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { updateConfig } from "../../redux/slices/configSlice";
|
||||
|
|
@ -158,24 +158,11 @@ function MCPServersPreview() {
|
|||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex max-h-[170px] flex-col gap-1 overflow-y-auto overflow-x-hidden pr-2">
|
||||
<div>
|
||||
{servers.length === 0 && (
|
||||
<SecondaryButton
|
||||
className="flex h-7 flex-col items-center justify-center"
|
||||
onClick={() => {
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: undefined,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Add MCP Servers
|
||||
</SecondaryButton>
|
||||
)}
|
||||
</div>
|
||||
{servers.map((server, idx) => (
|
||||
<MCPServerPreview key={idx} server={server} />
|
||||
))}
|
||||
</div>
|
||||
<AddBlockButton blockType="mcpServers" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue