package com.atlassian.stash.internal.web.soy.functions.nav;

import com.atlassian.bitbucket.nav.NavBuilder;

import static com.atlassian.stash.internal.web.soy.functions.SoyArgumentUtils.argCountFromTo;

public class LoginNavFunction extends BaseNavFunction {

    public LoginNavFunction(NavBuilder navBuilder) {
        super(navBuilder, "nav_login", argCountFromTo(0, 2));
    }

    /**
     * @param args pass in Boolean.TRUE value as the first argument, if current url should be appended as the "next" param
     * @return a {@link NavBuilder.Builder} to construct the URL of the login page
     */

    @Override
    protected NavBuilder.Builder initBuilder(Object... args) {
        NavBuilder.Login login = navBuilder.login();
        if (args.length > 0 && Boolean.TRUE.equals(args[0])) {
            return login.next();
        }
        return login;
    }

}
