feat: add max upload size setting to UI & UI improvements (#1646)

* Add preliminar Windows support for both
development and production environments.

Default profile.Data will be set to "C:\ProgramData\memos" on Windows.
Folder will be created if it does not exist, as this behavior is
expected for Windows applications.

System service installation can be achieved with third-party tools,
explained in docs/windows-service.md.

Not sure if it's worth using https://github.com/kardianos/service
to make service support built-in.

This could be a nice addition alongside #1583 (add Windows artifacts)

* feat: improve Windows support

- Fix local file storage path handling on Windows

- Improve Windows dev script

* feat: add max upload size setting to UI & more

- feat: add max upload size setting to UI

- feat: max upload size setting is checked on UI during upload,
but also enforced by the server

- fix: overflowing mobile layout for Create SSO, Create Storage
and other Settings dialogs

- feat: add HelpButton component with some links to docs were appropriate

- remove LearnMore component in favor of HelpButton

- refactor: change some if/else to switch statements

- refactor: inline some err == nil checks

! Existing databases without the new setting 'max-upload-size-mib'
will show an upload error, but this can be user-fixed by simply
setting the value on system settings UI.

* improvements requested by @boojack
This commit is contained in:
Lincoln Nogueira
2023-05-13 11:27:28 -03:00
committed by GitHub
parent 5c5199920e
commit 96021e518a
20 changed files with 591 additions and 204 deletions

View File

@ -6,7 +6,7 @@ import * as api from "@/helpers/api";
import { generateDialog } from "./Dialog";
import Icon from "./Icon";
import RequiredBadge from "./RequiredBadge";
import LearnMore from "./LearnMore";
import HelpButton from "./kit/HelpButton";
interface Props extends DialogProps {
storage?: ObjectStorage;
@ -106,15 +106,12 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {
return (
<>
<div className="dialog-header-container">
<p className="title-text">
{t("setting.storage-section." + (isCreating ? "create" : "update") + "-storage")}
<LearnMore className="ml-2" url="https://usememos.com/docs/storage" />
</p>
<button className="btn close-btn" onClick={handleCloseBtnClick}>
<span className="title-text ml-auto">{t("setting.storage-section." + (isCreating ? "create" : "update") + "-storage")}</span>
<button className="btn close-btn ml-auto" onClick={handleCloseBtnClick}>
<Icon.X />
</button>
</div>
<div className="dialog-content-container">
<div className="dialog-content-container min-w-[19rem]">
<Typography className="!mb-1" level="body2">
{t("common.name")}
<RequiredBadge />
@ -186,13 +183,12 @@ const CreateStorageServiceDialog: React.FC<Props> = (props: Props) => {
onChange={(e) => setPartialS3Config({ bucket: e.target.value })}
fullWidth
/>
<Typography className="!mb-1" level="body2">
{t("setting.storage-section.path")}
</Typography>
<Typography className="!mb-1" level="body2">
<p className="text-sm text-gray-400 ml-1">{t("setting.storage-section.path-description")}</p>
<LearnMore className="ml-2" url="https://usememos.com/docs/local-storage" />
</Typography>
<div className="flex flex-row">
<Typography className="!mb-1" level="body2">
{t("setting.storage-section.path")}
</Typography>
<HelpButton text={t("setting.storage-section.path-description")} url="https://usememos.com/docs/local-storage" />
</div>
<Input
className="mb-2"
placeholder={t("setting.storage-section.path-placeholder") + "/{year}/{month}/{filename}"}