Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow NR Dashboard to be loaded in iFrames #4900

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions forge/lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
'disableTours',
'httpAdminRoot',
'dashboardUI',
'dashboardIFrame',
'codeEditor',
'theme',
'page_title',
Expand Down Expand Up @@ -36,6 +37,7 @@ module.exports = {
disableTours: false,
httpAdminRoot: '',
dashboardUI: '/ui',
dashboardIFrame: false,
codeEditor: 'monaco',
theme: 'forge-light',
page_title: 'FlowFuse',
Expand Down Expand Up @@ -65,6 +67,7 @@ module.exports = {
disableTours: true,
httpAdminRoot: true,
dashboardUI: true,
dashboardIFrame: true,
codeEditor: true,
theme: true,
page_title: false,
Expand Down
30 changes: 30 additions & 0 deletions frontend/src/pages/admin/Template/sections/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@
</div>
<LockSetting class="flex justify-end flex-col" tooltip="This setting is fixed and cannot be changed." />
</div>
<div v-if="dashboardIFrameAvailable">
<div class="flex flex-col sm:flex-row">
<div class="w-full max-w-md sm:mr-8">
<FormRow v-model="editable.settings.dashboardIFrame" :error="editable.errors.dashboardIFrame" :disabled="!editTemplate && !editable.policy.dashboardIFrame" type="checkbox">
Allow Dashboard to be embedded in an iFrame
<template #description>
Sets the <span>Content-Security-Policy: frame-ancestor '*'</span> HTTP Header for the Dashboard
</template>
<template #append><ChangeIndicator :value="editable.changed.settings.dashboardIFrame" /></template>
</FormRow>
</div>
<LockSetting v-model="editable.policy.dashboardIFrame" class="flex justify-end flex-col" :editTemplate="editTemplate" :changed="editable.changed.policy.dashboardIFrame" />
</div>
</div>
<div v-else class="flex flex-col sm:flex-row">
<div class="space-y-4 w-full max-w-md sm:mr-8">
<p>Upgrade your stack to be able to enable</p>
<p>embedding Dashboards in iFrames</p>
<ff-button size="small" to="general">Upgrade</ff-button>
</div>
</div>
<div class="flex flex-col sm:flex-row">
<div class="w-full max-w-md sm:mr-8">
<FormRow v-model="editable.settings.codeEditor" :disabled="!editTemplate && !editable.policy.codeEditor" type="select" :options="[{label:'monaco', value:'monaco'},{label:'ace', value:'ace'}]">
Expand Down Expand Up @@ -248,6 +269,15 @@ export default {
},
debugLimitDisabled () {
return !this.editTemplate && !this.editable.policy.debugMaxLength
},
dashboardIFrameAvailable () {
const launcherVersion = this.instance?.meta?.versions?.launcher
if (!launcherVersion) {
// We won't have this for a suspended project - so err on the side
// of permissive
return true
}
return SemVer.satisfies(SemVer.coerce(launcherVersion), '>=2.12.0')
}
}
}
Expand Down
Loading