Option to disable page share

This commit is contained in:
n4ze3m
2024-04-30 20:43:53 +05:30
parent ad5601a038
commit b09fbcdfe6
7 changed files with 40 additions and 11 deletions

View File

@@ -20,6 +20,7 @@ import { ShareBtn } from "~/components/Common/ShareBtn"
import { useTranslation } from "react-i18next"
import { OllamaIcon } from "../Icons/Ollama"
import { SelectedKnowledge } from "../Option/Knowledge/SelectedKnwledge"
import { useStorage } from "@plasmohq/storage/hook"
export default function OptionLayout({
children
@@ -28,6 +29,7 @@ export default function OptionLayout({
}) {
const [sidebarOpen, setSidebarOpen] = useState(false)
const { t } = useTranslation(["option", "common"])
const [shareModeEnabled] = useStorage("shareMode", true)
const {
selectedModel,
@@ -107,7 +109,7 @@ export default function OptionLayout({
<div>
<Select
value={selectedModel}
onChange={(e) => {
onChange={(e) => {
setSelectedModel(e)
localStorage.setItem("selectedModel", e)
}}
@@ -175,9 +177,10 @@ export default function OptionLayout({
<div className="flex flex-1 justify-end px-4">
<div className="ml-4 flex items-center md:ml-6">
<div className="flex gap-4 items-center">
{pathname === "/" && messages.length > 0 && !streaming && (
<ShareBtn messages={messages} />
)}
{pathname === "/" &&
messages.length > 0 &&
!streaming &&
shareModeEnabled && <ShareBtn messages={messages} />}
<Tooltip title={t("githubRepository")}>
<a
href="https://github.com/n4ze3m/page-assist"

View File

@@ -1,15 +1,17 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
import { Form, Input, Skeleton, Table, Tooltip, message } from "antd"
import { Form, Input, Skeleton, Switch, Table, Tooltip, message } from "antd"
import { Trash2 } from "lucide-react"
import { Trans, useTranslation } from "react-i18next"
import { SaveButton } from "~/components/Common/SaveButton"
import { deleteWebshare, getAllWebshares, getUserId } from "@/db"
import { getPageShareUrl, setPageShareUrl } from "~/services/ollama"
import { verifyPageShareURL } from "~/utils/verify-page-share"
import { useStorage } from "@plasmohq/storage/hook"
export const OptionShareBody = () => {
const queryClient = useQueryClient()
const { t } = useTranslation(["settings"])
const [shareModeEnabled, setShareModelEnabled] = useStorage("shareMode", true)
const { status, data } = useQuery({
queryKey: ["fetchShareInfo"],
@@ -132,6 +134,20 @@ export const OptionShareBody = () => {
</div>
</Form.Item>
</Form>
<div className="space-y-2 flex mb-4 flex-row items-center justify-between rounded-lg dark:border-gray-600 ">
<div className="space-y-0.5">
<label className="text-sm font-semibold leading-5 text-gray-900 dark:text-white">
{t("manageShare.webshare.label")}
</label>
<p className="text-sm font-normal leading-5 text-gray-500 dark:text-gray-400">
{t("manageShare.webshare.description")}
</p>
</div>
<Switch
checked={shareModeEnabled}
onChange={setShareModelEnabled}
/>
</div>
</div>
<div>
<div>