-
Notifications
You must be signed in to change notification settings - Fork 12
feat(hub-common): new sites are fully upgraded to the new catalog, old sites can opt into the upgrade #2013
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
Open
sonofflynn89
wants to merge
10
commits into
master
Choose a base branch
from
f/13504-allow-site-migration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e9a0a8f
feat(hub-common): ungate hub:site:workspace:catalog:upgrade permissio…
sonofflynn89 a25fc3b
feat(hub-common): delete the v1 catalog for upgraded sites
sonofflynn89 88e53a6
test(hub-common): add tests
sonofflynn89 aa34138
fix(hub-common): remove unnecessary versionless migration that delete…
sonofflynn89 b64ff67
Merge branch 'master' into f/13504-allow-site-migration
sonofflynn89 6d47adc
Merge branch 'master' into f/13504-allow-site-migration
sonofflynn89 4670785
Merge branch 'master' into f/13504-allow-site-migration
sonofflynn89 96ce59b
test: convert jasmine to vitest
sonofflynn89 abb432b
feat: add changeset
sonofflynn89 ea601c2
fix: fix bug in HubSites' createSite() function where new sites weren…
sonofflynn89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@esri/hub-common": minor | ||
| --- | ||
|
|
||
| Sites can now be fully upgraded to use the new catalog. New sites created via workspaces will automatically be fully upgraded and won't have any default collections. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,10 +24,7 @@ import { IHubRequestOptions, IModel } from "../hub-types"; | |
| import { removeDomainsBySiteId } from "./domains/remove-domains-by-site-id"; | ||
| import { IHubSearchResult } from "../search/types/IHubSearchResult"; | ||
| import { reflectCollectionsToSearchCategories } from "./_internal/reflectCollectionsToSearchCategories"; | ||
| import { | ||
| catalogToLegacy, | ||
| convertCatalogToLegacyFormat, | ||
| } from "./_internal/convertCatalogToLegacyFormat"; | ||
| import { convertCatalogToLegacyFormat } from "./_internal/convertCatalogToLegacyFormat"; | ||
| import { convertFeaturesToLegacyCapabilities } from "./_internal/capabilities/convertFeaturesToLegacyCapabilities"; | ||
| import { computeLinks } from "./_internal/computeLinks"; | ||
| import { handleSubdomainChange } from "./_internal/subdomains"; | ||
|
|
@@ -40,6 +37,7 @@ import { setProp } from "../objects/set-prop"; | |
| import { mapBy } from "../utils/map-by"; | ||
| import { handleDomainChanges } from "./_internal/handleDomainChanges"; | ||
| import { AccessLevel } from "../core/types/types"; | ||
| import { upgradeSiteSchema } from "./upgrade-site-schema"; | ||
| export const HUB_SITE_ITEM_TYPE = "Hub Site Application"; | ||
| export const ENTERPRISE_SITE_ITEM_TYPE = "Site Application"; | ||
|
|
||
|
|
@@ -127,9 +125,7 @@ const DEFAULT_SITE_MODEL: IModel = { | |
| url: "", | ||
| } as IItem, | ||
| data: { | ||
| catalog: { | ||
| groups: [], | ||
| }, | ||
| catalogV2: { schemaVersion: 0 }, | ||
| feeds: {}, | ||
| values: { | ||
| title: "", | ||
|
|
@@ -282,15 +278,21 @@ export async function createSite( | |
| ); | ||
| let model = mapper.entityToStore(site, cloneObject(DEFAULT_SITE_MODEL)); | ||
|
|
||
| // At this point `data.catalog` may have become a full IHubCatalog object due to an in-memory | ||
| // migration. However, we can't persist an IHubCatalog in `data.catalog` without breaking | ||
| // the application, since most of the app relies on the old catalog structure. As such, | ||
| // we convert any changes made to the catalog scope into the old format and merge the changes | ||
| // with the existing structure on the most current model. | ||
| // TODO: Remove once the application is plumbed to work off an IHubCatalog | ||
| if (getProp(model, "data.catalog.scopes")) { | ||
| model.data.catalog = catalogToLegacy(model.data.catalog); | ||
| } | ||
| // There's no guarantee that the combination DEFAULT_SITE_MODEL + partialSite | ||
| // will result in a model with the latest schemaVersion. To prevent issues with | ||
| // post-processing the catalogV2, we run the upgrade here just in case. | ||
| model = upgradeSiteSchema(model); | ||
|
|
||
| // TODO: Remove once all sites are fully on catalogV2 | ||
| // Remove the v1 catalog that might be populated during migrations | ||
| delete model.data.catalog; | ||
| // Remove default collections and set the v2 catalog | ||
| const catalogV2 = cloneObject(site.catalog); | ||
| catalogV2.collections = []; | ||
sonofflynn89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| model.data.catalogV2 = catalogV2; | ||
| // TODO: Remove once all sites are fully on catalogV2. We have to use this flag | ||
| // to get around some oddities with creating/deploying site templates | ||
| model.data.useCatalogV2 = true; | ||
|
|
||
| // create the backing item | ||
| model = await createModel( | ||
|
|
@@ -314,7 +316,7 @@ export async function createSite( | |
| ); | ||
|
|
||
| // convert the model into a IHubSite and return | ||
| return mapper.storeToEntity(updatedModel, {}) as IHubSite; | ||
| return convertModelToSite(updatedModel, requestOptions); | ||
sonofflynn89 marked this conversation as resolved.
Show resolved
Hide resolved
sonofflynn89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -377,20 +379,31 @@ export async function updateSite( | |
| await handleDomainChanges(modelToUpdate, currentModel, requestOptions); | ||
| } | ||
|
|
||
| // Persist the new catalog to new property until the app is fully migrated | ||
| // Persist the v2 catalog | ||
| modelToUpdate.data.catalogV2 = site.catalog; | ||
| // Because some old (but critical) application code still uses `data.values.searchCategories` | ||
| // as the source of truth for collection display configuration, we port all display changes | ||
| // in `data.catalog.collections` to the search category format. | ||
| // TODO: Remove once the app no longer relies on `data.values.searchCategories` | ||
| modelToUpdate = reflectCollectionsToSearchCategories(modelToUpdate); | ||
| // At this point `data.catalog` has become a full IHubCatalog object due to an in-memory | ||
| // migration. However, we can't persist an IHubCatalog in `data.catalog` without breaking | ||
| // the application, since most of the app relies on the old catalog structure. As such, | ||
| // we convert any changes made to the catalog scope into the old format and merge the changes | ||
| // with the existing structure on the most current model. | ||
| // TODO: Remove once the application is plumbed to work off an IHubCatalog | ||
| modelToUpdate = convertCatalogToLegacyFormat(modelToUpdate, currentModel); | ||
|
|
||
| // Perform backwards compatibility steps if the site is still using the v1 catalog | ||
| if (site.isCatalogV1Enabled) { | ||
| // Because some old (but critical) application code still uses `data.values.searchCategories` | ||
| // as the source of truth for collection display configuration, we port all display changes | ||
| // in `data.catalog.collections` to the search category format. | ||
| // TODO: Remove once the app no longer relies on `data.values.searchCategories` | ||
| modelToUpdate = reflectCollectionsToSearchCategories(modelToUpdate); | ||
| // We can't persist an IHubCatalog in `data.catalog` without breaking | ||
| // the application, since most of the app relies on the old catalog structure. As such, | ||
| // we convert any changes made to the catalog scope into the old format and merge the changes | ||
| // with the existing structure on the most current model. | ||
| // TODO: Remove once the application is fully migrated to always use IHubCatalog | ||
| modelToUpdate = convertCatalogToLegacyFormat(modelToUpdate, currentModel); | ||
| } else { | ||
| // ensure the old catalog is removed if the site is not using v1 | ||
| delete modelToUpdate.data.catalog; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🥳🎉 |
||
| delete (modelToUpdate.data.values as Record<string, unknown>) | ||
| .searchCategories; | ||
| // set the temporary property to indicate the site is fully upgraded to catalogV2. | ||
| // (only needed to circumvent some oddities around creating / deploying site templates) | ||
| modelToUpdate.data.useCatalogV2 = true; | ||
| } | ||
| /** | ||
| * Site capabilities are currently saved as an array on the | ||
| * site.data.values.capabilities. We want to migragte these | ||
sonofflynn89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a bunch of new TODOs in this file. Do we need to document them anywhere before we forget?