Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support publish view #5576

Merged
merged 160 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
4151c48
feat: support a event for getting encoded collab of document
qinluhe Jun 19, 2024
1c8913e
feat: support publish view and unpublish views
qinluhe Jun 20, 2024
3edcc08
feat: publish page to the web
LucasXu0 Jun 21, 2024
360f3df
chore: refacotor share bloc
LucasXu0 Jun 21, 2024
9519493
feat: call the publish event
LucasXu0 Jun 21, 2024
e88423c
feat: support publish view and unpublish views
qinluhe Jun 20, 2024
14ba35c
feat: integrate publish api
LucasXu0 Jun 21, 2024
9119e4a
feat: integrate unpublish api
LucasXu0 Jun 21, 2024
02199e3
feat: fetch the publish info to show the publish status
LucasXu0 Jun 21, 2024
1309a94
feat: support publish interfaces
qinluhe Jun 25, 2024
1c90d93
fix: lint error
qinluhe Jun 25, 2024
431e03e
fix: modified web server
qinluhe Jun 26, 2024
2557d90
fix: some style
qinluhe Jun 26, 2024
971c0e1
fix: some style
qinluhe Jun 26, 2024
b64514c
fix: some style
qinluhe Jun 26, 2024
990c149
fix: some style
qinluhe Jun 26, 2024
4cef37d
fix: some style
qinluhe Jun 26, 2024
492b9fd
fix: some style
qinluhe Jun 26, 2024
303e2b3
fix: some style
qinluhe Jun 26, 2024
dc910e4
fix: some style
qinluhe Jun 26, 2024
a5cb427
fix: some style
qinluhe Jun 26, 2024
3f05ac8
fix: update codes
qinluhe Jun 27, 2024
e27ddde
fix: update codes
qinluhe Jun 27, 2024
3b76ee9
fix: update codes
qinluhe Jun 27, 2024
0ffc4cb
fix: update codes
qinluhe Jun 27, 2024
c9b1591
fix: update codes
qinluhe Jun 27, 2024
39f2789
chore: refactor publish bloc
LucasXu0 Jun 27, 2024
b67a576
Merge branch 'feat/support-get-encoded-collab-event' of https://githu…
LucasXu0 Jun 27, 2024
e51b0f9
Merge branch 'main' into feat/support-get-encoded-collab-event
LucasXu0 Jun 27, 2024
127d031
fix: some style
qinluhe Jun 27, 2024
163a80a
fix: some style
qinluhe Jun 27, 2024
2cbcf29
fix: some style
qinluhe Jun 27, 2024
516cf1c
fix: some style
qinluhe Jun 27, 2024
8c0d451
fix: some style
qinluhe Jun 27, 2024
15dfd19
fix: some style
qinluhe Jun 27, 2024
2f9f2c1
fix: the name is too long to publish
LucasXu0 Jun 28, 2024
b4fe7fa
Merge branch 'feat/support-get-encoded-collab-event' of https://githu…
LucasXu0 Jun 28, 2024
701b55d
chore: change color
LucasXu0 Jun 28, 2024
3497057
fix: some style
qinluhe Jun 28, 2024
40f7e8e
fix: some style
qinluhe Jun 28, 2024
95c4da5
feat: refacotor share menu UI
LucasXu0 Jun 28, 2024
2eeac03
Merge branch 'feat/support-get-encoded-collab-event' of https://githu…
LucasXu0 Jun 28, 2024
c071589
fix: some style
qinluhe Jun 28, 2024
c398c0c
fix: lint
qinluhe Jun 28, 2024
07f22a9
fix: some style
qinluhe Jun 28, 2024
7dd4a52
feat: refacotor export-as
LucasXu0 Jun 28, 2024
eab1519
// Merge branch 'feat/support-get-encoded-collab-event' of https://gi…
LucasXu0 Jun 28, 2024
f83bf10
fix: some style
qinluhe Jun 28, 2024
6033e12
chore: refactor share menu colors
LucasXu0 Jun 28, 2024
a379e80
Merge branch 'feat/support-get-encoded-collab-event' of https://githu…
LucasXu0 Jun 28, 2024
724f1ce
fix: rust ci
LucasXu0 Jun 28, 2024
70e6a5c
fix: some style
qinluhe Jun 28, 2024
14d62db
Merge branch 'main' into feat/support-get-encoded-collab-event
LucasXu0 Jun 28, 2024
6cb81d7
Merge branch 'feat/support-get-encoded-collab-event' of https://githu…
LucasXu0 Jun 28, 2024
37864a0
fix: some style
qinluhe Jun 28, 2024
7d55369
fix: deploy
qinluhe Jun 28, 2024
30e2429
fix: deploy
qinluhe Jun 28, 2024
9ab1ed8
fix: deploy
qinluhe Jun 28, 2024
967a647
fix: deploy
qinluhe Jun 28, 2024
91368a0
fix: deploy
qinluhe Jun 28, 2024
f717472
fix: deploy
qinluhe Jun 28, 2024
1c0992e
fix: deploy
qinluhe Jun 28, 2024
8bd1df5
fix: deploy
qinluhe Jun 28, 2024
6e8b0aa
fix: deploy
qinluhe Jun 28, 2024
df7e70e
fix: deploy
qinluhe Jun 28, 2024
b1afc45
fix: deploy
qinluhe Jun 28, 2024
e211fdc
fix: deploy
qinluhe Jun 28, 2024
215910c
fix: bugs
qinluhe Jun 29, 2024
7b133e6
fix: bugs
qinluhe Jun 29, 2024
d4c5180
fix: bugs
qinluhe Jun 29, 2024
e5fd455
fix: bugs
qinluhe Jun 29, 2024
a5a8e8f
fix: bugs
qinluhe Jun 29, 2024
deae07b
fix: bugs
qinluhe Jun 29, 2024
de3a1df
fix: bugs
qinluhe Jun 29, 2024
2b602f1
fix: bugs
qinluhe Jun 29, 2024
3aabe71
fix: bugs
qinluhe Jun 29, 2024
b59bda9
fix: bugs
qinluhe Jun 29, 2024
a519347
fix: bugs
qinluhe Jun 29, 2024
5396f07
fix: bugs
qinluhe Jun 29, 2024
b9b7ce6
fix: bugs
qinluhe Jun 29, 2024
4ae9aac
fix: bugs
qinluhe Jun 29, 2024
4e43ee1
fix: bugs
qinluhe Jun 29, 2024
460b996
fix: bugs
qinluhe Jun 29, 2024
28e3025
fix: rerelease
qinluhe Jun 29, 2024
655b073
fix: deploy
qinluhe Jun 30, 2024
357988c
fix: deploy
qinluhe Jun 30, 2024
9595011
fix: deploy
qinluhe Jun 30, 2024
80255f9
fix: deploy
qinluhe Jun 30, 2024
15de98d
fix: deploy
qinluhe Jun 30, 2024
4348355
fix: deploy
qinluhe Jun 30, 2024
03a068e
fix: deploy
qinluhe Jun 30, 2024
2bf83df
fix: og image
qinluhe Jul 1, 2024
0a40e67
fix: support copy button
qinluhe Jul 2, 2024
df51cfd
fix: support copy button
qinluhe Jul 2, 2024
9c68983
fix: support copy button
qinluhe Jul 2, 2024
e852d25
chore: add a params
qinluhe Jul 2, 2024
be4d60c
Merge branch 'main' into feat/support-get-encoded-collab-event
LucasXu0 Jul 2, 2024
0daabd2
feat: use default publish name
LucasXu0 Jul 2, 2024
2da3744
chore: update copy
LucasXu0 Jul 2, 2024
cb2a7c9
feat: show a confirm deletion dialog if the deleted page contains pub…
LucasXu0 Jul 2, 2024
81f0100
feat: add copy toast in publish tab
LucasXu0 Jul 2, 2024
2a74fbc
fix: to 404
qinluhe Jul 2, 2024
5be4155
feat: unpublish the page auto when moving it to another space
LucasXu0 Jul 3, 2024
38f49d6
Merge branch 'feat/support-get-encoded-collab-event' of https://githu…
LucasXu0 Jul 3, 2024
59b36f6
feat: improve confirm deletion dialog
LucasXu0 Jul 3, 2024
4ece2ff
feat: show unpublish error
LucasXu0 Jul 3, 2024
bec7227
chore: use beta.appflowy.com
LucasXu0 Jul 3, 2024
f962188
feat: disable publish in non-apppflowy-cloud user mode
LucasXu0 Jul 3, 2024
d5c08a3
fix: modified bullted icon style
qinluhe Jul 3, 2024
b2d6876
fix: the dark mode color
qinluhe Jul 3, 2024
1b69f78
fix: save the dark mode in local storage
qinluhe Jul 3, 2024
e21ad18
fix: text color
qinluhe Jul 3, 2024
55f06cb
chore: make bash script more portable (#5679)
speed2exe Jul 3, 2024
1534a02
fix: title longer
qinluhe Jul 3, 2024
59bbc43
chore: move the files and modified the en
qinluhe Jul 3, 2024
e9ce211
chore: update deploy.sh
qinluhe Jul 4, 2024
6e4cc3a
chore: modified Dockerfile
qinluhe Jul 4, 2024
a7397b7
chore: modified server.cjs to server.js
qinluhe Jul 4, 2024
9b4b8a7
chore: modifed server.js to server.ts
qinluhe Jul 4, 2024
a34daf3
chore: replace publish url
LucasXu0 Jul 4, 2024
4a54496
chore: remove todo list hover
qinluhe Jul 4, 2024
1620481
chore: show confirm dialog before deleting page
LucasXu0 Jul 4, 2024
498e4b2
Merge branch 'feat/support-get-encoded-collab-event' of https://githu…
LucasXu0 Jul 4, 2024
0daf212
fix: unpublish the pages before deleting
LucasXu0 Jul 4, 2024
b8e0020
fix: table cell bg color
qinluhe Jul 4, 2024
72c1ef2
fix: callout icon
qinluhe Jul 4, 2024
dfdc6d8
fix: list number
qinluhe Jul 4, 2024
236acdd
fix: emoji
qinluhe Jul 4, 2024
ce1a43a
fix: number icon
qinluhe Jul 4, 2024
d29795a
fix: callout icon position
qinluhe Jul 4, 2024
9c25796
fix: add margin bottom
qinluhe Jul 4, 2024
72e7339
fix: code block
qinluhe Jul 4, 2024
e7297b2
fix: support scroll for breadcrumbs
qinluhe Jul 4, 2024
e0625aa
fix: the breadcrumb doesn't update after moving page
LucasXu0 Jul 5, 2024
eb11b37
Merge branch 'feat/support-get-encoded-collab-event' of https://githu…
LucasXu0 Jul 5, 2024
2814476
fix: 0705 issues
qinluhe Jul 5, 2024
66e6bdb
fix: update publish status afer deleting page
LucasXu0 Jul 5, 2024
8922a2a
Merge branch 'feat/support-get-encoded-collab-event' of https://githu…
LucasXu0 Jul 5, 2024
fd296b7
chore: add hover effect for visit site button
LucasXu0 Jul 5, 2024
ba11597
fix: remove puiblish url text field enable border color
LucasXu0 Jul 5, 2024
04302da
chore: update delete page copy
LucasXu0 Jul 5, 2024
0f95543
chore: enable debug category
LucasXu0 Jul 5, 2024
e5d62e6
fix: only render sidebar if the spaces are ready
LucasXu0 Jul 5, 2024
a869c43
fix: the breadcrumb doesn't update after moving page
LucasXu0 Jul 5, 2024
ed82d18
fix: auto code
qinluhe Jul 5, 2024
39e3b4a
fix: add emoji
qinluhe Jul 5, 2024
77807a1
fix: add emoji
qinluhe Jul 5, 2024
43cea95
fix: favicon
qinluhe Jul 6, 2024
ba6f9d1
fix: cypress test
qinluhe Jul 6, 2024
19c5329
fix: remove deploy ci
qinluhe Jul 6, 2024
14b2576
fix: default url
qinluhe Jul 7, 2024
1608842
chore: revert launch.json
LucasXu0 Jul 8, 2024
a524b75
fix: docker ci
LucasXu0 Jul 8, 2024
48200c0
fix: change favicon
qinluhe Jul 8, 2024
a69b4b0
fix: flutter integration test
LucasXu0 Jul 8, 2024
ee6a29f
Merge branch 'feat/support-get-encoded-collab-event' of https://githu…
LucasXu0 Jul 8, 2024
487c16f
feat: add hover effect to share menu
LucasXu0 Jul 8, 2024
ddab180
chore: add a checkmark if the page has been published
LucasXu0 Jul 8, 2024
8488334
chore: revert space deletion
LucasXu0 Jul 8, 2024
40fc9a1
Merge branch 'main' into feat/support-get-encoded-collab-event
LucasXu0 Jul 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
72 changes: 0 additions & 72 deletions .github/workflows/deploy_test_web.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('Empty', () {
testWidgets('toggle theme mode', (tester) async {
testWidgets('empty test', (tester) async {
await tester.initializeAppFlowy();
await tester.tapAnonymousSignInButton();
await tester.wait(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ void main() {
},
);

final shareButton = find.byType(ShareActionList);
final shareButton = find.byType(DocumentShareButton);
final shareButtonState =
tester.state(shareButton) as ShareActionListState;
tester.widget(shareButton) as DocumentShareButton;

final path = await mockSaveFilePath(
p.join(
context.applicationDataDirectory,
'${shareButtonState.name}.md',
'${shareButtonState.view.name}.md',
),
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,190 @@
import 'dart:io';

import 'package:appflowy/user/application/user_service.dart';
import 'package:appflowy/workspace/application/export/document_exporter.dart';
import 'package:appflowy/workspace/application/view/view_listener.dart';
import 'package:appflowy/workspace/application/view/view_service.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-document/entities.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
import 'package:appflowy_result/appflowy_result.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'document_share_bloc.freezed.dart';

const _url = 'https://appflowy.com';

class DocumentShareBloc extends Bloc<DocumentShareEvent, DocumentShareState> {
DocumentShareBloc({
required this.view,
}) : super(const DocumentShareState.initial()) {
}) : super(DocumentShareState.initial()) {
on<DocumentShareEvent>((event, emit) async {
await event.when(
initial: () async {
viewListener = ViewListener(viewId: view.id)
..start(
onViewUpdated: (value) {
add(DocumentShareEvent.updateViewName(value.name));
},
onViewMoveToTrash: (p0) {
add(const DocumentShareEvent.setPublishStatus(false));
},
);

add(const DocumentShareEvent.updatePublishStatus());
},
share: (type, path) async {
if (DocumentShareType.unimplemented.contains(type)) {
Log.error('DocumentShareType $type is not implemented');
return;
}

emit(const DocumentShareState.loading());

final exporter = DocumentExporter(view);
final FlowyResult<ExportDataPB, FlowyError> result =
await exporter.export(type.exportType).then((value) {
return value.fold(
(s) {
if (path != null) {
switch (type) {
case DocumentShareType.markdown:
return FlowyResult.success(_saveMarkdownToPath(s, path));
case DocumentShareType.html:
return FlowyResult.success(_saveHTMLToPath(s, path));
default:
break;
}
}
return FlowyResult.failure(FlowyError());
},
(f) => FlowyResult.failure(f),
emit(state.copyWith(isLoading: true));

final result = await _export(type, path);

emit(
state.copyWith(
isLoading: false,
exportResult: result,
),
);
},
publish: (nameSpace, publishName) async {
// set space name
try {
final result =
await ViewBackendService.getPublishNameSpace().getOrThrow();

await ViewBackendService.publish(
view,
name: publishName,
).getOrThrow();

emit(
state.copyWith(
isPublished: true,
publishResult: FlowySuccess(null),
unpublishResult: null,
url: '$_url/${result.namespace}/$publishName',
),
);
} catch (e) {
Log.error('publish error: $e');

emit(
state.copyWith(
isPublished: false,
publishResult: FlowyResult.failure(
FlowyError(msg: 'publish error: $e'),
),
unpublishResult: null,
url: '',
),
);
}
},
unPublish: () async {
emit(
state.copyWith(
publishResult: null,
unpublishResult: null,
),
);

final result = await ViewBackendService.unpublish(view);
final isPublished = !result.isSuccess;
result.onFailure((f) {
Log.error('unpublish error: $f');
});

emit(DocumentShareState.finish(result));
emit(
state.copyWith(
isPublished: isPublished,
publishResult: null,
unpublishResult: result,
url: result.fold((_) => '', (_) => state.url),
),
);
},
updateViewName: (viewName) async {
emit(state.copyWith(viewName: viewName));
},
setPublishStatus: (isPublished) {
emit(
state.copyWith(
isPublished: isPublished,
url: isPublished ? state.url : '',
),
);
},
updatePublishStatus: () async {
final publishInfo = await ViewBackendService.getPublishInfo(view);
final enablePublish =
await UserBackendService.getCurrentUserProfile().fold(
(v) => v.authenticator == AuthenticatorPB.AppFlowyCloud,
(p) => false,
);
publishInfo.fold((s) {
emit(
state.copyWith(
isPublished: true,
url: '$_url/${s.namespace}/${s.publishName}',
viewName: view.name,
enablePublish: enablePublish,
),
);
}, (f) {
emit(
state.copyWith(
isPublished: false,
url: '',
viewName: view.name,
enablePublish: enablePublish,
),
);
});
},
);
});
}

final ViewPB view;
late final ViewListener viewListener;

late final exporter = DocumentExporter(view);

@override
Future<void> close() async {
await viewListener.stop();
return super.close();
}

Future<FlowyResult<ExportDataPB, FlowyError>> _export(
DocumentShareType type,
String? path,
) async {
final result = await exporter.export(type.exportType);
return result.fold(
(s) {
if (path != null) {
switch (type) {
case DocumentShareType.markdown:
return FlowySuccess(_saveMarkdownToPath(s, path));
case DocumentShareType.html:
return FlowySuccess(_saveHTMLToPath(s, path));
default:
break;
}
}
return FlowyResult.failure(FlowyError());
},
(f) => FlowyResult.failure(f),
);
}

ExportDataPB _saveMarkdownToPath(String markdown, String path) {
File(path).writeAsStringSync(markdown);
Expand Down Expand Up @@ -93,15 +225,41 @@ enum DocumentShareType {

@freezed
class DocumentShareEvent with _$DocumentShareEvent {
const factory DocumentShareEvent.share(DocumentShareType type, String? path) =
Share;
const factory DocumentShareEvent.initial() = _Initial;
const factory DocumentShareEvent.share(
DocumentShareType type,
String? path,
) = _Share;
const factory DocumentShareEvent.publish(
String nameSpace,
String pageId,
) = _Publish;
const factory DocumentShareEvent.unPublish() = _UnPublish;
const factory DocumentShareEvent.updateViewName(String name) =
_UpdateViewName;
const factory DocumentShareEvent.updatePublishStatus() = _UpdatePublishStatus;
const factory DocumentShareEvent.setPublishStatus(bool isPublished) =
_SetPublishStatus;
}

@freezed
class DocumentShareState with _$DocumentShareState {
const factory DocumentShareState.initial() = _Initial;
const factory DocumentShareState.loading() = _Loading;
const factory DocumentShareState.finish(
FlowyResult<ExportDataPB, FlowyError> successOrFail,
) = _Finish;
const factory DocumentShareState({
required bool isPublished,
required bool isLoading,
required String url,
required String viewName,
required bool enablePublish,
FlowyResult<ExportDataPB, FlowyError>? exportResult,
FlowyResult<void, FlowyError>? publishResult,
FlowyResult<void, FlowyError>? unpublishResult,
}) = _DocumentShareState;

factory DocumentShareState.initial() => const DocumentShareState(
isLoading: false,
isPublished: false,
enablePublish: true,
url: '',
viewName: '',
);
}
Loading
Loading