create app's views

This commit is contained in:
appflowy 2021-07-20 15:51:49 +08:00
parent b1f4f0520a
commit 7868305a32
34 changed files with 946 additions and 148 deletions

View File

@ -9,6 +9,8 @@ import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
import 'view_create.pb.dart' as $0;
class CreateAppRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CreateAppRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'workspaceId')
@ -153,6 +155,7 @@ class App extends $pb.GeneratedMessage {
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'workspaceId')
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'desc')
..aOM<$0.RepeatedView>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'views', subBuilder: $0.RepeatedView.create)
..hasRequiredFields = false
;
@ -162,6 +165,7 @@ class App extends $pb.GeneratedMessage {
$core.String? workspaceId,
$core.String? name,
$core.String? desc,
$0.RepeatedView? views,
}) {
final _result = create();
if (id != null) {
@ -176,6 +180,9 @@ class App extends $pb.GeneratedMessage {
if (desc != null) {
_result.desc = desc;
}
if (views != null) {
_result.views = views;
}
return _result;
}
factory App.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
@ -234,6 +241,17 @@ class App extends $pb.GeneratedMessage {
$core.bool hasDesc() => $_has(3);
@$pb.TagNumber(4)
void clearDesc() => clearField(4);
@$pb.TagNumber(5)
$0.RepeatedView get views => $_getN(4);
@$pb.TagNumber(5)
set views($0.RepeatedView v) { setField(5, v); }
@$pb.TagNumber(5)
$core.bool hasViews() => $_has(4);
@$pb.TagNumber(5)
void clearViews() => clearField(5);
@$pb.TagNumber(5)
$0.RepeatedView ensureViews() => $_ensure(4);
}
class RepeatedApp extends $pb.GeneratedMessage {

View File

@ -39,11 +39,12 @@ const App$json = const {
const {'1': 'workspace_id', '3': 2, '4': 1, '5': 9, '10': 'workspaceId'},
const {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'},
const {'1': 'desc', '3': 4, '4': 1, '5': 9, '10': 'desc'},
const {'1': 'views', '3': 5, '4': 1, '5': 11, '6': '.RepeatedView', '10': 'views'},
],
};
/// Descriptor for `App`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List appDescriptor = $convert.base64Decode('CgNBcHASDgoCaWQYASABKAlSAmlkEiEKDHdvcmtzcGFjZV9pZBgCIAEoCVILd29ya3NwYWNlSWQSEgoEbmFtZRgDIAEoCVIEbmFtZRISCgRkZXNjGAQgASgJUgRkZXNj');
final $typed_data.Uint8List appDescriptor = $convert.base64Decode('CgNBcHASDgoCaWQYASABKAlSAmlkEiEKDHdvcmtzcGFjZV9pZBgCIAEoCVILd29ya3NwYWNlSWQSEgoEbmFtZRgDIAEoCVIEbmFtZRISCgRkZXNjGAQgASgJUgRkZXNjEiMKBXZpZXdzGAUgASgLMg0uUmVwZWF0ZWRWaWV3UgV2aWV3cw==');
@$core.Deprecated('Use repeatedAppDescriptor instead')
const RepeatedApp$json = const {
'1': 'RepeatedApp',

View File

@ -0,0 +1,72 @@
///
// Generated code. Do not modify.
// source: app_query.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class QueryAppRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'QueryAppRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'appId')
..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'readViews')
..hasRequiredFields = false
;
QueryAppRequest._() : super();
factory QueryAppRequest({
$core.String? appId,
$core.bool? readViews,
}) {
final _result = create();
if (appId != null) {
_result.appId = appId;
}
if (readViews != null) {
_result.readViews = readViews;
}
return _result;
}
factory QueryAppRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory QueryAppRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
QueryAppRequest clone() => QueryAppRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
QueryAppRequest copyWith(void Function(QueryAppRequest) updates) => super.copyWith((message) => updates(message as QueryAppRequest)) as QueryAppRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static QueryAppRequest create() => QueryAppRequest._();
QueryAppRequest createEmptyInstance() => create();
static $pb.PbList<QueryAppRequest> createRepeated() => $pb.PbList<QueryAppRequest>();
@$core.pragma('dart2js:noInline')
static QueryAppRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<QueryAppRequest>(create);
static QueryAppRequest? _defaultInstance;
@$pb.TagNumber(1)
$core.String get appId => $_getSZ(0);
@$pb.TagNumber(1)
set appId($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasAppId() => $_has(0);
@$pb.TagNumber(1)
void clearAppId() => clearField(1);
@$pb.TagNumber(2)
$core.bool get readViews => $_getBF(1);
@$pb.TagNumber(2)
set readViews($core.bool v) { $_setBool(1, v); }
@$pb.TagNumber(2)
$core.bool hasReadViews() => $_has(1);
@$pb.TagNumber(2)
void clearReadViews() => clearField(2);
}

View File

@ -0,0 +1,7 @@
///
// Generated code. Do not modify.
// source: app_query.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields

View File

@ -0,0 +1,21 @@
///
// Generated code. Do not modify.
// source: app_query.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use queryAppRequestDescriptor instead')
const QueryAppRequest$json = const {
'1': 'QueryAppRequest',
'2': const [
const {'1': 'app_id', '3': 1, '4': 1, '5': 9, '10': 'appId'},
const {'1': 'read_views', '3': 2, '4': 1, '5': 8, '10': 'readViews'},
],
};
/// Descriptor for `QueryAppRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List queryAppRequestDescriptor = $convert.base64Decode('Cg9RdWVyeUFwcFJlcXVlc3QSFQoGYXBwX2lkGAEgASgJUgVhcHBJZBIdCgpyZWFkX3ZpZXdzGAIgASgIUglyZWFkVmlld3M=');

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: app_query.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
export 'app_query.pb.dart';

View File

@ -14,6 +14,7 @@ class WorkspaceEvent extends $pb.ProtobufEnum {
static const WorkspaceEvent GetCurWorkspace = WorkspaceEvent._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'GetCurWorkspace');
static const WorkspaceEvent GetWorkspace = WorkspaceEvent._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'GetWorkspace');
static const WorkspaceEvent CreateApp = WorkspaceEvent._(101, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CreateApp');
static const WorkspaceEvent GetApp = WorkspaceEvent._(102, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'GetApp');
static const WorkspaceEvent CreateView = WorkspaceEvent._(201, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CreateView');
static const $core.List<WorkspaceEvent> values = <WorkspaceEvent> [
@ -21,6 +22,7 @@ class WorkspaceEvent extends $pb.ProtobufEnum {
GetCurWorkspace,
GetWorkspace,
CreateApp,
GetApp,
CreateView,
];

View File

@ -16,9 +16,10 @@ const WorkspaceEvent$json = const {
const {'1': 'GetCurWorkspace', '2': 1},
const {'1': 'GetWorkspace', '2': 2},
const {'1': 'CreateApp', '2': 101},
const {'1': 'GetApp', '2': 102},
const {'1': 'CreateView', '2': 201},
],
};
/// Descriptor for `WorkspaceEvent`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List workspaceEventDescriptor = $convert.base64Decode('Cg5Xb3Jrc3BhY2VFdmVudBITCg9DcmVhdGVXb3Jrc3BhY2UQABITCg9HZXRDdXJXb3Jrc3BhY2UQARIQCgxHZXRXb3Jrc3BhY2UQAhINCglDcmVhdGVBcHAQZRIPCgpDcmVhdGVWaWV3EMkB');
final $typed_data.Uint8List workspaceEventDescriptor = $convert.base64Decode('Cg5Xb3Jrc3BhY2VFdmVudBITCg9DcmVhdGVXb3Jrc3BhY2UQABITCg9HZXRDdXJXb3Jrc3BhY2UQARIQCgxHZXRXb3Jrc3BhY2UQAhINCglDcmVhdGVBcHAQZRIKCgZHZXRBcHAQZhIPCgpDcmVhdGVWaWV3EMkB');

View File

@ -1,4 +1,5 @@
// Auto-generated, do not edit
export './app_query.pb.dart';
export './errors.pb.dart';
export './workspace_update.pb.dart';
export './app_create.pb.dart';

View File

@ -232,3 +232,44 @@ class View extends $pb.GeneratedMessage {
void clearViewType() => clearField(5);
}
class RepeatedView extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RepeatedView', createEmptyInstance: create)
..pc<View>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'items', $pb.PbFieldType.PM, subBuilder: View.create)
..hasRequiredFields = false
;
RepeatedView._() : super();
factory RepeatedView({
$core.Iterable<View>? items,
}) {
final _result = create();
if (items != null) {
_result.items.addAll(items);
}
return _result;
}
factory RepeatedView.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory RepeatedView.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
RepeatedView clone() => RepeatedView()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
RepeatedView copyWith(void Function(RepeatedView) updates) => super.copyWith((message) => updates(message as RepeatedView)) as RepeatedView; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static RepeatedView create() => RepeatedView._();
RepeatedView createEmptyInstance() => create();
static $pb.PbList<RepeatedView> createRepeated() => $pb.PbList<RepeatedView>();
@$core.pragma('dart2js:noInline')
static RepeatedView getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<RepeatedView>(create);
static RepeatedView? _defaultInstance;
@$pb.TagNumber(1)
$core.List<View> get items => $_getList(0);
}

View File

@ -49,3 +49,13 @@ const View$json = const {
/// Descriptor for `View`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List viewDescriptor = $convert.base64Decode('CgRWaWV3Eg4KAmlkGAEgASgJUgJpZBIVCgZhcHBfaWQYAiABKAlSBWFwcElkEhIKBG5hbWUYAyABKAlSBG5hbWUSEgoEZGVzYxgEIAEoCVIEZGVzYxIwCgl2aWV3X3R5cGUYBSABKA4yEy5WaWV3VHlwZUlkZW50aWZpZXJSCHZpZXdUeXBl');
@$core.Deprecated('Use repeatedViewDescriptor instead')
const RepeatedView$json = const {
'1': 'RepeatedView',
'2': const [
const {'1': 'items', '3': 1, '4': 3, '5': 11, '6': '.View', '10': 'items'},
],
};
/// Descriptor for `RepeatedView`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List repeatedViewDescriptor = $convert.base64Decode('CgxSZXBlYXRlZFZpZXcSGwoFaXRlbXMYASADKAsyBS5WaWV3UgVpdGVtcw==');

View File

@ -16,6 +16,7 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
"u8" => TypeCategory::Bytes,
"String" => TypeCategory::Str,
"KeyValue"
| "QueryAppRequest"
| "CreateAppRequest"
| "ColorStyle"
| "App"
@ -28,6 +29,7 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
| "CurrentWorkspace"
| "CreateViewRequest"
| "View"
| "RepeatedView"
| "WorkspaceError"
| "FFIRequest"
| "FFIResponse"

View File

@ -1,6 +1,7 @@
use crate::{
entities::{
app::parser::{AppColorStyle, AppName},
view::RepeatedView,
workspace::parser::WorkspaceId,
},
errors::*,
@ -81,6 +82,9 @@ pub struct App {
#[pb(index = 4)]
pub desc: String,
#[pb(index = 5)]
pub views: RepeatedView,
}
#[derive(Debug, Default, ProtoBuf)]

View File

@ -0,0 +1,36 @@
use crate::{entities::app::parser::AppId, errors::*};
use flowy_derive::ProtoBuf;
use std::convert::TryInto;
#[derive(Default, ProtoBuf)]
pub struct QueryAppRequest {
#[pb(index = 1)]
pub app_id: String,
#[pb(index = 2)]
pub read_views: bool,
}
pub struct QueryAppParams {
pub app_id: String,
pub read_views: bool,
}
impl TryInto<QueryAppParams> for QueryAppRequest {
type Error = WorkspaceError;
fn try_into(self) -> Result<QueryAppParams, Self::Error> {
let app_id = AppId::parse(self.app_id)
.map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::AppIdInvalid)
.msg(e)
.build()
})?
.0;
Ok(QueryAppParams {
app_id,
read_views: self.read_views,
})
}
}

View File

@ -2,5 +2,8 @@ pub use app_create::*;
pub use app_update::*;
mod app_create;
mod app_query;
mod app_update;
pub mod parser;
pub use app_query::*;

View File

@ -1,12 +1,13 @@
use crate::{
entities::{app::parser::AppId, view::parser::*},
errors::{ErrorBuilder, WorkspaceError, WorkspaceErrorCode},
impl_def_and_def_mut,
sql_tables::view::ViewType,
};
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use std::convert::TryInto;
#[derive(Debug, ProtoBuf_Enum)]
#[derive(PartialEq, Debug, ProtoBuf_Enum)]
pub enum ViewTypeIdentifier {
Docs = 0,
}
@ -85,7 +86,7 @@ impl TryInto<CreateViewParams> for CreateViewRequest {
}
}
#[derive(ProtoBuf, Default, Debug)]
#[derive(PartialEq, ProtoBuf, Default, Debug)]
pub struct View {
#[pb(index = 1)]
pub id: String,
@ -102,3 +103,11 @@ pub struct View {
#[pb(index = 5)]
pub view_type: ViewTypeIdentifier,
}
#[derive(PartialEq, Debug, Default, ProtoBuf)]
pub struct RepeatedView {
#[pb(index = 1)]
pub items: Vec<View>,
}
impl_def_and_def_mut!(RepeatedView, View);

View File

@ -16,10 +16,14 @@ pub enum WorkspaceEvent {
#[event(input = "QueryWorkspaceRequest", output = "Workspace")]
GetWorkspace = 2,
#[display(fmt = "Create app")]
#[display(fmt = "Create app information")]
#[event(input = "CreateAppRequest", output = "App")]
CreateApp = 101,
#[display(fmt = "Get app information")]
#[event(input = "QueryAppRequest", output = "App")]
GetApp = 102,
#[display(fmt = "Create view")]
#[event(input = "CreateViewRequest", output = "View")]
CreateView = 201,

View File

@ -1,5 +1,8 @@
use crate::{
entities::app::{App, CreateAppParams, CreateAppRequest},
entities::{
app::{App, CreateAppParams, CreateAppRequest, QueryAppParams, QueryAppRequest},
view::RepeatedView,
},
errors::WorkspaceError,
services::AppController,
};
@ -14,3 +17,17 @@ pub async fn create_app(
let detail = controller.save_app(params)?;
response_ok(detail)
}
pub async fn get_app(
data: Data<QueryAppRequest>,
controller: ModuleData<Arc<AppController>>,
) -> ResponseResult<App, WorkspaceError> {
let params: QueryAppParams = data.into_inner().try_into()?;
let mut app = controller.get_app(&params.app_id).await?;
if params.read_views {
let views = controller.get_views(&params.app_id).await?;
app.views = RepeatedView { items: views };
}
response_ok(app)
}

View File

@ -45,5 +45,6 @@ pub fn create(user: Arc<dyn WorkspaceUser>, database: Arc<dyn WorkspaceDatabase>
.event(WorkspaceEvent::GetCurWorkspace, get_cur_workspace)
.event(WorkspaceEvent::GetWorkspace, get_workspace)
.event(WorkspaceEvent::CreateApp, create_app)
.event(WorkspaceEvent::GetApp, get_app)
.event(WorkspaceEvent::CreateView, create_view)
}

View File

@ -489,6 +489,7 @@ pub struct App {
pub workspace_id: ::std::string::String,
pub name: ::std::string::String,
pub desc: ::std::string::String,
pub views: ::protobuf::SingularPtrField<super::view_create::RepeatedView>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
@ -608,10 +609,48 @@ impl App {
pub fn take_desc(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.desc, ::std::string::String::new())
}
// .RepeatedView views = 5;
pub fn get_views(&self) -> &super::view_create::RepeatedView {
self.views.as_ref().unwrap_or_else(|| <super::view_create::RepeatedView as ::protobuf::Message>::default_instance())
}
pub fn clear_views(&mut self) {
self.views.clear();
}
pub fn has_views(&self) -> bool {
self.views.is_some()
}
// Param is passed by value, moved
pub fn set_views(&mut self, v: super::view_create::RepeatedView) {
self.views = ::protobuf::SingularPtrField::some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_views(&mut self) -> &mut super::view_create::RepeatedView {
if self.views.is_none() {
self.views.set_default();
}
self.views.as_mut().unwrap()
}
// Take field
pub fn take_views(&mut self) -> super::view_create::RepeatedView {
self.views.take().unwrap_or_else(|| super::view_create::RepeatedView::new())
}
}
impl ::protobuf::Message for App {
fn is_initialized(&self) -> bool {
for v in &self.views {
if !v.is_initialized() {
return false;
}
};
true
}
@ -631,6 +670,9 @@ impl ::protobuf::Message for App {
4 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.desc)?;
},
5 => {
::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.views)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
@ -655,6 +697,10 @@ impl ::protobuf::Message for App {
if !self.desc.is_empty() {
my_size += ::protobuf::rt::string_size(4, &self.desc);
}
if let Some(ref v) = self.views.as_ref() {
let len = v.compute_size();
my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len;
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
@ -673,6 +719,11 @@ impl ::protobuf::Message for App {
if !self.desc.is_empty() {
os.write_string(4, &self.desc)?;
}
if let Some(ref v) = self.views.as_ref() {
os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?;
os.write_raw_varint32(v.get_cached_size())?;
v.write_to_with_cached_sizes(os)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
@ -731,6 +782,11 @@ impl ::protobuf::Message for App {
|m: &App| { &m.desc },
|m: &mut App| { &mut m.desc },
));
fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<super::view_create::RepeatedView>>(
"views",
|m: &App| { &m.views },
|m: &mut App| { &mut m.views },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<App>(
"App",
fields,
@ -751,6 +807,7 @@ impl ::protobuf::Clear for App {
self.workspace_id.clear();
self.name.clear();
self.desc.clear();
self.views.clear();
self.unknown_fields.clear();
}
}
@ -934,49 +991,54 @@ impl ::protobuf::reflect::ProtobufValue for RepeatedApp {
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x10app_create.proto\"\x8b\x01\n\x10CreateAppRequest\x12!\n\x0cworkspa\
ce_id\x18\x01\x20\x01(\tR\x0bworkspaceId\x12\x12\n\x04name\x18\x02\x20\
\x01(\tR\x04name\x12\x12\n\x04desc\x18\x03\x20\x01(\tR\x04desc\x12,\n\
\x0bcolor_style\x18\x04\x20\x01(\x0b2\x0b.ColorStyleR\ncolorStyle\"-\n\n\
ColorStyle\x12\x1f\n\x0btheme_color\x18\x01\x20\x01(\tR\nthemeColor\"`\n\
\x03App\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12!\n\x0cworkspace_id\
\x18\x02\x20\x01(\tR\x0bworkspaceId\x12\x12\n\x04name\x18\x03\x20\x01(\t\
R\x04name\x12\x12\n\x04desc\x18\x04\x20\x01(\tR\x04desc\")\n\x0bRepeated\
App\x12\x1a\n\x05items\x18\x01\x20\x03(\x0b2\x04.AppR\x05itemsJ\xa6\x05\
\n\x06\x12\x04\0\0\x13\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\
\0\x12\x04\x02\0\x07\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x18\n\x0b\n\
\x04\x04\0\x02\0\x12\x03\x03\x04\x1c\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\
\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0b\x17\n\x0c\n\x05\
\x04\0\x02\0\x03\x12\x03\x03\x1a\x1b\n\x0b\n\x04\x04\0\x02\x01\x12\x03\
\x04\x04\x14\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\
\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0f\n\x0c\n\x05\x04\0\x02\x01\x03\x12\
\x03\x04\x12\x13\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\x04\x14\n\x0c\n\
\x05\x04\0\x02\x02\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\0\x02\x02\x01\
\x12\x03\x05\x0b\x0f\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05\x12\x13\n\
\x0b\n\x04\x04\0\x02\x03\x12\x03\x06\x04\x1f\n\x0c\n\x05\x04\0\x02\x03\
\x06\x12\x03\x06\x04\x0e\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\x06\x0f\
\x1a\n\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\x06\x1d\x1e\n\n\n\x02\x04\x01\
\x12\x04\x08\0\n\x01\n\n\n\x03\x04\x01\x01\x12\x03\x08\x08\x12\n\x0b\n\
\x04\x04\x01\x02\0\x12\x03\t\x04\x1b\n\x0c\n\x05\x04\x01\x02\0\x05\x12\
\x03\t\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\t\x0b\x16\n\x0c\n\x05\
\x04\x01\x02\0\x03\x12\x03\t\x19\x1a\n\n\n\x02\x04\x02\x12\x04\x0b\0\x10\
\x01\n\n\n\x03\x04\x02\x01\x12\x03\x0b\x08\x0b\n\x0b\n\x04\x04\x02\x02\0\
\x12\x03\x0c\x04\x12\n\x0c\n\x05\x04\x02\x02\0\x05\x12\x03\x0c\x04\n\n\
\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\x0c\x0b\r\n\x0c\n\x05\x04\x02\x02\0\
\x03\x12\x03\x0c\x10\x11\n\x0b\n\x04\x04\x02\x02\x01\x12\x03\r\x04\x1c\n\
\x0c\n\x05\x04\x02\x02\x01\x05\x12\x03\r\x04\n\n\x0c\n\x05\x04\x02\x02\
\x01\x01\x12\x03\r\x0b\x17\n\x0c\n\x05\x04\x02\x02\x01\x03\x12\x03\r\x1a\
\x1b\n\x0b\n\x04\x04\x02\x02\x02\x12\x03\x0e\x04\x14\n\x0c\n\x05\x04\x02\
\x02\x02\x05\x12\x03\x0e\x04\n\n\x0c\n\x05\x04\x02\x02\x02\x01\x12\x03\
\x0e\x0b\x0f\n\x0c\n\x05\x04\x02\x02\x02\x03\x12\x03\x0e\x12\x13\n\x0b\n\
\x04\x04\x02\x02\x03\x12\x03\x0f\x04\x14\n\x0c\n\x05\x04\x02\x02\x03\x05\
\x12\x03\x0f\x04\n\n\x0c\n\x05\x04\x02\x02\x03\x01\x12\x03\x0f\x0b\x0f\n\
\x0c\n\x05\x04\x02\x02\x03\x03\x12\x03\x0f\x12\x13\n\n\n\x02\x04\x03\x12\
\x04\x11\0\x13\x01\n\n\n\x03\x04\x03\x01\x12\x03\x11\x08\x13\n\x0b\n\x04\
\x04\x03\x02\0\x12\x03\x12\x04\x1b\n\x0c\n\x05\x04\x03\x02\0\x04\x12\x03\
\x12\x04\x0c\n\x0c\n\x05\x04\x03\x02\0\x06\x12\x03\x12\r\x10\n\x0c\n\x05\
\x04\x03\x02\0\x01\x12\x03\x12\x11\x16\n\x0c\n\x05\x04\x03\x02\0\x03\x12\
\x03\x12\x19\x1ab\x06proto3\
\n\x10app_create.proto\x1a\x11view_create.proto\"\x8b\x01\n\x10CreateApp\
Request\x12!\n\x0cworkspace_id\x18\x01\x20\x01(\tR\x0bworkspaceId\x12\
\x12\n\x04name\x18\x02\x20\x01(\tR\x04name\x12\x12\n\x04desc\x18\x03\x20\
\x01(\tR\x04desc\x12,\n\x0bcolor_style\x18\x04\x20\x01(\x0b2\x0b.ColorSt\
yleR\ncolorStyle\"-\n\nColorStyle\x12\x1f\n\x0btheme_color\x18\x01\x20\
\x01(\tR\nthemeColor\"\x85\x01\n\x03App\x12\x0e\n\x02id\x18\x01\x20\x01(\
\tR\x02id\x12!\n\x0cworkspace_id\x18\x02\x20\x01(\tR\x0bworkspaceId\x12\
\x12\n\x04name\x18\x03\x20\x01(\tR\x04name\x12\x12\n\x04desc\x18\x04\x20\
\x01(\tR\x04desc\x12#\n\x05views\x18\x05\x20\x01(\x0b2\r.RepeatedViewR\
\x05views\")\n\x0bRepeatedApp\x12\x1a\n\x05items\x18\x01\x20\x03(\x0b2\
\x04.AppR\x05itemsJ\xe8\x05\n\x06\x12\x04\0\0\x15\x01\n\x08\n\x01\x0c\
\x12\x03\0\0\x12\n\t\n\x02\x03\0\x12\x03\x01\0\x1b\n\n\n\x02\x04\0\x12\
\x04\x03\0\x08\x01\n\n\n\x03\x04\0\x01\x12\x03\x03\x08\x18\n\x0b\n\x04\
\x04\0\x02\0\x12\x03\x04\x04\x1c\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x04\
\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x04\x0b\x17\n\x0c\n\x05\x04\0\
\x02\0\x03\x12\x03\x04\x1a\x1b\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x05\x04\
\x14\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\0\
\x02\x01\x01\x12\x03\x05\x0b\x0f\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\
\x05\x12\x13\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x06\x04\x14\n\x0c\n\x05\
\x04\0\x02\x02\x05\x12\x03\x06\x04\n\n\x0c\n\x05\x04\0\x02\x02\x01\x12\
\x03\x06\x0b\x0f\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x06\x12\x13\n\x0b\
\n\x04\x04\0\x02\x03\x12\x03\x07\x04\x1f\n\x0c\n\x05\x04\0\x02\x03\x06\
\x12\x03\x07\x04\x0e\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\x07\x0f\x1a\n\
\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\x07\x1d\x1e\n\n\n\x02\x04\x01\x12\
\x04\t\0\x0b\x01\n\n\n\x03\x04\x01\x01\x12\x03\t\x08\x12\n\x0b\n\x04\x04\
\x01\x02\0\x12\x03\n\x04\x1b\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\n\x04\
\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\n\x0b\x16\n\x0c\n\x05\x04\x01\
\x02\0\x03\x12\x03\n\x19\x1a\n\n\n\x02\x04\x02\x12\x04\x0c\0\x12\x01\n\n\
\n\x03\x04\x02\x01\x12\x03\x0c\x08\x0b\n\x0b\n\x04\x04\x02\x02\0\x12\x03\
\r\x04\x12\n\x0c\n\x05\x04\x02\x02\0\x05\x12\x03\r\x04\n\n\x0c\n\x05\x04\
\x02\x02\0\x01\x12\x03\r\x0b\r\n\x0c\n\x05\x04\x02\x02\0\x03\x12\x03\r\
\x10\x11\n\x0b\n\x04\x04\x02\x02\x01\x12\x03\x0e\x04\x1c\n\x0c\n\x05\x04\
\x02\x02\x01\x05\x12\x03\x0e\x04\n\n\x0c\n\x05\x04\x02\x02\x01\x01\x12\
\x03\x0e\x0b\x17\n\x0c\n\x05\x04\x02\x02\x01\x03\x12\x03\x0e\x1a\x1b\n\
\x0b\n\x04\x04\x02\x02\x02\x12\x03\x0f\x04\x14\n\x0c\n\x05\x04\x02\x02\
\x02\x05\x12\x03\x0f\x04\n\n\x0c\n\x05\x04\x02\x02\x02\x01\x12\x03\x0f\
\x0b\x0f\n\x0c\n\x05\x04\x02\x02\x02\x03\x12\x03\x0f\x12\x13\n\x0b\n\x04\
\x04\x02\x02\x03\x12\x03\x10\x04\x14\n\x0c\n\x05\x04\x02\x02\x03\x05\x12\
\x03\x10\x04\n\n\x0c\n\x05\x04\x02\x02\x03\x01\x12\x03\x10\x0b\x0f\n\x0c\
\n\x05\x04\x02\x02\x03\x03\x12\x03\x10\x12\x13\n\x0b\n\x04\x04\x02\x02\
\x04\x12\x03\x11\x04\x1b\n\x0c\n\x05\x04\x02\x02\x04\x06\x12\x03\x11\x04\
\x10\n\x0c\n\x05\x04\x02\x02\x04\x01\x12\x03\x11\x11\x16\n\x0c\n\x05\x04\
\x02\x02\x04\x03\x12\x03\x11\x19\x1a\n\n\n\x02\x04\x03\x12\x04\x13\0\x15\
\x01\n\n\n\x03\x04\x03\x01\x12\x03\x13\x08\x13\n\x0b\n\x04\x04\x03\x02\0\
\x12\x03\x14\x04\x1b\n\x0c\n\x05\x04\x03\x02\0\x04\x12\x03\x14\x04\x0c\n\
\x0c\n\x05\x04\x03\x02\0\x06\x12\x03\x14\r\x10\n\x0c\n\x05\x04\x03\x02\0\
\x01\x12\x03\x14\x11\x16\n\x0c\n\x05\x04\x03\x02\0\x03\x12\x03\x14\x19\
\x1ab\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -0,0 +1,243 @@
// This file is generated by rust-protobuf 2.22.1. 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 `app_query.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct QueryAppRequest {
// message fields
pub app_id: ::std::string::String,
pub read_views: bool,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a QueryAppRequest {
fn default() -> &'a QueryAppRequest {
<QueryAppRequest as ::protobuf::Message>::default_instance()
}
}
impl QueryAppRequest {
pub fn new() -> QueryAppRequest {
::std::default::Default::default()
}
// string app_id = 1;
pub fn get_app_id(&self) -> &str {
&self.app_id
}
pub fn clear_app_id(&mut self) {
self.app_id.clear();
}
// Param is passed by value, moved
pub fn set_app_id(&mut self, v: ::std::string::String) {
self.app_id = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_app_id(&mut self) -> &mut ::std::string::String {
&mut self.app_id
}
// Take field
pub fn take_app_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.app_id, ::std::string::String::new())
}
// bool read_views = 2;
pub fn get_read_views(&self) -> bool {
self.read_views
}
pub fn clear_read_views(&mut self) {
self.read_views = false;
}
// Param is passed by value, moved
pub fn set_read_views(&mut self, v: bool) {
self.read_views = v;
}
}
impl ::protobuf::Message for QueryAppRequest {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.app_id)?;
},
2 => {
if wire_type != ::protobuf::wire_format::WireTypeVarint {
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
}
let tmp = is.read_bool()?;
self.read_views = tmp;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.app_id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.app_id);
}
if self.read_views != false {
my_size += 2;
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.app_id.is_empty() {
os.write_string(1, &self.app_id)?;
}
if self.read_views != false {
os.write_bool(2, self.read_views)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> QueryAppRequest {
QueryAppRequest::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"app_id",
|m: &QueryAppRequest| { &m.app_id },
|m: &mut QueryAppRequest| { &mut m.app_id },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>(
"read_views",
|m: &QueryAppRequest| { &m.read_views },
|m: &mut QueryAppRequest| { &mut m.read_views },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<QueryAppRequest>(
"QueryAppRequest",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static QueryAppRequest {
static instance: ::protobuf::rt::LazyV2<QueryAppRequest> = ::protobuf::rt::LazyV2::INIT;
instance.get(QueryAppRequest::new)
}
}
impl ::protobuf::Clear for QueryAppRequest {
fn clear(&mut self) {
self.app_id.clear();
self.read_views = false;
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for QueryAppRequest {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for QueryAppRequest {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0fapp_query.proto\"G\n\x0fQueryAppRequest\x12\x15\n\x06app_id\x18\
\x01\x20\x01(\tR\x05appId\x12\x1d\n\nread_views\x18\x02\x20\x01(\x08R\tr\
eadViewsJ\x98\x01\n\x06\x12\x04\0\0\x05\x01\n\x08\n\x01\x0c\x12\x03\0\0\
\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\
\x02\x08\x17\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x16\n\x0c\n\x05\x04\
\0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\
\x0b\x11\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x14\x15\n\x0b\n\x04\x04\
\0\x02\x01\x12\x03\x04\x04\x18\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\
\x04\x08\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\t\x13\n\x0c\n\x05\x04\
\0\x02\x01\x03\x12\x03\x04\x16\x17b\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()
})
}

View File

@ -29,6 +29,7 @@ pub enum WorkspaceEvent {
GetCurWorkspace = 1,
GetWorkspace = 2,
CreateApp = 101,
GetApp = 102,
CreateView = 201,
}
@ -43,6 +44,7 @@ impl ::protobuf::ProtobufEnum for WorkspaceEvent {
1 => ::std::option::Option::Some(WorkspaceEvent::GetCurWorkspace),
2 => ::std::option::Option::Some(WorkspaceEvent::GetWorkspace),
101 => ::std::option::Option::Some(WorkspaceEvent::CreateApp),
102 => ::std::option::Option::Some(WorkspaceEvent::GetApp),
201 => ::std::option::Option::Some(WorkspaceEvent::CreateView),
_ => ::std::option::Option::None
}
@ -54,6 +56,7 @@ impl ::protobuf::ProtobufEnum for WorkspaceEvent {
WorkspaceEvent::GetCurWorkspace,
WorkspaceEvent::GetWorkspace,
WorkspaceEvent::CreateApp,
WorkspaceEvent::GetApp,
WorkspaceEvent::CreateView,
];
values
@ -83,22 +86,24 @@ impl ::protobuf::reflect::ProtobufValue for WorkspaceEvent {
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0bevent.proto*l\n\x0eWorkspaceEvent\x12\x13\n\x0fCreateWorkspace\x10\
\n\x0bevent.proto*x\n\x0eWorkspaceEvent\x12\x13\n\x0fCreateWorkspace\x10\
\0\x12\x13\n\x0fGetCurWorkspace\x10\x01\x12\x10\n\x0cGetWorkspace\x10\
\x02\x12\r\n\tCreateApp\x10e\x12\x0f\n\nCreateView\x10\xc9\x01J\xf7\x01\
\n\x06\x12\x04\0\0\x08\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\
\0\x12\x04\x02\0\x08\x01\n\n\n\x03\x05\0\x01\x12\x03\x02\x05\x13\n\x0b\n\
\x04\x05\0\x02\0\x12\x03\x03\x04\x18\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\
\x03\x04\x13\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x03\x16\x17\n\x0b\n\x04\
\x05\0\x02\x01\x12\x03\x04\x04\x18\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\
\x04\x04\x13\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x04\x16\x17\n\x0b\n\
\x04\x05\0\x02\x02\x12\x03\x05\x04\x15\n\x0c\n\x05\x05\0\x02\x02\x01\x12\
\x03\x05\x04\x10\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\x05\x13\x14\n\x0b\
\n\x04\x05\0\x02\x03\x12\x03\x06\x04\x14\n\x0c\n\x05\x05\0\x02\x03\x01\
\x12\x03\x06\x04\r\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\x06\x10\x13\n\
\x0b\n\x04\x05\0\x02\x04\x12\x03\x07\x04\x15\n\x0c\n\x05\x05\0\x02\x04\
\x01\x12\x03\x07\x04\x0e\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x07\x11\
\x14b\x06proto3\
\x02\x12\r\n\tCreateApp\x10e\x12\n\n\x06GetApp\x10f\x12\x0f\n\nCreateVie\
w\x10\xc9\x01J\xa0\x02\n\x06\x12\x04\0\0\t\x01\n\x08\n\x01\x0c\x12\x03\0\
\0\x12\n\n\n\x02\x05\0\x12\x04\x02\0\t\x01\n\n\n\x03\x05\0\x01\x12\x03\
\x02\x05\x13\n\x0b\n\x04\x05\0\x02\0\x12\x03\x03\x04\x18\n\x0c\n\x05\x05\
\0\x02\0\x01\x12\x03\x03\x04\x13\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x03\
\x16\x17\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x04\x04\x18\n\x0c\n\x05\x05\0\
\x02\x01\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\
\x04\x16\x17\n\x0b\n\x04\x05\0\x02\x02\x12\x03\x05\x04\x15\n\x0c\n\x05\
\x05\0\x02\x02\x01\x12\x03\x05\x04\x10\n\x0c\n\x05\x05\0\x02\x02\x02\x12\
\x03\x05\x13\x14\n\x0b\n\x04\x05\0\x02\x03\x12\x03\x06\x04\x14\n\x0c\n\
\x05\x05\0\x02\x03\x01\x12\x03\x06\x04\r\n\x0c\n\x05\x05\0\x02\x03\x02\
\x12\x03\x06\x10\x13\n\x0b\n\x04\x05\0\x02\x04\x12\x03\x07\x04\x11\n\x0c\
\n\x05\x05\0\x02\x04\x01\x12\x03\x07\x04\n\n\x0c\n\x05\x05\0\x02\x04\x02\
\x12\x03\x07\r\x10\n\x0b\n\x04\x05\0\x02\x05\x12\x03\x08\x04\x15\n\x0c\n\
\x05\x05\0\x02\x05\x01\x12\x03\x08\x04\x0e\n\x0c\n\x05\x05\0\x02\x05\x02\
\x12\x03\x08\x11\x14b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -1,5 +1,8 @@
// Auto-generated, do not edit
mod app_query;
pub use app_query::*;
mod errors;
pub use errors::*;

View File

@ -695,6 +695,172 @@ impl ::protobuf::reflect::ProtobufValue for View {
}
}
#[derive(PartialEq,Clone,Default)]
pub struct RepeatedView {
// message fields
pub items: ::protobuf::RepeatedField<View>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a RepeatedView {
fn default() -> &'a RepeatedView {
<RepeatedView as ::protobuf::Message>::default_instance()
}
}
impl RepeatedView {
pub fn new() -> RepeatedView {
::std::default::Default::default()
}
// repeated .View items = 1;
pub fn get_items(&self) -> &[View] {
&self.items
}
pub fn clear_items(&mut self) {
self.items.clear();
}
// Param is passed by value, moved
pub fn set_items(&mut self, v: ::protobuf::RepeatedField<View>) {
self.items = v;
}
// Mutable pointer to the field.
pub fn mut_items(&mut self) -> &mut ::protobuf::RepeatedField<View> {
&mut self.items
}
// Take field
pub fn take_items(&mut self) -> ::protobuf::RepeatedField<View> {
::std::mem::replace(&mut self.items, ::protobuf::RepeatedField::new())
}
}
impl ::protobuf::Message for RepeatedView {
fn is_initialized(&self) -> bool {
for v in &self.items {
if !v.is_initialized() {
return false;
}
};
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.items)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
for value in &self.items {
let len = value.compute_size();
my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len;
};
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
for v in &self.items {
os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?;
os.write_raw_varint32(v.get_cached_size())?;
v.write_to_with_cached_sizes(os)?;
};
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> RepeatedView {
RepeatedView::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<View>>(
"items",
|m: &RepeatedView| { &m.items },
|m: &mut RepeatedView| { &mut m.items },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<RepeatedView>(
"RepeatedView",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static RepeatedView {
static instance: ::protobuf::rt::LazyV2<RepeatedView> = ::protobuf::rt::LazyV2::INIT;
instance.get(RepeatedView::new)
}
}
impl ::protobuf::Clear for RepeatedView {
fn clear(&mut self) {
self.items.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for RepeatedView {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for RepeatedView {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum ViewTypeIdentifier {
Docs = 0,
@ -751,43 +917,48 @@ static file_descriptor_proto_data: &'static [u8] = b"\
\x87\x01\n\x04View\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x15\n\
\x06app_id\x18\x02\x20\x01(\tR\x05appId\x12\x12\n\x04name\x18\x03\x20\
\x01(\tR\x04name\x12\x12\n\x04desc\x18\x04\x20\x01(\tR\x04desc\x120\n\tv\
iew_type\x18\x05\x20\x01(\x0e2\x13.ViewTypeIdentifierR\x08viewType*\x1e\
\n\x12ViewTypeIdentifier\x12\x08\n\x04Docs\x10\0J\xc4\x05\n\x06\x12\x04\
\0\0\x12\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\
\0\x08\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x19\n\x0b\n\x04\x04\0\x02\
\0\x12\x03\x03\x04\x16\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x03\x04\n\n\
\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0b\x11\n\x0c\n\x05\x04\0\x02\0\
\x03\x12\x03\x03\x14\x15\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\x14\n\
\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\x02\x01\
\x01\x12\x03\x04\x0b\x0f\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x12\
\x13\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\x04\x14\n\x0c\n\x05\x04\0\x02\
\x02\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x05\x0b\
\x0f\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05\x12\x13\n\x0b\n\x04\x04\0\
\x08\0\x12\x03\x06\x044\n\x0c\n\x05\x04\0\x08\0\x01\x12\x03\x06\n\x1a\n\
\x0b\n\x04\x04\0\x02\x03\x12\x03\x06\x1d2\n\x0c\n\x05\x04\0\x02\x03\x05\
\x12\x03\x06\x1d#\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\x06$-\n\x0c\n\
\x05\x04\0\x02\x03\x03\x12\x03\x0601\n\x0b\n\x04\x04\0\x02\x04\x12\x03\
\x07\x04%\n\x0c\n\x05\x04\0\x02\x04\x06\x12\x03\x07\x04\x16\n\x0c\n\x05\
\x04\0\x02\x04\x01\x12\x03\x07\x17\x20\n\x0c\n\x05\x04\0\x02\x04\x03\x12\
\x03\x07#$\n\n\n\x02\x04\x01\x12\x04\t\0\x0f\x01\n\n\n\x03\x04\x01\x01\
\x12\x03\t\x08\x0c\n\x0b\n\x04\x04\x01\x02\0\x12\x03\n\x04\x12\n\x0c\n\
\x05\x04\x01\x02\0\x05\x12\x03\n\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\
\x03\n\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\n\x10\x11\n\x0b\n\x04\
\x04\x01\x02\x01\x12\x03\x0b\x04\x16\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\
\x03\x0b\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\x0b\x0b\x11\n\x0c\
\n\x05\x04\x01\x02\x01\x03\x12\x03\x0b\x14\x15\n\x0b\n\x04\x04\x01\x02\
\x02\x12\x03\x0c\x04\x14\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\x03\x0c\x04\
\n\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\x0c\x0b\x0f\n\x0c\n\x05\x04\
\x01\x02\x02\x03\x12\x03\x0c\x12\x13\n\x0b\n\x04\x04\x01\x02\x03\x12\x03\
\r\x04\x14\n\x0c\n\x05\x04\x01\x02\x03\x05\x12\x03\r\x04\n\n\x0c\n\x05\
\x04\x01\x02\x03\x01\x12\x03\r\x0b\x0f\n\x0c\n\x05\x04\x01\x02\x03\x03\
\x12\x03\r\x12\x13\n\x0b\n\x04\x04\x01\x02\x04\x12\x03\x0e\x04%\n\x0c\n\
\x05\x04\x01\x02\x04\x06\x12\x03\x0e\x04\x16\n\x0c\n\x05\x04\x01\x02\x04\
\x01\x12\x03\x0e\x17\x20\n\x0c\n\x05\x04\x01\x02\x04\x03\x12\x03\x0e#$\n\
\n\n\x02\x05\0\x12\x04\x10\0\x12\x01\n\n\n\x03\x05\0\x01\x12\x03\x10\x05\
\x17\n\x0b\n\x04\x05\0\x02\0\x12\x03\x11\x04\r\n\x0c\n\x05\x05\0\x02\0\
\x01\x12\x03\x11\x04\x08\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x11\x0b\x0c\
b\x06proto3\
iew_type\x18\x05\x20\x01(\x0e2\x13.ViewTypeIdentifierR\x08viewType\"+\n\
\x0cRepeatedView\x12\x1b\n\x05items\x18\x01\x20\x03(\x0b2\x05.ViewR\x05i\
tems*\x1e\n\x12ViewTypeIdentifier\x12\x08\n\x04Docs\x10\0J\xa1\x06\n\x06\
\x12\x04\0\0\x15\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\
\x04\x02\0\x08\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x19\n\x0b\n\x04\
\x04\0\x02\0\x12\x03\x03\x04\x16\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x03\
\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0b\x11\n\x0c\n\x05\x04\0\
\x02\0\x03\x12\x03\x03\x14\x15\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\
\x14\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\
\x02\x01\x01\x12\x03\x04\x0b\x0f\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\
\x04\x12\x13\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\x04\x14\n\x0c\n\x05\
\x04\0\x02\x02\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\0\x02\x02\x01\x12\
\x03\x05\x0b\x0f\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05\x12\x13\n\x0b\
\n\x04\x04\0\x08\0\x12\x03\x06\x044\n\x0c\n\x05\x04\0\x08\0\x01\x12\x03\
\x06\n\x1a\n\x0b\n\x04\x04\0\x02\x03\x12\x03\x06\x1d2\n\x0c\n\x05\x04\0\
\x02\x03\x05\x12\x03\x06\x1d#\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\x06$\
-\n\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\x0601\n\x0b\n\x04\x04\0\x02\x04\
\x12\x03\x07\x04%\n\x0c\n\x05\x04\0\x02\x04\x06\x12\x03\x07\x04\x16\n\
\x0c\n\x05\x04\0\x02\x04\x01\x12\x03\x07\x17\x20\n\x0c\n\x05\x04\0\x02\
\x04\x03\x12\x03\x07#$\n\n\n\x02\x04\x01\x12\x04\t\0\x0f\x01\n\n\n\x03\
\x04\x01\x01\x12\x03\t\x08\x0c\n\x0b\n\x04\x04\x01\x02\0\x12\x03\n\x04\
\x12\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\n\x04\n\n\x0c\n\x05\x04\x01\
\x02\0\x01\x12\x03\n\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\n\x10\
\x11\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\x0b\x04\x16\n\x0c\n\x05\x04\x01\
\x02\x01\x05\x12\x03\x0b\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\
\x0b\x0b\x11\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x0b\x14\x15\n\x0b\n\
\x04\x04\x01\x02\x02\x12\x03\x0c\x04\x14\n\x0c\n\x05\x04\x01\x02\x02\x05\
\x12\x03\x0c\x04\n\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\x0c\x0b\x0f\n\
\x0c\n\x05\x04\x01\x02\x02\x03\x12\x03\x0c\x12\x13\n\x0b\n\x04\x04\x01\
\x02\x03\x12\x03\r\x04\x14\n\x0c\n\x05\x04\x01\x02\x03\x05\x12\x03\r\x04\
\n\n\x0c\n\x05\x04\x01\x02\x03\x01\x12\x03\r\x0b\x0f\n\x0c\n\x05\x04\x01\
\x02\x03\x03\x12\x03\r\x12\x13\n\x0b\n\x04\x04\x01\x02\x04\x12\x03\x0e\
\x04%\n\x0c\n\x05\x04\x01\x02\x04\x06\x12\x03\x0e\x04\x16\n\x0c\n\x05\
\x04\x01\x02\x04\x01\x12\x03\x0e\x17\x20\n\x0c\n\x05\x04\x01\x02\x04\x03\
\x12\x03\x0e#$\n\n\n\x02\x04\x02\x12\x04\x10\0\x12\x01\n\n\n\x03\x04\x02\
\x01\x12\x03\x10\x08\x14\n\x0b\n\x04\x04\x02\x02\0\x12\x03\x11\x04\x1c\n\
\x0c\n\x05\x04\x02\x02\0\x04\x12\x03\x11\x04\x0c\n\x0c\n\x05\x04\x02\x02\
\0\x06\x12\x03\x11\r\x11\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\x11\x12\
\x17\n\x0c\n\x05\x04\x02\x02\0\x03\x12\x03\x11\x1a\x1b\n\n\n\x02\x05\0\
\x12\x04\x13\0\x15\x01\n\n\n\x03\x05\0\x01\x12\x03\x13\x05\x17\n\x0b\n\
\x04\x05\0\x02\0\x12\x03\x14\x04\r\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\
\x14\x04\x08\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x14\x0b\x0cb\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -1,4 +1,5 @@
syntax = "proto3";
import "view_create.proto";
message CreateAppRequest {
string workspace_id = 1;
@ -14,6 +15,7 @@ message App {
string workspace_id = 2;
string name = 3;
string desc = 4;
RepeatedView views = 5;
}
message RepeatedApp {
repeated App items = 1;

View File

@ -0,0 +1,6 @@
syntax = "proto3";
message QueryAppRequest {
string app_id = 1;
bool read_views = 2;
}

View File

@ -5,5 +5,6 @@ enum WorkspaceEvent {
GetCurWorkspace = 1;
GetWorkspace = 2;
CreateApp = 101;
GetApp = 102;
CreateView = 201;
}

View File

@ -14,6 +14,9 @@ message View {
string desc = 4;
ViewTypeIdentifier view_type = 5;
}
message RepeatedView {
repeated View items = 1;
}
enum ViewTypeIdentifier {
Docs = 0;
}

View File

@ -39,17 +39,21 @@ impl AppController {
Ok(app)
}
pub async fn get_app(&self, app_id: &str) -> Result<App, WorkspaceError> {
let app_table = self.get_app_table(app_id).await?;
Ok(app_table.into())
}
pub fn update_app(&self, params: UpdateAppParams) -> Result<(), WorkspaceError> {
let changeset = AppTableChangeset::new(params);
let _ = self.sql.update_app_table(changeset)?;
Ok(())
}
pub async fn get_cur_views(&self, app_id: &str) -> Result<Vec<View>, WorkspaceError> {
let app_table = self.get_app_table(app_id).await?;
pub async fn get_views(&self, app_id: &str) -> Result<Vec<View>, WorkspaceError> {
let views = self
.sql
.read_views_belong_to_app(&app_table)?
.read_views_belong_to_app(app_id)?
.into_iter()
.map(|view_table| view_table.into())
.collect::<Vec<View>>();

View File

@ -47,10 +47,17 @@ impl AppTableSql {
pub(crate) fn read_views_belong_to_app(
&self,
app_table: &AppTable,
app_id: &str,
) -> Result<Vec<ViewTable>, WorkspaceError> {
let conn = self.database.db_connection()?;
let views = ViewTable::belonging_to(app_table).load::<ViewTable>(&*conn)?;
let views = conn.immediate_transaction::<_, WorkspaceError, _>(|| {
let app_table: AppTable = dsl::app_table
.filter(app_table::id.eq(app_id))
.first::<AppTable>(&*(conn))?;
let views = ViewTable::belonging_to(&app_table).load::<ViewTable>(&*conn)?;
Ok(views)
})?;
Ok(views)
}

View File

@ -1,5 +1,8 @@
use crate::{
entities::app::{App, ColorStyle, CreateAppParams, UpdateAppParams},
entities::{
app::{App, ColorStyle, CreateAppParams, UpdateAppParams},
view::RepeatedView,
},
impl_sql_binary_expression,
sql_tables::workspace::WorkspaceTable,
};
@ -101,6 +104,7 @@ impl std::convert::Into<App> for AppTable {
workspace_id: self.workspace_id,
name: self.name,
desc: self.desc,
views: RepeatedView::default(),
}
}
}

View File

@ -1,7 +1,9 @@
use crate::helper::*;
use flowy_test::builder::WorkspaceTestBuilder;
use flowy_workspace::{
entities::{
app::{App, CreateAppRequest},
app::{App, CreateAppRequest, QueryAppRequest},
view::*,
workspace::Workspace,
},
event::WorkspaceEvent::{CreateApp, GetCurWorkspace},
@ -9,48 +11,54 @@ use flowy_workspace::{
#[test]
fn app_create_success() {
let user_workspace = WorkspaceTestBuilder::new()
.event(GetCurWorkspace)
.sync_send()
.parse::<Workspace>();
let request = CreateAppRequest {
workspace_id: user_workspace.id,
name: "Github".to_owned(),
desc: "AppFlowy Github Project".to_owned(),
color_style: Default::default(),
};
let app_detail = WorkspaceTestBuilder::new()
.event(CreateApp)
.request(request)
.sync_send()
.parse::<App>();
dbg!(&app_detail);
let workspace = create_workspace("Workspace", "");
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
dbg!(&app);
}
#[test]
fn app_list_from_cur_workspace_test() {
let user_workspace = WorkspaceTestBuilder::new()
.event(GetCurWorkspace)
.sync_send()
.parse::<Workspace>();
fn app_create_and_then_get_success() {
let workspace = create_workspace("Workspace", "");
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
let request = QueryAppRequest {
app_id: app.id.clone(),
read_views: false,
};
let app_from_db = get_app(request);
assert_eq!(app_from_db, app);
}
let request = CreateAppRequest {
workspace_id: user_workspace.id,
name: "Github".to_owned(),
desc: "AppFlowy Github Project".to_owned(),
color_style: Default::default(),
#[test]
fn app_create_with_view_and_then_get_success() {
let workspace = create_workspace("Workspace", "");
let app = create_app("App A", "AppFlowy Github Project", &workspace.id);
let request_a = CreateViewRequest {
app_id: app.id.clone(),
name: "View A".to_string(),
desc: "".to_string(),
thumbnail: None,
view_type: ViewTypeIdentifier::Docs,
};
let app_detail = WorkspaceTestBuilder::new()
.event(CreateApp)
.request(request)
.sync_send()
.parse::<App>();
let request_b = CreateViewRequest {
app_id: app.id.clone(),
name: "View B".to_string(),
desc: "".to_string(),
thumbnail: None,
view_type: ViewTypeIdentifier::Docs,
};
dbg!(&app_detail);
let view_a = create_view(request_a);
let view_b = create_view(request_b);
let query = QueryAppRequest {
app_id: app.id.clone(),
read_views: true,
};
let view_from_db = get_app(query);
assert_eq!(view_from_db.views[0], view_a);
assert_eq!(view_from_db.views[1], view_b);
}
// TODO 1) test update app 2) delete app

View File

@ -1,7 +1,7 @@
pub use flowy_test::builder::WorkspaceTestBuilder;
use flowy_workspace::{
entities::{app::*, workspace::*},
event::WorkspaceEvent::{CreateApp, CreateWorkspace, GetWorkspace},
entities::{app::*, view::*, workspace::*},
event::WorkspaceEvent::*,
};
pub(crate) fn invalid_workspace_name_test_case() -> Vec<String> {
@ -51,3 +51,23 @@ pub fn get_workspace(request: QueryWorkspaceRequest) -> Workspace {
workspace
}
pub fn get_app(request: QueryAppRequest) -> App {
let app = WorkspaceTestBuilder::new()
.event(GetApp)
.request(request)
.sync_send()
.parse::<App>();
app
}
pub fn create_view(request: CreateViewRequest) -> View {
let view = WorkspaceTestBuilder::new()
.event(CreateView)
.request(request)
.sync_send()
.parse::<View>();
view
}

View File

@ -13,13 +13,13 @@ use serial_test::*;
fn workspace_create_success() { let _ = create_workspace("First workspace", ""); }
#[test]
fn workspace_get_detail_success() {
let user_workspace = WorkspaceTestBuilder::new()
fn workspace_get_success() {
let workspace = WorkspaceTestBuilder::new()
.event(GetCurWorkspace)
.sync_send()
.parse::<Workspace>();
dbg!(&user_workspace);
dbg!(&workspace);
}
#[test]