There is a migration path from Confluence Data Center app with macros to Forge apps in Cloud. Macros will be migrated and usable in cloud. Editable macros will be automatically converted from the P2 Data Center storage format to the Forge storage format the first time that a user edits the macro on Cloud.
The rendering and updating capabilities introduced in this feature are only compatible with the modern Confluence Editor. Migrated P2 macros cannot be rendered or updated in the Confluence Legacy Editor.
Ensure your app is using at least version 1.8.0 of the atlassian-app-cloud-migration-listener.
You will need to implement the ConfluenceAppCloudMigrationListenerV1 interface on the same class that implements DiscoverableForgeListener.
There should be only one class implementing these interfaces for each Forge App ID that you support migrating.
The method to be implemented is:
| Method | Description |
|---|---|
getServerToForgeMacroMapping | A mapping between your Data Center macro name and your Forge macro key. |
1 2@Override public Map<String, String> getServerToForgeMacroMapping() { Map<String, String> macroMappings = new HashMap<>(); macroMappings.put("my-dc-app-macro-name", "my-forge-app-macro-key"); return macroMappings; }
If you enable this feature by implementing the above interface in your Data Center app, the App Migration Platform will migrate your Confluence Macro with necessary metadata for the Confluence Editor to understand that your Forge app is responsible for rendering the migrated macro.
Declare the Forge macro module in your Forge app's manifest.
Make sure the Forge macro key matches your Data Center macro name as returned by getServerToForgeMacroMapping.
1 2modules: macro: - key: my-forge-app-macro-name # Forge macro key - must match the value in your DC app's getServerToForgeMacroMapping map. resource: main # ...
After migration, your Data Center macros are stored in Confluence in an intermediate storage format. Note that the intermediate format uses an extensionType of com.atlassian.confluence.macro.core:
1 2{ "type": "extension", "attrs": { "extensionType": "com.atlassian.confluence.macro.core", "extensionKey": "my-forge-app-macro-name", "parameters": { "macroParams": { "myDCField": { "value": "some text" } } } } }
When a user views a page with a migrated Data Center macro, Confluence looks for the corresponding macro with a matching key in your Forge app, and renders it. Even though the macro hasn't been fully migrated to the Forge format yet, the existing Data Center config parameters are provided to your Forge macro.
Only when a user edits the configuration of the macro and publishes the page does the storage format get migrated to the Forge format.
Note that the Forge format uses an extensionType of com.atlassian.ecosystem, and the extensionKey is now prefixed with your app ID (aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
in the example below):
1 2{ "type": "extension", "attrs": { "extensionType": "com.atlassian.ecosystem", "extensionKey": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/static/my-forge-app-macro-name", "parameters": { "guestParams": { "myForgeField": "some text" }, "macroParams": { "myDCField": { "value": "some text" } } } } }
Note that the type of the macro (extension for default block layout, bodiedExtension for bodied, inlineExtension for inline), is preserved during migration,
even if the Forge macro declares a different type in the layout parameter.
You can revert the macro to the intermediate format by restoring an older version of the Confluence page from the page history view. This can be useful during development and testing of Data Center macro data migration, covered in the next section.
The method to access data from your migrated Data Center macros is the same as accessing configuration data for a Forge app.
The first time a user edits a migrated Data Center macro using Forge, all existing Data Center parameters are available through the provided config object.
Then, when the user saves the macro, only the parameters explicitly declared by your Forge app are stored. Only these parameters are available in the config object on subsequent macro edits. Any other Data Center parameters will no longer be available to the Forge app. You can think of this as a one-time migration of Data Center parameters to Forge parameters.
If your Forge macro does not save some of the Data Center parameters on a user's first macro edit, they will no longer be accessible through the config object on subsequent edits.
You can revert the page to a previous version during development to access the Data Center parameters again.
You can choose to use the same parameter keys in your Forge app as in your Data Center app, or you can rename them. Renaming is recommended if you have to transform the values to be compatible with your Forge app.
For example, if you had a parameter from your Data Center app called myDCField, and you create a Textfield component with name="myDCField", the value will be automatically populated:
1 2import React from "react"; import { view } from "@forge/bridge"; import ForgeReconciler, { Textfield } from "@forge/react"; const Config = () => { const [context, setContext] = useState(undefined); useEffect(() => { view.getContext().then(setContext); }, []); const config = context?.extension.config; return ( <> {/* Keep an existing Data Center field as is. * This will automatically be populated with the parameter from your migrated Data Center macro, if it exists */} <Textfield name="myDCField" label="My DC Field" /> {/* Add a new Forge field, with a transformed value from the Data Center macro, if it exists */} <Textfield name="myForgeField" label="My Forge Field" defaultValue={config?.myOldDCField?.replace("old", "new")} /> </> ); }; ForgeReconciler.addConfig(<Config />);
Migrated Data Center macro parameters maintain their existing format when passed to a Forge macro module, and do not undergo any automatic conversion.
Here are some notable differences to be aware of:
VALUE1,VALUE2.
,) this is not automatically escaped, so special handling is needed.spacekey parameter type,
the Forge app receives the string "currentSpace()", instead of the literal space key.The below table shows how various Data Center macro parameter types are passed to Forge macro modules. Note that values are always passed as strings, regardless of the original type.
| Data Center parameter type | Examples |
|---|---|
attachment |
|
boolean |
|
confluence-content |
|
enum |
|
int |
|
spacekey |
|
url |
|
username |
|
string |
|
The below table lists some special cases, and how they can be accessed from Forge macro modules:
| Data Center macro parameter | Example | Forge equivalent |
|---|---|---|
| Matched Autoconvert URL | "https://www.example.com/converted" | extension.config[urlParameter] |
plain-text macro body | "Plain text body\n\nThis is a new line" | extension.config.__bodyContent |
rich-text macro body | "<h1>Rich Text Body</h1>" | extension.macro.body |
Many context parameters available to Data Center macros are still accessible via Forge product context.
The following table lists the mappings between these parameters:
| Data Center macro context parameter | Forge product context | Description |
|---|---|---|
macro.id | extension.connectMetadata.macroId | The unique ID of the macro instance. |
macro.body | Not supported | The macro body, truncated to 128 characters |
macro.truncated | Not supported | True if the macro body was truncated, false if not |
page.id | extension.content.id | The ID of the content this component appears in |
page.title | Not supported. Page information can be fetched using the Confluence API using the content ID. | The page title |
page.type | The page type | |
page.version | The page version | |
space.id | extension.space.id | The space ID |
space.key | extension.space.key | The space key |
output.type | extension.isEditing | Whether the page is in view or edit mode (formerly display or preview) |
macroId is not available for newly created Forge macros. You can use the more generic localId instead.adfExport function, that static content will be shown.plain-text bodies from migrated Data Center macros is supported through the __bodyContent key in the config object.layout parameter.adfExport function.defaultValue properties of your Forge fields to match the default values in your Data Center app.Rate this page: