Merge pull request #469 from AppFlowy-IO/feat_local_folder

chore: show appflowy document path in debug info
This commit is contained in:
Nathan.fooo 2022-04-28 21:53:49 +08:00 committed by GitHub
commit fa3a28e850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 142 additions and 182 deletions

View File

@ -58,7 +58,7 @@ jobs:
working-directory: frontend/app_flowy
run: |
flutter packages pub get
flutter packages pub run easy_localization:generate -S ./assets/translations -f keys -O lib/generated -o locale_keys.g.dart
flutter packages pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations -s en.json
flutter packages pub run build_runner build --delete-conflicting-outputs
- name: Build FlowySDK

View File

@ -9,27 +9,21 @@ class InitRustSDKTask extends LaunchTask {
@override
Future<void> initialize(LaunchContext context) async {
switch (context.env) {
case IntegrationMode.release:
Directory documentsDir = await getApplicationDocumentsDirectory();
return Directory('${documentsDir.path}/flowy').create().then(
(Directory directory) async {
await context.getIt<FlowySDK>().init(directory);
},
);
case IntegrationMode.develop:
Directory documentsDir = await getApplicationDocumentsDirectory();
return Directory('${documentsDir.path}/flowy_dev').create().then(
(Directory directory) async {
await context.getIt<FlowySDK>().init(directory);
},
);
case IntegrationMode.test:
final directory = Directory("${Directory.current.path}/.sandbox");
await context.getIt<FlowySDK>().init(directory);
break;
default:
assert(false, 'Unsupported env');
}
await appFlowyDocumentDirectory().then((directory) async {
await context.getIt<FlowySDK>().init(directory);
});
}
}
Future<Directory> appFlowyDocumentDirectory() async {
Directory documentsDir = await getApplicationDocumentsDirectory();
switch (integrationEnv()) {
case IntegrationMode.develop:
return Directory('${documentsDir.path}/flowy_dev').create();
case IntegrationMode.release:
return Directory('${documentsDir.path}/flowy').create();
case IntegrationMode.test:
return Directory("${Directory.current.path}/.sandbox");
}
}

View File

