diff --git a/src/templates/_shared/stub-extension-registration.ejs b/src/templates/_shared/stub-extension-registration.ejs index 5bd0d1d..3fd3886 100644 --- a/src/templates/_shared/stub-extension-registration.ejs +++ b/src/templates/_shared/stub-extension-registration.ejs @@ -2,7 +2,12 @@ * */ +<% if ( + extensionManifest.actionBarButtons && (extensionManifest.actionBarButtons.filter(button => button.needsModal)).length || + extensionManifest.headerMenuButtons && (extensionManifest.headerMenuButtons.filter(button => button.needsModal)).length +) { %> import { generatePath } from "react-router"; +<% } %> import { Text } from "@adobe/react-spectrum"; import { register } from "@adobe/uix-guest"; import { extensionId } from "./Constants"; diff --git a/src/templates/_shared/stub-modal.ejs b/src/templates/_shared/stub-modal.ejs index 417c699..dbae91b 100644 --- a/src/templates/_shared/stub-modal.ejs +++ b/src/templates/_shared/stub-modal.ejs @@ -22,8 +22,6 @@ import { <% if (extensionArea === 'actionBar') { %> import { useParams } from "react-router-dom" <% } %> -import allActions from '../config.json' -import actionWebInvoke from '../utils' import { extensionId } from "./Constants" @@ -32,7 +30,7 @@ export default function <%- functionName %> () { const [guestConnection, setGuestConnection] = useState() <% if (extensionArea === 'actionBar') { %> const fragmentId = useParams() - + if (!fragmentId) { console.error("fragmentId parameter is missing") return @@ -55,7 +53,7 @@ export default function <%- functionName %> () { Your modal content - + diff --git a/src/templates/web/src/exc-runtime.js b/src/templates/web/src/exc-runtime.js deleted file mode 100644 index a398f6c..0000000 --- a/src/templates/web/src/exc-runtime.js +++ /dev/null @@ -1,14 +0,0 @@ -/* -* -*/ - -/** - * - * Script to load the Adobe Experience Cloud Runtime. - * - * @throws {Error} error in case of failure, most likely when the app is not running in - * the Experience Cloud Shell. - * - */ -/* eslint-disable-next-line */ -(function(e,t){if(t.location===t.parent.location)throw new Error("Module Runtime: Needs to be within an iframe!");var o=function(e){var t=new URL(e.location.href).searchParams.get("_mr");return t||!e.EXC_US_HMR?t:e.sessionStorage.getItem("unifiedShellMRScript")}(t);if(!o)throw new Error("Module Runtime: Missing script!");if("https:"!==(o=new URL(decodeURIComponent(o))).protocol)throw new Error("Module Runtime: Must be HTTPS!");if(!/^(exc-unifiedcontent\.)?experience(-qa|-stage|-cdn|-cdn-stage)?\.adobe\.(com|net)$/.test(o.hostname)&&!/localhost\.corp\.adobe\.com$/.test(o.hostname))throw new Error("Module Runtime: Invalid domain!");if(!/\.js$/.test(o.pathname))throw new Error("Module Runtime: Must be a JavaScript file!");t.EXC_US_HMR&&t.sessionStorage.setItem("unifiedShellMRScript",o.toString());var n=e.createElement("script");n.async=1,n.src=o.toString(),n.onload=n.onreadystatechange=function(){n.readyState&&!/loaded|complete/.test(n.readyState)||(n.onload=n.onreadystatechange=null,n=void 0,"EXC_MR_READY"in t&&t.EXC_MR_READY())},e.head.appendChild(n)})(document,window); diff --git a/src/templates/web/src/index.js b/src/templates/web/src/index.js index 4668f5f..035bb93 100644 --- a/src/templates/web/src/index.js +++ b/src/templates/web/src/index.js @@ -1,73 +1,16 @@ -/* +/* * */ import 'core-js/stable' -import 'regenerator-runtime/runtime' window.React = require('react') import ReactDOM from 'react-dom' -import Runtime, { init } from '@adobe/exc-app' - import App from './components/App' import './index.css' -/* Here you can bootstrap your application and configure the integration with the Adobe Experience Cloud Shell */ -try { - // attempt to load the Experience Cloud Runtime - require('./exc-runtime') - // if there are no errors, bootstrap the app in the Experience Cloud Shell - init(bootstrapInExcShell) -} catch (e) { - console.log('application not running in Adobe Experience Cloud Shell') - // fallback mode, run the application without the Experience Cloud Runtime - bootstrapRaw() -} - -function bootstrapRaw () { - /* **here you can mock the exc runtime and ims objects** */ - const mockRuntime = { on: () => {} } - const mockIms = {} - // render the actual react application and pass along the runtime object to make it available to the App - ReactDOM.render( - , +ReactDOM.render( + , document.getElementById('root') - ) -} - -function bootstrapInExcShell () { - // get the Experience Cloud Runtime object - const runtime = Runtime() - - // use this to set a favicon - // runtime.favicon = 'url-to-favicon' - - // use this to respond to clicks on the app-bar title - // runtime.heroClick = () => window.alert('Did I ever tell you you\'re my hero?') - - // ready event brings in authentication/user info - runtime.on('ready', ({ imsOrg, imsToken, imsProfile, locale }) => { - // tell the exc-runtime object we are done - runtime.done() - console.log('Ready! received imsProfile:', imsProfile) - const ims = { - profile: imsProfile, - org: imsOrg, - token: imsToken - } - // render the actual react application and pass along the runtime and ims objects to make it available to the App - ReactDOM.render( - , - document.getElementById('root') - ) - }) - - // set solution info, shortTitle is used when window is too small to display full title - runtime.solution = { - icon: 'AdobeExperienceCloud', - title: '<%- extensionManifest.name %>', - shortTitle: 'JGR' - } - runtime.title = '<%- extensionManifest.name %>' -} +) diff --git a/test/generator-add-web-assets-cf-admin.test.js b/test/generator-add-web-assets-cf-admin.test.js index c905980..8f22d37 100644 --- a/test/generator-add-web-assets-cf-admin.test.js +++ b/test/generator-add-web-assets-cf-admin.test.js @@ -52,10 +52,8 @@ function assertEnvContent (prevContent) { function assertFiles (extensionManifest) { // Asert generated web assets files assert.file(`${webSrcFolder}/index.html`) - assert.file(`${webSrcFolder}/src/exc-runtime.js`) assert.file(`${webSrcFolder}/src/index.css`) assert.file(`${webSrcFolder}/src/index.js`) - assert.file(`${webSrcFolder}/src/utils.js`) assert.file(`${webSrcFolder}/src/components/Constants.js`) assert.file(`${webSrcFolder}/src/components/App.js`) assert.file(`${webSrcFolder}/src/components/ExtensionRegistration.js`) @@ -83,7 +81,7 @@ function assertFiles (extensionManifest) { `${webSrcFolder}/src/components/Constants.js`, `extensionId: '${extensionManifest.id}'` ) - + assert.fileContent( `${webSrcFolder}/index.html`, '