diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..dcf8960 --- /dev/null +++ b/.env.development @@ -0,0 +1,8 @@ +VITE_API_BASE_URL=http://localhost:8080 +VITE_OAUTH_CLIENT_ID=stalwart-webui +#VITE_ACCESS_TOKEN=OPEN_SESAME +VITE_OAUTH_SCOPES= + +# Dev-only debug logging (any non-empty value enables; only active when DEV=true) +VITE_DEBUG_JMAP=true +VITE_DEBUG_FORMS=true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5434166 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +name: Build and Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-node@v6 + with: + node-version: 22 + cache: npm + + - run: npm ci + + - run: npm run typecheck + + - run: npx eslint src/ + + - run: npx vitest run + + - run: npm run build + + - name: Create webui.zip + working-directory: dist + run: zip -r ../webui.zip . + + - name: Upload release asset + uses: softprops/action-gh-release@v3 + with: + files: webui.zip diff --git a/.gitignore b/.gitignore index ad67955..4d704be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,29 @@ -# Generated by Cargo -# will have compiled files and executables -debug -target +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* -# These are backup files generated by rustfmt -**/*.rs.bk +node_modules +dist +dist-ssr +*.local -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb - -# Generated by cargo mutants -# Contains mutation testing data -**/mutants.out*/ - -# RustRover -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? +.ignore +scripts/ +*.md +!README.md +/SPEC-* diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..9db28a2 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "printWidth": 120 +} diff --git a/README.md b/README.md index 449b42b..2d0adbb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,149 @@ -# webui -Stalwart WebUI +
+
+
+
+
+
+## Get Started
+
+Stalwart WebUI is included with Stalwart Mail Server, to install Stalwart Mail Server on your server by following the instructions for your platform:
+
+- [Linux / MacOS](https://stalw.art/docs/install/linux)
+- [Windows](https://stalw.art/docs/install/windows)
+- [Docker](https://stalw.art/docs/install/docker)
+
+All documentation is available at [stalw.art/docs/get-started](https://stalw.art/docs/get-started).
+
+## Getting started
+
+Prerequisites:
+
+- Node.js 18 or later
+- A running Stalwart instance (for JMAP API calls)
+
+Install dependencies:
+
+```
+npm install
+```
+
+### Environment variables
+
+Configuration is done through Vite environment variables. Copy or edit `.env.development` in the project root:
+
+```
+VITE_API_BASE_URL=http://localhost:443
+VITE_OAUTH_CLIENT_ID=stalwart-webui
+VITE_ACCESS_TOKEN=
+VITE_OAUTH_SCOPES=
+```
+
+| Variable | Description |
+|---|---|
+| `VITE_API_BASE_URL` | URL of the Stalwart server. Used for all API requests during development. In production builds (when empty or unset) requests are relative to the current origin. |
+| `VITE_OAUTH_CLIENT_ID` | OAuth 2.0 client ID. Defaults to `stalwart-webui`. |
+| `VITE_ACCESS_TOKEN` | When set, skips the OAuth flow entirely and uses this token for all requests. Useful for local development and testing. |
+| `VITE_OAUTH_SCOPES` | Optional OAuth scopes. Omitted from the authorization request when empty. |
+
+### Bypassing OAuth for development
+
+Set `VITE_ACCESS_TOKEN` to a valid bearer token to skip the login page and go straight to the admin panel. You can obtain a token from the Stalwart server's token endpoint or use an API key:
+
+```
+VITE_ACCESS_TOKEN=your-bearer-token-here
+```
+
+### Running the dev server
+
+```
+npm run dev
+```
+
+This starts Vite's development server with hot module replacement, typically at `http://localhost:5173`.
+
+## Testing
+
+Run the unit tests (Vitest):
+
+```
+npm test
+```
+
+Run tests in watch mode:
+
+```
+npm run test:watch
+```
+
+## Building for production
+
+```
+npm run build
+```
+
+This runs the TypeScript compiler followed by Vite's production build. Output
+goes to the `dist/` directory.
+
+To preview the production build locally:
+
+```
+npm run preview
+```
+
+## Support
+
+If you are having problems running Stalwart Mail Server, you found a bug or just have a question,
+do not hesitate to reach us on [Github Discussions](https://github.com/stalwartlabs/mail-server/discussions),
+[Reddit](https://www.reddit.com/r/stalwartlabs), [Discord](https://discord.gg/aVQr3jF8jd) or [Matrix](https://matrix.to/#/#stalwart:matrix.org).
+Additionally you may purchase a subscription to obtain priority support from Stalwart Labs LLC
+
+## License
+
+This project is dual-licensed under the **GNU Affero General Public License v3.0** (AGPL-3.0; as published by the Free Software Foundation) and the **Stalwart Enterprise License v1 (SELv1)**:
+
+- The [GNU Affero General Public License v3.0](./LICENSES/AGPL-3.0-only.txt) is a free software license that ensures your freedom to use, modify, and distribute the software, with the condition that any modified versions of the software must also be distributed under the same license.
+- The [Stalwart Enterprise License v1 (SELv1)](./LICENSES/LicenseRef-SEL.txt) is a proprietary license designed for commercial use. It offers additional features and greater flexibility for businesses that do not wish to comply with the AGPL-3.0 license requirements.
+
+Each file in this project contains a license notice at the top, indicating the applicable license(s). The license notice follows the [REUSE guidelines](https://reuse.software/) to ensure clarity and consistency. The full text of each license is available in the [LICENSES](./LICENSES/) directory.
+
+## Copyright
+
+Copyright (C) 2024, Stalwart Labs LLC
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..2febeec
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+set -euo pipefail
+
+npm ci
+npm run build
+
+mkdir -p .ignore
+rm -f .ignore/webui.zip
+cd dist && zip -r ../.ignore/webui.zip .
diff --git a/eslint.config.js b/eslint.config.js
new file mode 100644
index 0000000..aafe486
--- /dev/null
+++ b/eslint.config.js
@@ -0,0 +1,31 @@
+import js from '@eslint/js'
+import globals from 'globals'
+import reactHooks from 'eslint-plugin-react-hooks'
+import reactRefresh from 'eslint-plugin-react-refresh'
+import tseslint from 'typescript-eslint'
+import prettierConfig from 'eslint-config-prettier'
+import { defineConfig, globalIgnores } from 'eslint/config'
+
+export default defineConfig([
+ globalIgnores(['dist']),
+ {
+ files: ['**/*.{ts,tsx}'],
+ extends: [
+ js.configs.recommended,
+ tseslint.configs.recommended,
+ reactHooks.configs.flat.recommended,
+ reactRefresh.configs.vite,
+ prettierConfig,
+ ],
+ languageOptions: {
+ ecmaVersion: 2020,
+ globals: globals.browser,
+ },
+ },
+ {
+ files: ['src/components/ui/**/*.{ts,tsx}'],
+ rules: {
+ 'react-refresh/only-export-components': 'off',
+ },
+ },
+])
diff --git a/img/logo-red.svg b/img/logo-red.svg
new file mode 100644
index 0000000..eb8888a
--- /dev/null
+++ b/img/logo-red.svg
@@ -0,0 +1,25 @@
+
\ No newline at end of file
diff --git a/img/screencast-setup.gif b/img/screencast-setup.gif
new file mode 100644
index 0000000..3d79f01
Binary files /dev/null and b/img/screencast-setup.gif differ
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..dc1ddff
--- /dev/null
+++ b/index.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+ + {t('bootstrap.welcomeSubtitle', "Let's get your server set up.")} +
+{generalError}
++ {hasCredentials + ? t( + 'bootstrap.credentialsCreated', + 'Your administrator account has been created. Write these down now: the password will not be shown again.', + ) + : t('bootstrap.configuredSuccessfully', 'Stalwart has been configured successfully.')} +
+{value}
+
+ + {t('bootstrap.nextStepLabel', 'Next step:')}{' '} + {t( + 'bootstrap.nextStepBody', + 'restart Stalwart for the new configuration to take effect. Once restarted, sign in with the credentials above to continue administering your server.', + )} +
+{formSubtitle}
} +{generalError}
+{t('enterprise.featureDisabled', 'This feature requires an Enterprise license.')}
+Unsupported field type
; + } + } + })(); + + if (isSelfContained) { + return ( +{error}
} +{error}
} +