Skip to content

Commit 50e6d51

Browse files
authored
Improve clarity on suggested URL for user when deploying a draft (#682)
1 parent 1dd0e7a commit 50e6d51

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

rsconnect/api.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ def deploy(
573573
# http://ADDRESS/preview/APP_GUID/BUNDLE_ID
574574
# Using replace makes this a bit more robust to changes in the URL structure
575575
# like connect being served on a subpath.
576-
preview_url = app["url"].replace("/content/", "/preview/") + f"/{app_bundle['id']}"
576+
preview_url = app["url"].replace("/content/", "/preview/").rstrip("/") + f"/{app_bundle['id']}"
577577

578578
return {
579579
"task_id": task["task_id"],
@@ -1131,14 +1131,16 @@ def emit_task_log(
11311131
raise_on_error,
11321132
)
11331133
log_lines = self.remote_server.handle_bad_response(log_lines)
1134-
app_config = self.client.app_config(self.deployed_info["app_id"])
1135-
app_config = self.remote_server.handle_bad_response(app_config)
1136-
app_dashboard_url = app_config.get("config_url")
1134+
11371135
log_callback.info("Deployment completed successfully.")
1138-
log_callback.info("\t Dashboard content URL: %s", app_dashboard_url)
1139-
log_callback.info(
1140-
"\t Direct content URL: %s", self.deployed_info["preview_url"] or self.deployed_info["app_url"]
1141-
)
1136+
if self.deployed_info.get("preview_url"):
1137+
log_callback.info("\t Preview content URL: %s", self.deployed_info["preview_url"])
1138+
else:
1139+
app_config = self.client.app_config(self.deployed_info["app_id"])
1140+
app_config = self.remote_server.handle_bad_response(app_config)
1141+
app_dashboard_url = app_config.get("config_url")
1142+
log_callback.info("\t Dashboard content URL: %s", app_dashboard_url)
1143+
log_callback.info("\t Direct content URL: %s", self.deployed_info["app_url"])
11421144

11431145
return self
11441146

tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def post_application_deploy_callback(request, uri, response_headers):
252252
assert "Direct content URL: http://fake_server/content/1234-5678-9012-3456" in caplog.text
253253
else:
254254
assert (
255-
"Direct content URL: http://fake_server/preview/1234-5678-9012-3456/FAKE_BUNDLE_ID" in caplog.text
255+
"Preview content URL: http://fake_server/preview/1234-5678-9012-3456/FAKE_BUNDLE_ID" in caplog.text
256256
)
257257
finally:
258258
if original_api_key_value:

0 commit comments

Comments
 (0)