mirror of
https://github.com/docmost/docmost.git
synced 2026-05-25 20:12:45 +08:00
license
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod/v4";
|
import { z } from "zod/v4";
|
||||||
import React from "react";
|
import React, { useRef } from "react";
|
||||||
import { Button, Group, Modal, Textarea } from "@mantine/core";
|
import { Button, Divider, Group, Modal, Stack, Textarea } from "@mantine/core";
|
||||||
import { useForm } from "@mantine/form";
|
import { useForm } from "@mantine/form";
|
||||||
import { zod4Resolver } from "mantine-form-zod-resolver";
|
import { zod4Resolver } from "mantine-form-zod-resolver";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -49,6 +49,7 @@ interface ActivateLicenseFormProps {
|
|||||||
export function ActivateLicenseForm({ onClose }: ActivateLicenseFormProps) {
|
export function ActivateLicenseForm({ onClose }: ActivateLicenseFormProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const activateLicenseMutation = useActivateMutation();
|
const activateLicenseMutation = useActivateMutation();
|
||||||
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
validate: zod4Resolver(formSchema),
|
validate: zod4Resolver(formSchema),
|
||||||
@@ -63,29 +64,68 @@ export function ActivateLicenseForm({ onClose }: ActivateLicenseFormProps) {
|
|||||||
onClose?.();
|
onClose?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleFileUpload(event: React.ChangeEvent<HTMLInputElement>) {
|
||||||
|
const file = event.target.files?.[0];
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = (e) => {
|
||||||
|
const content = (e.target?.result as string)?.trim();
|
||||||
|
if (content) {
|
||||||
|
form.setFieldValue("licenseKey", content);
|
||||||
|
handleSubmit({ licenseKey: content });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
reader.readAsText(file);
|
||||||
|
|
||||||
|
if (fileInputRef.current) {
|
||||||
|
fileInputRef.current.value = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={form.onSubmit(handleSubmit)}>
|
<form onSubmit={form.onSubmit(handleSubmit)}>
|
||||||
<Textarea
|
<input
|
||||||
label={t("License key")}
|
type="file"
|
||||||
description="Enter a valid enterprise license key. Contact sales@docmost.com to purchase one."
|
accept=".txt"
|
||||||
placeholder={t("e.g eyJhb.....")}
|
ref={fileInputRef}
|
||||||
variant="filled"
|
onChange={handleFileUpload}
|
||||||
autosize
|
hidden
|
||||||
minRows={3}
|
|
||||||
maxRows={5}
|
|
||||||
data-autofocus
|
|
||||||
{...form.getInputProps("licenseKey")}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Group justify="flex-end" mt="md">
|
<Stack gap="xs">
|
||||||
<Button
|
<Textarea
|
||||||
type="submit"
|
label={t("License key")}
|
||||||
disabled={activateLicenseMutation.isPending}
|
placeholder={t("e.g eyJhb.....")}
|
||||||
loading={activateLicenseMutation.isPending}
|
variant="filled"
|
||||||
>
|
autosize
|
||||||
{t("Save")}
|
minRows={3}
|
||||||
</Button>
|
maxRows={5}
|
||||||
</Group>
|
data-autofocus
|
||||||
|
{...form.getInputProps("licenseKey")}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Group justify="flex-end">
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
disabled={activateLicenseMutation.isPending}
|
||||||
|
loading={activateLicenseMutation.isPending}
|
||||||
|
>
|
||||||
|
{t("Save")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Divider label={t("Or")} labelPosition="center" />
|
||||||
|
|
||||||
|
<Group justify="center">
|
||||||
|
<Button
|
||||||
|
variant="light"
|
||||||
|
onClick={() => fileInputRef.current?.click()}
|
||||||
|
>
|
||||||
|
{t("Upload license file")}
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,11 @@ export default function OssDetails() {
|
|||||||
</List>
|
</List>
|
||||||
|
|
||||||
<Text size="sm" c="dimmed">
|
<Text size="sm" c="dimmed">
|
||||||
Contact <a href="mailto:sales@docmost.com?subject=Enterprise%20License%20Inquiry">sales@docmost.com </a> to purchase an enterprise license.
|
Get an enterprise trial key at <a href="https://customers.docmost.com/" target="_blank" rel="noopener noreferrer">customers.docmost.com</a>.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
Visit <a href="https://docmost.com/pricing" target="_blank" rel="noopener noreferrer">docmost.com/pricing</a> to purchase an enterprise license.
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
Reference in New Issue
Block a user