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

HubSiteManager & HubSites module #741

Merged
merged 9 commits into from
Mar 23, 2022
Merged

HubSiteManager & HubSites module #741

merged 9 commits into from
Mar 23, 2022

Conversation

dbouwman
Copy link
Member

@dbouwman dbouwman commented Mar 9, 2022

  1. Description:
  • Adds the HubSiteManager class, and it's backing HubSites module
  • Adds .sites to the Hub class.
  • DRY-ed up how .search(..) works for the Manager classes. They now delegate to searchContentEntities(...) which takes a conversion function that handles converting from an item to the entity type. These search functions only search against the Portal API - they never search using the Hub API.
  • additionally, Managers have .fromItem(IItem, requestOptions)

Note: The e2e's are intentionally brittle. They are not intended to be run in CI, but rather, are used during development / debugging to ensure the platform responds as expected. If we want to have ci-runnable e2e's we can add tasks to do that

Note Part Deux
FireFox tests failed in CI on this. Took a few hours of digging but the issue was due to rebuilding package-lock.json, which picked up jasmine-core 3.99.0from3.4.0. Forcing things back to 3.4.0` resolved the issue, and I created an issue to resolve

  1. Instructions for testing:
  • run tests
  • run e2e tests to see it work with real items
  1. Closes Issues: #3346

  2. ran commit script (npm run c)

For more information see the README

@codecov
Copy link

codecov bot commented Mar 9, 2022

Codecov Report

Merging #741 (6054f48) into master (62791d8) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 6054f48 differs from pull request most recent head 253a7dc. Consider uploading reports for the commit 253a7dc to get more accurate results

@@             Coverage Diff             @@
##            master      #741     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files          345       484    +139     
  Lines         6528      8374   +1846     
  Branches      1193      1410    +217     
===========================================
+ Hits          6528      8374   +1846     
Impacted Files Coverage Δ
packages/common/src/search/_searchContent.ts 100.00% <ø> (ø)
packages/common/src/search/group-utils.ts 100.00% <ø> (ø)
packages/common/src/search/utils.ts 100.00% <ø> (ø)
packages/sites/src/index.ts 100.00% <ø> (ø)
packages/sites/src/register-site-as-application.ts 100.00% <ø> (ø)
packages/common/src/ArcGISContext.ts 100.00% <100.00%> (ø)
packages/common/src/Hub.ts 100.00% <100.00%> (ø)
packages/common/src/core/helpers/index.ts 100.00% <100.00%> (ø)
packages/common/src/core/index.ts 100.00% <100.00%> (ø)
packages/common/src/core/types/index.ts 100.00% <100.00%> (ø)
... and 155 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca8d754...253a7dc. Read the comment docs.

@@ -53,7 +53,7 @@
"husky": "^4.3.0",

"jasmine": "^3.6.4",
"jasmine-core": "^3.4.0",
"jasmine-core": "3.4.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

This was needed to resolve some FireFox test failures. I've opened #742 to look into this

hubApiUrl: this.hubUrl,
};
}

Copy link
Member Author

Choose a reason for hiding this comment

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

We need to be able to create IHubRequestOptions when not auth'd

serializeContentFilterForPortal,
} from ".";
import { ISearchResponse } from "..";

Copy link
Member Author

Choose a reason for hiding this comment

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

Would appreciate input from @tomwayson on this - it all works - even after this is merged

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what you are expecting not to work, but we definitely should not be importing from "." and ".." b/c of circular deps.

Copy link
Member Author

Choose a reason for hiding this comment

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

was more the use of createContentEntitySearchFn which holds a closure over a ItemToEntityFunction<T>. It's really useful but a little complex. That said, the IHubItemEntity interface now requires an fromItem(IItem):Promise<T> which is the function needed in the closure... so... complex, but not random?

async create(
site: Partial<IHubSite>,
requestOptions?: IHubRequestOptions
): Promise<IHubSite> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Since this is a multi-step operation, I'm considering returning the IHubSite & OperationStack but mulling how best to encapsulate that w/o it getting gross

Copy link
Member

@tomwayson tomwayson left a comment

Choose a reason for hiding this comment

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

there's a lot of code here, so I only gave a cursory glance, esp w/ the tests. Main thing from my POV is to not export anything we don't need at the time of release in opendata-ui. We can always add exports to index.ts files later.

@@ -16,3 +16,4 @@ export * from "./get-structured-license";
export * from "./slugs";
export * from "./normalize-solution-template-item";
export * from "./setItemThumbnail";
export * from "./registerBrowserApp";
Copy link
Member

Choose a reason for hiding this comment

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

does this need to be part of the external API? Is anyone ever going to use this fn on it's own, or just registerSiteAsApplication()?

Copy link
Member Author

Choose a reason for hiding this comment

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

needed b/c it's re-exported in sites package

Comment on lines +4 to +10
export * from "./fetchSiteModel";
export * from "./get-site-by-id";
export * from "./HubSiteManager";
export * from "./HubSites";
export * from "./registerSiteAsApplication";
export * from "./site-schema-version";
export * from "./themes";
Copy link
Member

Choose a reason for hiding this comment

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

ditto w/ all these - if we don't have a known place where we are going to call any of them from the Hub app, or hub-components, let's not export them. We can always export them later if needed. If we needlessly export them now it becomes very difficult to modify or remove them and adds to our maintenance costs.

Copy link
Member Author

Choose a reason for hiding this comment

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

either needed directly or re-exported in hub-sites

packages/common/src/sites/themes.ts Show resolved Hide resolved
packages/common/src/core/helpers/index.ts Outdated Show resolved Hide resolved
packages/common/src/core/index.ts Outdated Show resolved Hide resolved
packages/common/src/search/index.ts Outdated Show resolved Hide resolved
serializeContentFilterForPortal,
} from ".";
import { ISearchResponse } from "..";

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what you are expecting not to work, but we definitely should not be importing from "." and ".." b/c of circular deps.

@github-actions
Copy link

There hasn't been any activity on this pull request in the past 3 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. If you want this PR to never become stale, please apply the "Draft" label.

@github-actions github-actions bot added the Stale Stale issue - update or it will be closed label Mar 15, 2022
Copy link
Member

@tomwayson tomwayson left a comment

Choose a reason for hiding this comment

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

thanks for making these fns internal-only.

I'm still wary of the from "..". I understand that it can cause mocking issues. The way I got around those w/ content was to move the shared fn out into it's own module, or a "lower level" module that could be safely imported by all consuming locations.

@dbouwman
Copy link
Member Author

@tomwayson I'll see what I can do about those... fwiw - I believe that's what vscode does when you move files around / automatically add the imports vs manually typing the import

@tomwayson
Copy link
Member

yep, that's exactly what it does, which is unfortunate. I have already pulled this, and started fixing them locally, you want me to push what I have?

@github-actions github-actions bot removed the Stale Stale issue - update or it will be closed label Mar 23, 2022
@dbouwman dbouwman merged commit e0f9d7d into master Mar 23, 2022
@tomwayson tomwayson deleted the f/hub-sites branch March 23, 2022 21:17
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.

2 participants