mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
* refactor: weak passed-in params in handler * refactor: rename struct * chore: update tables * chore: update schema * chore: add permission * chore: update tables * chore: support transaction mode * chore: workspace database id * chore: add user workspace * feat: return list of workspaces * chore: add user to workspace * feat: separate database row table * refactor: update schema * chore: partition table * chore: use transaction * refactor: dir * refactor: collab db ref * fix: collab db lock * chore: rename files * chore: add tables descriptions * chore: update readme * docs: update documentation * chore: rename crate * chore: update ref * chore: update tests * chore: update tests * refactor: crate deps * chore: update crate ref * chore: remove unused deps * chore: remove unused deps * chore: update collab crate refs * chore: replace client with transaction in pooler * refactor: return error type * refactor: use anyhow error in deps * feat: supabase postgrest user signin (wip) * fix: Cargo.toml source git deps, changed Error to anyhow::Error * fix: uuid serialization * chore: fix conflict * chore: extend the response * feat: add implementation place holders * feat: impl get_user_workspaces * feat: impl get_user_profile * test: create workspace * fix: postgrest: field names and alias * chore: implement folder restful api * chore: implement collab storate with restful api * feat: added placeholders for impl: update_user_profile, check_user * feat: impl: update_user_profile * feat: impl: check_user * fix: use UidResponse, add more debug info for serde serialization error * fix: get_user_profile: use Optional<UserProfileResponse> * chore: imple init sync * chore: support soft delete * feat: postgresql: add migration test * feat: postgresql migration test: added UID display and colored output * feat: postgresql migration test: workspace role * feat: postgresql migration test: create shared common utils * feat: postgresql migration test: fixed shebang * chore: add flush_collab_update pg function * chore: implement datbaase and document restful api * chore: migrate to use restful api * chore: update table schema * chore: fix tests * chore: remove unused code * chore: format code * chore: remove unused env * fix: tauri build * fix: tauri build --------- Co-authored-by: Fu Zi Xiang <speed2exe@live.com.sg>
146 lines
4.7 KiB
Rust
146 lines
4.7 KiB
Rust
use std::sync::Weak;
|
|
|
|
use strum_macros::Display;
|
|
|
|
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
|
use lib_dispatch::prelude::*;
|
|
|
|
use crate::event_handler::*;
|
|
use crate::manager::FolderManager;
|
|
|
|
pub fn init(folder: Weak<FolderManager>) -> AFPlugin {
|
|
AFPlugin::new().name("Flowy-Folder").state(folder)
|
|
// Workspace
|
|
.event(FolderEvent::CreateWorkspace, create_workspace_handler)
|
|
.event(
|
|
FolderEvent::GetCurrentWorkspace,
|
|
get_current_workspace_setting_handler,
|
|
)
|
|
.event(FolderEvent::ReadAllWorkspaces, read_workspaces_handler)
|
|
.event(FolderEvent::OpenWorkspace, open_workspace_handler)
|
|
.event(FolderEvent::ReadWorkspaceViews, get_workspace_views_handler)
|
|
// View
|
|
.event(FolderEvent::CreateView, create_view_handler)
|
|
.event(FolderEvent::CreateOrphanView, create_orphan_view_handler)
|
|
.event(FolderEvent::ReadView, read_view_handler)
|
|
.event(FolderEvent::UpdateView, update_view_handler)
|
|
.event(FolderEvent::DeleteView, delete_view_handler)
|
|
.event(FolderEvent::DuplicateView, duplicate_view_handler)
|
|
.event(FolderEvent::SetLatestView, set_latest_view_handler)
|
|
.event(FolderEvent::CloseView, close_view_handler)
|
|
.event(FolderEvent::MoveView, move_view_handler)
|
|
.event(FolderEvent::MoveNestedView, move_nested_view_handler)
|
|
// Trash
|
|
.event(FolderEvent::ReadTrash, read_trash_handler)
|
|
.event(FolderEvent::PutbackTrash, putback_trash_handler)
|
|
.event(FolderEvent::DeleteTrash, delete_trash_handler)
|
|
.event(FolderEvent::RestoreAllTrash, restore_all_trash_handler)
|
|
.event(FolderEvent::DeleteAllTrash, delete_all_trash_handler)
|
|
.event(FolderEvent::ImportData, import_data_handler)
|
|
.event(FolderEvent::GetFolderSnapshots, get_folder_snapshots_handler)
|
|
}
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
|
#[event_err = "FlowyError"]
|
|
pub enum FolderEvent {
|
|
/// Create a new workspace
|
|
#[event(input = "CreateWorkspacePayloadPB", output = "WorkspacePB")]
|
|
CreateWorkspace = 0,
|
|
|
|
/// Read the current opening workspace. Currently, we only support one workspace
|
|
#[event(output = "WorkspaceSettingPB")]
|
|
GetCurrentWorkspace = 1,
|
|
|
|
/// Return a list of workspaces that the current user can access.
|
|
#[event(input = "WorkspaceIdPB", output = "RepeatedWorkspacePB")]
|
|
ReadAllWorkspaces = 2,
|
|
|
|
/// Delete the workspace
|
|
#[event(input = "WorkspaceIdPB")]
|
|
DeleteWorkspace = 3,
|
|
|
|
/// Open the workspace and mark it as the current workspace
|
|
#[event(input = "WorkspaceIdPB", output = "WorkspacePB")]
|
|
OpenWorkspace = 4,
|
|
|
|
/// Return a list of views of the current workspace.
|
|
/// Only the first level of child views are included.
|
|
#[event(input = "WorkspaceIdPB", output = "RepeatedViewPB")]
|
|
ReadWorkspaceViews = 5,
|
|
|
|
/// Create a new view in the corresponding app
|
|
#[event(input = "CreateViewPayloadPB", output = "ViewPB")]
|
|
CreateView = 10,
|
|
|
|
/// Return the view info
|
|
#[event(input = "ViewIdPB", output = "ViewPB")]
|
|
ReadView = 11,
|
|
|
|
/// Update the view's properties including the name,description, etc.
|
|
#[event(input = "UpdateViewPayloadPB", output = "ViewPB")]
|
|
UpdateView = 12,
|
|
|
|
/// Move the view to the trash folder
|
|
#[event(input = "RepeatedViewIdPB")]
|
|
DeleteView = 13,
|
|
|
|
/// Duplicate the view
|
|
#[event(input = "ViewPB")]
|
|
DuplicateView = 14,
|
|
|
|
/// Close and release the resources that are used by this view.
|
|
/// It should get called when the 'View' page get destroy
|
|
#[event(input = "ViewIdPB")]
|
|
CloseView = 15,
|
|
|
|
/// Create a new view in the corresponding app
|
|
#[event(input = "CreateOrphanViewPayloadPB", output = "ViewPB")]
|
|
CreateOrphanView = 16,
|
|
|
|
#[event()]
|
|
CopyLink = 20,
|
|
|
|
/// Set the current visiting view
|
|
#[event(input = "ViewIdPB")]
|
|
SetLatestView = 21,
|
|
|
|
/// Move the view or app to another place
|
|
#[event(input = "MoveViewPayloadPB")]
|
|
MoveView = 22,
|
|
|
|
/// Read the trash that was deleted by the user
|
|
#[event(output = "RepeatedTrashPB")]
|
|
ReadTrash = 23,
|
|
|
|
/// Put back the trash to the origin folder
|
|
#[event(input = "TrashIdPB")]
|
|
PutbackTrash = 24,
|
|
|
|
/// Delete the trash from the disk
|
|
#[event(input = "RepeatedTrashIdPB")]
|
|
DeleteTrash = 25,
|
|
|
|
/// Put back all the trash to its original folder
|
|
#[event()]
|
|
RestoreAllTrash = 26,
|
|
|
|
/// Delete all the trash from the disk
|
|
#[event()]
|
|
DeleteAllTrash = 27,
|
|
|
|
#[event(input = "ImportPB")]
|
|
ImportData = 30,
|
|
|
|
#[event()]
|
|
GetFolderSnapshots = 31,
|
|
|
|
/// Moves a nested view to a new location in the hierarchy.
|
|
///
|
|
/// This function takes the `view_id` of the view to be moved,
|
|
/// `new_parent_id` of the view under which the `view_id` should be moved,
|
|
/// and an optional `prev_view_id` to position the `view_id` right after
|
|
/// this specific view.
|
|
#[event(input = "MoveNestedViewPayloadPB")]
|
|
MoveNestedView = 32,
|
|
}
|