|
| 1 | +--- |
| 2 | +title: App registration |
| 3 | +description: Learn about registering your app in the App Registry |
| 4 | +--- |
| 5 | + |
| 6 | +# App registration |
| 7 | + |
| 8 | +When the application on App Builder is ready to be published, a registration to the Adobe Registry is required to add a menu in the Admin Panel. |
| 9 | + |
| 10 | +## Add or update the `install.yml` file |
| 11 | + |
| 12 | +Create an `install.yml` file in the root of your project. |
| 13 | + |
| 14 | +Make sure you target the correct `extensionPointId`: `commerce/backend-ui/1` |
| 15 | + |
| 16 | +```yaml |
| 17 | +$schema: http://json-schema.org/draft-07/schema |
| 18 | +$id: https://adobe.io/schemas/app-builder-templates/1 |
| 19 | + |
| 20 | +categories: |
| 21 | + - action |
| 22 | + - ui |
| 23 | + |
| 24 | +extensions: |
| 25 | + - extensionPointId: commerce/backend-ui/1 |
| 26 | +``` |
| 27 | +
|
| 28 | +## Create or update the `extension-manifest.json` file |
| 29 | + |
| 30 | +Create or update your project `extension-manifest.json` file so that it is similar to the following: |
| 31 | + |
| 32 | +```json |
| 33 | +{ |
| 34 | + "name": "commerce-first-app", |
| 35 | + "displayName": "Commerce First App on App Builder", |
| 36 | + "description": "Commerce First App on App Builder", |
| 37 | + "platform": "web", |
| 38 | + "id": "commerce-first-app", |
| 39 | + "version": "1.0.0" |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +## Add an `ExtensionRegistration` component |
| 44 | + |
| 45 | +Create an `ExtensionRegistration` component that registers the menu configuration in the App Registry. Use the `adobe/uix-sdk` with the `adobe-uix-guest` dependency. The [UI Extensibility](https://developer.adobe.com/uix/docs/overview/design/) Guide describes this process further. |
| 46 | + |
| 47 | +1. Add the `uix-guest` dependency in the `package.json`. |
| 48 | + |
| 49 | + ```json |
| 50 | + "@adobe/uix-guest": "^<latest-version>" |
| 51 | + ``` |
| 52 | + |
| 53 | +2. Run `npm install`. |
| 54 | + |
| 55 | + ```bash |
| 56 | + npm install |
| 57 | + ``` |
| 58 | + |
| 59 | +3. Create an `ExtensionRegistration.js` file as follows: |
| 60 | + |
| 61 | + ```javascript |
| 62 | + import { register } from '@adobe/uix-guest'; |
| 63 | +
|
| 64 | + export default function ExtensionRegistration() { |
| 65 | + init().catch(console.error); |
| 66 | + return <></>; |
| 67 | + } |
| 68 | +
|
| 69 | + const extensionId = 'commerce-first-app' |
| 70 | + |
| 71 | + const init = async () => { |
| 72 | + await register({ |
| 73 | + id: extensionId, |
| 74 | + debug: false, |
| 75 | + methods: { |
| 76 | + extension: { |
| 77 | + getId() { |
| 78 | + return 'commerce-first-app'; |
| 79 | + } |
| 80 | + }, |
| 81 | + menu: { |
| 82 | + getItems() { |
| 83 | + return [ |
| 84 | + { |
| 85 | + id: 'ext_page', |
| 86 | + title: 'First App on App Builder', |
| 87 | + action: `uixpage/index/index/uix-ext/${extensionId}`, |
| 88 | + parent: 'Magento_Backend::marketing', |
| 89 | + }, |
| 90 | + ]; |
| 91 | + }, |
| 92 | + }, |
| 93 | + page: { |
| 94 | + getTitle() { |
| 95 | + return 'Commerce First App on App Builder'; |
| 96 | + }, |
| 97 | + }, |
| 98 | + }, |
| 99 | + } |
| 100 | + ); |
| 101 | + }; |
| 102 | + ``` |
| 103 | + |
| 104 | +Upon registration, the `extension:getId`, `menu:getItems`, and `page:getTitle` methods should be defined for the app. |
| 105 | + |
| 106 | +In this example, the merchant accesses the custom menu from the **Marketing** menu in the Commerce Admin. The title displayed in the menu is defined in `getItems`, whereas the title displayed on page load is defined in `getTitle`. |
| 107 | + |
| 108 | +## Update the `App.js` routing |
| 109 | + |
| 110 | +Add the following route to your `App.js` file to define the correct routing to your app: |
| 111 | + |
| 112 | +```javascript |
| 113 | +<Route path={'index.html'} element={<ExtensionRegistration />} /> |
| 114 | +``` |
| 115 | + |
| 116 | +Make sure that your main page is correctly routed to the index. Here is an example of the first app routing in the `App.js` component: |
| 117 | + |
| 118 | +```javascript |
| 119 | +<ErrorBoundary onError={onError} FallbackComponent={fallbackComponent}> |
| 120 | + <BrowserRouter> |
| 121 | + <Provider theme={lightTheme} colorScheme={'light'}> |
| 122 | + <Routes> |
| 123 | + <Route path={'index.html'} element={<ExtensionRegistration />} /> |
| 124 | + <Route index element={<MainPage runtime={props.runtime} ims={props.ims} />} /> |
| 125 | + </Routes> |
| 126 | + </Provider> |
| 127 | + </BrowserRouter> |
| 128 | +</ErrorBoundary> |
| 129 | +``` |
| 130 | + |
| 131 | +## Update the `app.config.yaml` file |
| 132 | + |
| 133 | +Update the `app.config.yaml` [configuration file](https://developer.adobe.com/app-builder/docs/guides/configuration/) as follows: |
| 134 | + |
| 135 | +```yaml |
| 136 | +extensions: |
| 137 | + commerce/backend-ui/1: |
| 138 | + $include: ext.config.yaml |
| 139 | +``` |
| 140 | +
|
| 141 | +This file now declares extensions and redirects to an `ext.config.yaml` file. |
| 142 | + |
| 143 | +## Add or update the `ext.config.yaml` |
| 144 | + |
| 145 | +Your extension configuration file should look like this: |
| 146 | + |
| 147 | +```yaml |
| 148 | +operations: |
| 149 | + view: |
| 150 | + - type: web |
| 151 | + impl: index.html |
| 152 | +actions: actions |
| 153 | +web: web-src |
| 154 | +runtimeManifest: |
| 155 | + packages: |
| 156 | + SampleExtension: |
| 157 | + license: Apache-2.0 |
| 158 | + actions: |
| 159 | +``` |
| 160 | + |
| 161 | +Complete this file with the actions from your app. |
0 commit comments