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

remove modal and vue.js, create guests only by email #149

Merged
merged 3 commits into from
Sep 14, 2017

Conversation

cortho
Copy link
Contributor

@cortho cortho commented Sep 13, 2017

Related issues:
#147, #115

I have been testing locally at the frontend and with the integration tests.

What is done in this PR:

  • moved dynamically created guests.bundle.js to guestshare.js
  • removed modal window (fixes Remove guest creation modal #147)
  • extended \Files_Sharing\Controller\ShareesController to be able to distinguish between guests and oc users (Guest users cannot be distinguished from regular users in the sharingTabView #115)
  • use constant for default group name
  • show (guest) in autocomplete, when user is a guest (this value will be taken from appconfig's group name)
  • do not offer guest user creation in autocomplete when an email is already in use
  • removed vue.js along with composer & co
  • removed build information from Makefile

Edit: current status

this.model = model;
this.email = email;

let self = this;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does let work with IE11 without transpiler ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and other browsers like latest Safari, etc... I'd prefer to be safe and use var instead

}).fail(function (xhr) {
let response = JSON.parse(xhr.responseText);
let error = response.errorMessages;
OCdialogs.alert(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: OC.dialogs.alert (OC.dialogs is an alias of the internal OCdialogs)

data: attributes,
dataType: 'json'
}).done(function () {
if (self.model)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OC.Plugins.register('OC.Share.ShareDialogView', {
attach: function (obj) {

// Override ShareDigalogView
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Digalog

function (result) {
$loading.addClass('hidden');
$loading.removeClass('inlineblock');
if (result.ocs.meta.statuscode == 100) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: use "api/v2" for slightly more status code sanity and receive 200 here instead of 100

*
*/

var Guests = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class is called Guests but the file is called sharedialogview.js ?

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right approach.

What if another app also decides to influence the share autocomplete ? They'd both fight for the sharee route.

Also I'm not happy with the huge copy-paste of the share dialog view code. If we ever fix stuff in core there we'd need to recopy again.

How did the old vuejs code do ? From what I remember we added a plugin hook in core to allow an app to inject stuff / results from its own JS class. Did it not work with that approach ?

@PVince81
Copy link
Contributor

I also need to think about it a bit... my gut feeling tells me that doing "do not offer guest user creation in autocomplete when an email is already in use" is not trivial and might need some backend work instead.


// Override ShareDigalogView

obj.autocompleteHandler = function (search, response) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok now I realize that this is the old existing code that you just moved here... argh... I wish I saw this earlier

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually what I expected from the original dev was to extend the function, not copy paste it.
To extend:

var oldHandler = obj.autocompleteHandler;
obj.autocompleteHandler = function(search, response) {
    return oldHandler.call(obj, search, function() {
        // add additional entries here (challenge might be to get it sorted properly)
        // ...
        response();
    });
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add more hooks in core for the autocomplete handler to allow injecting results inside the array from separate/different requests so they can be sorted and also the "no users" message would work too.

Trying to think of a way without additional hooks...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised here #150


// Add potential guests to the suggestions
if (searchTerm.search("@") !== -1) {
groupName = groupName = "(gast)";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(gast) would need to be translated: t('guests', '(guest)')

Copy link
Contributor

@PVince81 PVince81 Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and syntax problem, there are two equals. Change this row to:

groupName += ' ' + t('guests', '(guest)');

@PVince81
Copy link
Contributor

Sorry if my comments might sounds confusing. I commented as soon as I saw the code.
I'm starting to get a fuller picture of what you are trying to achieve.

From what I understand:

  • ShareesController was overridden to be able to append "($guestGroupName)" for any guest user in the result list
  • client-side JS is just a copy of the old vue.js plugin registration, the only change is the endpoint that goes to the guest app's sharee endpoint instead of the core one, to reach ShareesController
  • the client-side autocompleteHandler override is only here to inject the extra "create new guest" entry in case an email address was entered.

I'd like to find a way that removes the need to override/extend the ShareesController.
On the other hand, one might say, if we already copy-pasted so much code for the JS override, why not do the same for the server ? :-/

@PVince81
Copy link
Contributor

Ideal would to be to have the distinction possible in core, we have been discussing this here: owncloud/core#28979

@PVince81
Copy link
Contributor

@cortho I had a chat with @pmaier1 and we agreed that the suffix "($guestGroupName)" is not needed for this version. We'll look into a way for distinguishing users in the share autocomplete directly in core: owncloud/core#28979

Can you remove ShareesController and the custom route ?
Removing the dialog and switching to email should be enough for now.

@cortho
Copy link
Contributor Author

cortho commented Sep 14, 2017

@PVince81 ok. I'll look over this and give feedback/changes ASAP

@cortho
Copy link
Contributor Author

cortho commented Sep 14, 2017

@PVince81 I removed SharesController and we are now extending the autocomplete handler, plus the cosmetic/syntax fixes from above. The PR is much smaller now.

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better, thanks a lot!

Needs some careful testing especially for cases where the server response might be empty but we still add the guest entry. And cases where we don't display any result at all.

See comments, some additions are needed to cater for such cases.

js/guestshare.js Outdated
username: this.email,
email: this.email
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest running JSLint/JSHint on your JS code. It would tell you to add a semicolon here.

js/guestshare.js Outdated
});
}

response(result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it did work, that is really awesome !

Did you notice any sort order issue while testing ? From what I see the original handler sorts before calling the callback: https://github.com/owncloud/core/blob/master/core/js/sharedialogview.js#L248. So you might need to sort again here. Since the list is usually not too long it's ok to do it again.

js/guestshare.js Outdated

return oldHandler.call(obj, search, function(result) {

var searchTerm = search.term.trim();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check if result is defined, if not, call response(). See https://github.com/owncloud/core/blob/master/core/js/sharedialogview.js#L269 for an example when it can happen.

@cortho
Copy link
Contributor Author

cortho commented Sep 14, 2017

@PVince81 Thank you for your good review. It looks like we're done then.

@PVince81
Copy link
Contributor

hmmm weird

± % git checkout -b cortho-new_sharetab_behavior master
git pull https://github.com/cortho/guests.git new_sharetab_behavior

Switched to a new branch 'cortho-new_sharetab_behavior'
From https://github.com/cortho/guests
 * branch            new_sharetab_behavior -> FETCH_HEAD
fatal: refusing to merge unrelated histories

@PVince81
Copy link
Contributor

wrong repo 🤦‍♂️

@PVince81
Copy link
Contributor

@cortho thanks a lot, I'll test it a bit

@PVince81
Copy link
Contributor

  • TEST: share with email, create guest, account works

  • TEST: share with existing guest by entering email address

  • BUG: if I type in the email address of an existing user, the user appears both as "Add guest" and as existing user

@cortho to fix this, I suggest that in your autocompleteHandler, iterate over the results and check if there is any result with the same email address. If yes, then don't add "Add guests".

  • BUG: disable federated sharing (settings/Sharing, untick both under "Federated Cloud Sharing) then share with a new email address like "mail@example.com" (make sure there is no other result). The dropdown does not appear.

Not sure how to fix this. The former autocomplete handler had no results in the set and decided to not display the dropdown, so adding an entry afterwards doesn't properly re-set it.

@cortho would be good if you could fix at least the first issue above. The second one might need dirty hacks, not sure if it will work.

});
}

if (result !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move this check at the begining of the function. Because if result is undefined, the result.push above will fail hard

@PVince81
Copy link
Contributor

@cortho another trick to try: instead of adding "Add guest" result inside the overridden handler, add it to the results returned by the server before calling oldAutocompleteHandler. Might help solving the second issue and will also resolve the double sorting issue.

@PVince81
Copy link
Contributor

I need to finish this, merging for now. Almost there.

@PVince81 PVince81 merged commit 3d80a81 into owncloud:master Sep 14, 2017
@PVince81
Copy link
Contributor

the travis tests fail for some strange reason, need to investigate separately

@PVince81
Copy link
Contributor

Follow up here: #151

@cortho cortho deleted the new_sharetab_behavior branch September 15, 2017 09:31
@felixboehm
Copy link
Contributor

This PR removed vue.js, which we agreed on very clear to use as FE framework for this app.
Also the functionality is completely broken, app whitelist is not working.

@cortho

@felixboehm
Copy link
Contributor

Question here about vue.js #147 (comment)

IMHO: Even without modal, the vue.js is still needed. So do not remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove guest creation modal
3 participants