Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default example for preview URLs is wrong #315

Open
deckdom opened this issue Mar 12, 2020 · 0 comments
Open

Default example for preview URLs is wrong #315

deckdom opened this issue Mar 12, 2020 · 0 comments
Labels
docs Issues regarding erroneous or missing documentation

Comments

@deckdom
Copy link
Member

deckdom commented Mar 12, 2020

When Mesh initially creates the mesh-ui2-config.js, it uses a very outdated format which does not work with the UI:

/**
 * Within the node editor in UI the feature "Preview" of a node will open a new tab to a defined frontend app.
 * Here a function can be provided returning the URL which will be called by that component.
 * 
 * @example:
 * ```javascript
 * previewUrls: [
 *    {
 *        label: 'Gentics Mesh Angular Demo',
 *        urlResolver: function (node) { return 'http://test.myapp/category/' + node.uuid + '?preview=true'; }
 *    }
 * ]
 * ```
 */
previewUrls: [
    {
        /** display name to see within preview url selection in frontend */
        label: 'Gentics Mesh Angular Demo',
        /**
         * Function to be called in frontend to get url
         * @param nodeUuid unique Mesh node
         */
        // adopt to angular demo
        urlResolver: function (node) {

            // custom route mapping
            var segmentParent;
            switch (node.schema.name) {
                case 'category':
                    segmentParent = 'category';
                    break;

                case 'vehicle':
                    segmentParent = 'product';
                    break;
            
                default:
                    throw new Error('No existing app route preview mapping configured for node of schema: ' + node.schema.name);
            }

            // return app preview URL
            return '/demo/' + segmentParent + '/' + node.uuid + '?preview=true';
        }
    }
]

However, the correct format would be like this:

previewUrls: {
    "PROJECT_NAME": [
        {
            label: "Example",
            urlResolver: function(node) {
                return "http://localhost" + node.path;
            }
        }
    ]
}
@deckdom deckdom added the docs Issues regarding erroneous or missing documentation label Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Issues regarding erroneous or missing documentation
Projects
None yet
Development

No branches or pull requests

1 participant