mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: add grid event
This commit is contained in:
22
frontend/rust-lib/Cargo.lock
generated
22
frontend/rust-lib/Cargo.lock
generated
@ -1041,6 +1041,27 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "flowy-grid"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"flowy-derive",
|
||||
"flowy-error",
|
||||
"flowy-grid-data-model",
|
||||
"lib-dispatch",
|
||||
"lib-infra",
|
||||
"protobuf",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-grid-data-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"flowy-derive",
|
||||
"lib-infra",
|
||||
"protobuf",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-net"
|
||||
@ -1091,6 +1112,7 @@ dependencies = [
|
||||
"flowy-collaboration",
|
||||
"flowy-database",
|
||||
"flowy-folder",
|
||||
"flowy-grid",
|
||||
"flowy-net",
|
||||
"flowy-sync",
|
||||
"flowy-user",
|
||||
|
@ -49,11 +49,11 @@ serde_json = "1.0"
|
||||
flowy-folder = { path = "../flowy-folder", features = ["flowy_unit_test"]}
|
||||
flowy-test = { path = "../flowy-test" }
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "proto_gen"] }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
http_server = []
|
||||
flowy_unit_test = ["lib-ot/flowy_unit_test", "flowy-sync/flowy_unit_test"]
|
||||
dart = ["lib-infra/dart", "flowy-folder/dart", "flowy-folder/dart",]
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "proto_gen"] }
|
||||
dart = ["lib-infra/dart", "flowy-folder/dart"]
|
@ -6,3 +6,20 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
flowy-grid-data-model = { path = "../../../shared-lib/flowy-grid-data-model" }
|
||||
lib-dispatch = { path = "../lib-dispatch" }
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
||||
flowy-error = { path = "../flowy-error"}
|
||||
strum = "0.21"
|
||||
strum_macros = "0.21"
|
||||
flowy-derive = { path = "../../../shared-lib/flowy-derive" }
|
||||
tracing = { version = "0.1", features = ["log"] }
|
||||
protobuf = {version = "2.18.0"}
|
||||
|
||||
[build-dependencies]
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "proto_gen"] }
|
||||
|
||||
|
||||
[features]
|
||||
default = []
|
||||
dart = ["lib-infra/dart"]
|
3
frontend/rust-lib/flowy-grid/Flowy.toml
Normal file
3
frontend/rust-lib/flowy-grid/Flowy.toml
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
proto_crates = ["src/event_map.rs"]
|
||||
event_files = ["src/event_map.rs"]
|
7
frontend/rust-lib/flowy-grid/build.rs
Normal file
7
frontend/rust-lib/flowy-grid/build.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use lib_infra::code_gen;
|
||||
|
||||
fn main() {
|
||||
let crate_name = env!("CARGO_PKG_NAME");
|
||||
code_gen::protobuf_file::gen(crate_name, "./src/protobuf/proto");
|
||||
code_gen::dart_event::gen(crate_name);
|
||||
}
|
1
frontend/rust-lib/flowy-grid/src/controller.rs
Normal file
1
frontend/rust-lib/flowy-grid/src/controller.rs
Normal file
@ -0,0 +1 @@
|
||||
pub struct GridManager {}
|
23
frontend/rust-lib/flowy-grid/src/event_handler.rs
Normal file
23
frontend/rust-lib/flowy-grid/src/event_handler.rs
Normal file
@ -0,0 +1,23 @@
|
||||
use crate::controller::GridManager;
|
||||
use flowy_error::FlowyError;
|
||||
use flowy_grid_data_model::entities::{CreateGridPayload, Grid, GridId};
|
||||
use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[tracing::instrument(skip(data, controller), err)]
|
||||
pub(crate) async fn create_grid_handler(
|
||||
data: Data<CreateGridPayload>,
|
||||
controller: AppData<Arc<GridManager>>,
|
||||
) -> DataResult<Grid, FlowyError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(data, controller), err)]
|
||||
pub(crate) async fn open_grid_handler(
|
||||
data: Data<GridId>,
|
||||
controller: AppData<Arc<GridManager>>,
|
||||
) -> DataResult<Grid, FlowyError> {
|
||||
let params: GridId = data.into_inner();
|
||||
|
||||
todo!()
|
||||
}
|
26
frontend/rust-lib/flowy-grid/src/event_map.rs
Normal file
26
frontend/rust-lib/flowy-grid/src/event_map.rs
Normal file
@ -0,0 +1,26 @@
|
||||
use crate::controller::GridManager;
|
||||
use crate::event_handler::*;
|
||||
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
||||
use lib_dispatch::prelude::*;
|
||||
use std::sync::Arc;
|
||||
use strum_macros::Display;
|
||||
|
||||
pub fn create(grid_manager: Arc<GridManager>) -> Module {
|
||||
let mut module = Module::new().name(env!("CARGO_PKG_NAME")).data(grid_manager);
|
||||
|
||||
module = module
|
||||
.event(GridEvent::CreateGrid, create_grid_handler)
|
||||
.event(GridEvent::OpenGrid, open_grid_handler);
|
||||
|
||||
module
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
||||
#[event_err = "FlowyError"]
|
||||
pub enum GridEvent {
|
||||
#[event(input = "CreateGridPayload", output = "Grid")]
|
||||
CreateGrid = 0,
|
||||
|
||||
#[event(input = "GridId", output = "Grid")]
|
||||
OpenGrid = 1,
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = 2 + 2;
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
mod controller;
|
||||
mod event_handler;
|
||||
mod event_map;
|
||||
|
||||
mod protobuf;
|
||||
|
4
frontend/rust-lib/flowy-grid/src/protobuf/mod.rs
Normal file
4
frontend/rust-lib/flowy-grid/src/protobuf/mod.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#![cfg_attr(rustfmt, rustfmt::skip)]
|
||||
// Auto-generated, do not edit
|
||||
mod model;
|
||||
pub use model::*;
|
91
frontend/rust-lib/flowy-grid/src/protobuf/model/event_map.rs
Normal file
91
frontend/rust-lib/flowy-grid/src/protobuf/model/event_map.rs
Normal file
@ -0,0 +1,91 @@
|
||||
// This file is generated by rust-protobuf 2.25.2. Do not edit
|
||||
// @generated
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/702
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(clippy::all)]
|
||||
|
||||
#![allow(unused_attributes)]
|
||||
#![cfg_attr(rustfmt, rustfmt::skip)]
|
||||
|
||||
#![allow(box_pointers)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(missing_docs)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(trivial_casts)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_results)]
|
||||
//! Generated file from `event_map.proto`
|
||||
|
||||
/// Generated files are compatible only with the same version
|
||||
/// of protobuf runtime.
|
||||
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;
|
||||
|
||||
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
|
||||
pub enum GridEvent {
|
||||
CreateGrid = 0,
|
||||
OpenGrid = 1,
|
||||
}
|
||||
|
||||
impl ::protobuf::ProtobufEnum for GridEvent {
|
||||
fn value(&self) -> i32 {
|
||||
*self as i32
|
||||
}
|
||||
|
||||
fn from_i32(value: i32) -> ::std::option::Option<GridEvent> {
|
||||
match value {
|
||||
0 => ::std::option::Option::Some(GridEvent::CreateGrid),
|
||||
1 => ::std::option::Option::Some(GridEvent::OpenGrid),
|
||||
_ => ::std::option::Option::None
|
||||
}
|
||||
}
|
||||
|
||||
fn values() -> &'static [Self] {
|
||||
static values: &'static [GridEvent] = &[
|
||||
GridEvent::CreateGrid,
|
||||
GridEvent::OpenGrid,
|
||||
];
|
||||
values
|
||||
}
|
||||
|
||||
fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor {
|
||||
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::LazyV2::INIT;
|
||||
descriptor.get(|| {
|
||||
::protobuf::reflect::EnumDescriptor::new_pb_name::<GridEvent>("GridEvent", file_descriptor_proto())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::marker::Copy for GridEvent {
|
||||
}
|
||||
|
||||
impl ::std::default::Default for GridEvent {
|
||||
fn default() -> Self {
|
||||
GridEvent::CreateGrid
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for GridEvent {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Enum(::protobuf::ProtobufEnum::descriptor(self))
|
||||
}
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x0fevent_map.proto*)\n\tGridEvent\x12\x0e\n\nCreateGrid\x10\0\x12\x0c\
|
||||
\n\x08OpenGrid\x10\x01b\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
||||
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
|
||||
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
|
||||
}
|
||||
|
||||
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
|
||||
file_descriptor_proto_lazy.get(|| {
|
||||
parse_descriptor_proto()
|
||||
})
|
||||
}
|
5
frontend/rust-lib/flowy-grid/src/protobuf/model/mod.rs
Normal file
5
frontend/rust-lib/flowy-grid/src/protobuf/model/mod.rs
Normal file
@ -0,0 +1,5 @@
|
||||
#![cfg_attr(rustfmt, rustfmt::skip)]
|
||||
// Auto-generated, do not edit
|
||||
|
||||
mod event_map;
|
||||
pub use event_map::*;
|
@ -0,0 +1,6 @@
|
||||
syntax = "proto3";
|
||||
|
||||
enum GridEvent {
|
||||
CreateGrid = 0;
|
||||
OpenGrid = 1;
|
||||
}
|
@ -11,6 +11,7 @@ lib-log = { path = "../lib-log" }
|
||||
flowy-user = { path = "../flowy-user" }
|
||||
flowy-net = { path = "../flowy-net" }
|
||||
flowy-folder = { path = "../flowy-folder", default-features = false }
|
||||
flowy-grid = { path = "../flowy-grid", default-features = false }
|
||||
flowy-database = { path = "../flowy-database" }
|
||||
flowy-block = { path = "../flowy-block" }
|
||||
flowy-sync = { path = "../flowy-sync" }
|
||||
@ -39,4 +40,4 @@ futures-util = "0.3.15"
|
||||
[features]
|
||||
http_server = ["flowy-user/http_server", "flowy-folder/http_server", "flowy-block/http_server"]
|
||||
use_bunyan = ["lib-log/use_bunyan"]
|
||||
dart = ["flowy-user/dart", "flowy-net/dart", "flowy-folder/dart", "flowy-collaboration/dart"]
|
||||
dart = ["flowy-user/dart", "flowy-net/dart", "flowy-folder/dart", "flowy-collaboration/dart", "flowy-grid/dart"]
|
||||
|
Reference in New Issue
Block a user