@ -1,3 +1,4 @@
import 'package:app_flowy/startup/tasks/rust_sdk.dart';
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
import 'package:easy_localization/easy_localization.dart';
@ -6,7 +7,6 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flowy_sdk/log.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
@ -46,67 +46,7 @@ class QuestionBubble extends StatelessWidget {
_launchURL("https://discord.gg/9Q2xaN37tV");
break;
case BubbleAction.debug:
final deviceInfoPlugin = DeviceInfoPlugin();
final deviceInfo = deviceInfoPlugin.deviceInfo;
deviceInfo.then((info) {
var debugText = "";
info.toMap().forEach((key, value) {
debugText = debugText + "$key: $value\n";
});
Clipboard.setData(ClipboardData(text: debugText));
Widget toast = Container(
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
color: theme.main1,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.check),
const SizedBox(
width: 12.0,
),
Text(LocaleKeys.questionBubble_debug_success.tr()),
],
),
);
fToast.showToast(
child: toast,
gravity: ToastGravity.BOTTOM,
toastDuration: const Duration(seconds: 3),
);
}).catchError((error) {
Log.info("Debug info has not yet been implemented on this platform");
Widget toast = Container(
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
color: Colors.red,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.close),
const SizedBox(
width: 12.0,
),
Text(LocaleKeys.questionBubble_debug_fail.tr()),
],
),
);
fToast.showToast(
child: toast,
gravity: ToastGravity.BOTTOM,
toastDuration: const Duration(seconds: 3),
);
}, test: (e) => e is UnimplementedError);
const _DebugToast().show();
break;
}
});
@ -130,6 +70,78 @@ class QuestionBubble extends StatelessWidget {
}
}
class _DebugToast extends StatelessWidget {
const _DebugToast({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: Future(() async {
var debugInfo = "";
debugInfo += await _getDeviceInfo();
debugInfo += await _getDocumentPath();
Clipboard.setData(ClipboardData(text: debugInfo));
}),
builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return _done(context, Text("Error: ${snapshot.error}"));
} else {
return _done(context, null);
}
} else {
return const CircularProgressIndicator();
}
},
);
}
Widget _done(BuildContext context, Widget? error) {
final theme = context.watch<AppTheme>();
return Container(
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(25.0), color: theme.main1),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.check),
const SizedBox(width: 12.0),
(error == null) ? Text(LocaleKeys.questionBubble_debug_success.tr()) : error
],
),
);
}
void show() {
fToast.showToast(
child: this,
gravity: ToastGravity.BOTTOM,
toastDuration: const Duration(seconds: 3),
);
}
Future<String> _getDeviceInfo() async {
final deviceInfoPlugin = DeviceInfoPlugin();
final deviceInfo = deviceInfoPlugin.deviceInfo;
return deviceInfo.then((info) {
var debugText = "";
info.toMap().forEach((key, value) {
debugText = debugText + "$key: $value\n";
});
return debugText;
});
}
Future<String> _getDocumentPath() async {
return appFlowyDocumentDirectory().then((directory) {
final path = directory.path.toString();
return "Document: $path\n";
});
}
}
class QuestionBubbleActionSheet with ActionList<BubbleActionWrapper>, FlowyOverlayDelegate {
final Function(dartz.Option<BubbleAction>) onSelected;
final _items = BubbleAction.values.map((action) => BubbleActionWrapper(action)).toList();

View File

@ -712,16 +712,6 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "env_logger"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.8.4"
@ -782,9 +772,9 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "fancy-regex"
version = "0.5.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe09872bd11351a75f22b24c3769fc863e8212d926d6db46b94ad710d14cc5cc"
checksum = "0678ab2d46fa5195aaf59ad034c083d351377d4af57f3e073c074d0da3e3c766"
dependencies = [
"bit-set",
"regex",
@ -1163,7 +1153,7 @@ dependencies = [
"lib-ws",
"log",
"protobuf",
"rand 0.7.3",
"rand 0.8.5",
"serde",
"serde_json",
"strum",
@ -1698,7 +1688,7 @@ dependencies = [
"dashmap",
"derivative",
"dyn-clone",
"env_logger 0.8.4",
"env_logger",
"futures",
"futures-channel",
"futures-core",
@ -1735,7 +1725,7 @@ dependencies = [
"pin-project",
"protoc-bin-vendored",
"protoc-rust",
"rand 0.8.4",
"rand 0.8.5",
"serde",
"serde_json",
"similar",
@ -1973,7 +1963,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8"
dependencies = [
"rand 0.8.4",
"rand 0.8.5",
]
[[package]]
@ -2261,7 +2251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6"
dependencies = [
"phf_shared 0.10.0",
"rand 0.8.4",
"rand 0.8.5",
]
[[package]]
@ -2497,14 +2487,13 @@ dependencies = [
[[package]]
name = "quickcheck"
version = "0.9.2"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f"
checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
dependencies = [
"env_logger 0.7.1",
"env_logger",
"log",
"rand 0.7.3",
"rand_core 0.5.1",
"rand 0.8.5",
]
[[package]]
@ -2548,20 +2537,19 @@ dependencies = [
"libc",
"rand_chacha 0.2.2",
"rand_core 0.5.1",
"rand_hc 0.2.0",
"rand_hc",
"rand_pcg",
]
[[package]]
name = "rand"
version = "0.8.4"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha 0.3.1",
"rand_core 0.6.3",
"rand_hc 0.3.1",
]
[[package]]
@ -2611,15 +2599,6 @@ dependencies = [
"rand_core 0.5.1",
]
[[package]]
name = "rand_hc"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [
"rand_core 0.6.3",
]
[[package]]
name = "rand_pcg"
version = "0.2.1"
@ -2631,9 +2610,9 @@ dependencies = [
[[package]]
name = "rayon"
version = "1.5.1"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90"
checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221"
dependencies = [
"autocfg",
"crossbeam-deque",
@ -2643,14 +2622,13 @@ dependencies = [
[[package]]
name = "rayon-core"
version = "1.9.1"
version = "1.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e"
checksum = "9f51245e1e62e1f1629cbfec37b5793bbabcaeb90f30e94d2ba03564687353e4"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
"lazy_static",
"num_cpus",
]
@ -3136,7 +3114,7 @@ dependencies = [
"percent-encoding",
"pest",
"pest_derive",
"rand 0.8.4",
"rand 0.8.5",
"regex",
"serde",
"serde_json",
@ -3462,7 +3440,7 @@ dependencies = [
"http",
"httparse",
"log",
"rand 0.8.4",
"rand 0.8.5",
"sha-1 0.9.8",
"thiserror",
"url",

View File

@ -30,7 +30,7 @@ bytes = { version = "1.0" }
diesel = {version = "1.4.8", features = ["sqlite"]}
dashmap = "4.0"
tokio = {version = "1", features = ["sync"]}
rayon = "1.5"
rayon = "1.5.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = {version = "1.0"}
serde_repr = "0.1"

View File

@ -29,7 +29,7 @@ bytes = "1.0"
nanoid = "0.4.0"
[dev-dependencies]
quickcheck = "0.9.2"
quickcheck = "1.0.3"
quickcheck_macros = "0.9.1"
fake = "~2.3.0"
claim = "0.4.0"

View File

@ -45,7 +45,7 @@ derive_more = {version = "0.99", features = ["display"]}
color-eyre = { version = "0.5", default-features = false }
criterion = "0.3"
rand = "0.7.3"
rand = "0.8.5"
[build-dependencies]
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "proto_gen"] }

View File

@ -309,9 +309,9 @@ impl Rng {
let i = if left == 1 {
1
} else {
1 + self.0.gen_range(0, std::cmp::min(left - 1, 20))
1 + self.0.gen_range(0..std::cmp::min(left - 1, 20))
};
match self.0.gen_range(0.0, 1.0) {
match self.0.gen_range(0.0..1.0) {
f if f < 0.2 => {
delta.insert(&self.gen_string(i), RichTextAttributes::default());
}
@ -323,7 +323,7 @@ impl Rng {
}
}
}
if self.0.gen_range(0.0, 1.0) < 0.3 {
if self.0.gen_range(0.0..1.0) < 0.3 {
delta.insert(&("1".to_owned() + &self.gen_string(10)), RichTextAttributes::default());
}
delta

View File

@ -16,7 +16,7 @@ env_logger = "0.8.2"
cmd_lib = "1.1"
flowy-ast = { path = "../../../shared-lib/flowy-ast" }
console = "0.14.0"
fancy-regex = "0.5.0"
fancy-regex = "0.10.0"
lazy_static = "1.4.0"
phf = { version = "0.8.0", features = ["macros"] }
similar = "1.2.2"

51
shared-lib/Cargo.lock generated
View File

@ -325,16 +325,6 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
[[package]]
name = "env_logger"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.8.4"
@ -376,9 +366,9 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "fancy-regex"
version = "0.5.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe09872bd11351a75f22b24c3769fc863e8212d926d6db46b94ad710d14cc5cc"
checksum = "0678ab2d46fa5195aaf59ad034c083d351377d4af57f3e073c074d0da3e3c766"
dependencies = [
"bit-set",
"regex",
@ -843,7 +833,7 @@ dependencies = [
"pin-project",
"protoc-bin-vendored",
"protoc-rust",
"rand 0.8.4",
"rand 0.8.5",
"serde",
"serde_json",
"similar",
@ -881,7 +871,7 @@ version = "0.1.0"
dependencies = [
"bytes",
"dashmap",
"env_logger 0.8.4",
"env_logger",
"flowy-derive",
"futures",
"futures-channel",
@ -977,7 +967,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8"
dependencies = [
"rand 0.8.4",
"rand 0.8.5",
]
[[package]]
@ -1182,7 +1172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6"
dependencies = [
"phf_shared 0.10.0",
"rand 0.8.4",
"rand 0.8.5",
]
[[package]]
@ -1390,14 +1380,13 @@ dependencies = [
[[package]]
name = "quickcheck"
version = "0.9.2"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f"
checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
dependencies = [
"env_logger 0.7.1",
"env_logger",
"log",
"rand 0.7.3",
"rand_core 0.5.1",
"rand 0.8.5",
]
[[package]]
@ -1430,20 +1419,19 @@ dependencies = [
"libc",
"rand_chacha 0.2.2",
"rand_core 0.5.1",
"rand_hc 0.2.0",
"rand_hc",
"rand_pcg",
]
[[package]]
name = "rand"
version = "0.8.4"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha 0.3.1",
"rand_core 0.6.3",
"rand_hc 0.3.1",
]
[[package]]
@ -1493,15 +1481,6 @@ dependencies = [
"rand_core 0.5.1",
]
[[package]]
name = "rand_hc"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [
"rand_core 0.6.3",
]
[[package]]
name = "rand_pcg"
version = "0.2.1"
@ -1782,7 +1761,7 @@ dependencies = [
"percent-encoding",
"pest",
"pest_derive",
"rand 0.8.4",
"rand 0.8.5",
"regex",
"serde",
"serde_json",
@ -1976,7 +1955,7 @@ dependencies = [
"http",
"httparse",
"log",
"rand 0.8.4",
"rand 0.8.5",
"sha-1 0.9.8",
"thiserror",
"url",

View File

@ -41,8 +41,10 @@ impl FolderPadBuilder {
// TODO: Reconvert from history if delta.to_str() failed.
let folder_json = delta.to_str()?;
let mut folder: FolderPad = serde_json::from_str(&folder_json)
.map_err(|e| CollaborateError::internal().context(format!("Deserialize delta to folder failed: {}", e)))?;
let mut folder: FolderPad = serde_json::from_str(&folder_json).map_err(|e| {
tracing::error!("Deserialize folder from json failed: {}", folder_json);
return CollaborateError::internal().context(format!("Deserialize delta to folder failed: {}", e));
})?;
folder.delta = delta;
Ok(folder)
}

View File

@ -15,14 +15,14 @@ derive_more = {version = "0.99", features = ["display"]}
serde = { version = "1.0", features = ["derive"] }
validator = "0.12.0"
log = "0.4.14"
fancy-regex = "0.5.0"
fancy-regex = "0.10.0"
lazy_static = "1.4"
[build-dependencies]
lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
[dev-dependencies]
quickcheck = "0.9.2"
quickcheck = "1.0.3"
quickcheck_macros = "0.9.1"
fake = "~2.3.0"
claim = "0.4.0"

View File

@ -12,7 +12,7 @@ bytes = { version = "1.0" }
pin-project = "1.0"
futures-core = { version = "0.3" }
tokio = { version = "1.0", features = ["time", "rt"] }
rand = "0.8.3"
rand = "0.8.5"
serde = { version = "1.0", features = ["derive"]}
serde_json = "1.0"
@ -23,7 +23,7 @@ walkdir = { version = "2", optional = true }
flowy-ast = { path = "../flowy-ast", optional = true}
similar = { version = "1.2.2", optional = true }
syn = { version = "1.0.60", features = ["extra-traits", "parsing", "derive", "full"], optional = true }
fancy-regex = { version = "0.5.0", optional = true }
fancy-regex = { version = "0.10.0", optional = true }
lazy_static = { version = "1.4.0", optional = true }
tera = { version = "1.5.0", optional = true}
itertools = { version = "0.10", optional = true }

View File

@ -1,9 +1,4 @@
pub fn move_vec_element<T, F>(
vec: &mut Vec<T>,
filter: F,
_from_index: usize,
mut to_index: usize,
) -> Result<bool, String>
pub fn move_vec_element<T, F>(vec: &mut Vec<T>, filter: F, _from_index: usize, to_index: usize) -> Result<bool, String>
where
F: FnMut(&T) -> bool,
{