When you load a Tecton widget, the tct-id changes. In this case you'll want to use:
IframedExtension_Main_widget.IframedExtension.Main
I have an extension that is loading an external website. When the extension loads it just automatically performs a redirect.
<script>
window.addEventListener('load', function() {
window.location = 'http://localhost:3000?tct-id=tectonRoute.IframedExtension.Main'
})
</script>
In my app (the external website that is loaded), I'm connecting to Q2 using the q2-tecton-sdk library and then calling setFetching(false).
import {connect } from 'q2-tecton-sdk';
connect().then((tecton) => {
tecton.actions.setFetching(false)
})
This works fine when I load the extension as a full page (https://stack.q2developer.com/sdk/rocketmortgage/ardent/uux.aspx#/extension/IframedExtension/Main). It shows the loading icon, loads the page and then the loading icon disappears to show the external website.
However, when I display that extension as a widget (https://stack.q2developer.com/sdk/rocketmortgage/ardent/uux.aspx?widget_location=dashboard.right&widget_name=IframedExtension.Main#/landingPage) it shows the loading icon and connects to Q2 but then the loading icon keeps on spinning forever. I've confirmed that the connection to Q2 has been made by logging a message to the server using tecton.actions.logToServer.
The other option I experimented with is to connect to Q2 from the Tecton extensions JS and call setFetching(false) before performing a redirect.
// frontend/src/index.js
import { connect } from 'q2-tecton-sdk';
async function main() {
const capabilities = await connect()
capabilities.actions.setFetching(false)
window.location.href = "http://localhost:3000?tct-id=tectonRoute.IframedExtension.Main"
}
main()
This partially worked but I noticed that it wouldn't always display the page. It seemed like the redirect was happening too quickly. I tested adding a setTimeout and that seemed to work better.
import { connect } from 'q2-tecton-sdk';
async function main() {
const capabilities = await connect()
capabilities.actions.setFetching(false)
setTimeout(() => {
window.location.href = "http://localhost:3000?tct-id=tectonRoute.IframedExtension.Main"
}, 1000)
}
main()
Again, this seems to work fine when viewing the extension as a full page. But when I would display it as a widget, it would load but it wasn't responsive. Resizing the window wouldn't affect the size of the iframe like it did when viewing the extension as a full page.
Using the setTimeout also feels a bit icky. I'm wondering if there's a more reliable way to handle this or if I'm missing something.
When you load a Tecton widget, the tct-id changes. In this case you'll want to use:
IframedExtension_Main_widget.IframedExtension.Main