
<%
  /*
<!--

  Copyright (C) 2012 eXo Platform SAS.
 
  This is free software; you can redistribute it and/or modify it
  under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation; either version 2.1 of
  the License, or (at your option) any later version.
 
  This software is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.
 
  You should have received a copy of the GNU Lesser General Public
  License along with this software; if not, write to the Free
  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  02110-1301 USA, or see the FSF site: http://www.fsf.org.

-->
*/
import org.exoplatform.clouddrive.CloudDriveService
import org.exoplatform.clouddrive.CloudProvider
import org.exoplatform.clouddrive.ecms.CloudDriveContext
import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer
import org.exoplatform.services.wcm.utils.WCMCoreUtils
import org.exoplatform.web.application.JavascriptManager

def driveService = WCMCoreUtils.getService(CloudDriveService.class)
if (!driveService) {
  throw new IllegalArgumentException('CloudDriveService not registred in the container.');
}

def uiExplorer = uicomponent.getAncestorOfType(UIJCRExplorer.class)
def nodePath = uiExplorer.getCurrentNode().getPath()
def workspace = uiExplorer.getCurrentNode().getSession().getWorkspace().getName()

def rcontext = _ctx.getRequestContext()

def formId = rcontext.windowId + "#" + uiform.id

CloudDriveContext.init(rcontext, workspace, nodePath)

def connectYour = _ctx.appRes("UIPopupWindow.title.ConnectYour")
//def connectLink = uiform.event("Connect");
%>
<div class="UIForm $uicomponent.id" form-id="$formId">
	<%
	  uiform.begin()
	%>
	<div class="HorizontalLayout">
		<div id="CloudDriveConnectDialog" class="FormContainer">
			<div id="CloudDriveConnectDialogMessage" style="display: none;"></div>
			<%
			  for(provider in driveService.providers) {
			%>
			<div class="UIAction">
				<div class="tab-content">
					<ul>
						<li>
							<a class="actionIcon">
								<i style="vertical-align:middle;" class="uiIconEcmsConnectDialog-${provider.id}" provider-id="${provider.id}"></i>
								<span style="vertical-align:middle;">${connectYour} ${provider.name}</span>
							</a>
						</li>
					</ul>
				</div>
			</div>
			<%
			  }
			%>
		</div>
	</div>
	<div class="uiAction uiActionBorder">
    <% 
      String cancelLabel = _ctx.appRes(uiform.getName() + ".action.Cancel");
      String cancelLink = uiform.event("Cancel");
    %>
      <button type="button" onclick="$cancelLink" class="btn">$cancelLabel</button>
  </div>
	<%
	  uiform.end()
	%>
</div>