-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Factor out providers from accounts ui unstyled #572
Changes from all commits
865776a
1034514
83627e4
2d8402f
b11204f
326af44
c27c482
63e172e
3746d38
504e565
c50a06f
4c51764
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#login-buttons-image-facebook { | ||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAq0lEQVQ4jWP8//8/AyWAhYGBgcEmauYZBgYGYxL1nj2yLN2ECcohVTNcDwsxKlXlhRm6yzwZRAS5GRgYGBhsombC5ZhwaUIGyJrRAVEuwGYzSS7AB/C64MiydKx8ZJfgNeDN+68MDAwIL8D4RLsgIHsJis0wPjKgOAyoE4hcnGwMGkpiBBUbacvA2TfuvaKiC759/3X23NUnOPMDtgTEwMBwloGBgYGR0uwMAGOPLJS9mkQHAAAAAElFTkSuQmCC); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(function(environment) { | ||
// setup | ||
Accounts._loginButtons.loginServices.push('password'); | ||
environment.meteorServices = function() { | ||
return Accounts._loginButtons.getLoginServices(); | ||
}; | ||
|
||
Tinytest.add( | ||
'accounts-ui - getLoginServices retuns an array of service hashes', | ||
function (test) { | ||
test.equal(_.first(environment.meteorServices()), {name: "password"}); | ||
} | ||
); | ||
|
||
Tinytest.add( | ||
'accounts-ui - getLoginServices should always return password last', | ||
function (test) { | ||
Accounts._loginButtons.loginServices.push('some_other_service'); | ||
test.equal(_.last(environment.meteorServices()), {name: "password"}); | ||
} | ||
); | ||
})(Tinytest); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,18 +115,25 @@ | |
return ''; | ||
}; | ||
|
||
Accounts._loginButtons.loginServices = []; | ||
|
||
Accounts._loginButtons.getLoginServices = function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does accounts-ui still work now that we don't guarantee that password is last? As far as I can tell, you removed this comment and related functionality without replacing it with anything equivalent. Alternatively, we could refactor accounts-ui to not require password to be last in the list but just to render them completely separately. BTW, a helpful way to test changes to accounts-ui is by using the accounts-ui-viewer app in examples/unfinished/accounts-ui-viewer. |
||
var ret = []; | ||
var self = this, | ||
services = self.loginServices, // memoize services array | ||
passwordIndex = services.indexOf("password"), // memoize password idx. | ||
lastServiceAt = services.length - 1, // memoize last service idx. | ||
lastService = _.last(services); // in case we need to swap anything | ||
|
||
// make sure to put password last, since this is how it is styled | ||
// in the ui as well. | ||
_.each( | ||
['facebook', 'github', 'google', 'twitter', 'weibo', 'password'], | ||
function (service) { | ||
if (Accounts[service]) | ||
ret.push({name: service}); | ||
}); | ||
// if we had found password, swap w last service | ||
if (passwordIndex !== -1) { | ||
services[lastServiceAt] = services[passwordIndex]; | ||
services[passwordIndex] = lastService; | ||
} | ||
|
||
return ret; | ||
return _.map(services, function(service) { | ||
return {name: service}; | ||
}); | ||
}; | ||
|
||
Accounts._loginButtons.hasPasswordService = function () { | ||
|
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 code doesn't work in case the facebook package was added before accounts-ui. Don't worry about fixing this -- I'm redo'ing the login service listing to iterate over the Meteor.loginWith{ServiceName} methods instead, which I believe won't have the problem because all javascript must have been loaded before any template helpers are called.
I think the next step (outside this PR) would be to eliminate all of the boilerplate code in files like facebook_client.js. It could be pretty easy to create a function in accounts-base/accounts_client.js named, say,
Accounts.registerLoginService
that does 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.
Ah, indeed. Dependencies...
Do you have a branch where you're doing that work? I'd love to take a look and/or contribute.
Was definitely my plan - I think
Accounts.registerLoginService
would be the correct sort of abstraction that I had in mind as well for later :) Wanted to get something out there first, and then iterate.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.
Just pushed my work-in-progress onto branch avital-pr-572. I'm going to rename the accounts_github.css, etc files and then I think I'm done.