Hi,
I was able to create an administrate page with the Custom UI. Amazing work by the Forge Team, I was able to create an app that store data from an interface in few hours.
However, I’ve some trouble when i want to add another module in the same app.
I’m not very keen in node.js environment (Forge is my first experience in this framework) so I don’t know what I’m doing wrong.
I tried to follow the suggested GitHub - facebook/create-react-app: Set up a modern web app by running one command. in the documentation, but I’m not able to run the new app after Its installation. In addiction to this, the skeleton of the new custom app has different structure then the one created by forge.
Could you suggest a simple way to add a new module in the same app for CustomUI projects?
As of today (02/04/2021), with the newest version of @forge/bridge, we can easily archive this.
Short description: Just define the same resource for your modules. And render the content of React app based on where the app is running.
Here is my manifest.yml which shared just one resource and resolver for multi modules:
import React, { useEffect, useState } from 'react';
import { view } from '@forge/bridge';
function App() {
const [context, setContext] = useState({});
const [isDetectingContext, setDetectingContext] = useState(true);
useEffect(() => {
setDetectingContext(true);
// Use the "view" from Forge Bridge to get the context
// where this React app is running
view.getContext()
.then(setContext)
.finally(() => setDetectingContext(false));
}, []);
if (isDetectingContext) {
return <div>Detecting context...</div>;
}
// Detect the module which calling this React app,
// and render the content for that
switch (context.moduleKey) {
case 'admin-page':
// Render and "AdminPage" if we are in module "admin-page"
return <AdminPage />;
case 'issue-panel':
// Render and "IssuePanel" if we are in module "issue-panel"
return <IssuePanel />;
default:
return <div>Cannot Detect Context</div>;
}
}
export default App;
The code and comments tell everything. I hope it help.
Thank you for your solution. It’s been almost 1 year since you wrote the answer. Is there any better option available now ??
I am looking for an easier way to add multiple modules in to the same forge app. If you had worked with server SDK, there is a command ‘atlas-create-jira-plugin-module’ to create new modules within same app. Do we have something similar in Forge ??
Hi @MajoFrancis, for your first question, I did not find any better solution since I answered that.
And the second question, as far as I know, we have no support to create modules like atlas-create-jira-plugin-module available in Forge. Sadly, we need to manually type (or copy-paste) the module into the manifest.yml.