mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13:33 +00:00
restructure files onto electron-vite boilerplate
This commit is contained in:
parent
91ce2cd8a1
commit
1cf587bc8f
457 changed files with 9927 additions and 11705 deletions
|
|
@ -1,18 +1,19 @@
|
|||
import { useState } from 'react';
|
||||
import { Stack, Group, Checkbox } from '@mantine/core';
|
||||
import { Button, PasswordInput, SegmentedControl, TextInput, toast } from '/@/renderer/components';
|
||||
import { Checkbox, Group, Stack } from '@mantine/core';
|
||||
import { useForm } from '@mantine/form';
|
||||
import { useFocusTrap } from '@mantine/hooks';
|
||||
import { closeAllModals } from '@mantine/modals';
|
||||
import isElectron from 'is-electron';
|
||||
import { nanoid } from 'nanoid/non-secure';
|
||||
import { AuthenticationResponse } from '/@/renderer/api/types';
|
||||
import { useAuthStoreActions } from '/@/renderer/store';
|
||||
import { ServerType, toServerType } from '/@/renderer/types';
|
||||
import { api } from '/@/renderer/api';
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
import { api } from '/@/renderer/api';
|
||||
import { AuthenticationResponse } from '/@/renderer/api/types';
|
||||
import { Button, PasswordInput, SegmentedControl, TextInput, toast } from '/@/renderer/components';
|
||||
import { useAuthStoreActions } from '/@/renderer/store';
|
||||
import { ServerType, toServerType } from '/@/renderer/types';
|
||||
|
||||
const localSettings = isElectron() ? window.api.localSettings : null;
|
||||
|
||||
const SERVER_TYPES = [
|
||||
{ label: 'Jellyfin', value: ServerType.JELLYFIN },
|
||||
|
|
@ -124,8 +125,8 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
|||
return (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<Stack
|
||||
ref={focusTrapRef}
|
||||
m={5}
|
||||
ref={focusTrapRef}
|
||||
>
|
||||
<SegmentedControl
|
||||
data={SERVER_TYPES}
|
||||
|
|
@ -187,8 +188,8 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
|||
)}
|
||||
<Group position="right">
|
||||
<Button
|
||||
variant="subtle"
|
||||
onClick={onCancel}
|
||||
variant="subtle"
|
||||
>
|
||||
{t('common.cancel', { postProcess: 'titleCase' })}
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -1,25 +1,26 @@
|
|||
import { useState } from 'react';
|
||||
import { Stack, Group } from '@mantine/core';
|
||||
import { Button, Checkbox, PasswordInput, TextInput, toast, Tooltip } from '/@/renderer/components';
|
||||
import { Group, Stack } from '@mantine/core';
|
||||
import { useForm } from '@mantine/form';
|
||||
import { useFocusTrap } from '@mantine/hooks';
|
||||
import { closeAllModals } from '@mantine/modals';
|
||||
import isElectron from 'is-electron';
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RiInformationLine } from 'react-icons/ri';
|
||||
import { AuthenticationResponse, ServerListItem, ServerType } from '/@/renderer/api/types';
|
||||
import { useAuthStoreActions } from '/@/renderer/store';
|
||||
import { api } from '/@/renderer/api';
|
||||
import i18n from '/@/i18n/i18n';
|
||||
import { queryClient } from '/@/renderer/lib/react-query';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
import i18n from '/@/i18n/i18n';
|
||||
import { api } from '/@/renderer/api';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
import { AuthenticationResponse, ServerListItem, ServerType } from '/@/renderer/api/types';
|
||||
import { Button, Checkbox, PasswordInput, TextInput, toast, Tooltip } from '/@/renderer/components';
|
||||
import { queryClient } from '/@/renderer/lib/react-query';
|
||||
import { useAuthStoreActions } from '/@/renderer/store';
|
||||
|
||||
const localSettings = isElectron() ? window.api.localSettings : null;
|
||||
|
||||
interface EditServerFormProps {
|
||||
isUpdate?: boolean;
|
||||
onCancel: () => void;
|
||||
password: string | null;
|
||||
password: null | string;
|
||||
server: ServerListItem;
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ const ModifiedFieldIndicator = () => {
|
|||
);
|
||||
};
|
||||
|
||||
export const EditServerForm = ({ isUpdate, password, server, onCancel }: EditServerFormProps) => {
|
||||
export const EditServerForm = ({ isUpdate, onCancel, password, server }: EditServerFormProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { updateServer } = useAuthStoreActions();
|
||||
const focusTrapRef = useFocusTrap();
|
||||
|
|
@ -127,29 +128,29 @@ export const EditServerForm = ({ isUpdate, password, server, onCancel }: EditSer
|
|||
<form onSubmit={handleSubmit}>
|
||||
<Stack ref={focusTrapRef}>
|
||||
<TextInput
|
||||
required
|
||||
label={t('form.addServer.input', {
|
||||
context: 'name',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
required
|
||||
rightSection={form.isDirty('name') && <ModifiedFieldIndicator />}
|
||||
{...form.getInputProps('name')}
|
||||
/>
|
||||
<TextInput
|
||||
required
|
||||
label={t('form.addServer.input', {
|
||||
context: 'url',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
required
|
||||
rightSection={form.isDirty('url') && <ModifiedFieldIndicator />}
|
||||
{...form.getInputProps('url')}
|
||||
/>
|
||||
<TextInput
|
||||
required
|
||||
label={t('form.addServer.input', {
|
||||
context: 'username',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
required
|
||||
rightSection={form.isDirty('username') && <ModifiedFieldIndicator />}
|
||||
{...form.getInputProps('username')}
|
||||
/>
|
||||
|
|
@ -186,8 +187,8 @@ export const EditServerForm = ({ isUpdate, password, server, onCancel }: EditSer
|
|||
)}
|
||||
<Group position="right">
|
||||
<Button
|
||||
variant="subtle"
|
||||
onClick={onCancel}
|
||||
variant="subtle"
|
||||
>
|
||||
{t('common.cancel', { postProcess: 'titleCase' })}
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
import { useCallback, useState } from 'react';
|
||||
import { Stack, Group, Divider } from '@mantine/core';
|
||||
import { Button, Text, TimeoutButton } from '/@/renderer/components';
|
||||
import { Divider, Group, Stack } from '@mantine/core';
|
||||
import { useDisclosure } from '@mantine/hooks';
|
||||
import isElectron from 'is-electron';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RiDeleteBin2Line, RiEdit2Fill } from 'react-icons/ri';
|
||||
|
||||
import { ServerListItem as ServerItem } from '/@/renderer/api/types';
|
||||
import { Button, Text, TimeoutButton } from '/@/renderer/components';
|
||||
import { EditServerForm } from '/@/renderer/features/servers/components/edit-server-form';
|
||||
import { ServerSection } from '/@/renderer/features/servers/components/server-section';
|
||||
import { useAuthStoreActions } from '/@/renderer/store';
|
||||
import { ServerListItem as ServerItem } from '/@/renderer/api/types';
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
const localSettings = isElectron() ? window.api.localSettings : null;
|
||||
|
||||
interface ServerListItemProps {
|
||||
server: ServerItem;
|
||||
|
|
@ -31,7 +32,7 @@ export const ServerListItem = ({ server }: ServerListItemProps) => {
|
|||
if (!edit && localSettings && server.savePassword) {
|
||||
localSettings
|
||||
.passwordGet(server.id)
|
||||
.then((password: string | null) => {
|
||||
.then((password: null | string) => {
|
||||
if (password) {
|
||||
setSavedPassword(password);
|
||||
} else {
|
||||
|
|
@ -66,9 +67,9 @@ export const ServerListItem = ({ server }: ServerListItemProps) => {
|
|||
>
|
||||
{edit ? (
|
||||
<EditServerForm
|
||||
onCancel={() => editHandlers.toggle()}
|
||||
password={savedPassword}
|
||||
server={server}
|
||||
onCancel={() => editHandlers.toggle()}
|
||||
/>
|
||||
) : (
|
||||
<Stack>
|
||||
|
|
@ -93,13 +94,13 @@ export const ServerListItem = ({ server }: ServerListItemProps) => {
|
|||
<Group grow>
|
||||
<Button
|
||||
leftIcon={<RiEdit2Fill />}
|
||||
onClick={() => handleEdit()}
|
||||
tooltip={{
|
||||
label: t('page.manageServers.editServerDetailsTooltip', {
|
||||
postProcess: 'sentenceCase',
|
||||
}),
|
||||
}}
|
||||
variant="subtle"
|
||||
onClick={() => handleEdit()}
|
||||
>
|
||||
{t('common.edit')}
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
import { ChangeEvent } from 'react';
|
||||
import { Divider, Group, Stack } from '@mantine/core';
|
||||
import { Accordion, Button, ContextModalVars, Switch, Text } from '/@/renderer/components';
|
||||
import { useLocalStorage } from '@mantine/hooks';
|
||||
import { openContextModal } from '@mantine/modals';
|
||||
import isElectron from 'is-electron';
|
||||
import { ChangeEvent } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RiAddFill, RiServerFill } from 'react-icons/ri';
|
||||
|
||||
import { Accordion, Button, ContextModalVars, Switch, Text } from '/@/renderer/components';
|
||||
import { AddServerForm } from '/@/renderer/features/servers/components/add-server-form';
|
||||
import { ServerListItem } from '/@/renderer/features/servers/components/server-list-item';
|
||||
import { useCurrentServer, useServerList } from '/@/renderer/store';
|
||||
import { titleCase } from '/@/renderer/utils';
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
const localSettings = isElectron() ? window.api.localSettings : null;
|
||||
|
||||
export const ServerList = () => {
|
||||
const { t } = useTranslation();
|
||||
|
|
@ -21,7 +22,6 @@ export const ServerList = () => {
|
|||
const handleAddServerModal = () => {
|
||||
openContextModal({
|
||||
innerProps: {
|
||||
// eslint-disable-next-line react/no-unstable-nested-components
|
||||
modalBody: (vars: ContextModalVars) => (
|
||||
<AddServerForm onCancel={() => vars.context.closeModal(vars.id)} />
|
||||
),
|
||||
|
|
@ -73,9 +73,9 @@ export const ServerList = () => {
|
|||
autoFocus
|
||||
compact
|
||||
leftIcon={<RiAddFill size={15} />}
|
||||
onClick={handleAddServerModal}
|
||||
size="sm"
|
||||
variant="filled"
|
||||
onClick={handleAddServerModal}
|
||||
>
|
||||
{t('form.addServer.title', { postProcess: 'titleCase' })}
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { Text } from '/@/renderer/components';
|
||||
|
||||
interface ServerSectionProps {
|
||||
children: React.ReactNode;
|
||||
title: string | React.ReactNode;
|
||||
title: React.ReactNode | string;
|
||||
}
|
||||
|
||||
const Container = styled.div``;
|
||||
|
|
@ -14,7 +15,7 @@ const Section = styled.div`
|
|||
border: 1px dashed var(--generic-border-color);
|
||||
`;
|
||||
|
||||
export const ServerSection = ({ title, children }: ServerSectionProps) => {
|
||||
export const ServerSection = ({ children, title }: ServerSectionProps) => {
|
||||
return (
|
||||
<Container>
|
||||
{React.isValidElement(title) ? title : <Text>{title}</Text>}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue