chore: merge with main

This commit is contained in:
Zack Fu Zi Xiang 2024-03-07 16:23:19 +08:00
commit da509392e9
No known key found for this signature in database
122 changed files with 1776 additions and 1095 deletions

104
.github/actions/flutter_build/action.yml vendored Normal file
View File

@ -0,0 +1,104 @@
name: Flutter Integration Test
description: Run integration tests for AppFlowy
inputs:
os:
description: "The operating system to run the tests on"
required: true
flutter_version:
description: "The version of Flutter to use"
required: true
rust_toolchain:
description: "The version of Rust to use"
required: true
cargo_make_version:
description: "The version of cargo-make to use"
required: true
rust_target:
description: "The target to build for"
required: true
flutter_profile:
description: "The profile to build with"
required: true
runs:
using: "composite"
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Rust toolchain
id: rust_toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ inputs.rust_toolchain }}
target: ${{ inputs.rust_target }}
override: true
profile: minimal
- name: Export pub environment variables and add to PATH
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
echo "PUB_CACHE=$LOCALAPPDATA\\Pub\\Cache" >> $GITHUB_ENV
fi
shell: bash
- name: Install flutter
id: flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version: ${{ inputs.flutter_version }}
cache: true
- uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ inputs.os }}
workspaces: |
frontend/rust-lib
cache-all-crates: true
- uses: taiki-e/install-action@v2
with:
tool: cargo-make@${{ inputs.cargo_make_version }}, duckscript_cli
- name: Install prerequisites
working-directory: frontend
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub
sudo wget -qO /etc/apt/sources.list.d/dart_stable.list https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list
sudo apt-get update
sudo apt-get install -y dart curl build-essential libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev keybinder-3.0 libnotify-dev
elif [ "$RUNNER_OS" == "Windows" ]; then
vcpkg integrate install
elif [ "$RUNNER_OS" == "macOS" ]; then
echo 'do nothing'
fi
cargo make appflowy-flutter-deps-tools
shell: bash
- name: Build AppFlowy
working-directory: frontend
run: cargo make --profile ${{ inputs.flutter_profile }} appflowy-core-dev
shell: bash
- name: Run code generation
working-directory: frontend
run: cargo make code_generation
shell: bash
- name: Flutter Analyzer
working-directory: frontend/appflowy_flutter
run: flutter analyze .
shell: bash
- name: Compress appflowy_flutter
run: tar -czf appflowy_flutter.tar.gz frontend/appflowy_flutter
shell: bash
- uses: actions/upload-artifact@v4
with:
name: ${{ github.run_id }}-${{ matrix.os }}
path: appflowy_flutter.tar.gz

View File

@ -0,0 +1,78 @@
name: Flutter Integration Test
description: Run integration tests for AppFlowy
inputs:
test_path:
description: "The path to the integration test file"
required: true
flutter_version:
description: "The version of Flutter to use"
required: true
rust_toolchain:
description: "The version of Rust to use"
required: true
cargo_make_version:
description: "The version of cargo-make to use"
required: true
rust_target:
description: "The target to build for"
required: true
runs:
using: "composite"
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Rust toolchain
id: rust_toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ inputs.RUST_TOOLCHAIN }}
target: ${{ inputs.rust_target }}
override: true
profile: minimal
- name: Install flutter
id: flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version: ${{ inputs.flutter_version }}
cache: true
- uses: taiki-e/install-action@v2
with:
tool: cargo-make@${{ inputs.cargo_make_version }}
- name: Install prerequisites
working-directory: frontend
run: |
sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub
sudo wget -qO /etc/apt/sources.list.d/dart_stable.list https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list
sudo apt-get update
sudo apt-get install -y dart curl build-essential libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev keybinder-3.0 libnotify-dev network-manager
shell: bash
- name: Enable Flutter Desktop
run: |
flutter config --enable-linux-desktop
shell: bash
- uses: actions/download-artifact@v4
with:
name: ${{ github.run_id }}-ubuntu-latest
- name: Uncompressed appflowy_flutter
run: tar -xf appflowy_flutter.tar.gz
shell: bash
- name: Run Flutter integration tests
working-directory: frontend/appflowy_flutter
run: |
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
sudo apt-get install network-manager
flutter test ${{ inputs.test_path }} -d Linux --coverage
shell: bash

View File

@ -32,28 +32,21 @@ concurrency:
cancel-in-progress: true
jobs:
prepare:
prepare-linux:
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
include:
- os: ubuntu-latest
flutter_profile: development-linux-x86_64
target: x86_64-unknown-linux-gnu
- os: macos-latest
flutter_profile: development-mac-x86_64
target: x86_64-apple-darwin
- os: windows-latest
flutter_profile: development-windows-x86
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
# the following step is required to avoid running out of space
- name: Maximize build space
if: matrix.os == 'ubuntu-latest'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
@ -63,80 +56,70 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Rust toolchain
id: rust_toolchain
uses: actions-rs/toolchain@v1
- name: Flutter build
uses: ./.github/actions/flutter_build
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
target: ${{ matrix.target }}
override: true
profile: minimal
os: ${{ matrix.os }}
flutter_version: ${{ env.FLUTTER_VERSION }}
rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
rust_target: ${{ matrix.target }}
flutter_profile: ${{ matrix.flutter_profile }}
- name: Export pub environment variables and add to PATH
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
echo "PUB_CACHE=$LOCALAPPDATA\\Pub\\Cache" >> $GITHUB_ENV
fi
shell: bash
prepare-windows:
if: github.event.pull_request.draft != true
strategy:
fail-fast: true
matrix:
os: [windows-latest]
include:
- os: windows-latest
flutter_profile: development-windows-x86
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
- name: Install flutter
id: flutter
uses: subosito/flutter-action@v2
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Flutter build
uses: ./.github/actions/flutter_build
with:
channel: "stable"
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
os: ${{ matrix.os }}
flutter_version: ${{ env.FLUTTER_VERSION }}
rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
rust_target: ${{ matrix.target }}
flutter_profile: ${{ matrix.flutter_profile }}
- uses: Swatinem/rust-cache@v2
prepare-macos:
if: github.event.pull_request.draft != true
strategy:
fail-fast: true
matrix:
os: [macos-latest]
include:
- os: macos-latest
flutter_profile: development-mac-x86_64
target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Flutter build
uses: ./.github/actions/flutter_build
with:
prefix-key: ${{ matrix.os }}
workspaces: |
frontend/rust-lib
cache-all-crates: true
- uses: taiki-e/install-action@v2
with:
tool: cargo-make@${{ env.CARGO_MAKE_VERSION }}, duckscript_cli
- name: Install prerequisites
working-directory: frontend
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub
sudo wget -qO /etc/apt/sources.list.d/dart_stable.list https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list
sudo apt-get update
sudo apt-get install -y dart curl build-essential libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev keybinder-3.0 libnotify-dev
elif [ "$RUNNER_OS" == "Windows" ]; then
vcpkg integrate install
elif [ "$RUNNER_OS" == "macOS" ]; then
echo 'do nothing'
fi
cargo make appflowy-flutter-deps-tools
shell: bash
- name: Build AppFlowy
working-directory: frontend
run: cargo make --profile ${{ matrix.flutter_profile }} appflowy-core-dev
- name: Run code generation
working-directory: frontend
run: cargo make code_generation
- name: Flutter Analyzer
working-directory: frontend/appflowy_flutter
run: flutter analyze .
- name: Compress appflowy_flutter
run: |
tar -czf appflowy_flutter.tar.gz frontend/appflowy_flutter
- uses: actions/upload-artifact@v4
with:
name: ${{ github.run_id }}-${{ matrix.os }}
path: appflowy_flutter.tar.gz
os: ${{ matrix.os }}
flutter_version: ${{ env.FLUTTER_VERSION }}
rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
rust_target: ${{ matrix.target }}
flutter_profile: ${{ matrix.flutter_profile }}
unit_test:
needs: [prepare]
needs: [prepare-linux]
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
@ -227,7 +210,7 @@ jobs:
shell: bash
cloud_integration_test:
needs: [prepare]
needs: [prepare-linux]
strategy:
fail-fast: false
matrix:
@ -314,8 +297,9 @@ jobs:
flutter test integration_test/cloud/cloud_runner.dart -d Linux --coverage
shell: bash
integration_test:
needs: [prepare]
# split the integration tests into different machines to minimize the time
integration_test_1:
needs: [prepare-linux]
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
@ -323,158 +307,65 @@ jobs:
os: [ubuntu-latest]
include:
- os: ubuntu-latest
flutter_profile: development-linux-x86_64
target: x86_64-unknown-linux-gnu
target: 'x86_64-unknown-linux-gnu'
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Rust toolchain
id: rust_toolchain
uses: actions-rs/toolchain@v1
- name: Flutter Integration Test 1
uses: ./.github/actions/flutter_integration_test
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
target: ${{ matrix.target }}
override: true
profile: minimal
test_path: integration_test/desktop_runner_1.dart
flutter_version: ${{ env.FLUTTER_VERSION }}
rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
rust_target: ${{ matrix.target }}
- name: Install flutter
id: flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- uses: taiki-e/install-action@v2
with:
tool: cargo-make@${{ env.CARGO_MAKE_VERSION }}
- name: Install prerequisites
working-directory: frontend
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub
sudo wget -qO /etc/apt/sources.list.d/dart_stable.list https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list
sudo apt-get update
sudo apt-get install -y dart curl build-essential libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev keybinder-3.0 libnotify-dev
fi
shell: bash
- name: Enable Flutter Desktop
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
flutter config --enable-linux-desktop
elif [ "$RUNNER_OS" == "macOS" ]; then
flutter config --enable-macos-desktop
elif [ "$RUNNER_OS" == "Windows" ]; then
git config --system core.longpaths true
flutter config --enable-windows-desktop
fi
shell: bash
- uses: actions/download-artifact@v4
with:
name: ${{ github.run_id }}-${{ matrix.os }}
- name: Uncompressed appflowy_flutter
run: tar -xf appflowy_flutter.tar.gz
- name: Run flutter pub get
working-directory: frontend
run: cargo make pub_get
- name: Run Flutter integration tests
working-directory: frontend/appflowy_flutter
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
sudo apt-get install network-manager
flutter test integration_test/runner.dart -d Linux --coverage
elif [ "$RUNNER_OS" == "macOS" ]; then
flutter test integration_test/runner.dart -d macOS --coverage
elif [ "$RUNNER_OS" == "Windows" ]; then
flutter test integration_test/runner.dart -d Windows --coverage
fi
shell: bash
build:
needs: [prepare]
integration_test_2:
needs: [prepare-linux]
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
include:
- os: ubuntu-latest
flutter_profile: development-linux-x86_64
target: x86_64-unknown-linux-gnu
- os: macos-latest
flutter_profile: development-mac-x86_64
target: x86_64-apple-darwin
- os: windows-latest
flutter_profile: development-windows-x86
target: x86_64-pc-windows-msvc
target: 'x86_64-unknown-linux-gnu'
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Rust toolchain
id: rust_toolchain
uses: actions-rs/toolchain@v1
- name: Flutter Integration Test 2
uses: ./.github/actions/flutter_integration_test
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
target: ${{ matrix.target }}
override: true
profile: minimal
test_path: integration_test/desktop_runner_2.dart
flutter_version: ${{ env.FLUTTER_VERSION }}
rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
rust_target: ${{ matrix.target }}
- name: Install flutter
id: flutter
uses: subosito/flutter-action@v2
integration_test_3:
needs: [prepare-linux]
if: github.event.pull_request.draft != true
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
include:
- os: ubuntu-latest
target: 'x86_64-unknown-linux-gnu'
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Flutter Integration Test 3
uses: ./.github/actions/flutter_integration_test
with:
channel: "stable"
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- uses: taiki-e/install-action@v2
with:
tool: cargo-make@${{ env.CARGO_MAKE_VERSION }}
- name: Install prerequisites
working-directory: frontend
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub
sudo wget -qO /etc/apt/sources.list.d/dart_stable.list https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list
sudo apt-get update
sudo apt-get install -y dart curl build-essential libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev keybinder-3.0 libnotify-dev
fi
shell: bash
- name: Enable Flutter Desktop
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
flutter config --enable-linux-desktop
elif [ "$RUNNER_OS" == "macOS" ]; then
flutter config --enable-macos-desktop
elif [ "$RUNNER_OS" == "Windows" ]; then
git config --system core.longpaths true
flutter config --enable-windows-desktop
fi
shell: bash
- uses: actions/download-artifact@v4
with:
name: ${{ github.run_id }}-${{ matrix.os }}
- name: Uncompressed appflowy_flutter
run: tar -xf appflowy_flutter.tar.gz
- name: Build flutter product
working-directory: frontend
run: |
cargo make --profile ${{ matrix.flutter_profile }} appflowy-make-product-dev
test_path: integration_test/desktop_runner_3.dart
flutter_version: ${{ env.FLUTTER_VERSION }}
rust_toolchain: ${{ env.RUST_TOOLCHAIN }}
cargo_make_version: ${{ env.CARGO_MAKE_VERSION }}
rust_target: ${{ matrix.target }}

View File

@ -25,6 +25,22 @@ jobs:
test-on-ubuntu:
runs-on: ubuntu-latest
steps:
# - name: Maximize build space
# uses: easimon/maximize-build-space@master
# with:
# root-reserve-mb: 2048
# swap-size-mb: 1024
# remove-dotnet: 'true'
#
# # the following step is required to avoid running out of space
# - name: Maximize build space
# run: |
# sudo rm -rf /usr/share/dotnet
# sudo rm -rf /opt/ghc
# sudo rm -rf "/usr/local/share/boost"
# sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# sudo docker image prune --all --force
- name: Checkout source code
uses: actions/checkout@v4
@ -86,3 +102,8 @@ jobs:
- name: clippy rust-lib
run: cargo clippy --all-targets -- -D warnings
working-directory: frontend/rust-lib
- name: Clean up Docker images
run: |
docker image prune -af
docker volume prune -f

View File

