Search in sources :

Example 1 with RSConnectLintResults

use of org.rstudio.studio.client.rsconnect.model.RSConnectLintResults in project rstudio by rstudio.

the class RSConnect method onRSConnectDeployInitiated.

@Override
public void onRSConnectDeployInitiated(final RSConnectDeployInitiatedEvent event) {
    // shortcut: when deploying static content we don't need to do any linting
    if (event.getSettings().getAsStatic()) {
        doDeployment(event);
        return;
    }
    // get lint results for the file or directory being deployed, as 
    // appropriate
    server_.getLintResults(event.getSource().getDeployKey(), new ServerRequestCallback<RSConnectLintResults>() {

        @Override
        public void onResponseReceived(RSConnectLintResults results) {
            if (results.getErrorMessage().length() > 0) {
                display_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Lint Failed", "The content you tried to publish could not be checked " + "for errors. Do you want to proceed? \n\n" + results.getErrorMessage(), false, new ProgressOperation() {

                    @Override
                    public void execute(ProgressIndicator indicator) {
                        // "Publish Anyway"
                        doDeployment(event);
                        indicator.onCompleted();
                    }
                }, new ProgressOperation() {

                    @Override
                    public void execute(ProgressIndicator indicator) {
                        // "Cancel"
                        indicator.onCompleted();
                    }
                }, "Publish Anyway", "Cancel", false);
            } else if (results.hasLint()) {
                display_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Publish Content Issues Found", "Some issues were found in your content, which may " + "prevent it from working correctly after publishing. " + "Do you want to review these issues or publish anyway? ", false, new ProgressOperation() {

                    @Override
                    public void execute(ProgressIndicator indicator) {
                        // "Review Issues" -- we automatically show the
                        // markers so they're already behind the dialog.
                        indicator.onCompleted();
                    }
                }, new ProgressOperation() {

                    @Override
                    public void execute(ProgressIndicator indicator) {
                        // "Publish Anyway"
                        doDeployment(event);
                        indicator.onCompleted();
                    }
                }, "Review Issues", "Publish Anyway", true);
            } else {
                // no lint and no errors -- good to go for deployment
                doDeployment(event);
            }
        }

        @Override
        public void onError(ServerError error) {
            // we failed to lint, which is not encouraging, but we don't want to
            // fail the whole deployment lest a balky linter prevent people from
            // getting their work published, so forge on ahead.
            doDeployment(event);
        }
    });
}
Also used : ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) RSConnectLintResults(org.rstudio.studio.client.rsconnect.model.RSConnectLintResults)

Aggregations

ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)1 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)1 RSConnectLintResults (org.rstudio.studio.client.rsconnect.model.RSConnectLintResults)1 ServerError (org.rstudio.studio.client.server.ServerError)1