mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
web: add support for configuring server urls from login screen
This commit is contained in:
1509
apps/web/package-lock.json
generated
1509
apps/web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -18,13 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { Box, Flex, Image, Link, Text } from "@theme-ui/components";
|
import { Box, Button, Flex, Image, Link, Text } from "@theme-ui/components";
|
||||||
import { useStore as useThemeStore } from "../../stores/theme-store";
|
import { getRandom, usePromise } from "@notesnook/common";
|
||||||
import { getRandom } from "@notesnook/common";
|
|
||||||
import Grberk from "../../assets/testimonials/grberk.jpeg";
|
import Grberk from "../../assets/testimonials/grberk.jpeg";
|
||||||
import Holenstein from "../../assets/testimonials/holenstein.jpg";
|
import Holenstein from "../../assets/testimonials/holenstein.jpg";
|
||||||
import Jason from "../../assets/testimonials/jason.jpg";
|
import Jason from "../../assets/testimonials/jason.jpg";
|
||||||
import Cameron from "../../assets/testimonials/cameron.jpg";
|
import Cameron from "../../assets/testimonials/cameron.jpg";
|
||||||
|
import hosts from "@notesnook/core/dist/utils/constants";
|
||||||
|
import { SettingsDialog } from "../../dialogs/settings";
|
||||||
|
|
||||||
const testimonials = [
|
const testimonials = [
|
||||||
{
|
{
|
||||||
@@ -74,10 +75,16 @@ function randomTitle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function AuthContainer(props) {
|
function AuthContainer(props) {
|
||||||
const colorScheme = useThemeStore((store) => store.colorScheme);
|
|
||||||
const testimonial = useMemo(() => randomTestimonial(), []);
|
const testimonial = useMemo(() => randomTestimonial(), []);
|
||||||
const title = useMemo(() => randomTitle(), []);
|
const title = useMemo(() => randomTitle(), []);
|
||||||
|
|
||||||
|
const version = usePromise(
|
||||||
|
async () =>
|
||||||
|
await fetch(`${hosts.API_HOST}/version`)
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch(() => undefined)
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
sx={{
|
sx={{
|
||||||
@@ -165,7 +172,6 @@ function AuthContainer(props) {
|
|||||||
<Text variant={"heading"} sx={{ fontSize: 48 }}>
|
<Text variant={"heading"} sx={{ fontSize: 48 }}>
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Text
|
<Text
|
||||||
variant="body"
|
variant="body"
|
||||||
mt={10}
|
mt={10}
|
||||||
@@ -193,6 +199,34 @@ function AuthContainer(props) {
|
|||||||
<Text variant="subBody">@{testimonial.username}</Text>
|
<Text variant="subBody">@{testimonial.username}</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
|
<Flex
|
||||||
|
mt={2}
|
||||||
|
pt={2}
|
||||||
|
sx={{
|
||||||
|
justifyContent: "space-between",
|
||||||
|
borderTop: "1px solid var(--border)",
|
||||||
|
width: "100%"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text variant={"subBody"}>
|
||||||
|
{version.status === "fulfilled" &&
|
||||||
|
version.value.instance !== "default" ? (
|
||||||
|
<>
|
||||||
|
Using{" "}
|
||||||
|
{version.value.instance + ` (v${version.value.version})`}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>Using official Notesnook instance.</>
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
<Button
|
||||||
|
variant="anchor"
|
||||||
|
onClick={() => SettingsDialog.show({ activeSection: "servers" })}
|
||||||
|
>
|
||||||
|
Configure
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Box>
|
</Box>
|
||||||
<Flex
|
<Flex
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ import { AppLockSettings } from "./app-lock-settings";
|
|||||||
import { BaseDialogProps, DialogManager } from "../../common/dialog-manager";
|
import { BaseDialogProps, DialogManager } from "../../common/dialog-manager";
|
||||||
import { ServersSettings } from "./servers-settings";
|
import { ServersSettings } from "./servers-settings";
|
||||||
|
|
||||||
type SettingsDialogProps = BaseDialogProps<false>;
|
type SettingsDialogProps = BaseDialogProps<false> & {
|
||||||
|
activeSection?: SectionKeys;
|
||||||
|
};
|
||||||
|
|
||||||
const sectionGroups: SectionGroup[] = [
|
const sectionGroups: SectionGroup[] = [
|
||||||
{
|
{
|
||||||
@@ -187,7 +189,9 @@ export const SettingsDialog = DialogManager.register(function SettingsDialog(
|
|||||||
props: SettingsDialogProps
|
props: SettingsDialogProps
|
||||||
) {
|
) {
|
||||||
const [activeSettings, setActiveSettings] = useState<SettingsGroup[]>(
|
const [activeSettings, setActiveSettings] = useState<SettingsGroup[]>(
|
||||||
SettingsGroups.filter((g) => g.section === "profile")
|
SettingsGroups.filter(
|
||||||
|
(g) => g.section === (props.activeSection || "profile")
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -205,6 +209,7 @@ export const SettingsDialog = DialogManager.register(function SettingsDialog(
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SettingsSideBar
|
<SettingsSideBar
|
||||||
|
activeSection={props.activeSection}
|
||||||
onNavigate={(settings) => {
|
onNavigate={(settings) => {
|
||||||
const scrollbar = document.getElementById("settings-scrollbar");
|
const scrollbar = document.getElementById("settings-scrollbar");
|
||||||
if (scrollbar !== null) scrollbar.scrollTop = 0;
|
if (scrollbar !== null) scrollbar.scrollTop = 0;
|
||||||
@@ -233,10 +238,13 @@ export const SettingsDialog = DialogManager.register(function SettingsDialog(
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
type SettingsSideBarProps = { onNavigate: (settings: SettingsGroup[]) => void };
|
type SettingsSideBarProps = {
|
||||||
|
onNavigate: (settings: SettingsGroup[]) => void;
|
||||||
|
activeSection?: SectionKeys;
|
||||||
|
};
|
||||||
function SettingsSideBar(props: SettingsSideBarProps) {
|
function SettingsSideBar(props: SettingsSideBarProps) {
|
||||||
const { onNavigate } = props;
|
const { onNavigate, activeSection } = props;
|
||||||
const [route, setRoute] = useState<SectionKeys>("profile");
|
const [route, setRoute] = useState<SectionKeys>(activeSection || "profile");
|
||||||
useUserStore((store) => store.isLoggedIn);
|
useUserStore((store) => store.isLoggedIn);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user