Skip to content

Commit eddb55a

Browse files
authored
Limit safe preview export warning translation (#3433)
1 parent 3317985 commit eddb55a

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

frontend/components/Editor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,7 @@ ${t("t_key_autosave_description")}`
16271627
}
16281628
notebookfile_url=${this.export_url("notebookfile")}
16291629
notebookexport_url=${this.export_url("notebookexport")}
1630+
process_waiting_for_permission=${status.process_waiting_for_permission}
16301631
open=${export_menu_open}
16311632
onClose=${() => this.setState({ export_menu_open: false })}
16321633
start_recording=${() => this.setState({ recording_waiting_to_start: true })}

frontend/components/ExportBanner.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,16 @@ export const exportNotebookDesktop = (
6262
}
6363
}
6464

65-
export const ExportBanner = ({ notebook_id, print_title, open, onClose, notebookfile_url, notebookexport_url, start_recording }) => {
65+
export const ExportBanner = ({
66+
notebook_id,
67+
print_title,
68+
open,
69+
onClose,
70+
notebookfile_url,
71+
notebookexport_url,
72+
start_recording,
73+
process_waiting_for_permission,
74+
}) => {
6675
//
6776
let print_old_title_ref = useRef("")
6877
useEventListener(
@@ -115,6 +124,9 @@ export const ExportBanner = ({ notebook_id, print_title, open, onClose, notebook
115124
const pride = true
116125
const prideMonth = new Date().getMonth() === 5
117126

127+
const warn_if_safe_preview = () =>
128+
process_waiting_for_permission ? confirm(t("t_export_safe_preview_warning")) : true
129+
118130
return html`
119131
<dialog id="export" inert=${!open} open=${open} ref=${element_ref} class=${prideMonth ? "pride" : ""}>
120132
<div id="container">
@@ -130,6 +142,10 @@ export const ExportBanner = ({ notebook_id, print_title, open, onClose, notebook
130142
class="export_card"
131143
download=""
132144
onClick=${(e) => {
145+
if (!warn_if_safe_preview()) {
146+
e.preventDefault()
147+
return
148+
}
133149
e.preventDefault()
134150
WarnForVisisblePasswords()
135151
window.dispatchEvent(new CustomEvent("open pluto html export", { detail: { download_url: notebookexport_url } }))
@@ -138,7 +154,17 @@ export const ExportBanner = ({ notebook_id, print_title, open, onClose, notebook
138154
<header role="none"><${Square} fill="#E86F51" /> ${t("t_export_card_static_html")}</header>
139155
<section>${th("t_export_card_static_html_description")}</section>
140156
</a>
141-
<a href="#" class="export_card" onClick=${() => window.print()}>
157+
<a
158+
href="#"
159+
class="export_card"
160+
onClick=${(e) => {
161+
if (!warn_if_safe_preview()) {
162+
e.preventDefault()
163+
return
164+
}
165+
window.print()
166+
}}
167+
>
142168
<header role="none"><${Square} fill="#619b3d" />${t("t_export_card_pdf")}</header>
143169
<section>${th("t_export_card_pdf_description")}</section>
144170
</a>

frontend/lang/english.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"t_safe_preview_body": "You are reading and editing this file without running Julia code.",
130130
"t_safe_preview_run_this_notebook": "When you are ready, you can {{run_this_notebook}}.",
131131
"t_safe_preview_run_this_notebook_link": "run this notebook",
132+
"t_export_safe_preview_warning": "This notebook is still in Safe Preview, and cells are not executed. You might want to run the notebook first. Are you sure you want to export it?",
132133
"t_instant_feedback_ellipsis": "Instant feedback...",
133134
"t_instant_feedback_send": "Send",
134135
"t_how_can_we_improve": "🙋 How can we make {{pluto}} better?",

0 commit comments

Comments
 (0)