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

Enterprise support with db #340

Merged
merged 5 commits into from
Nov 17, 2016
Merged

Enterprise support with db #340

merged 5 commits into from
Nov 17, 2016

Conversation

cocojoe
Copy link
Member

@cocojoe cocojoe commented Nov 11, 2016

More swift in places
View spacing
Tests

EnterpriseInteractor embedded in the now multi role Database Presenter
Created InfoBar Component for SSO Message
Retired Enterprise Route, now handled in DatabaseView
Seamless keyboard behaviour between enterprise mode switch
More swift in places
View spacing


func presentEnterprise() {
if self.infoBar != nil { return }
Copy link
Member

Choose a reason for hiding this comment

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

Why is the reason we check this?

func presentEnterprise() {
if self.infoBar != nil { return }

let form = self.form as! CredentialView
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid the force unwrap, also if there is a chance this might not hold use a guard and report the error


let form = self.form as! CredentialView
let infoBar = InfoBarView()
let viewCount = self.container!.subviews.count
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid this force-unwrap too


func removeEnterprise() {
guard let infoBar = self.infoBar, spacer = self.spacer else { return }
let form = self.form as! CredentialView
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid this force-unwrap too

var initialEmail: String? { return self.authenticator.validEmail ? self.authenticator.email : nil }
var initialUsername: String? { return self.authenticator.validUsername ? self.authenticator.username : nil }


weak var databaseView:DatabaseOnlyView?
Copy link
Member

Choose a reason for hiding this comment

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

Space after :

guard let attr = attribute else { return }
do {
try self.authenticator.update(attr, value: input.text)
// Check for Entperise domain match in login view
if var enterpriseInteractor = self.enterpriseInteractor, let mode = self.databaseView?.switcher?.selected {
Copy link
Member

Choose a reason for hiding this comment

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

use let

Copy link
Member Author

Choose a reason for hiding this comment

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

it's mutating. However, this section can be refined a bit anyway so will do that.

guard let attr = attribute else { return }
do {
try self.authenticator.update(attr, value: input.text)
// Check for Entperise domain match in login view
if var enterpriseInteractor = self.enterpriseInteractor, let mode = self.databaseView?.switcher?.selected {
if enterpriseInteractor.isEnterprise(input.text) && mode == .Login {
Copy link
Member

Choose a reason for hiding this comment

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

I think there is no need for the nested if

mutating func isEnterprise(value: String?) -> Bool {
do {
try updateEmail(value)
if self.connection != nil { return true }
Copy link
Member

Choose a reason for hiding this comment

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

just return , there is no need for the if

Copy link
Member Author

Choose a reason for hiding this comment

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

A valid email does not always mean a valid connection, hence the check.

@@ -41,15 +41,22 @@ class EnterpriseDomainPresenter: Presentable, Loggable {
let authCollectionView = self.authPresenter?.newViewToEmbed(withInsets: UIEdgeInsetsMake(0, 0, 0, 0), isLogin: true)
let view = EnterpriseDomainView(email: email, authCollectionView: authCollectionView)
let form = view.form

if self.interactor.connection != nil {
view.infoBar?.hidden = false
Copy link
Member

Choose a reason for hiding this comment

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

Can't we just

view.infoBar?.hidden = self.interactor.connection != nil

Copy link
Member Author

Choose a reason for hiding this comment

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

it will make Ray sad, but yes we can :)

}

public override func intrinsicContentSize() -> CGSize {
return CGSize(width: 200, height: 35)
Copy link
Member

Choose a reason for hiding this comment

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

Set the with as non determined otherwise you'll have a hard time making it grow. The only fix is the height like we have now with 35 pts

Feedback changes
EnterpriseDomainInteractor refactored
Tests updated
@hzalaz hzalaz merged commit 6b4a2f7 into v2 Nov 17, 2016
@hzalaz hzalaz deleted the enterprise_support_with_db branch November 17, 2016 15:08
@hzalaz hzalaz modified the milestone: 2.0.0-rc.1 Nov 18, 2016
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.

2 participants