@ -25,32 +25,33 @@ jobs:
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
env:
CI: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Maximize build space (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo docker image prune --all --force
sudo rm -rf /opt/hostedtoolcache/codeQL
sudo rm -rf ${GITHUB_WORKSPACE}/.git
sudo rm -rf $ANDROID_HOME/ndk
- name: setup node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Rust Dependencies
uses: Swatinem/rust-cache@v2
- name: setup pnpm
uses: pnpm/action-setup@v2
with:
key: rust-dependencies-${{ runner.os }}
workspaces: |
frontend/rust-lib
frontend/appflowy_tauri/src-tauri
- name: Cache Node.js dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ runner.os }}
- name: Cache node_modules
uses: actions/cache@v2
with:
path: frontend/appflowy_tauri/node_modules
key: node-modules-${{ runner.os }}
version: ${{ env.PNPM_VERSION }}
- name: Install Rust toolchain
id: rust_toolchain
@ -60,15 +61,23 @@ jobs:
override: true
profile: minimal
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: "./frontend/appflowy_tauri/src-tauri -> target"
- name: Node_modules cache
uses: actions/cache@v2
with:
path: frontend/appflowy_tauri/node_modules
key: node-modules-${{ runner.os }}
- name: install dependencies (windows only)
if: matrix.platform == 'windows-latest'
working-directory: frontend
run: |
cargo install --force cargo-make
cargo install --force duckscript_cli
vcpkg integrate install
cargo make appflowy-tauri-deps-tools
npm install -g pnpm@${{ env.PNPM_VERSION }}
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
@ -76,35 +85,29 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
cargo install --force cargo-make
cargo make appflowy-tauri-deps-tools
npm install -g pnpm@${{ env.PNPM_VERSION }}
- name: install dependencies (macOS only)
if: matrix.platform == 'macos-latest'
- name: install cargo-make
working-directory: frontend
run: |
cargo install --force cargo-make
cargo make appflowy-tauri-deps-tools
npm install -g pnpm@${{ env.PNPM_VERSION }}
- name: Build
- name: install frontend dependencies
working-directory: frontend/appflowy_tauri
run: |
mkdir dist
pnpm install
cargo make --cwd .. tauri_build
- name: frontend tests and linting
working-directory: frontend/appflowy_tauri
run: |
pnpm test
pnpm test:errors
- name: Check for uncommitted changes
run: |
diff_files=$(git status --porcelain)
if [ -n "$diff_files" ]; then
echo "There are uncommitted changes in the working tree. Please commit them before pushing."
exit 1
fi
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tauriScript: pnpm tauri
projectPath: frontend/appflowy_tauri

153
.github/workflows/tauri_release.yml vendored Normal file
View File

@ -0,0 +1,153 @@
name: Publish Tauri Release
on:
workflow_dispatch:
inputs:
branch:
description: 'The branch to release'
required: true
default: 'main'
version:
description: 'The version to release'
required: true
default: '0.0.0'
env:
NODE_VERSION: "18.16.0"
PNPM_VERSION: "8.5.0"
RUST_TOOLCHAIN: "1.75"
jobs:
publish-tauri:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
settings:
- platform: windows-latest
args: "--verbose"
target: "windows-x86_64"
- platform: macos-latest
args: "--target x86_64-apple-darwin"
target: "macos-x86_64"
- platform: ubuntu-latest
args: "--target x86_64-unknown-linux-gnu"
target: "linux-x86_64"
runs-on: ${{ matrix.settings.platform }}
env:
CI: true
PACKAGE_PREFIX: AppFlowy_Tauri-${{ github.event.inputs.version }}-${{ matrix.settings.target }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Maximize build space (ubuntu only)
if: matrix.settings.platform == 'ubuntu-latest'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo docker image prune --all --force
sudo rm -rf /opt/hostedtoolcache/codeQL
sudo rm -rf ${GITHUB_WORKSPACE}/.git
sudo rm -rf $ANDROID_HOME/ndk
- name: setup node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Install Rust toolchain
id: rust_toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
profile: minimal
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: "./frontend/appflowy_tauri/src-tauri -> target"
- name: install dependencies (windows only)
if: matrix.settings.platform == 'windows-latest'
working-directory: frontend
run: |
cargo install --force duckscript_cli
vcpkg integrate install
- name: install dependencies (ubuntu only)
if: matrix.settings.platform == 'ubuntu-latest'
working-directory: frontend
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- name: install cargo-make
working-directory: frontend
run: |
cargo install --force cargo-make
cargo make appflowy-tauri-deps-tools
- name: install frontend dependencies
working-directory: frontend/appflowy_tauri
run: |
mkdir dist
pnpm install
pnpm exec node scripts/update_version.cjs ${{ github.event.inputs.version }}
cargo make --cwd .. tauri_build
- uses: tauri-apps/tauri-action@dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPLE_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.MACOS_TEAM_ID }}
APPLE_ID: ${{ secrets.MACOS_NOTARY_USER }}
APPLE_TEAM_ID: ${{ secrets.MACOS_TEAM_ID }}
APPLE_PASSWORD: ${{ secrets.MACOS_NOTARY_PWD }}
CI: true
with:
args: ${{ matrix.settings.args }}
appVersion: ${{ github.event.inputs.version }}
tauriScript: pnpm tauri
projectPath: frontend/appflowy_tauri
- name: Upload EXE package(windows only)
uses: actions/upload-artifact@v4
if: matrix.settings.platform == 'windows-latest'
with:
name: ${{ env.PACKAGE_PREFIX }}.exe
path: frontend/appflowy_tauri/src-tauri/target/release/bundle/nsis/AppFlowy_${{ github.event.inputs.version }}_x64-setup.exe
- name: Upload DMG package(macos only)
uses: actions/upload-artifact@v4
if: matrix.settings.platform == 'macos-latest'
with:
name: ${{ env.PACKAGE_PREFIX }}.dmg
path: frontend/appflowy_tauri/src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/AppFlowy_${{ github.event.inputs.version }}_x64.dmg
- name: Upload Deb package(ubuntu only)
uses: actions/upload-artifact@v4
if: matrix.settings.platform == 'ubuntu-latest'
with:
name: ${{ env.PACKAGE_PREFIX }}.deb
path: frontend/appflowy_tauri/src-tauri/target/x86_64-unknown-linux-gnu/release/bundle/deb/app-flowy_${{ github.event.inputs.version }}_amd64.deb
- name: Upload AppImage package(ubuntu only)
uses: actions/upload-artifact@v4
if: matrix.settings.platform == 'ubuntu-latest'
with:
name: ${{ env.PACKAGE_PREFIX }}.AppImage
path: frontend/appflowy_tauri/src-tauri/target/x86_64-unknown-linux-gnu/release/bundle/appimage/app-flowy_${{ github.event.inputs.version }}_amd64.AppImage

View File

@ -16,7 +16,7 @@ void main() {
await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid);
await tester.tapCreateRowButtonInGrid();
// The initial number of rows is 3
// 3 initial rows + 1 created
await tester.assertNumberOfRowsInGridPage(4);
await tester.pumpAndSettle();
});
@ -31,9 +31,8 @@ void main() {
await tester.tapCreateRowButtonInRowMenuOfGrid();
// The initial number of rows is 3
// 3 initial rows + 1 created
await tester.assertNumberOfRowsInGridPage(4);
await tester.assertRowCountInGridPage(4);
await tester.pumpAndSettle();
});
@ -48,9 +47,8 @@ void main() {
await tester.tapRowMenuButtonInGrid();
await tester.tapDeleteOnRowMenu();
// The initial number of rows is 3
// 3 initial rows - 1 deleted
await tester.assertNumberOfRowsInGridPage(2);
await tester.assertRowCountInGridPage(2);
await tester.pumpAndSettle();
});
@ -60,7 +58,6 @@ void main() {
await tester.tapGoButton();
await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Grid);
await tester.assertRowCountInGridPage(3);
await tester.pumpAndSettle();
});

View File

@ -1,68 +0,0 @@
import 'desktop/uncategorized/appearance_settings_test.dart' as appearance_test_runner;
import 'desktop/board/board_test_runner.dart' as board_test_runner;
import 'desktop/database/database_calendar_test.dart' as database_calendar_test;
import 'desktop/database/database_cell_test.dart' as database_cell_test;
import 'desktop/database/database_field_settings_test.dart'
as database_field_settings_test;
import 'desktop/database/database_field_test.dart' as database_field_test;
import 'desktop/database/database_filter_test.dart' as database_filter_test;
import 'desktop/database/database_row_page_test.dart' as database_row_page_test;
import 'desktop/database/database_row_test.dart' as database_row_test;
import 'desktop/database/database_setting_test.dart' as database_setting_test;
import 'desktop/database/database_share_test.dart' as database_share_test;
import 'desktop/database/database_sort_test.dart' as database_sort_test;
import 'desktop/database/database_view_test.dart' as database_view_test;
import 'desktop/document/document_test_runner.dart' as document_test_runner;
import 'desktop/uncategorized/emoji_shortcut_test.dart' as emoji_shortcut_test;
import 'desktop/uncategorized/empty_test.dart' as first_test;
import 'desktop/uncategorized/hotkeys_test.dart' as hotkeys_test;
import 'desktop/uncategorized/import_files_test.dart' as import_files_test;
import 'desktop/settings/settings_runner.dart' as settings_test_runner;
import 'desktop/uncategorized/share_markdown_test.dart' as share_markdown_test;
import 'desktop/sidebar/sidebar_test_runner.dart' as sidebar_test_runner;
import 'desktop/uncategorized/switch_folder_test.dart' as switch_folder_test;
import 'desktop/uncategorized/tabs_test.dart' as tabs_test;
Future<void> runIntegrationOnDesktop() async {
// This test must be run first, otherwise the CI will fail.
first_test.main();
switch_folder_test.main();
share_markdown_test.main();
import_files_test.main();
// Document integration tests
document_test_runner.startTesting();
// Sidebar integration tests
sidebar_test_runner.startTesting();
// Board integration test
board_test_runner.startTesting();
// Database integration tests
database_cell_test.main();
database_field_test.main();
database_field_settings_test.main();
database_share_test.main();
database_row_page_test.main();
database_row_test.main();
database_setting_test.main();
database_filter_test.main();
database_sort_test.main();
database_view_test.main();
database_calendar_test.main();
// Tabs
tabs_test.main();
// Others
hotkeys_test.main();
emoji_shortcut_test.main();
// Appearance integration test
appearance_test_runner.main();
// User settings
settings_test_runner.main();
}

View File

@ -0,0 +1,21 @@
import 'package:integration_test/integration_test.dart';
import 'desktop/document/document_test_runner.dart' as document_test_runner;
import 'desktop/uncategorized/empty_test.dart' as first_test;
import 'desktop/uncategorized/switch_folder_test.dart' as switch_folder_test;
Future<void> main() async {
await runIntegration1OnDesktop();
}
Future<void> runIntegration1OnDesktop() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
// This test must be run first, otherwise the CI will fail.
first_test.main();
switch_folder_test.main();
document_test_runner.startTesting();
// DON'T add more tests here. This is the first test runner for desktop.
}

View File

@ -0,0 +1,40 @@
import 'package:integration_test/integration_test.dart';
import 'desktop/database/database_calendar_test.dart' as database_calendar_test;
import 'desktop/database/database_cell_test.dart' as database_cell_test;
import 'desktop/database/database_field_settings_test.dart'
as database_field_settings_test;
import 'desktop/database/database_field_test.dart' as database_field_test;
import 'desktop/database/database_filter_test.dart' as database_filter_test;
import 'desktop/database/database_row_page_test.dart' as database_row_page_test;
import 'desktop/database/database_row_test.dart' as database_row_test;
import 'desktop/database/database_setting_test.dart' as database_setting_test;
import 'desktop/database/database_share_test.dart' as database_share_test;
import 'desktop/database/database_sort_test.dart' as database_sort_test;
import 'desktop/database/database_view_test.dart' as database_view_test;
import 'desktop/uncategorized/empty_test.dart' as first_test;
Future<void> main() async {
await runIntegration2OnDesktop();
}
Future<void> runIntegration2OnDesktop() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
// This test must be run first, otherwise the CI will fail.
first_test.main();
database_cell_test.main();
database_field_test.main();
database_field_settings_test.main();
database_share_test.main();
database_row_page_test.main();
database_row_test.main();
database_setting_test.main();
database_filter_test.main();
database_sort_test.main();
database_view_test.main();
database_calendar_test.main();
// DON'T add more tests here. This is the second test runner for desktop.
}

View File

@ -0,0 +1,36 @@
import 'package:integration_test/integration_test.dart';
import 'desktop/board/board_test_runner.dart' as board_test_runner;
import 'desktop/settings/settings_runner.dart' as settings_test_runner;
import 'desktop/sidebar/sidebar_test_runner.dart' as sidebar_test_runner;
import 'desktop/uncategorized/appearance_settings_test.dart'
as appearance_test_runner;
import 'desktop/uncategorized/emoji_shortcut_test.dart' as emoji_shortcut_test;
import 'desktop/uncategorized/empty_test.dart' as first_test;
import 'desktop/uncategorized/hotkeys_test.dart' as hotkeys_test;
import 'desktop/uncategorized/import_files_test.dart' as import_files_test;
import 'desktop/uncategorized/share_markdown_test.dart' as share_markdown_test;
import 'desktop/uncategorized/tabs_test.dart' as tabs_test;
Future<void> main() async {
await runIntegration3OnDesktop();
}
Future<void> runIntegration3OnDesktop() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
// This test must be run first, otherwise the CI will fail.
first_test.main();
hotkeys_test.main();
emoji_shortcut_test.main();
hotkeys_test.main();
emoji_shortcut_test.main();
appearance_test_runner.main();
settings_test_runner.main();
share_markdown_test.main();
import_files_test.main();
sidebar_test_runner.startTesting();
board_test_runner.startTesting();
tabs_test.main();
}

View File

@ -1,5 +1,8 @@
import 'package:integration_test/integration_test.dart';
import 'mobile/sign_in/anonymous_sign_in_test.dart' as anonymous_sign_in_test;
Future<void> runIntegrationOnMobile() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
anonymous_sign_in_test.main();
}

View File

@ -1,8 +1,8 @@
import 'dart:io';
import 'package:integration_test/integration_test.dart';
import 'desktop_runner.dart';
import 'desktop_runner_1.dart';
import 'desktop_runner_2.dart';
import 'desktop_runner_3.dart';
import 'mobile_runner.dart';
/// The main task runner for all integration tests in AppFlowy.
@ -13,9 +13,10 @@ import 'mobile_runner.dart';
/// Once removed, the integration_test.yaml must be updated to exclude this as
/// as the test target.
Future<void> main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
await runIntegrationOnDesktop();
await runIntegration1OnDesktop();
await runIntegration2OnDesktop();
await runIntegration3OnDesktop();
} else if (Platform.isIOS || Platform.isAndroid) {
await runIntegrationOnMobile();
} else {

View File

@ -1,26 +1,12 @@
import 'dart:io';
import 'package:appflowy/plugins/database/application/calculations/calculation_type_ext.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/calculations/calculate_cell.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/calculations/calculation_type_item.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/common/type_option_separator.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/header/type_option/number.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/checkbox.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/checklist.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/date.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/number.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/select_option.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/text.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/timestamp.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/url.dart';
import 'package:appflowy/util/field_type_extension.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database/application/calculations/calculation_type_ext.dart';
import 'package:appflowy/plugins/database/board/presentation/board_page.dart';
import 'package:appflowy/plugins/database/board/presentation/widgets/board_column_header.dart';
import 'package:appflowy/plugins/database/calendar/application/calendar_bloc.dart';
@ -30,6 +16,9 @@ import 'package:appflowy/plugins/database/calendar/presentation/calendar_event_e
import 'package:appflowy/plugins/database/calendar/presentation/calendar_page.dart';
import 'package:appflowy/plugins/database/calendar/presentation/toolbar/calendar_layout_setting.dart';
import 'package:appflowy/plugins/database/grid/presentation/grid_page.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/calculations/calculate_cell.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/calculations/calculation_type_item.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/common/type_option_separator.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/checkbox.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/checklist/checklist.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/select_option/option_list.dart';
@ -43,6 +32,7 @@ import 'package:appflowy/plugins/database/grid/presentation/widgets/header/deskt
import 'package:appflowy/plugins/database/grid/presentation/widgets/header/field_editor.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/header/field_type_list.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/header/type_option/date/date_time_format.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/header/type_option/number.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/row/row.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/sort/create_sort_list.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/sort/order_panel.dart';
@ -52,14 +42,22 @@ import 'package:appflowy/plugins/database/grid/presentation/widgets/toolbar/filt
import 'package:appflowy/plugins/database/grid/presentation/widgets/toolbar/sort_button.dart';
import 'package:appflowy/plugins/database/tab_bar/desktop/tab_bar_add_button.dart';
import 'package:appflowy/plugins/database/tab_bar/desktop/tab_bar_header.dart';
import 'package:appflowy/plugins/database/widgets/database_layout_ext.dart';
import 'package:appflowy/plugins/database/widgets/row/accessory/cell_accessory.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/checkbox.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/checklist.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/date.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/number.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/select_option.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/text.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/timestamp.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/url.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/checklist_cell_editor.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/checklist_progress_bar.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/date_editor.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/extension.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/select_option_editor.dart';
import 'package:appflowy/plugins/database/widgets/cell_editor/select_option_text_field.dart';
import 'package:appflowy/plugins/database/widgets/database_layout_ext.dart';
import 'package:appflowy/plugins/database/widgets/row/accessory/cell_accessory.dart';
import 'package:appflowy/plugins/database/widgets/row/row_action.dart';
import 'package:appflowy/plugins/database/widgets/row/row_banner.dart';
import 'package:appflowy/plugins/database/widgets/row/row_detail.dart';
@ -70,6 +68,7 @@ import 'package:appflowy/plugins/database/widgets/setting/database_setting_actio
import 'package:appflowy/plugins/database/widgets/setting/database_settings_list.dart';
import 'package:appflowy/plugins/database/widgets/setting/setting_button.dart';
import 'package:appflowy/plugins/database/widgets/setting/setting_property_list.dart';
import 'package:appflowy/util/field_type_extension.dart';
import 'package:appflowy/workspace/presentation/widgets/date_picker/widgets/clear_date_button.dart';
import 'package:appflowy/workspace/presentation/widgets/date_picker/widgets/date_type_option_button.dart';
import 'package:appflowy/workspace/presentation/widgets/date_picker/widgets/end_time_button.dart';
@ -77,6 +76,7 @@ import 'package:appflowy/workspace/presentation/widgets/date_picker/widgets/remi
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
import 'package:appflowy/workspace/presentation/widgets/toggle/toggle.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:appflowy_board/appflowy_board.dart';
import 'package:calendar_view/calendar_view.dart';
@ -86,10 +86,9 @@ import 'package:flowy_infra_ui/style_widget/text_input.dart';
import 'package:flowy_infra_ui/widget/buttons/primary_button.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:path/path.dart' as p;
import 'package:table_calendar/table_calendar.dart';
// Non-exported member of the table_calendar library
import 'package:table_calendar/src/widgets/cell_content.dart';
import 'package:table_calendar/table_calendar.dart';
import 'base.dart';
import 'common_operations.dart';
@ -974,11 +973,6 @@ extension AppFlowyDatabaseTest on WidgetTester {
await tapButtonWithName(LocaleKeys.grid_row_delete.tr());
}
Future<void> assertRowCountInGridPage(int num) async {
final text = find.text('${rowCountString()} $num', findRichText: true);
expect(text, findsOneWidget);
}
Future<void> createField(FieldType fieldType, String name) async {
await scrollToRight(find.byType(GridPage));
await tapNewPropertyButton();

View File

@ -1,6 +1,9 @@
import 'dart:async';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/base/emoji/emoji_picker.dart';
import 'package:appflowy/plugins/base/emoji/emoji_skin_tone.dart';
@ -14,8 +17,6 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/image/embe
import 'package:appflowy/plugins/inline_actions/widgets/inline_actions_handler.dart';
import 'package:appflowy_editor/appflowy_editor.dart' hide Log;
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_emoji_mart/flutter_emoji_mart.dart';
import 'package:flutter_test/flutter_test.dart';
@ -132,8 +133,7 @@ class EditorOperations {
of: find.byType(EmbedImageUrlWidget),
matching: find.byType(TextField),
);
final textField = tester.widget<TextField>(imageUrlTextField);
textField.controller?.text = imageUrl;
await tester.enterText(imageUrlTextField, imageUrl);
await tester.pumpAndSettle();
await tester.tapButton(
find.descendant(

View File

@ -58,4 +58,10 @@ class KVKeys {
/// The value range is from 0.8 to 1.0. If it's greater than 1.0, it will cause
/// the text to be too large and not aligned with the icon
static const String textScaleFactor = 'textScaleFactor';
/// The key for saving the feature flags
///
/// The value is a json string with the following format:
/// {'feature_flag_1': true, 'feature_flag_2': false}
static const String featureFlag = 'featureFlag';
}

View File

@ -281,7 +281,7 @@ Future<AppFlowyCloudConfiguration> configurationFromUri(
if (authenticatorType == AuthenticatorType.appflowyCloudDevelop) {
return AppFlowyCloudConfiguration(
base_url: "$baseUrl:8000",
ws_base_url: "ws://${baseUri.host}:8000/ws",
ws_base_url: "ws://${baseUri.host}:8000/ws/v1",
gotrue_url: "$baseUrl:9999",
);
} else {
@ -319,7 +319,7 @@ Future<String> _getAppFlowyCloudWSUrl(String baseURL) async {
// Construct the WebSocket URL directly from the parsed URI.
final wsScheme = uri.isScheme('HTTPS') ? 'wss' : 'ws';
final wsUrl = Uri(scheme: wsScheme, host: uri.host, path: '/ws');
final wsUrl = Uri(scheme: wsScheme, host: uri.host, path: '/ws/v1');
return wsUrl.toString();
} catch (e) {

View File

@ -42,12 +42,13 @@ class OptionTextField extends StatelessWidget {
width: 38,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: type.mobileIconBackgroundColor,
color: Theme.of(context).brightness == Brightness.light
? type.mobileIconBackgroundColor
: type.mobileIconBackgroundColorDark,
),
child: Center(
child: FlowySvg(
type.svgData,
blendMode: null,
size: const Size.square(22),
),
),

View File

@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/base/app_bar.dart';
import 'package:appflowy/mobile/presentation/widgets/flowy_mobile_search_text_field.dart';
import 'package:appflowy/mobile/presentation/widgets/widgets.dart';
import 'package:appflowy/util/google_font_family_extension.dart';
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart';
@ -23,9 +25,7 @@ class FontPickerScreen extends StatelessWidget {
}
class LanguagePickerPage extends StatefulWidget {
const LanguagePickerPage({
super.key,
});
const LanguagePickerPage({super.key});
@override
State<LanguagePickerPage> createState() => _LanguagePickerPageState();
@ -52,6 +52,7 @@ class _LanguagePickerPageState extends State<LanguagePickerPage> {
body: SafeArea(
child: Scrollbar(
child: ListView.builder(
itemCount: availableFonts.length + 1, // with search bar
itemBuilder: (context, index) {
if (index == 0) {
// search bar
@ -65,7 +66,8 @@ class _LanguagePickerPageState extends State<LanguagePickerPage> {
setState(() {
availableFonts = _availableFonts
.where(
(element) => parseFontFamilyName(element)
(font) => font
.parseFontFamilyName()
.toLowerCase()
.contains(keyword.toLowerCase()),
)
@ -75,8 +77,9 @@ class _LanguagePickerPageState extends State<LanguagePickerPage> {
),
);
}
final fontFamilyName = availableFonts[index - 1];
final displayName = parseFontFamilyName(fontFamilyName);
final displayName = fontFamilyName.parseFontFamilyName();
return FlowyOptionTile.checkbox(
text: displayName,
isSelected: selectedFontFamilyName == fontFamilyName,
@ -86,17 +89,9 @@ class _LanguagePickerPageState extends State<LanguagePickerPage> {
backgroundColor: Colors.transparent,
);
},
itemCount: availableFonts.length + 1, // with search bar
),
),
),
);
}
String parseFontFamilyName(String fontFamilyName) {
final camelCase = RegExp('(?<=[a-z])[A-Z]');
return fontFamilyName
.replaceAll('_regular', '')
.replaceAllMapped(camelCase, (m) => ' ${m.group(0)}');
}
}

View File

@ -11,8 +11,22 @@ extension CalcTypeLabel on CalculationType {
LocaleKeys.grid_calculationTypeLabel_median.tr(),
CalculationType.Min => LocaleKeys.grid_calculationTypeLabel_min.tr(),
CalculationType.Sum => LocaleKeys.grid_calculationTypeLabel_sum.tr(),
CalculationType.Count =>
LocaleKeys.grid_calculationTypeLabel_count.tr(),
CalculationType.CountEmpty =>
LocaleKeys.grid_calculationTypeLabel_countEmpty.tr(),
CalculationType.CountNonEmpty =>
LocaleKeys.grid_calculationTypeLabel_countNonEmpty.tr(),
_ => throw UnimplementedError(
'Label for $this has not been implemented',
),
};
String get shortLabel => switch (this) {
CalculationType.CountEmpty =>
LocaleKeys.grid_calculationTypeLabel_countEmptyShort.tr(),
CalculationType.CountNonEmpty =>
LocaleKeys.grid_calculationTypeLabel_countNonEmptyShort.tr(),
_ => label,
};
}

View File

@ -128,7 +128,7 @@ extension NumberFormatExtension on NumberFormatPB {
}
}
String iconSymbol() {
String iconSymbol([bool defaultPrefixInc = true]) {
switch (this) {
case NumberFormatPB.ArgentinePeso:
return "\$";
@ -169,7 +169,7 @@ extension NumberFormatExtension on NumberFormatPB {
case NumberFormatPB.NorwegianKrone:
return "kr";
case NumberFormatPB.Num:
return "#";
return defaultPrefixInc ? "#" : "";
case NumberFormatPB.Percent:
return "%";
case NumberFormatPB.PhilippinePeso:

View File

@ -0,0 +1,34 @@
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
extension AvailableCalculations on FieldType {
List<CalculationType> calculationsForFieldType() {
final calculationTypes = [
CalculationType.Count,
];
// These FieldTypes cannot be empty, no need to count empty/non-empty
if (![FieldType.Checkbox, FieldType.LastEditedTime, FieldType.CreatedTime]
.contains(this)) {
calculationTypes.addAll([
CalculationType.CountEmpty,
CalculationType.CountNonEmpty,
]);
}
switch (this) {
case FieldType.Number:
calculationTypes.addAll([
CalculationType.Sum,
CalculationType.Average,
CalculationType.Min,
CalculationType.Max,
CalculationType.Median,
]);
break;
default:
break;
}
return calculationTypes;
}
}

View File

@ -12,7 +12,6 @@ import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:collection/collection.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scrollview.dart';
import 'package:flowy_infra_ui/widget/error_page.dart';
@ -237,7 +236,6 @@ class _GridPageContentState extends State<GridPageContent> {
viewId: widget.view.id,
scrollController: _scrollController,
),
const _GridFooter(),
],
);
}
@ -431,40 +429,3 @@ class _WrapScrollView extends StatelessWidget {
);
}
}
class _GridFooter extends StatelessWidget {
const _GridFooter();
@override
Widget build(BuildContext context) {
return BlocSelector<GridBloc, GridState, int>(
selector: (state) => state.rowCount,
builder: (context, rowCount) {
return Padding(
padding: GridSize.contentInsets,
child: RichText(
text: TextSpan(
text: rowCountString(),
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Theme.of(context).hintColor),
children: [
TextSpan(
text: ' $rowCount',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: AFThemeExtension.of(context).gridRowCountColor,
),
),
],
),
),
);
},
);
}
}
String rowCountString() {
return '${LocaleKeys.grid_row_count.tr()} :';
}

View File

@ -5,9 +5,11 @@ import 'package:appflowy/plugins/database/application/calculations/calculation_t
import 'package:appflowy/plugins/database/application/field/field_info.dart';
import 'package:appflowy/plugins/database/application/field/type_option/number_format_bloc.dart';
import 'package:appflowy/plugins/database/grid/application/calculations/calculations_bloc.dart';
import 'package:appflowy/plugins/database/grid/application/calculations/field_type_calc_ext.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/calculations/calculation_selector.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/calculations/calculation_type_item.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/calculations/remove_calculation_button.dart';
import 'package:appflowy/shared/patterns/common_patterns.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/calculation_entities.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/number_entities.pb.dart';
@ -67,31 +69,29 @@ class _CalculateCellState extends State<CalculateCell> {
),
),
),
...CalculationType.values.map(
(type) => CalculationTypeItem(
type: type,
onTap: () {
if (type != widget.calculation?.calculationType) {
context.read<CalculationsBloc>().add(
CalculationsEvent.updateCalculationType(
widget.fieldInfo.id,
type,
calculationId: widget.calculation?.id,
),
);
}
},
),
),
...widget.fieldInfo.fieldType.calculationsForFieldType().map(
(type) => CalculationTypeItem(
type: type,
onTap: () {
if (type != widget.calculation?.calculationType) {
context.read<CalculationsBloc>().add(
CalculationsEvent.updateCalculationType(
widget.fieldInfo.id,
type,
calculationId: widget.calculation?.id,
),
);
}
},
),
),
],
),
);
},
child: widget.fieldInfo.fieldType == FieldType.Number
? widget.calculation != null
? _showCalculateValue(context, prefix)
: CalculationSelector(isSelected: isSelected)
: const SizedBox.shrink(),
child: widget.calculation != null
? _showCalculateValue(context, prefix)
: CalculationSelector(isSelected: isSelected),
),
);
}
@ -107,7 +107,7 @@ class _CalculateCellState extends State<CalculateCell> {
children: [
Flexible(
child: FlowyText(
widget.calculation!.calculationType.label,
widget.calculation!.calculationType.shortLabel,
color: Theme.of(context).hintColor,
overflow: TextOverflow.ellipsis,
),
@ -133,9 +133,8 @@ class _CalculateCellState extends State<CalculateCell> {
}
String _withoutTrailingZeros(String value) {
final regex = RegExp(r'^(\d+(?:\.\d*?[1-9](?=0|\b))?)\.?0*$');
if (regex.hasMatch(value)) {
final match = regex.firstMatch(value)!;
if (trailingZerosRegex.hasMatch(value)) {
final match = trailingZerosRegex.firstMatch(value)!;
return match.group(1)!;
}
@ -146,7 +145,7 @@ class _CalculateCellState extends State<CalculateCell> {
FieldType.Number =>
NumberTypeOptionPB.fromBuffer(widget.fieldInfo.field.typeOptionData)
.format
.iconSymbol(),
.iconSymbol(false),
_ => null,
};
}

View File

@ -20,6 +20,7 @@ const List<FieldType> _supportedFieldTypes = [
FieldType.URL,
FieldType.LastEditedTime,
FieldType.CreatedTime,
FieldType.Relation,
];
class FieldTypeList extends StatelessWidget with FlowyOverlayDelegate {

View File

@ -84,12 +84,11 @@ class _MobileSelectOptionEditorState extends State<MobileSelectOptionEditor> {
const height = 44.0;
return Stack(
children: [
Align(
alignment: Alignment.centerLeft,
child: showMoreOptions
? AppBarBackButton(onTap: _popOrBack)
: AppBarCloseButton(onTap: _popOrBack),
),
if (showMoreOptions)
Align(
alignment: Alignment.centerLeft,
child: AppBarBackButton(onTap: _popOrBack),
),
SizedBox(
height: 44.0,
child: Align(

View File

@ -1,10 +1,7 @@
import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/editor_state_paste_node_extension.dart';
import 'package:appflowy/shared/patterns/common_patterns.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
RegExp _hrefRegex = RegExp(
r'https?://(?:www\.)?[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}(?:/[^\s]*)?',
);
extension PasteFromPlainText on EditorState {
Future<void> pastePlainText(String plainText) async {
if (await pasteHtmlIfAvailable(plainText)) {
@ -23,7 +20,7 @@ extension PasteFromPlainText on EditorState {
.map((e) {
// parse the url content
final Attributes attributes = {};
if (_hrefRegex.hasMatch(e)) {
if (hrefRegex.hasMatch(e)) {
attributes[AppFlowyRichTextKeys.href] = e;
}
return Delta()..insert(e, attributes: attributes);
@ -45,7 +42,7 @@ extension PasteFromPlainText on EditorState {
if (selection == null ||
!selection.isSingle ||
selection.isCollapsed ||
!_hrefRegex.hasMatch(plainText)) {
!hrefRegex.hasMatch(plainText)) {
return false;
}

View File

@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/shared/patterns/common_patterns.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
class EmbedImageUrlWidget extends StatefulWidget {
const EmbedImageUrlWidget({
@ -16,6 +18,7 @@ class EmbedImageUrlWidget extends StatefulWidget {
}
class _EmbedImageUrlWidgetState extends State<EmbedImageUrlWidget> {
bool isUrlValid = true;
String inputText = '';
@override
@ -25,8 +28,15 @@ class _EmbedImageUrlWidgetState extends State<EmbedImageUrlWidget> {
FlowyTextField(
hintText: LocaleKeys.document_imageBlock_embedLink_placeholder.tr(),
onChanged: (value) => inputText = value,
onEditingComplete: () => widget.onSubmit(inputText),
onEditingComplete: submit,
),
if (!isUrlValid) ...[
const VSpace(8),
FlowyText(
LocaleKeys.document_plugins_cover_invalidImageUrl.tr(),
color: Theme.of(context).colorScheme.error,
),
],
const VSpace(8),
SizedBox(
width: 160,
@ -37,10 +47,20 @@ class _EmbedImageUrlWidgetState extends State<EmbedImageUrlWidget> {
LocaleKeys.document_imageBlock_embedLink_label.tr(),
textAlign: TextAlign.center,
),
onTap: () => widget.onSubmit(inputText),
onTap: submit,
),
),
],
);
}
void submit() {
if (checkUrlValidity(inputText)) {
return widget.onSubmit(inputText);
}
setState(() => isUrlValid = false);
}
bool checkUrlValidity(String url) => imgUrlRegex.hasMatch(url);
}

View File

@ -1,12 +1,13 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:appflowy/mobile/presentation/setting/font/font_picker_screen.dart';
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/mobile_toolbar_v3/_toolbar_theme.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
import 'package:appflowy/util/google_font_family_extension.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';

View File

@ -1,3 +1,4 @@
import 'package:appflowy/shared/feature_flags.dart';
import 'package:appflowy_backend/log.dart';
import 'package:path_provider/path_provider.dart';
@ -59,3 +60,15 @@ class TemporaryDirectoryCache implements ICache {
await tmpDir.delete(recursive: true);
}
}
class FeatureFlagCache implements ICache {
@override
Future<int> cacheSize() async {
return 0;
}
@override
Future<void> clearAll() async {
await FeatureFlag.clear();
}
}

View File

@ -1,10 +1,17 @@
import 'dart:collection';
import 'dart:convert';
import 'package:appflowy/core/config/kv.dart';
import 'package:appflowy/core/config/kv_keys.dart';
import 'package:appflowy/startup/startup.dart';
typedef FeatureFlagMap = Map<FeatureFlag, bool>;
/// The [FeatureFlag] is used to control the front-end features of the app.
///
/// For example, if your feature is still under development,
/// you can set the value to `false` to hide the feature.
enum FeatureFlag {
// Feature flags
// used to control the visibility of the collaborative workspace feature
// if it's on, you can see the workspace list and the workspace settings
// in the top-left corner of the app
@ -14,7 +21,56 @@ enum FeatureFlag {
// if it's on, you can see the members settings in the settings page
membersSettings;
static Future<void> initialize() async {
final values = await getIt<KeyValueStorage>().getWithFormat<FeatureFlagMap>(
KVKeys.featureFlag,
(value) => Map.from(jsonDecode(value)).map(
(key, value) => MapEntry(
FeatureFlag.values.firstWhere((e) => e.name == key),
value as bool,
),
),
) ??
{};
_values = {
...{for (final flag in FeatureFlag.values) flag: false},
...values,
};
}
static UnmodifiableMapView<FeatureFlag, bool> get data =>
UnmodifiableMapView(_values);
Future<void> turnOn() async {
await update(true);
}
Future<void> turnOff() async {
await update(false);
}
Future<void> update(bool value) async {
_values[this] = value;
await getIt<KeyValueStorage>().set(
KVKeys.featureFlag,
jsonEncode(
_values.map((key, value) => MapEntry(key.name, value)),
),
);
}
static Future<void> clear() async {
_values = {};
await getIt<KeyValueStorage>().remove(KVKeys.featureFlag);
}
bool get isOn {
if (_values.containsKey(this)) {
return _values[this]!;
}
switch (this) {
case FeatureFlag.collaborativeWorkspace:
return false;
@ -22,4 +78,17 @@ enum FeatureFlag {
return false;
}
}
String get description {
switch (this) {
case FeatureFlag.collaborativeWorkspace:
return 'if it\'s on, you can see the workspace list and the workspace settings in the top-left corner of the app';
case FeatureFlag.membersSettings:
return 'if it\'s on, you can see the members settings in the settings page';
}
}
String get key => 'appflowy_feature_flag_${toString()}';
}
FeatureFlagMap _values = {};

View File

@ -0,0 +1,23 @@
const _trailingZerosPattern = r'^(\d+(?:\.\d*?[1-9](?=0|\b))?)\.?0*$';
final trailingZerosRegex = RegExp(_trailingZerosPattern);
const _hrefPattern =
r'https?://(?:www\.)?[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}(?:/[^\s]*)?';
final hrefRegex = RegExp(_hrefPattern);
/// This pattern allows for both HTTP and HTTPS Scheme
/// It allows for query parameters
/// It only allows the following image extensions: .png, .jpg, .gif, .webm
///
const _imgUrlPattern =
r'(https?:\/\/)([^\s(["<,>/]*)(\/)[^\s[",><]*(.png|.jpg|.gif|.webm)(\?[^\s[",><]*)?';
final imgUrlRegex = RegExp(_imgUrlPattern);
const _appflowyCloudUrlPattern = r'^(https:\/\/)(.*)(\.appflowy\.cloud\/)(.*)';
final appflowyCloudUrlRegex = RegExp(_appflowyCloudUrlPattern);
const _camelCasePattern = '(?<=[a-z])[A-Z]';
final camelCaseRegex = RegExp(_camelCasePattern);
const _macOSVolumesPattern = '^/Volumes/[^/]+';
final macOSVolumesRegex = RegExp(_macOSVolumesPattern);

View File

@ -0,0 +1,19 @@
/// RegExp to match Twelve Hour formats
/// Source: https://stackoverflow.com/a/33906224
///
/// Matches eg: "05:05 PM", "5:50 Pm", "10:59 am", etc.
///
const _twelveHourTimePattern =
r'\b((1[0-2]|0?[1-9]):([0-5][0-9]) ([AaPp][Mm]))';
final twelveHourTimeRegex = RegExp(_twelveHourTimePattern);
bool isTwelveHourTime(String? time) => twelveHourTimeRegex.hasMatch(time ?? '');
/// RegExp to match Twenty Four Hour formats
/// Source: https://stackoverflow.com/a/7536768
///
/// Matches eg: "0:01", "04:59", "16:30", etc.
///
const _twentyFourHourtimePattern = r'^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$';
final tewentyFourHourTimeRegex = RegExp(_twentyFourHourtimePattern);
bool isTwentyFourHourTime(String? time) =>
tewentyFourHourTimeRegex.hasMatch(time ?? '');

View File

@ -134,7 +134,8 @@ void _resolveCommonService(
getIt.registerFactory<FlowyCacheManager>(
() => FlowyCacheManager()
..registerCache(TemporaryDirectoryCache())
..registerCache(CustomImageCacheManager()),
..registerCache(CustomImageCacheManager())
..registerCache(FeatureFlagCache()),
);
}

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io';
import 'package:appflowy/env/cloud_env.dart';
import 'package:appflowy/startup/tasks/feature_flag_task.dart';
import 'package:appflowy/workspace/application/settings/prelude.dart';
import 'package:appflowy_backend/appflowy_backend.dart';
import 'package:flutter/foundation.dart';
@ -113,6 +114,7 @@ class FlowyRunner {
// there's a flag named _enable in memory_leak_detector.dart. If it's false, the task will be ignored.
MemoryLeakDetectorTask(),
const DebugTask(),
const FeatureFlagTask(),
// localization
const InitLocalizationTask(),

View File

@ -0,0 +1,21 @@
import 'package:appflowy/shared/feature_flags.dart';
import 'package:flutter/foundation.dart';
import '../startup.dart';
class FeatureFlagTask extends LaunchTask {
const FeatureFlagTask();
@override
Future<void> initialize(LaunchContext context) async {
// the hotkey manager is not supported on mobile
if (!kDebugMode) {
return;
}
await FeatureFlag.initialize();
}
@override
Future<void> dispose() async {}
}

View File

@ -1,7 +1,6 @@
import 'package:appflowy/shared/patterns/common_patterns.dart';
extension GoogleFontsParser on String {
String parseFontFamilyName() {
final camelCase = RegExp('(?<=[a-z])[A-Z]');
return replaceAll('_regular', '')
.replaceAllMapped(camelCase, (m) => ' ${m.group(0)}');
}
String parseFontFamilyName() => replaceAll('_regular', '')
.replaceAllMapped(camelCaseRegex, (m) => ' ${m.group(0)}');
}

View File

@ -2,6 +2,8 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:appflowy/shared/patterns/common_patterns.dart';
extension StringExtension on String {
static const _specialCharacters = r'\/:*?"<>| ';
@ -31,8 +33,6 @@ extension StringExtension on String {
return null;
}
/// Returns if the string is a appflowy cloud url.
bool get isAppFlowyCloudUrl {
return RegExp(r'^(https:\/\/)(.*)(\.appflowy\.cloud\/)(.*)').hasMatch(this);
}
/// Returns true if the string is a appflowy cloud url.
bool get isAppFlowyCloudUrl => appflowyCloudUrlRegex.hasMatch(this);
}

View File

@ -1,10 +1,12 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:appflowy/core/config/kv.dart';
import 'package:appflowy/core/config/kv_keys.dart';
import 'package:appflowy/shared/patterns/common_patterns.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy_backend/log.dart';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart' as p;
import '../../../startup/tasks/prelude.dart';
@ -26,7 +28,7 @@ class ApplicationDataStorage {
if (Platform.isMacOS) {
// remove the prefix `/Volumes/*`
path = path.replaceFirst(RegExp('^/Volumes/[^/]+'), '');
path = path.replaceFirst(macOSVolumesRegex, '');
} else if (Platform.isWindows) {
path = path.replaceAll('/', '\\');
}

View File

@ -1,18 +0,0 @@
/// RegExp to match Twelve Hour formats
/// Source: https://stackoverflow.com/a/33906224
///
/// Matches eg: "05:05 PM", "5:50 Pm", "10:59 am", etc.
///
final _twelveHourTimePattern =
RegExp(r'\b((1[0-2]|0?[1-9]):([0-5][0-9]) ([AaPp][Mm]))');
bool isTwelveHourTime(String? time) =>
_twelveHourTimePattern.hasMatch(time ?? '');
/// RegExp to match Twenty Four Hour formats
/// Source: https://stackoverflow.com/a/7536768
///
/// Matches eg: "0:01", "04:59", "16:30", etc.
///
final _twentyFourHourtimePattern = RegExp(r'^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$');
bool isTwentyFourHourTime(String? time) =>
_twentyFourHourtimePattern.hasMatch(time ?? '');

View File

@ -17,6 +17,7 @@ enum SettingsPage {
cloud,
shortcuts,
member,
featureFlags,
}
class SettingsDialogBloc

View File

@ -113,8 +113,7 @@ class WorkspaceMenuItem extends StatelessWidget {
return BlocProvider(
create: (_) =>
WorkspaceMemberBloc(userProfile: userProfile, workspace: workspace)
..add(const WorkspaceMemberEvent.initial())
..add(const WorkspaceMemberEvent.getWorkspaceMembers()),
..add(const WorkspaceMemberEvent.initial()),
child: BlocBuilder<WorkspaceMemberBloc, WorkspaceMemberState>(
builder: (context, state) {
final members = state.members;

View File

@ -1,6 +1,7 @@
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/workspace/application/settings/settings_dialog_bloc.dart';
import 'package:appflowy/workspace/presentation/settings/widgets/feature_flags/feature_flag_page.dart';
import 'package:appflowy/workspace/presentation/settings/widgets/members/workspace_member_page.dart';
import 'package:appflowy/workspace/presentation/settings/widgets/settings_appearance_view.dart';
import 'package:appflowy/workspace/presentation/settings/widgets/settings_customize_shortcuts_view.dart';
@ -114,6 +115,8 @@ class SettingsDialog extends StatelessWidget {
return const SettingsCustomizeShortcutsWrapper();
case SettingsPage.member:
return WorkspaceMembersPage(userProfile: user);
case SettingsPage.featureFlags:
return const FeatureFlagsPage();
default:
return const SizedBox.shrink();
}

View File

@ -0,0 +1,70 @@
import 'package:appflowy/shared/feature_flags.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
class FeatureFlagsPage extends StatelessWidget {
const FeatureFlagsPage({
super.key,
});
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: SeparatedColumn(
children: [
...FeatureFlag.data.entries.map(
(e) => _FeatureFlagItem(featureFlag: e.key),
),
FlowyTextButton(
'Restart the app to apply changes',
fontSize: 16.0,
fontColor: Colors.red,
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 12.0,
),
onPressed: () async {
await runAppFlowy();
},
),
],
),
);
}
}
class _FeatureFlagItem extends StatefulWidget {
const _FeatureFlagItem({
required this.featureFlag,
});
final FeatureFlag featureFlag;
@override
State<_FeatureFlagItem> createState() => _FeatureFlagItemState();
}
class _FeatureFlagItemState extends State<_FeatureFlagItem> {
@override
Widget build(BuildContext context) {
return ListTile(
title: FlowyText(
widget.featureFlag.name,
fontSize: 16.0,
),
subtitle: FlowyText.small(
widget.featureFlag.description,
maxLines: 3,
),
trailing: Switch(
value: widget.featureFlag.isOn,
onChanged: (value) {
setState(() {
widget.featureFlag.update(value);
});
},
),
);
}
}

View File

@ -38,6 +38,8 @@ class WorkspaceMemberBloc
workspaceId = '';
});
}
add(const WorkspaceMemberEvent.getWorkspaceMembers());
},
getWorkspaceMembers: () async {
final members = await _getWorkspaceMembers();

View File

@ -27,9 +27,7 @@ class WorkspaceMembersPage extends StatelessWidget {
Widget build(BuildContext context) {
return BlocProvider<WorkspaceMemberBloc>(
create: (context) => WorkspaceMemberBloc(userProfile: userProfile)
..add(
const WorkspaceMemberEvent.getWorkspaceMembers(),
),
..add(const WorkspaceMemberEvent.initial()),
child: BlocBuilder<WorkspaceMemberBloc, WorkspaceMemberState>(
builder: (context, state) {
return SingleChildScrollView(

View File

@ -95,7 +95,7 @@ class _FontFamilyDropDownState extends State<FontFamilyDropDown> {
return FlowySettingValueDropDown(
popoverKey: ThemeFontFamilySetting.popoverKey,
popoverController: widget.popoverController,
currentValue: parseFontFamilyName(widget.currentFontFamily),
currentValue: widget.currentFontFamily.parseFontFamilyName(),
onClose: () {
query.value = '';
widget.onClose?.call();
@ -162,18 +162,11 @@ class _FontFamilyDropDownState extends State<FontFamilyDropDown> {
);
}
String parseFontFamilyName(String fontFamilyName) {
final camelCase = RegExp('(?<=[a-z])[A-Z]');
return fontFamilyName
.replaceAll('_regular', '')
.replaceAllMapped(camelCase, (m) => ' ${m.group(0)}');
}
Widget _fontFamilyItemButton(
BuildContext context,
TextStyle style,
) {
final buttonFontFamily = parseFontFamilyName(style.fontFamily!);
final buttonFontFamily = style.fontFamily!.parseFontFamilyName();
return Tooltip(
message: buttonFontFamily,
@ -184,21 +177,19 @@ class _FontFamilyDropDownState extends State<FontFamilyDropDown> {
child: FlowyButton(
onHover: (_) => FocusScope.of(context).unfocus(),
text: FlowyText.medium(
parseFontFamilyName(style.fontFamily!),
buttonFontFamily,
fontFamily: style.fontFamily!,
),
rightIcon:
buttonFontFamily == parseFontFamilyName(widget.currentFontFamily)
? const FlowySvg(
FlowySvgs.check_s,
)
buttonFontFamily == widget.currentFontFamily.parseFontFamilyName()
? const FlowySvg(FlowySvgs.check_s)
: null,
onTap: () {
if (widget.onFontFamilyChanged != null) {
widget.onFontFamilyChanged!(style.fontFamily!);
} else {
final fontFamily = style.fontFamily!.parseFontFamilyName();
if (parseFontFamilyName(widget.currentFontFamily) !=
if (widget.currentFontFamily.parseFontFamilyName() !=
buttonFontFamily) {
context
.read<AppearanceSettingsCubit>()

View File

@ -4,6 +4,7 @@ import 'package:appflowy/workspace/application/settings/settings_dialog_bloc.dar
import 'package:appflowy/workspace/presentation/settings/widgets/settings_menu_element.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class SettingsMenu extends StatelessWidget {
@ -79,6 +80,15 @@ class SettingsMenu extends StatelessWidget {
icon: Icons.people,
changeSelectedPage: changeSelectedPage,
),
if (kDebugMode)
SettingsMenuElement(
// no need to translate this page
page: SettingsPage.featureFlags,
selectedPage: currentPage,
label: 'Feature Flags',
icon: Icons.flag,
changeSelectedPage: changeSelectedPage,
),
],
),
);

View File

@ -2,6 +2,9 @@ import 'package:flutter/material.dart';
typedef SeparatorBuilder = Widget Function();
Widget _defaultColumnSeparatorBuilder() => const Divider();
Widget _defaultRowSeparatorBuilder() => const VerticalDivider();
class SeparatedColumn extends Column {
SeparatedColumn({
super.key,
@ -11,7 +14,7 @@ class SeparatedColumn extends Column {
super.textBaseline,
super.textDirection,
super.verticalDirection,
required SeparatorBuilder separatorBuilder,
SeparatorBuilder separatorBuilder = _defaultColumnSeparatorBuilder,
required List<Widget> children,
}) : super(children: _insertSeparators(children, separatorBuilder));
}
@ -25,7 +28,7 @@ class SeparatedRow extends Row {
super.textBaseline,
super.textDirection,
super.verticalDirection,
required SeparatorBuilder separatorBuilder,
SeparatorBuilder separatorBuilder = _defaultRowSeparatorBuilder,
required List<Widget> children,
}) : super(children: _insertSeparators(children, separatorBuilder));
}

View File

@ -53,17 +53,17 @@ packages:
dependency: "direct main"
description:
path: "."
ref: d4d35c0
resolved-ref: d4d35c0d103a5d1bddf68181fcfaf9f75b0fccb5
ref: ce391a8
resolved-ref: ce391a8c0f492f7b5fdd8f44bbc89fc68882ff23
url: "https://github.com/AppFlowy-IO/appflowy-editor.git"
source: git
version: "2.3.2"
version: "2.3.3"
appflowy_editor_plugins:
dependency: "direct main"
description:
path: "."
ref: "0223cca"
resolved-ref: "0223ccabe74b86092d3f3849b69026c89df3b236"
ref: "8f238f2"
resolved-ref: "8f238f214de72e629fe2d90317518c5a0510cdc5"
url: "https://github.com/LucasXu0/appflowy_editor_plugins"
source: git
version: "0.0.1"

View File

@ -50,7 +50,7 @@ dependencies:
appflowy_editor_plugins:
git:
url: https://github.com/LucasXu0/appflowy_editor_plugins
ref: "0223cca"
ref: "8f238f2"
appflowy_popover:
path: packages/appflowy_popover
@ -167,7 +167,7 @@ dependency_overrides:
appflowy_editor:
git:
url: https://github.com/AppFlowy-IO/appflowy-editor.git
ref: "d4d35c0"
ref: "ce391a8"
sheet:
git:

View File

@ -1,7 +1,8 @@
import 'package:appflowy/plugins/database/grid/application/grid_bloc.dart';
import 'package:appflowy/plugins/database/application/database_controller.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:appflowy/plugins/database/grid/application/grid_bloc.dart';
import 'package:bloc_test/bloc_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'util.dart';
void main() {
@ -17,7 +18,8 @@ void main() {
context = await gridTest.createTestGrid();
});
// The initial number of rows is 3 for each grid.
// The initial number of rows is 3 for each grid
// We create one row so we expect 4 rows
blocTest<GridBloc, GridState>(
"create a row",
build: () => GridBloc(

View File

@ -79,8 +79,8 @@
"yjs": "^13.5.51"
},
"devDependencies": {
"@svgr/plugin-svgo": "^8.0.1",
"@tauri-apps/cli": "^1.5.6",
"@svgr/plugin-svgo": "^8.0.1",
"@types/google-protobuf": "^3.15.12",
"@types/is-hotkey": "^0.1.7",
"@types/jest": "^29.5.3",

View File

@ -0,0 +1,31 @@
const fs = require('fs');
const path = require('path');
if (process.argv.length < 3) {
console.error('Usage: node update-tauri-version.js <version>');
process.exit(1);
}
const newVersion = process.argv[2];
const tauriConfigPath = path.join(__dirname, '../src-tauri', 'tauri.conf.json');
fs.readFile(tauriConfigPath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading tauri.conf.json:', err);
return;
}
const config = JSON.parse(data);
config.package.version = newVersion;
fs.writeFile(tauriConfigPath, JSON.stringify(config, null, 2), 'utf8', (err) => {
if (err) {
console.error('Error writing tauri.conf.json:', err);
return;
}
console.log(`Tauri version updated to ${newVersion} successfully.`);
});
});

View File

@ -162,7 +162,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "app-error"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"bincode",
@ -714,7 +714,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"again",
"anyhow",
@ -1313,7 +1313,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"app-error",
@ -2587,7 +2587,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"futures-util",
@ -2604,7 +2604,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"app-error",
@ -3059,7 +3059,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"reqwest",
@ -4801,7 +4801,7 @@ dependencies = [
[[package]]
name = "realtime-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"bincode",
@ -4825,7 +4825,7 @@ dependencies = [
[[package]]
name = "realtime-protocol"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"bincode",
@ -5497,7 +5497,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"app-error",
@ -6993,7 +6993,7 @@ checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc"
[[package]]
name = "websocket"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"futures-channel",
"futures-util",
@ -7456,7 +7456,7 @@ dependencies = [
[[package]]
name = "workspace-template"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"async-trait",

View File

@ -82,7 +82,7 @@ custom-protocol = ["tauri/custom-protocol"]
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "eed20c25197109a3f799a5d18d0e38e9f5529d69" }
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "eb79b9f5e80846bd06b30b4f9c04039ce1452582" }
# Please use the following script to update collab.
# Working directory: frontend
#

View File

@ -99,4 +99,4 @@
}
]
}
}
}

View File

@ -60,6 +60,7 @@ function DeleteConfirmDialog({ open, title, onOk, onCancel, onClose, okText, can
<Button
className={'w-full'}
variant={'outlined'}
color={'inherit'}
onClick={() => {
onCancel?.();
onClose();

View File

@ -67,7 +67,7 @@ function RenameDialog({
</DialogContent>
<Divider className={'mb-1'} />
<DialogActions className={'mb-1 px-4'}>
<Button variant={'outlined'} onClick={onClose}>
<Button color={'inherit'} variant={'outlined'} onClick={onClose}>
{t('button.cancel')}
</Button>
<Button variant={'contained'} onClick={onDone}>

View File

@ -49,6 +49,7 @@ export interface KeyboardNavigationProps<T> {
onFocus?: () => void;
onBlur?: () => void;
itemClassName?: string;
itemStyle?: React.CSSProperties;
}
function KeyboardNavigation<T>({
@ -67,6 +68,7 @@ function KeyboardNavigation<T>({
onBlur,
onFocus,
itemClassName,
itemStyle,
}: KeyboardNavigationProps<T>) {
const { t } = useTranslation();
const ref = useRef<HTMLDivElement>(null);
@ -232,6 +234,7 @@ function KeyboardNavigation<T>({
}
}}
selected={isFocused}
style={itemStyle}
className={`ml-0 flex w-full items-center justify-start rounded-none px-2 py-1 text-xs ${
!isFocused ? 'hover:bg-transparent' : ''
} ${itemClassName ?? ''}`}
@ -246,7 +249,7 @@ function KeyboardNavigation<T>({
</div>
);
},
[itemClassName, focusedKey, onConfirm, onFocus]
[itemClassName, focusedKey, onConfirm, onFocus, itemStyle]
);
useEffect(() => {
@ -284,10 +287,16 @@ function KeyboardNavigation<T>({
onBlur={(e) => {
e.stopPropagation();
const target = e.relatedTarget as HTMLElement;
if (target?.closest('.keyboard-navigation')) {
return;
}
onBlur?.();
}}
autoFocus={!disableFocus}
className={'flex w-full flex-col gap-1 outline-none'}
className={'keyboard-navigation flex w-full flex-col gap-1 outline-none'}
ref={ref}
>
{options.length > 0 ? (

View File

@ -22,7 +22,7 @@ function ViewBanner({
<div className={'view-banner flex w-full flex-col'}>
{showCover && cover && <ViewCover cover={cover} onUpdateCover={onUpdateCover} />}
<div className={'relative min-h-[65px] px-16 pt-4'}>
<div className={`relative min-h-[65px] ${showCover ? 'px-16' : ''} pt-4`}>
<div
style={{
display: icon ? 'flex' : 'none',

View File

@ -22,6 +22,9 @@ function ViewIcon({ icon, onUpdateIcon }: { icon?: PageIcon; onUpdateIcon: (icon
const onEmojiSelect = useCallback(
(emoji: string) => {
onUpdateIcon(emoji);
if (!emoji) {
setAnchorPosition(undefined);
}
},
[onUpdateIcon]
);

View File

@ -1,10 +1,11 @@
import { t } from 'i18next';
import { AppflowyLogo } from '../../_shared/svg/AppflowyLogo';
import Button from '@mui/material/Button';
import { useLogin } from '$app/components/auth/get_started/useLogin';
import { useTranslation } from 'react-i18next';
export const GetStarted = () => {
const { onAutoSignInClick } = useLogin();
const { t } = useTranslation();
return (
<>

View File

@ -195,8 +195,8 @@ export const useConnectDatabase = (viewId: string) => {
return database;
};
const DatabaseRenderedContext = createContext<() => void>(() => {
// do nothing
const DatabaseRenderedContext = createContext<(viewId: string) => void>(() => {
return;
});
export const DatabaseRenderedProvider = DatabaseRenderedContext.Provider;

View File

@ -58,65 +58,43 @@ export const Database = forwardRef<HTMLDivElement, Props>(({ selectedViewId, set
}
}, [viewId]);
const parentId = page?.parentId;
useEffect(() => {
void handleGetPage();
void handleResetDatabaseViews(viewId);
const unsubscribePromise = subscribeNotifications(
{
[FolderNotification.DidUpdateView]: (changeset) => {
setChildViews((prev) => {
const index = prev.findIndex((view) => view.id === changeset.id);
const unsubscribePromise = subscribeNotifications({
[FolderNotification.DidUpdateView]: (changeset) => {
if (changeset.parent_view_id !== viewId && changeset.id !== viewId) return;
setChildViews((prev) => {
const index = prev.findIndex((view) => view.id === changeset.id);
if (index === -1) {
return prev;
}
const newViews = [...prev];
newViews[index] = {
...newViews[index],
name: changeset.name,
};
return newViews;
});
},
[FolderNotification.DidUpdateChildViews]: (changeset) => {
if (changeset.create_child_views.length === 0 && changeset.delete_child_views.length === 0) {
return;
if (index === -1) {
return prev;
}
void handleResetDatabaseViews(viewId);
},
const newViews = [...prev];
newViews[index] = {
...newViews[index],
name: changeset.name,
};
return newViews;
});
},
{
id: viewId,
}
);
[FolderNotification.DidUpdateChildViews]: (changeset) => {
if (changeset.parent_view_id !== viewId && changeset.parent_view_id !== parentId) return;
if (changeset.create_child_views.length === 0 && changeset.delete_child_views.length === 0) {
return;
}
void handleResetDatabaseViews(viewId);
},
});
return () => void unsubscribePromise.then((unsubscribe) => unsubscribe());
}, [handleGetPage, handleResetDatabaseViews, viewId]);
useEffect(() => {
const parentId = page?.parentId;
if (!parentId) return;
const unsubscribePromise = subscribeNotifications(
{
[FolderNotification.DidUpdateChildViews]: (changeset) => {
if (changeset.delete_child_views.includes(viewId)) {
setNotFound(true);
}
},
},
{
id: parentId,
}
);
return () => void unsubscribePromise.then((unsubscribe) => unsubscribe());
}, [page, viewId]);
}, [handleGetPage, handleResetDatabaseViews, viewId, parentId]);
const value = useMemo(() => {
return Math.max(
@ -183,7 +161,13 @@ export const Database = forwardRef<HTMLDivElement, Props>(({ selectedViewId, set
index={value}
>
{childViews.map((view, index) => (
<TabPanel className={'flex h-full w-full flex-col'} key={view.id} index={index} value={value}>
<TabPanel
data-view-id={view.id}
className={'flex h-full w-full flex-col'}
key={view.id}
index={index}
value={value}
>
<DatabaseLoader viewId={view.id}>
{selectedViewId === view.id && (
<>

View File

@ -1,12 +1,12 @@
import { FormEventHandler, useCallback } from 'react';
import { t } from 'i18next';
import { useViewId } from '$app/hooks';
import { useAppDispatch, useAppSelector } from '$app/stores/store';
import { updatePageName } from '$app_reducers/pages/async_actions';
import { useTranslation } from 'react-i18next';
export const DatabaseTitle = () => {
const viewId = useViewId();
const { t } = useTranslation();
const pageName = useAppSelector((state) => state.pages.pageMap[viewId]?.name || '');
const dispatch = useAppDispatch();

View File

@ -9,12 +9,12 @@ import Popover from '@mui/material/Popover';
const initialAnchorOrigin: PopoverOrigin = {
vertical: 'bottom',
horizontal: 'left',
horizontal: 'center',
};
const initialTransformOrigin: PopoverOrigin = {
vertical: 'top',
horizontal: 'left',
horizontal: 'center',
};
const SelectCellActions = lazy(
() => import('$app/components/database/components/field_types/select/select_cell_actions/SelectCellActions')

View File

@ -18,7 +18,7 @@ function DatabaseSettings(props: Props) {
<div className='flex h-[39px] items-center gap-2 border-b border-line-divider'>
<FilterSettings {...props} />
<SortSettings {...props} />
<TextButton color='inherit' onClick={(e) => setSettingAnchorEl(e.currentTarget)}>
<TextButton className={'min-w-fit'} color='inherit' onClick={(e) => setSettingAnchorEl(e.currentTarget)}>
{t('settings.title')}
</TextButton>
<SettingsMenu

View File

@ -23,7 +23,7 @@ function FilterSettings({ onToggleCollection }: { onToggleCollection: (forceOpen
return (
<>
<TextButton onClick={handleClick} color={highlight ? 'primary' : 'inherit'}>
<TextButton className={'min-w-fit'} onClick={handleClick} color={highlight ? 'primary' : 'inherit'}>
{t('grid.settings.filter')}
</TextButton>
<FilterFieldsMenu

View File

@ -31,7 +31,7 @@ function SortSettings({ onToggleCollection }: Props) {
return (
<>
<TextButton className={'p-1'} color={highlight ? 'primary' : 'inherit'} onClick={handleClick}>
<TextButton className={'min-w-fit p-1'} color={highlight ? 'primary' : 'inherit'} onClick={handleClick}>
{t('grid.settings.sort')}
</TextButton>
<SortFieldsMenu

View File

@ -5,6 +5,7 @@ import dayjs from 'dayjs';
import { ReactComponent as LeftSvg } from '$app/assets/arrow-left.svg';
import { ReactComponent as RightSvg } from '$app/assets/arrow-right.svg';
import { IconButton } from '@mui/material';
import './calendar.scss';
function CustomCalendar({
handleChange,

View File

@ -0,0 +1,82 @@
.react-datepicker__month-container {
width: 100%;
border-radius: 0;
}
.react-datepicker__header {
border-radius: 0;
background: transparent;
border-bottom: 0;
}
.react-datepicker__day-names {
border: none;
}
.react-datepicker__day-name {
color: var(--text-caption);
}
.react-datepicker__month {
border: none;
}
.react-datepicker__day {
border: none;
color: var(--text-title);
border-radius: 100%;
}
.react-datepicker__day:hover {
border-radius: 100%;
background: var(--fill-default);
color: var(--content-on-fill);
}
.react-datepicker__day--outside-month {
color: var(--text-caption);
}
.react-datepicker__day--in-range {
background: var(--fill-hover);
color: var(--content-on-fill);
}
.react-datepicker__day--today {
border: 1px solid var(--fill-default);
color: var(--text-title);
border-radius: 100%;
background: transparent;
font-weight: 500;
}
.react-datepicker__day--today:hover{
background: var(--fill-default);
color: var(--content-on-fill);
}
.react-datepicker__day--in-selecting-range, .react-datepicker__day--today.react-datepicker__day--in-range {
background: var(--fill-hover);
color: var(--content-on-fill);
border-color: transparent;
}
.react-datepicker__day--keyboard-selected {
background: transparent;
}
.react-datepicker__day--range-start, .react-datepicker__day--range-end, .react-datepicker__day--selected {
&.react-datepicker__day--today {
background: var(--fill-default);
color: var(--content-on-fill);
}
background: var(--fill-default) !important;
color: var(--content-on-fill);
}
.react-datepicker__day--range-start, .react-datepicker__day--range-end, .react-datepicker__day--selected:hover {
background: var(--fill-default);
color: var(--content-on-fill);
}
.react-swipeable-view-container {
height: 100%;
}

View File

@ -1,5 +1,4 @@
import { FC, useMemo, useRef, useState } from 'react';
import { t } from 'i18next';
import { Divider, ListSubheader, MenuItem, MenuList, MenuProps, OutlinedInput } from '@mui/material';
import { SelectOptionColorPB } from '@/services/backend';
import { ReactComponent as DeleteSvg } from '$app/assets/delete.svg';
@ -14,6 +13,7 @@ import {
import { useViewId } from '$app/hooks';
import Popover from '@mui/material/Popover';
import debounce from 'lodash-es/debounce';
import { useTranslation } from 'react-i18next';
interface SelectOptionMenuProps {
fieldId: string;
@ -34,6 +34,7 @@ const Colors = [
];
export const SelectOptionModifyMenu: FC<SelectOptionMenuProps> = ({ fieldId, option, MenuProps: menuProps }) => {
const { t } = useTranslation();
const [tagName, setTagName] = useState(option.name);
const viewId = useViewId();
const inputRef = useRef<HTMLInputElement>(null);
@ -83,6 +84,9 @@ export const SelectOptionModifyMenu: FC<SelectOptionMenuProps> = ({ fieldId, opt
horizontal: -32,
}}
{...menuProps}
onClick={(e) => {
e.stopPropagation();
}}
onClose={onClose}
onMouseDown={(e) => {
const isInput = inputRef.current?.contains(e.target as Node);
@ -95,6 +99,9 @@ export const SelectOptionModifyMenu: FC<SelectOptionMenuProps> = ({ fieldId, opt
<ListSubheader className='my-2 leading-tight'>
<OutlinedInput
inputRef={inputRef}
spellCheck={false}
autoCorrect={'off'}
autoCapitalize={'off'}
value={tagName}
onChange={(e) => {
setTagName(e.target.value);
@ -108,6 +115,9 @@ export const SelectOptionModifyMenu: FC<SelectOptionMenuProps> = ({ fieldId, opt
onClose();
}
}}
onClick={(e) => {
e.stopPropagation();
}}
autoFocus={true}
placeholder={t('grid.selectOption.tagName')}
size='small'
@ -139,6 +149,7 @@ export const SelectOptionModifyMenu: FC<SelectOptionMenuProps> = ({ fieldId, opt
}}
key={color}
value={color}
className={'px-1.5'}
>
<span className={`mr-2 inline-flex h-4 w-4 rounded-full ${SelectOptionColorMap[color]}`} />
<span className='flex-1'>{t(`grid.selectOption.${SelectOptionColorTextMap[color]}`)}</span>

View File

@ -1,16 +0,0 @@
import { MenuItem, MenuItemProps } from '@mui/material';
import { FC } from 'react';
import { Tag } from '../Tag';
export interface CreateOptionProps {
label: React.ReactNode;
onClick?: MenuItemProps['onClick'];
}
export const CreateOption: FC<CreateOptionProps> = ({ label, onClick }) => {
return (
<MenuItem className='px-2' onClick={onClick}>
<Tag className='ml-2' size='small' label={label} />
</MenuItem>
);
};

View File

@ -1,18 +1,17 @@
import React, { FormEvent, useCallback } from 'react';
import { OutlinedInput } from '@mui/material';
import { t } from 'i18next';
import { useTranslation } from 'react-i18next';
function SearchInput({
setNewOptionName,
newOptionName,
onEnter,
onEscape,
inputRef,
}: {
newOptionName: string;
setNewOptionName: (value: string) => void;
onEnter: () => void;
onEscape?: () => void;
inputRef?: React.RefObject<HTMLInputElement>;
}) {
const { t } = useTranslation();
const handleInput = useCallback(
(event: FormEvent) => {
const value = (event.target as HTMLInputElement).value;
@ -27,20 +26,10 @@ function SearchInput({
size='small'
className={'mx-4'}
autoFocus={true}
inputRef={inputRef}
value={newOptionName}
onInput={handleInput}
spellCheck={false}
onKeyDown={(e) => {
if (e.key === 'Enter') {
onEnter();
}
if (e.key === 'Escape') {
e.stopPropagation();
e.preventDefault();
onEscape?.();
}
}}
placeholder={t('grid.selectOption.searchOrCreateOption')}
/>
);

View File

@ -1,7 +1,4 @@
import React, { useCallback, useMemo, useState } from 'react';
import { MenuItem } from '@mui/material';
import { t } from 'i18next';
import { CreateOption } from '$app/components/database/components/field_types/select/select_cell_actions/CreateOption';
import React, { useCallback, useMemo, useRef, useState } from 'react';
import { SelectOptionItem } from '$app/components/database/components/field_types/select/select_cell_actions/SelectOptionItem';
import { cellService, SelectCell as SelectCellType, SelectField, SelectTypeOption } from '$app/application/database';
import { useViewId } from '$app/hooks';
@ -12,6 +9,13 @@ import {
import { FieldType } from '@/services/backend';
import { useTypeOption } from '$app/components/database';
import SearchInput from './SearchInput';
import { useTranslation } from 'react-i18next';
import KeyboardNavigation, {
KeyboardNavigationOption,
} from '$app/components/_shared/keyboard_navigation/KeyboardNavigation';
import { Tag } from '$app/components/database/components/field_types/select/Tag';
const CREATE_OPTION_KEY = 'createOption';
function SelectCellActions({
field,
@ -24,22 +28,43 @@ function SelectCellActions({
onUpdated?: () => void;
onClose?: () => void;
}) {
const { t } = useTranslation();
const rowId = cell?.rowId;
const viewId = useViewId();
const typeOption = useTypeOption<SelectTypeOption>(field.id);
const options = useMemo(() => typeOption.options ?? [], [typeOption.options]);
const scrollRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLInputElement>(null);
const selectedOptionIds = useMemo(() => cell?.data?.selectedOptionIds ?? [], [cell]);
const [newOptionName, setNewOptionName] = useState('');
const filteredOptions = useMemo(
() =>
options.filter((option) => {
return option.name.toLowerCase().includes(newOptionName.toLowerCase());
}),
[options, newOptionName]
);
const shouldCreateOption = !!newOptionName && filteredOptions.length === 0;
const filteredOptions: KeyboardNavigationOption[] = useMemo(() => {
const result = options
.filter((option) => {
return option.name.toLowerCase().includes(newOptionName.toLowerCase());
})
.map((option) => ({
key: option.id,
content: (
<SelectOptionItem
isSelected={selectedOptionIds?.includes(option.id)}
fieldId={cell?.fieldId || ''}
option={option}
/>
),
}));
if (result.length === 0) {
result.push({
key: CREATE_OPTION_KEY,
content: <Tag size='small' label={newOptionName} />,
});
}
return result;
}, [newOptionName, options, selectedOptionIds, cell?.fieldId]);
const shouldCreateOption = filteredOptions.length === 1 && filteredOptions[0].key === 'createOption';
const updateCell = useCallback(
async (optionIds: string[]) => {
@ -65,90 +90,67 @@ function SelectCellActions({
return option;
}, [viewId, field.id, newOptionName]);
const handleClickOption = useCallback(
(optionId: string) => {
const onConfirm = useCallback(
async (key: string) => {
let optionId = key;
if (key === CREATE_OPTION_KEY) {
const option = await createOption();
optionId = option?.id || '';
}
if (!optionId) return;
if (field.type === FieldType.SingleSelect) {
void updateCell([optionId]);
const newOptionIds = [optionId];
if (selectedOptionIds?.includes(optionId)) {
newOptionIds.pop();
}
void updateCell(newOptionIds);
return;
}
const prev = selectedOptionIds;
let newOptionIds = [];
if (!prev) {
if (!selectedOptionIds) {
newOptionIds.push(optionId);
} else {
const isSelected = prev.includes(optionId);
const isSelected = selectedOptionIds.includes(optionId);
if (isSelected) {
newOptionIds = prev.filter((id) => id !== optionId);
newOptionIds = selectedOptionIds.filter((id) => id !== optionId);
} else {
newOptionIds = [...prev, optionId];
newOptionIds = [...selectedOptionIds, optionId];
}
}
void updateCell(newOptionIds);
},
[field.type, selectedOptionIds, updateCell]
[createOption, field.type, selectedOptionIds, updateCell]
);
const handleNewTagClick = useCallback(async () => {
if (!cell || !rowId) return;
const option = await createOption();
if (!option) return;
handleClickOption(option.id);
}, [cell, createOption, handleClickOption, rowId]);
const handleEnter = useCallback(() => {
if (shouldCreateOption) {
void handleNewTagClick();
} else {
if (field.type === FieldType.SingleSelect) {
const firstOption = filteredOptions[0];
if (!firstOption) return;
void updateCell([firstOption.id]);
} else {
void updateCell(filteredOptions.map((option) => option.id));
}
}
setNewOptionName('');
}, [field.type, filteredOptions, handleNewTagClick, shouldCreateOption, updateCell]);
return (
<div className={'flex h-full flex-col overflow-hidden'}>
<SearchInput
onEscape={onClose}
setNewOptionName={setNewOptionName}
newOptionName={newOptionName}
onEnter={handleEnter}
/>
<SearchInput inputRef={inputRef} setNewOptionName={setNewOptionName} newOptionName={newOptionName} />
<div className='mx-4 mb-2 mt-4 text-xs'>
{shouldCreateOption ? t('grid.selectOption.createNew') : t('grid.selectOption.orSelectOne')}
</div>
<div className={'mx-1 flex-1 overflow-y-auto overflow-x-hidden'}>
{shouldCreateOption ? (
<CreateOption label={newOptionName} onClick={handleNewTagClick} />
) : (
<div className={' px-2'}>
{filteredOptions.map((option) => (
<MenuItem className={'px-2'} key={option.id} value={option.id}>
<SelectOptionItem
onClick={() => {
handleClickOption(option.id);
}}
isSelected={selectedOptionIds?.includes(option.id)}
fieldId={cell?.fieldId || ''}
option={option}
/>
</MenuItem>
))}
</div>
)}
<div ref={scrollRef} className={'mx-1 flex-1 overflow-y-auto overflow-x-hidden px-1'}>
<KeyboardNavigation
scrollRef={scrollRef}
focusRef={inputRef}
options={filteredOptions}
disableFocus={true}
onConfirm={onConfirm}
onEscape={onClose}
itemStyle={{
borderRadius: '4px',
}}
/>
</div>
</div>
);

View File

@ -10,10 +10,9 @@ export interface SelectOptionItemProps {
option: SelectOption;
fieldId: string;
isSelected?: boolean;
onClick?: () => void;
}
export const SelectOptionItem: FC<SelectOptionItemProps> = ({ onClick, isSelected, fieldId, option }) => {
export const SelectOptionItem: FC<SelectOptionItemProps> = ({ isSelected, fieldId, option }) => {
const [open, setOpen] = useState(false);
const anchorEl = useRef<HTMLDivElement | null>(null);
const [hovered, setHovered] = useState(false);
@ -25,7 +24,6 @@ export const SelectOptionItem: FC<SelectOptionItemProps> = ({ onClick, isSelecte
return (
<>
<div
onClick={onClick}
ref={anchorEl}
className={'flex w-full items-center justify-between'}
onMouseEnter={() => setHovered(true)}

View File

@ -15,12 +15,12 @@ export interface FieldProps {
const initialAnchorOrigin: PopoverOrigin = {
vertical: 'bottom',
horizontal: 'left',
horizontal: 'right',
};
const initialTransformOrigin: PopoverOrigin = {
vertical: 'top',
horizontal: 'left',
horizontal: 'center',
};
export const Property: FC<FieldProps> = ({ field, onCloseMenu, className, menuOpened }) => {
@ -54,7 +54,7 @@ export const Property: FC<FieldProps> = ({ field, onCloseMenu, className, menuOp
}, [menuOpened]);
const { paperHeight, paperWidth, transformOrigin, anchorOrigin, isEntered } = usePopoverAutoPosition({
initialPaperWidth: 369,
initialPaperWidth: 300,
initialPaperHeight: 400,
anchorPosition,
initialAnchorOrigin,
@ -81,7 +81,7 @@ export const Property: FC<FieldProps> = ({ field, onCloseMenu, className, menuOp
PaperProps={{
style: {
maxHeight: paperHeight,
maxWidth: paperWidth,
width: paperWidth,
height: 'auto',
},
className: 'flex h-full flex-col overflow-hidden',

View File

@ -1,4 +1,3 @@
import { t } from 'i18next';
import { FC, useMemo, useRef, useState } from 'react';
import { SortConditionPB } from '@/services/backend';
import KeyboardNavigation, {
@ -6,11 +5,13 @@ import KeyboardNavigation, {
} from '$app/components/_shared/keyboard_navigation/KeyboardNavigation';
import { Popover } from '@mui/material';
import { ReactComponent as DropDownSvg } from '$app/assets/more.svg';
import { useTranslation } from 'react-i18next';
export const SortConditionSelect: FC<{
onChange?: (value: SortConditionPB) => void;
value?: SortConditionPB;
}> = ({ onChange, value }) => {
const { t } = useTranslation();
const ref = useRef<HTMLDivElement>(null);
const [open, setOpen] = useState(false);
const handleClose = () => {
@ -28,7 +29,7 @@ export const SortConditionSelect: FC<{
content: t('grid.sort.descending'),
},
];
}, []);
}, [t]);
const onConfirm = (optionKey: SortConditionPB) => {
onChange?.(optionKey);

View File

@ -84,6 +84,7 @@ function ViewActions({ view, pageId, ...props }: { pageId: string; view: Page }
updatePageName({
id: viewId,
name: val,
immediate: true,
})
);
setOpenRenameDialog(false);

View File

@ -2,6 +2,7 @@ import React from 'react';
import { useDatabaseVisibilityRows } from '$app/components/database';
import { Field } from '$app/application/database';
import { DEFAULT_FIELD_WIDTH, GRID_ACTIONS_WIDTH } from '$app/components/database/grid/constants';
import { useTranslation } from 'react-i18next';
interface Props {
field: Field;
@ -13,6 +14,7 @@ export function GridCalculate({ field, index }: Props) {
const rowMetas = useDatabaseVisibilityRows();
const count = rowMetas.length;
const width = index === 0 ? GRID_ACTIONS_WIDTH : field.width ?? DEFAULT_FIELD_WIDTH;
const { t } = useTranslation();
return (
<div
@ -23,7 +25,7 @@ export function GridCalculate({ field, index }: Props) {
>
{field.isPrimary ? (
<>
<span className={'mr-2 text-text-caption'}>Count</span>
<span className={'mr-2 text-text-caption'}>{t('grid.calculationTypeLabel.count')}</span>
<span>{count}</span>
</>
) : null}

View File

@ -133,6 +133,10 @@ export const GridField: FC<GridFieldProps> = memo(
className='relative flex h-full w-full items-center rounded-none px-0'
disableRipple
onContextMenu={(event) => {
if (propertyMenuOpened || menuOpened || open) {
return;
}
event.stopPropagation();
event.preventDefault();
handleClick();

View File

@ -1,8 +1,8 @@
import React, { useCallback } from 'react';
import { rowService } from '$app/application/database';
import { useViewId } from '$app/hooks';
import { t } from 'i18next';
import { ReactComponent as AddSvg } from '$app/assets/add.svg';
import { useTranslation } from 'react-i18next';
interface Props {
index: number;
@ -15,6 +15,7 @@ const CSS_HIGHLIGHT_PROPERTY = 'bg-content-blue-50';
function GridNewRow({ index, groupId, getContainerRef }: Props) {
const viewId = useViewId();
const { t } = useTranslation();
const handleClick = useCallback(() => {
void rowService.createRow(viewId, {
groupId,

View File

@ -10,6 +10,7 @@ import { useGridColumn, useGridRow } from './GridTable.hooks';
import GridStickyHeader from '$app/components/database/grid/grid_sticky_header/GridStickyHeader';
import GridTableOverlay from '$app/components/database/grid/grid_overlay/GridTableOverlay';
import ReactDOM from 'react-dom';
import { useViewId } from '$app/hooks';
export interface GridTableProps {
onEditRecord: (rowId: string) => void;
@ -30,6 +31,7 @@ export const GridTable: FC<GridTableProps> = React.memo(({ onEditRecord }) => {
columns,
ref as React.MutableRefObject<Grid<GridColumn[] | { columns: GridColumn[]; renderRows: RenderRow[] }> | null>
);
const viewId = useViewId();
const { rowHeight } = useGridRow();
const onRendered = useDatabaseRendered();
@ -139,7 +141,7 @@ export const GridTable: FC<GridTableProps> = React.memo(({ onEditRecord }) => {
className={'grid-scroll-container'}
outerRef={(el) => {
scrollElementRef.current = el;
onRendered();
onRendered(viewId);
}}
innerRef={containerRef}
>

View File

@ -3,8 +3,19 @@ import { ViewLayoutPB } from '@/services/backend';
export function useLoadDatabaseList({ searchText, layout }: { searchText: string; layout: ViewLayoutPB }) {
const list = useAppSelector((state) => {
const workspaces = state.workspace.workspaces.map((item) => item.id) ?? [];
return Object.values(state.pages.pageMap).filter((page) => {
if (page.layout !== layout) return false;
const parentId = page.parentId;
if (!parentId) return false;
const parent = state.pages.pageMap[parentId];
const parentLayout = parent?.layout;
if (!workspaces.includes(parentId) && parentLayout !== ViewLayoutPB.Document) return false;
return page.name.toLowerCase().includes(searchText.toLowerCase());
});
});

View File

@ -7,17 +7,19 @@ function GridView({ viewId }: { viewId: string }) {
const ref = useRef<HTMLDivElement>(null);
const [rendered, setRendered] = useState(false);
const [rendered, setRendered] = useState<{ viewId: string; rendered: boolean } | undefined>(undefined);
// delegate wheel event to layout when grid is scrolled to top or bottom
useEffect(() => {
const element = ref.current;
if (!element) {
const viewId = rendered?.viewId;
if (!viewId || !element) {
return;
}
const gridScroller = element.querySelector('.grid-scroll-container') as HTMLDivElement;
const gridScroller = element.querySelector(`[data-view-id="${viewId}"] .grid-scroll-container`) as HTMLDivElement;
const scrollLayout = gridScroller?.closest('.appflowy-scroll-container') as HTMLDivElement;
@ -29,7 +31,7 @@ function GridView({ viewId }: { viewId: string }) {
const deltaY = event.deltaY;
const deltaX = event.deltaX;
if (deltaX > 10) {
if (Math.abs(deltaX) > 8) {
return;
}
@ -50,8 +52,11 @@ function GridView({ viewId }: { viewId: string }) {
};
}, [rendered]);
const onRendered = useCallback(() => {
setRendered(true);
const onRendered = useCallback((viewId: string) => {
setRendered({
viewId,
rendered: true,
});
}, []);
return (

View File

@ -133,9 +133,9 @@ function LinkEditContent({ onClose, defaultHref }: { onClose: () => void; defaul
<div ref={scrollRef} className={'mt-1 flex w-full flex-col items-start'}>
{isActivated && (
<KeyboardNavigation
options={editOptions}
disableFocus={!focusMenu}
scrollRef={scrollRef}
options={editOptions}
onConfirm={onConfirm}
onFocus={() => {
setFocusMenu(true);
@ -143,8 +143,8 @@ function LinkEditContent({ onClose, defaultHref }: { onClose: () => void; defaul
onBlur={() => {
setFocusMenu(false);
}}
onEscape={onClose}
disableSelect={!focusMenu}
onEscape={onClose}
onKeyDown={(e) => {
e.stopPropagation();
if (isHotkey('Tab', e)) {

View File

@ -40,7 +40,7 @@ export function LinkEditPopover({
initialAnchorOrigin,
initialTransformOrigin,
initialPaperWidth: 340,
initialPaperHeight: 180,
initialPaperHeight: 200,
});
return (

View File

@ -160,7 +160,7 @@ export function ColorPicker({ onEscape, onChange, disableFocus }: ColorPickerPro
}, [renderColorItem, t]);
return (
<div ref={ref} className={'flex h-full max-h-[360px] w-full flex-col overflow-y-auto'}>
<div ref={ref} className={'flex h-full max-h-[420px] w-full flex-col overflow-y-auto'}>
<KeyboardNavigation
disableFocus={disableFocus}
onPressLeft={onEscape}

View File

@ -14,9 +14,13 @@ const initialOrigin: {
anchorOrigin?: PopoverOrigin;
} = {
anchorOrigin: {
vertical: 'top',
vertical: 'center',
horizontal: 'right',
},
transformOrigin: {
vertical: 'center',
horizontal: 'left',
},
};
export function Color({

View File

@ -12,7 +12,7 @@ const ActionButton = forwardRef<
} & IconButtonProps
>(({ tooltip, onClick, disabled, children, active, className, ...props }, ref) => {
return (
<Tooltip placement={'top'} title={tooltip}>
<Tooltip disableInteractive={true} placement={'top'} title={tooltip}>
<IconButton
ref={ref}
onClick={onClick}

View File

@ -47,7 +47,7 @@ function ColorPopover({
const { paperHeight, transformOrigin, anchorOrigin, isEntered } = usePopoverAutoPosition({
initialPaperWidth: 200,
initialPaperHeight: 360,
initialPaperHeight: 420,
anchorEl,
initialAnchorOrigin: initialOrigin.anchorOrigin,
initialTransformOrigin: initialOrigin.transformOrigin,

View File

@ -112,13 +112,14 @@ export function withPasted(editor: ReactEditor) {
if (isText && parent) {
const [parentNode, parentPath] = parent as NodeEntry<Element>;
const pastedNodeIsPage = parentNode.type === EditorNodeType.Page;
const pastedNodeIsNotList = !LIST_TYPES.includes(parentNode.type as EditorNodeType);
const clonedFragment = transFragment(editor, fragment);
const [firstNode, ...otherNodes] = clonedFragment;
const lastNode = getLastNode(otherNodes[otherNodes.length - 1]);
const firstIsEmbed = editor.isEmbed(firstNode);
const insertNodes: Element[] = [...otherNodes];
const needMoveChildren = parentNode.children.length > 1 && !pastedNodeIsPage;
const needMoveChildren = parentNode.children.length > 1 && !pastedNodeIsPage && !pastedNodeIsNotList;
let moveStartIndex = 0;
if (firstIsEmbed) {
@ -138,7 +139,7 @@ export function withPasted(editor: ReactEditor) {
});
if (children.length > 0) {
if (pastedNodeIsPage) {
if (pastedNodeIsPage || pastedNodeIsNotList) {
// lift the children of the first fragment node to current node
insertNodes.unshift(...children);
} else {

View File

@ -1,4 +1,4 @@
import React, { useCallback, useMemo } from 'react';
import React, { useCallback } from 'react';
import { useLoadExpandedPages } from '$app/components/layout/bread_crumb/Breadcrumb.hooks';
import Breadcrumbs from '@mui/material/Breadcrumbs';
import Link from '@mui/material/Link';
@ -13,7 +13,6 @@ function Breadcrumb() {
const { isTrash, pagePath, currentPage } = useLoadExpandedPages();
const navigate = useNavigate();
const parentPages = useMemo(() => pagePath.slice(1, -1).filter(Boolean) as Page[], [pagePath]);
const navigateToPage = useCallback(
(page: Page) => {
const pageType = pageTypeMap[page.layout];
@ -33,26 +32,32 @@ function Breadcrumb() {
return (
<Breadcrumbs aria-label='breadcrumb'>
{parentPages?.map((page: Page) => (
<Link
key={page.id}
className={'flex cursor-pointer select-none gap-1'}
underline='hover'
color='inherit'
onClick={() => {
navigateToPage(page);
}}
>
<div>{getPageIcon(page)}</div>
{pagePath?.map((page: Page, index) => {
if (index === pagePath.length - 1) {
return (
<div key={page.id} className={'flex select-none gap-1 text-text-title'}>
<div className={'select-none'}>{getPageIcon(page)}</div>
{page.name || t('menuAppHeader.defaultNewPageName')}
</div>
);
}
{page.name || t('document.title.placeholder')}
</Link>
))}
return (
<Link
key={page.id}
className={'flex cursor-pointer select-none gap-1'}
underline='hover'
color='inherit'
onClick={() => {
navigateToPage(page);
}}
>
<div>{getPageIcon(page)}</div>
<div className={'flex select-none gap-1 text-text-title'}>
<div className={'select-none'}>{getPageIcon(currentPage)}</div>
{currentPage.name || t('menuAppHeader.defaultNewPageName')}
</div>
{page.name || t('document.title.placeholder')}
</Link>
);
})}
</Breadcrumbs>
);
}

View File

@ -1,72 +1,34 @@
import { useAppSelector } from '$app/stores/store';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useMemo } from 'react';
import { useParams, useLocation } from 'react-router-dom';
import { Page } from '$app_reducers/pages/slice';
import { getPage } from '$app/application/folder/page.service';
export function useLoadExpandedPages() {
const params = useParams();
const location = useLocation();
const isTrash = useMemo(() => location.pathname.includes('trash'), [location.pathname]);
const currentPageId = params.id;
const pageMap = useAppSelector((state) => state.pages.pageMap);
const currentPage = currentPageId ? pageMap[currentPageId] : null;
const currentPage = useAppSelector((state) => (currentPageId ? state.pages.pageMap[currentPageId] : undefined));
const [pagePath, setPagePath] = useState<
(
| Page
| {
name: string;
}
)[]
>([]);
const pagePath = useAppSelector((state) => {
const result: Page[] = [];
const loadPagePath = useCallback(
async (pageId: string) => {
let page = pageMap[pageId];
if (!currentPage) return result;
if (!page) {
try {
page = await getPage(pageId);
} catch (e) {
// do nothing
}
const findParent = (page: Page) => {
if (!page.parentId) return;
const parent = state.pages.pageMap[page.parentId];
if (!page) {
return;
}
if (parent) {
result.unshift(parent);
findParent(parent);
}
};
setPagePath((prev) => {
return [page, ...prev];
});
if (page.parentId) {
await loadPagePath(page.parentId);
}
},
[pageMap]
);
useEffect(() => {
setPagePath([]);
if (!currentPageId) {
return;
}
void loadPagePath(currentPageId);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentPageId]);
useEffect(() => {
setPagePath((prev) => {
return prev.map((page, index) => {
if (!page) return page;
if (index === 0) return page;
return 'id' in page && page.id ? pageMap[page.id] : page;
});
});
}, [pageMap]);
findParent(currentPage);
result.push(currentPage);
return result;
});
return {
pagePath,

View File

@ -1,7 +1,34 @@
* {
margin: 0;
padding: 0;
.sketch-picker {
background-color: var(--bg-body) !important;
border-color: transparent !important;
box-shadow: none !important;
}
.sketch-picker .flexbox-fix {
border-color: var(--line-divider) !important;
}
.sketch-picker [id^='rc-editable-input'] {
background-color: var(--bg-body) !important;
border-color: var(--line-divider) !important;
color: var(--text-title) !important;
box-shadow: var(--line-border) 0px 0px 0px 1px inset !important;
}
.appflowy-date-picker-calendar {
width: 100%;
}
.grid-sticky-header::-webkit-scrollbar {
width: 0;
height: 0;
}
.grid-scroll-container::-webkit-scrollbar {
width: 0;
height: 0;
}
.appflowy-scroll-container {
&::-webkit-scrollbar {

View File

@ -12,7 +12,16 @@ function NestedPage({ pageId }: { pageId: string }) {
const { toggleCollapsed, collapsed, childPages } = useLoadChildPages(pageId);
const { onAddPage, onPageClick, onDeletePage, onDuplicatePage, onRenamePage } = usePageActions(pageId);
const dispatch = useAppDispatch();
const page = useAppSelector((state) => state.pages.pageMap[pageId]);
const { page, parentLayout } = useAppSelector((state) => {
const page = state.pages.pageMap[pageId];
const parent = state.pages.pageMap[page?.parentId || ''];
return {
page,
parentLayout: parent?.layout,
};
});
const disableChildren = useAppSelector((state) => {
if (!page) return true;
const layout = state.pages.pageMap[page.parentId]?.layout;
@ -65,6 +74,9 @@ function NestedPage({ pageId }: { pageId: string }) {
}
}, [dropPosition, isDragging, isDraggingOver, page?.layout]);
// Only allow dragging if the parent layout is undefined or a document
const draggable = parentLayout === undefined || parentLayout === ViewLayoutPB.Document;
return (
<div
className={className}
@ -73,7 +85,7 @@ function NestedPage({ pageId }: { pageId: string }) {
onDragOver={onDragOver}
onDragEnd={onDragEnd}
onDrop={onDrop}
draggable={true}
draggable={draggable}
data-drop-enabled={page?.layout === ViewLayoutPB.Document}
data-dragging={isDragging}
data-page-id={pageId}

View File

@ -2,6 +2,7 @@ import { createAsyncThunk } from '@reduxjs/toolkit';
import { RootState } from '$app/stores/store';
import { pagesActions } from '$app_reducers/pages/slice';
import { movePage, updatePage } from '$app/application/folder/page.service';
import debounce from 'lodash-es/debounce';
export const movePageThunk = createAsyncThunk(
'pages/movePage',
@ -61,12 +62,14 @@ export const movePageThunk = createAsyncThunk(
}
);
const debounceUpdateName = debounce(updatePage, 1000);
export const updatePageName = createAsyncThunk(
'pages/updateName',
async (payload: { id: string; name: string }, thunkAPI) => {
async (payload: { id: string; name: string; immediate?: boolean }, thunkAPI) => {
const { dispatch, getState } = thunkAPI;
const { pageMap } = (getState() as RootState).pages;
const { id, name } = payload;
const { id, name, immediate } = payload;
const page = pageMap[id];
if (name === page.name) return;
@ -78,9 +81,13 @@ export const updatePageName = createAsyncThunk(
})
);
await updatePage({
id,
name,
});
if (immediate) {
await updatePage({ id, name });
} else {
await debounceUpdateName({
id,
name,
});
}
}
);

View File

@ -1,5 +1,10 @@
@import './variables/index.css';
* {
margin: 0;
padding: 0;
}
/* stop body from scrolling */
html,
body {
@ -53,114 +58,3 @@ th {
@apply text-left font-normal;
}
.sketch-picker {
background-color: var(--bg-body) !important;
border-color: transparent !important;
box-shadow: none !important;
}
.sketch-picker .flexbox-fix {
border-color: var(--line-divider) !important;
}
.sketch-picker [id^='rc-editable-input'] {
background-color: var(--bg-body) !important;
border-color: var(--line-divider) !important;
color: var(--text-title) !important;
box-shadow: var(--line-border) 0px 0px 0px 1px inset !important;
}
.appflowy-date-picker-calendar {
width: 100%;
}
.react-datepicker__month-container {
width: 100%;
border-radius: 0;
}
.react-datepicker__header {
border-radius: 0;
background: transparent;
border-bottom: 0;
}
.react-datepicker__day-names {
border: none;
}
.react-datepicker__day-name {
color: var(--text-caption);
}
.react-datepicker__month {
border: none;
}
.react-datepicker__day {
border: none;
color: var(--text-title);
border-radius: 100%;
}
.react-datepicker__day:hover {
border-radius: 100%;
background: var(--fill-default);
color: var(--content-on-fill);
}
.react-datepicker__day--outside-month {
color: var(--text-caption);
}
.react-datepicker__day--in-range {
background: var(--fill-hover);
color: var(--content-on-fill);
}
.react-datepicker__day--today {
border: 1px solid var(--fill-default);
color: var(--text-title);
border-radius: 100%;
background: transparent;
font-weight: 500;
}
.react-datepicker__day--today:hover{
background: var(--fill-default);
color: var(--content-on-fill);
}
.react-datepicker__day--in-selecting-range, .react-datepicker__day--today.react-datepicker__day--in-range {
background: var(--fill-hover);
color: var(--content-on-fill);
border-color: transparent;
}
.react-datepicker__day--keyboard-selected {
background: transparent;
}
.react-datepicker__day--range-start, .react-datepicker__day--range-end, .react-datepicker__day--selected {
&.react-datepicker__day--today {
background: var(--fill-default);
color: var(--content-on-fill);
}
background: var(--fill-default) !important;
color: var(--content-on-fill);
}
.react-datepicker__day--range-start, .react-datepicker__day--range-end, .react-datepicker__day--selected:hover {
background: var(--fill-default);
color: var(--content-on-fill);
}
.react-swipeable-view-container {
height: 100%;
}
.grid-sticky-header::-webkit-scrollbar {
width: 0;
height: 0;
}
.grid-scroll-container::-webkit-scrollbar {
width: 0;
height: 0;
}

View File

@ -221,7 +221,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "app-error"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"bincode",
@ -545,7 +545,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"again",
"anyhow",
@ -946,7 +946,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]]
name = "database-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"app-error",
@ -1700,7 +1700,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"futures-util",
@ -1717,7 +1717,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"app-error",
@ -2051,7 +2051,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"reqwest",
@ -3295,7 +3295,7 @@ dependencies = [
[[package]]
name = "realtime-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"bincode",
@ -3319,7 +3319,7 @@ dependencies = [
[[package]]
name = "realtime-protocol"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"bincode",
@ -3772,7 +3772,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"anyhow",
"app-error",
@ -4714,7 +4714,7 @@ checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10"
[[package]]
name = "websocket"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eed20c25197109a3f799a5d18d0e38e9f5529d69#eed20c25197109a3f799a5d18d0e38e9f5529d69"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [
"futures-channel",
"futures-util",

Some files were not shown because too many files have changed in this diff Show More