1 /*
2  * PublishDocServicePage.java
3  *
4  * Copyright (C) 2021 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant
7  * to the terms of a commercial license agreement with RStudio, then
8  * this program is licensed to you under the terms of version 3 of the
9  * GNU Affero General Public License. This program is distributed WITHOUT
10  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13  *
14  */package org.rstudio.studio.client.rsconnect.ui;
15 
16 import java.util.ArrayList;
17 
18 import org.rstudio.core.client.resources.ImageResource2x;
19 import org.rstudio.core.client.widget.WizardNavigationPage;
20 import org.rstudio.core.client.widget.WizardPage;
21 import org.rstudio.studio.client.rsconnect.model.RSConnectPublishInput;
22 import org.rstudio.studio.client.rsconnect.model.RSConnectPublishResult;
23 
24 import com.google.gwt.resources.client.ImageResource;
25 
26 public class PublishDocServicePage
27    extends WizardNavigationPage<RSConnectPublishInput, RSConnectPublishResult>
28 {
PublishDocServicePage(String title, String subTitle, ImageResource icon, RSConnectPublishInput input)29    public PublishDocServicePage(String title, String subTitle,
30                                 ImageResource icon,
31                                 RSConnectPublishInput input)
32    {
33       super(title, subTitle, "Publish To", icon, null, createPages(input));
34    }
35 
36    private static ArrayList<WizardPage<RSConnectPublishInput,
37                                        RSConnectPublishResult>>
createPages(RSConnectPublishInput input)38            createPages(RSConnectPublishInput input)
39    {
40       ArrayList<WizardPage<RSConnectPublishInput,
41                            RSConnectPublishResult>> pages = new ArrayList<>();
42       String rscTitle = RSConnectAccountWizard.SERVICE_NAME;
43       String rscDesc = RSConnectAccountWizard.SERVICE_DESCRIPTION;
44 
45       WizardPage<RSConnectPublishInput, RSConnectPublishResult> connectPage;
46       if (input.isMultiRmd() && !input.isWebsiteRmd())
47       {
48          connectPage = new PublishMultiplePage(rscTitle, rscDesc,
49                new ImageResource2x(RSConnectResources.INSTANCE.localAccountIcon2x()), input);
50       }
51       else
52       {
53          if (input.isStaticDocInput())
54          {
55             // static input implies static output
56             connectPage = new PublishFilesPage(rscTitle, rscDesc,
57                   new ImageResource2x(RSConnectResources.INSTANCE.localAccountIcon2x()), input,
58                   false, true);
59          }
60          else
61          {
62             connectPage = new PublishReportSourcePage(rscTitle, rscDesc,
63                   new ImageResource2x(RSConnectResources.INSTANCE.localAccountIcon2x()), input,
64                   false);
65          }
66       }
67       WizardPage<RSConnectPublishInput, RSConnectPublishResult> rpubsPage  =
68             new PublishRPubsPage("RPubs", "RPubs is a free service from " +
69          "RStudio for sharing documents on the web.");
70 
71       // make Rpubs the top selection for now since RStudioConnect is in beta
72       pages.add(rpubsPage);
73       pages.add(connectPage);
74 
75       return pages;
76    }
77 }
78