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

GH-244 - Extensible source support #245

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

auniverseaway
Copy link
Member

@auniverseaway auniverseaway commented Sep 6, 2024

Description

  • Provides ability to let project spec an editUrlFormat object
  • Supports {{contentSourceUrl}} {{org}} {{site}} {{pathname}} placeholders in pattern

API

UE

{
  "project": "XWalk Block Collection",
  "editUrlLabel": "Universal Editor",
  "editUrlPattern": "{{contentSourceUrl}}{{pathname}}?cmd=open"
}

DA

{
  "project": "DA Block Collection",
  "editUrlLabel": "Document Authoring",
  "editUrlPattern": "https://da.live/edit#/{{org}}/{{site}}{{pathname}}"
}

Related Issue

Resolves: GH-244

Motivation and Context

See the GH issue.

How Has This Been Tested?

E2E for now. Once approach is agreed upon, will write tests.

Screenshots (if appropriate):

Screenshot 2024-09-06 at 1 43 20 PM

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@auniverseaway
Copy link
Member Author

I tried to strike a balance between changing very deep parts of Sidekick / Admin and simply bolting on something that cannot be maintained.

My hope is that this can work for XWalk / UE as well.

@dylandepass
Copy link
Member

dylandepass commented Sep 6, 2024

Supporting this makes sense to me, and I don’t see any immediate issues with this approach. However, @rofe might have a different perspective. It would also be good to get input from UE to confirm if this works for them as you suggested.

One suggestion: instead of sourceFormat, perhaps something like contentSourceEditFormat would be more consistent with related fields like contentSourceUrl and contentSourceType.

@auniverseaway
Copy link
Member Author

auniverseaway commented Sep 7, 2024

One suggestion: instead of sourceFormat, perhaps something like contentSourceEditFormat would be more consistent with related fields like contentSourceUrl and contentSourceType.

I changed things to get closer to your comment above.

A couple notes:

  1. The patterns exposed in sidekick/config.json are less verbose, so I did keep sourceFormat as the entry for a project to try and keep similar short conventions..
  2. Putting two top-level properties in sidekick/config.json seemed heavy, so I did make sourceFormat an object with two properties.
  3. Since contentSourceType already exists, and is markup in these scenarios, I was reluctant to change that property to what is provided by the project. I see markup being useful in the long run. There would also be casing issues like the existing onedrive > SharePoint that is in getContentSourceLabel.
  4. This PR introduces contentSourceLabel as the text that is used in the button. SP & GDrive button labels by comparison are calculated based on other details (fstab, etc.) then matched to their title cased equivalents.
  5. This PR introduces contentSourcePattern to better match the naming conventions of the codebase.
  6. While the sidekick/config.json is an object with sub-props, I do flatten them down to better fit the style of the codebase. This makes null checks a bit cleaner, too.

Let me know what y'all think. Happy to adjust further.

The final sidekick/config.json format looks like:

{
  "project": "DA Block Collection",
  "sourceFormat": {
    "label": "Document Authoring",
    "pattern": "https://da.live/edit#/{{org}}/{{repo}}{{pathname}}"
  }
}

Copy link
Contributor

@rofe rofe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general, but I'm a little concerned that this will be a one-off solution since I'm not sure any of the other BYOM sources will be able provide a pattern containing org and site...

@@ -247,6 +247,7 @@ export class SiteStore {
specialViews,
transient = false,
scriptUrl = 'https://www.hlx.live/tools/sidekick/index.js',
sourceFormat,
Copy link
Contributor

@rofe rofe Sep 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think editUrlFormat would be more descriptive.

if (!contentSourcePattern || typeof contentSourcePattern !== 'string') return null;
const url = contentSourcePattern
.replace('{{org}}', owner)
.replace('{{repo}}', repo)
Copy link
Contributor

@rofe rofe Sep 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consistently switch from owner/repo to org/site in all public facing API surfaces.

Suggested change
.replace('{{repo}}', repo)
.replace('{{site}}', repo)

@rofe
Copy link
Contributor

rofe commented Sep 7, 2024

My hope is that this can work for XWalk / UE as well.

I looked at some existing xwalk mountpoints and it looks like the pattern could be fulfilled. Letting @buuhuu confirm.

@rofe
Copy link
Contributor

rofe commented Sep 8, 2024

Wondering if the label ever need to be localized? If so, you could add an additional, optional labelI18n object, analog to the existing titleI18n allowing localization of custom button texts in the current schema.

@mhaack
Copy link
Contributor

mhaack commented Sep 9, 2024

@rofe @auniverseaway and I chatted about this on Slack, I think this will work with XWalk as well. Today we have a Sidekick overlay which just does

const { pathname } = window.location;
const editorUrl = `${contentSourceUrl}${pathname}?cmd=open`;

In the new format this would be

{
  "project": "abc",
  "sourceFormat": {
    "label": "Universal Editor",
    "pattern": "https://author-p1234-e5678.adobeaemcloud.com/bin/franklin.delivery/{{org}}/{{repo}}/main/{{pathname}}?cmd=open"
  }
}

It will require us to put the content source URL here a second time, which I think is similar to DA was well. But give this is typically one time config it might be fine. Alternative would be to have a {{contentSource}} variable as well.

@buuhuu
Copy link

buuhuu commented Sep 9, 2024

We should not duplicate the {{contentSourceUrl}} if possible, same as we should not duplicate owner, repo, branch. Either we replace all patterns or none. If we say it is fine to duplicate these parameters in the config the proposal would even work without any parameter replacement iiuc.

@auniverseaway
Copy link
Member Author

@buuhuu,
If @rofe approves and it works for you, I think tokenizing {{contentSourceUrl}} makes sense. The goal is to put this property in the respective boilerplates and you don't have to change it project to project.

For an XWalk project, I show:

contentSourceUrl

https://author-p15404-e146221-cmstg.adobeaemcloud.com/bin/franklin.delivery/mhaack/my-aem-project/main

Edit URL

https://author-p15404-e146221-cmstg.adobeaemcloud.com/bin/franklin.delivery/mhaack/my-aem-project/main/index?cmd=open

Which means that should work well for UE.

DA / WordPress / Drupal / etc have different content and edit URLs.

@buuhuu
Copy link

buuhuu commented Sep 9, 2024

The goal is to put this property in the respective boilerplates and you don't have to change it project to project

Can you elaborate on this? With hlx5 repo-less it cannot be in the boilerplate / it changes from project to project.

@rofe
Copy link
Contributor

rofe commented Sep 9, 2024

@buuhuu the reason for supporting variables is that this edit url format can stay fully generic and doesn't need to be changed from project to project.

@auniverseaway I approve :)

