-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
js/sharedialogview.js
Outdated
this.model = model; | ||
this.email = email; | ||
|
||
let self = this; |
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.
does let
work with IE11 without transpiler ?
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.
and other browsers like latest Safari, etc... I'd prefer to be safe and use var
instead
js/sharedialogview.js
Outdated
}).fail(function (xhr) { | ||
let response = JSON.parse(xhr.responseText); | ||
let error = response.errorMessages; | ||
OCdialogs.alert( |
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.
optional: OC.dialogs.alert (OC.dialogs is an alias of the internal OCdialogs)
js/sharedialogview.js
Outdated
data: attributes, | ||
dataType: 'json' | ||
}).done(function () { | ||
if (self.model) |
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.
please add brackets even for a single line
js/sharedialogview.js
Outdated
OC.Plugins.register('OC.Share.ShareDialogView', { | ||
attach: function (obj) { | ||
|
||
// Override ShareDigalogView |
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.
Digalog
js/sharedialogview.js
Outdated
function (result) { | ||
$loading.addClass('hidden'); | ||
$loading.removeClass('inlineblock'); | ||
if (result.ocs.meta.statuscode == 100) { |
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.
optional: use "api/v2" for slightly more status code sanity and receive 200 here instead of 100
js/sharedialogview.js
Outdated
* | ||
*/ | ||
|
||
var Guests = { |
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.
class is called Guests
but the file is called sharedialogview.js
?
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 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 ?
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. |
js/sharedialogview.js
Outdated
|
||
// Override ShareDigalogView | ||
|
||
obj.autocompleteHandler = function (search, response) { |
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.
ok now I realize that this is the old existing code that you just moved here... argh... I wish I saw this earlier
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.
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();
});
}
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.
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...
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.
Raised here #150
js/sharedialogview.js
Outdated
|
||
// Add potential guests to the suggestions | ||
if (searchTerm.search("@") !== -1) { | ||
groupName = groupName = "(gast)"; |
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.
(gast)
would need to be translated: t('guests', '(guest)')
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.
and syntax problem, there are two equals. Change this row to:
groupName += ' ' + t('guests', '(guest)');
Sorry if my comments might sounds confusing. I commented as soon as I saw the code. From what I understand:
I'd like to find a way that removes the need to override/extend the ShareesController. |
Ideal would to be to have the distinction possible in core, we have been discussing this here: owncloud/core#28979 |
@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 |
@PVince81 ok. I'll look over this and give feedback/changes ASAP |
@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. |
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.
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 | ||
} | ||
} |
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 suggest running JSLint/JSHint on your JS code. It would tell you to add a semicolon here.
js/guestshare.js
Outdated
}); | ||
} | ||
|
||
response(result); |
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.
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(); |
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.
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.
@PVince81 Thank you for your good review. It looks like we're done then. |
hmmm weird
|
wrong repo 🤦♂️ |
@cortho thanks a lot, I'll test it a bit |
@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".
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) { |
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.
please move this check at the begining of the function. Because if result
is undefined, the result.push
above will fail hard
@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. |
I need to finish this, merging for now. Almost there. |
the travis tests fail for some strange reason, need to investigate separately |
Follow up here: #151 |
This PR removed vue.js, which we agreed on very clear to use as FE framework for this app. |
Question here about vue.js #147 (comment) IMHO: Even without modal, the vue.js is still needed. So do not remove it. |
Related issues:
#147,
#115I have been testing locally at the frontend and with the integration tests.
What is done in this PR:
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)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 useEdit: current status