-
Notifications
You must be signed in to change notification settings - Fork 94
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/read only setting #4902
Feat/read only setting #4902
Conversation
Thanks a lot for your contribution. Implementation wise I only had a first quick look, but this seems reasonable. I'd be ok having a setting for this if it is covered by a e2e test that verifies it doesn't break, however would also like some confirmation from @nextcloud/designers on this especially given the previous discussion in #3923 which didn't have a common conclusion yet on that topic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m quite unsure if this is a good idea – this is not something that desktop apps for text or office do, and neither Google Docs, Notion or others, at least by default.
If we do this (which as said I’m leaning against), then there is some feedback for this pull request:
- In view-only mode, the "checkmark" save button is also shown, floating in mid-air. This would need to be removed
- In edit mode, the "Save" button already exists as the "checkmark" save button on the right. The "Save document" button with the floppy disk icon (outdated, should not be used) is not necessary, also as it introduces another vertical bar
Hi @juliushaertl and @jancborchardt, thank you for your feedback. Before we put further effort into this PR and try to implement the final parts, we would like to make sure that there exists the chance it will actually get accepted eventually. We understand that some of you are not convinced by the feature, because comparable editors handle things differently. And adding a new feature always entails maintenance work. When looking at the votes of the currently open tickets, however, this feature is among the top 10 voted tickets with a handful of people that would be happy to see it coming. And the way it is implemented now, |
I think if everything is fixed and tests are ok this could be a very helpful addition. And because it's optional now it should not disturb anyone expecting to always edit files directly. At least to me it seemed in #3923 that there might be quite a few other people liking the more explicit editing behaviour. But indeed it depends on @jancborchardt first, before it makes sense to polish everything for a merge... |
Hi @juliushaertl and @jancborchardt, this is a friendly ping. Is there any progress in deciding whether the feature might get accepted? |
Desktop apps for text or office usually do not to automatically save the document in the background, but instead the user is notified upon closing the document that there are some unsaved changes, offering the possibility to prevent unwanted changes. Web based editors like |
cc @nimishavijay As Jan is currently out of office :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benthie sorry for the late reply! :) I would be fine with this feature, as long as the config.php setting (open_read_only_enabled
as far as I understand?) is false by default. And considering my design feedback from above comment #4902 (review)
All right, in order to get this merged I'd definitely require proper tests that cover this feature. I'd suggest to write a cypress e2e test that could make use of the "testing" app in server to set the app value, then load a file and check the new UI parts. |
src/components/Editor.vue
Outdated
<!-- Rich Menu --> | ||
<template v-else> | ||
<div v-if="openReadOnlyEnabled" class="text-editor--editable-bar-save"> | ||
<EditableBarSave /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UI wise I would prefer to not have an extra menu line but rather integrate this into the existing menu bar This could be passed into a slot of the Menubar component
src/components/Editor.vue
Outdated
@@ -457,9 +478,11 @@ export default { | |||
onOpened({ document, session }) { | |||
this.currentSession = session | |||
this.document = document | |||
this.readOnly = document.readOnly | |||
this.documentReadOnly = document.readOnly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of having a copy of the state, can we just use document.readOnly instead in places where this is used?
src/components/Editor.vue
Outdated
@@ -457,9 +478,11 @@ export default { | |||
onOpened({ document, session }) { | |||
this.currentSession = session | |||
this.document = document | |||
this.readOnly = document.readOnly | |||
this.documentReadOnly = document.readOnly | |||
this.editable = !this.documentReadOnly && !this.openReadOnlyEnabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call this editMode to be a bit more clear what this value is about?
src/components/Menu/entries.js
Outdated
@@ -65,6 +67,22 @@ export const ReadonlyEntries = [{ | |||
}, | |||
}] | |||
|
|||
export const EditEntries = [{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just directly hardcode those into the bar components and reduce the complexity a bit here.
Hi everybody, I finally have the time to get started working on the requested changes/tests. Right now I cannot get the cypress e2e tests running. What I do is running the following in the terminal of the devcontainer:
which produces this output:
If I do not set the
I looked for information in this section of the readme, but it only says that the user must be in the docker group. Is there anything I am missing or doing wrong? |
I think running within the dev container is currently not really working. If you can run it outside of the container you could just use your existing URL of your development environment and start cypress with Hope this helps |
44eeccb
to
77259a8
Compare
Hi @juliushaertl, that helped indeed, thanks. I've written the e2e tests, but currently the tests with If you prefer the commits squashed or with another commit message style, just let me know and I will adapt it. |
Pushed a small commit that hopefully makes them pass on CI. I had one chrome crash as well when trying locally but not reproducible anymore later on, so for that I have no real clue for now. However would not consider that a blocker once it passes on CI as some chromium or cypress bug could also be the case there. |
Hi @juliushaertl, did the tests pass as expected? And is there anything left for me to do? |
@juliushaertl, @benthie can we get this closer to merge? I would be really happy to have this on our NC instance... |
@juliushaertl I talked to @benthie and according to him all tests pass locally for him; how can we make them pass on CI as well? |
@rvjr @benthie First of all thanks a lot for your contribution! ❤️ I'm looking into ci issues right now and trying to make it run more robustly. I will also take a look at the failures here and check if they relate to your changes or are flaky tests for other reasons. I'll let you know if I run into anything you'd need to fix. |
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! |
Hi @max-nextcloud, do you have any updates on the test failures? I could try to reproduce this locally if the failures are related to this PR and if it helps bringing if closer to merging. As @rvjr already said, we would be happy to have this feature in our NC instance. |
Dear @benthie Sorry for letting this sit here for so long. We're making an effort to catch up on community PRs and I will follow up on this soon. |
So first of all I read the backlog. It looks like everything was addressed already. The cypress test failing was in runner 2 and I just fixed a flaky test there - so chances are it may pass now. I will rebase the PR on current master and then push again to see how the tests behave. Thanks a lot for your work and sorry for letting this slip through. |
b310305
to
491884a
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4902 +/- ##
==========================================
+ Coverage 46.86% 46.90% +0.03%
==========================================
Files 747 732 -15
Lines 34012 34057 +45
Branches 1240 1225 -15
==========================================
+ Hits 15940 15973 +33
- Misses 17451 17478 +27
+ Partials 621 606 -15 ☔ View full report in Codecov by Sentry. |
The autoload failure is unrelated to this PR also fails on other PRs now: |
fbccc51
to
3cfd707
Compare
@benthie I adjusted the cypress tests some so they run - but they fail because the setting seems to have no effect. Were they passing for you before? |
To be honest: I don't remember. But according to my comment above, some tests seemed to work:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works, small nitpick inline
src/components/Menu/entries.js
Outdated
export const ReadOnlyDoneEntries = [{ | ||
key: 'done', | ||
label: t('text', 'Done'), | ||
keyChar: 'esc', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem to work, would drop it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@max-nextcloud I tried to push a commit for this but failed. Maybe you can?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juliusknorr What exactly did you want to do? drop the keyChar
value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, my guess is that implementing proper esc key support is more tricky as it also may conflict with viewer and keyboard navigation handling, so I'd skip this for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
95cee60
to
2c7eae3
Compare
Signed-off-by: Benjamin Thiemann <[email protected]>
Signed-off-by: Benjamin Thiemann <[email protected]>
Signed-off-by: Benjamin Thiemann <[email protected]>
Signed-off-by: Benjamin Thiemann <[email protected]>
Signed-off-by: Benjamin Thiemann <[email protected]>
Signed-off-by: Benjamin Thiemann <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
* Does not work right now. * Would conflict with esc key use for viewer and other keyboard nav. Signed-off-by: Max <[email protected]>
2c7eae3
to
d7f4a75
Compare
📝 Summary
Hi everybody,
So far the following is implemented:
open_read_only_enabled
has been added, which can be toggled in the same way asworkspace_available
via command line. Thus, the original functionality remains untouched.open_read_only_enabled=true
text/markdown files are opened in read-only mode by default and an edit button is shown next to the "Show Outline" button. Clicking on the button makes the file editable, the edit button is replaced by a "Save document" button and the formatting menu bar is shown as in normal mode beneath the button.While playing around with that new mode, we figured it would be useful to have a possibility to prevent the file from being auto-saved on exit if the user changed the file. Instead, we thought of showing a confirmation dialog in case of unsaved changes asking whether the user wants to save them.
I tried to add such a dialog to the
Editor.vue
component, but as far as as I understand it, the editor is destroyed by the parentViewer
component and in the editor'sbeforeDestroy
life hook, where the auto-save is performed, I am not able to launch a modal that waits for the user input, because the remaining life hooks are executed immediately afterbeforeDestroy
.The
ImageEditor.vue
component of theViewer
app does exactly this, but it uses theFilerobotImageEditor
which can be provided with anonClose
callback.Is there any other way we could achieve the same functionality?
I am new to web development and I know that many of the changes I propose here can be improved. I happy about your feedback.
🖼️ Screenshots
Read-only
Editable
🚧 TODO
🏁 Checklist
npm run lint
/npm run stylelint
/composer run cs:check
)