@auniverseaway
Copy link
Member Author

I think I accounted for all feedback and suggestions.

@rofe the only thing I didn't add was i18n for the label as it didn't seem like proper nouns would need to be localized: SharePoint, Google Drive, Universal Editor, WordPress, Document Authoring (as a brand name), etc. If you feel strongly we should add the support, let me know.

I modified the original comment with the updated spec, but here it is as well. If I can get thumbs on the final naming conventions I can work on tests and docs.

Thanks!

Sidekick spec

UE

{
  "project": "XWalk Block Collection",
  "editUrlFormat": {
    "label": "Universal Editor",
    "pattern": "{{contentSourceUrl}}{{pathname}}?cmd=open"
  }
}

DA

{
  "project": "DA Block Collection",
  "editUrlFormat": {
    "label": "Document Authoring",
    "pattern": "https://da.live/edit#/{{org}}/{{site}}{{pathname}}"
  }
}

@rofe
Copy link
Contributor

rofe commented Sep 10, 2024

@auniverseaway we'd also need to update the config schema. That makes me wonder if it wouldn't be easier to just add 2 top level properies instead of an object?

@mhaack
Copy link
Contributor

mhaack commented Sep 10, 2024

Tested it with https://main--my-aem-project--mhaack.aem.page/ for UE & Crosswalks, works nicely. cc @buuhuu

@auniverseaway
Copy link
Member Author

@rofe I saw that as I was writing tests and getting yelled at by TypeScript. I'll make them both top level.

@dylandepass
Copy link
Member

dylandepass commented Sep 11, 2024

@rofe I saw that as I was writing tests and getting yelled at by TypeScript. I'll make them both top level.

@auniverseaway You'll want to add them to ClientConfig typedef to get the type checker to stop complaining.

* Provides ability to let project spec an `editUrlFormat` object
* Supports `{{contentSourceUrl}} {{org}} {{site}} {{pathname}}` placeholders in pattern
@auniverseaway
Copy link
Member Author

@rofe @dylandepass I think I've got all suggestions covered. I didn't see the schema in the codebase, so my assumption is that it's generated from the TS def?

@rofe
Copy link
Contributor

rofe commented Sep 19, 2024

I didn't see the schema in the codebase

At the moment, the schema needs to be updated manually here:
https://github.com/adobe/helix-website/blob/main/tools/sidekick/config.schema.json

@auniverseaway
Copy link
Member Author

@rofe updated: adobe/helix-website#657

@rofe
Copy link
Contributor

rofe commented Sep 20, 2024

@auniverseaway I'll merge this into a branch to make sure all checks are passing before mergin to main.

@rofe rofe changed the base branch from main to issue-244 September 20, 2024 07:59
@rofe rofe merged commit 5292c5f into adobe:issue-244 Sep 20, 2024
2 checks passed
rofe pushed a commit that referenced this pull request Sep 20, 2024
rofe added a commit that referenced this pull request Sep 20, 2024
rofe added a commit that referenced this pull request Sep 24, 2024
rofe pushed a commit that referenced this pull request Sep 24, 2024
# [1.32.0](v1.31.4...v1.32.0) (2024-09-24)

### Bug Fixes

* dynamically load in ui.js ([a4fc57d](a4fc57d))
* remove dynamic import from background script ([58cc888](58cc888))

### Features

* extensible source support ([#245](#245)) ([#268](#268)) ([a834be2](a834be2))
* **publish:** add confirm option ([#262](#262)) ([7e8e1fc](7e8e1fc))
* support transient site token ([#272](#272)) ([2aeb56a](2aeb56a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extensible Source Support
5 participants