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

[map-layers] migrate map layers to itwinui 3 #1136

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft

Conversation

hl662
Copy link

@hl662 hl662 commented Jan 7, 2025

For map-layers package:

  • Updated @itwin/itwinui-react to 3.16.0 - tests have been updated to no longer use .iui-xxxx class selectors, instead using [role="xxx"]. Also used data-testid where possible.
  • Updated eslint to 9.18.0, and relevant peerDeps of the pkg to latest.
  • Updated eslint config file to be ESM, addressed lint errors and warnings, including removing rule-disables that are outdated.
  • event.Keycode is deprecated, replaced usage with event.key in MapManagerSettings.
  • Removed usage of deprecated SpecialKey enums from appui-abstract, used string literals instead.

@hl662 hl662 changed the title migrate map layers to itwinui 3 [map-layers] migrate map layers to itwinui 3 Jan 16, 2025
@hl662 hl662 marked this pull request as ready for review January 16, 2025 15:10
@hl662 hl662 requested review from mdastous-bentley, eringram and a team as code owners January 16, 2025 15:10
@hl662
Copy link
Author

hl662 commented Jan 16, 2025

@mdastous-bentley I did a visual check against the test-viewer in this repo, everything looks fine and is interactable to me, can you double check as well?

@@ -0,0 +1,7 @@
{
"type": "patch",
Copy link
Member

Choose a reason for hiding this comment

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

updating peers will technically be a major ver bump,
might be able to get away with minor here but that might piss off some,
if we do a major ver bump, id want to make sure we are going to the latest versions of 4.x and react to all deprecations

Copy link
Author

@hl662 hl662 Jan 16, 2025

Choose a reason for hiding this comment

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

I changed this to minor, could be keen on doing major, after running the linter I've reacted to the deprecations in appui, no other deprecations were found (aside from event.Keycode)

Copy link
Member

Choose a reason for hiding this comment

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

id ant to update core and all other peer deps to the latest as well if we do a major bump

Copy link
Member

Choose a reason for hiding this comment

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

we could split that into multiple prs, just need to hold off on publishing map-layers pkg until we are ready, or we do pre-releases

Copy link
Author

@hl662 hl662 Jan 16, 2025

Choose a reason for hiding this comment

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

I switched the changefile type to major and bumped all core pkgs and other peerDeps to the latest, minus appui-react and imodel-components-react (which would require bumping up to their 5.x vers). Do we want to bump those 2? Should we also update the peerDeps to the latest as well?

Copy link
Member

Choose a reason for hiding this comment

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

i would look at what that change means, im not sure how big of an update it will be for those pkgs

Copy link
Author

Choose a reason for hiding this comment

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

it's quite big... some of the components used from `imodel-components-react' are marked deprecated. On top of that, these 2 packages drop support for react 17, so we have to bump up to react 18, and respectively update peer deps of React. We'll have to use new components, edit the test cases and update type definitions for some of the react hooks in the package. Probably a larger amount of effort than what this PR is about

Copy link
Member

Choose a reason for hiding this comment

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

there are only 3 imports from imodel-components-react
i imagine the colorswatch components are deprecated in favor of itwinui v3 components which we should be using

Copy link
Member

Choose a reason for hiding this comment

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

also now that im looking i see there was a mixup on what latest meant, i meant the latest 4.x, not latest version of appui which is 5.0, my apologies, shouldve been more clear

Copy link
Member

Choose a reason for hiding this comment

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

instead of going directly to a major, we should publish a pre-release to make sure everything works, and can also look updating other peer dep majors to include in the full major release

@hl662 hl662 self-assigned this Jan 16, 2025
@eringram
Copy link
Member

Code changes look fine to me and I also did a quick test of the widget in the test viewer. (I did have trouble adding a new map layer, but ran into the same problem on master so I'm probably doing it wrong and it's unrelated to these changes). @mdastous-bentley would be able to better confirm

* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import iTwinPlugin from "@itwin/eslint-plugin";
import reactPlugin from "eslint-plugin-react";
Copy link
Member

Choose a reason for hiding this comment

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

shouldnt we use the itwin ui eslint plugin config?
https://github.com/iTwin/eslint-plugin/blob/main/dist/configs/ui.js

@@ -389,6 +388,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick }:
await MapLayerPreferences.deleteByName(source, iTwinId, iModelId);
const msg = MapLayersUI.localization.getLocalizedString("mapLayers:CustomAttach.RemoveLayerDefSuccess", { layerName });
IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, msg));
// eslint-disable-next-line unused-imports/no-unused-vars
Copy link
Member

Choose a reason for hiding this comment

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

you could just delete err

catch {
    blah
}

@@ -70,7 +68,6 @@ export const getMapFeatureInfoToolItemDef = (): ToolItemDef =>
});

export class FeatureInfoUiItemsProvider implements UiItemsProvider {
// eslint-disable-line deprecation/deprecation
Copy link
Member

Choose a reason for hiding this comment

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

i dont get how this resolved the deprecation

@@ -23,7 +22,7 @@ export interface TransparencyPopupButtonProps {
}

/** @alpha */
// eslint-disable-next-line @typescript-eslint/naming-convention
// eslint-disable-next-line @typescript-eslint/unbound-method
Copy link
Member

Choose a reason for hiding this comment

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

what is unbound?

@@ -114,7 +111,7 @@ export function SubLayersTree(props: SubLayersTreeProps) {
// it selects/deselects node when checkbox is checked/unchecked and vice versa.
// `useDisposable` takes care of disposing old event handler when new is created in case 'nodeLoader' has changed
// `React.useCallback` is used to avoid creating new callback that creates handler on each render
const eventHandler = useDisposable(
const eventHandler = useOptionalDisposable(
Copy link
Member

Choose a reason for hiding this comment

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

was this due to deprecation?

@@ -249,7 +242,6 @@ export function MapLayerDroppable(props: MapLayerDroppableProps) {
activeViewport={props.activeViewport}
mapLayerSettings={activeLayer}
onMenuItemSelection={props.onMenuItemSelected}
disabled={props.disabled}
Copy link
Member

Choose a reason for hiding this comment

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

why the change?

@@ -1,10 +1,10 @@
import * as React from "react";
Copy link
Member

Choose a reason for hiding this comment

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

this is a little gross with the imports above the copyright, you could just nuke all the copyrights or turn off your formatter

@@ -105,18 +101,18 @@
"source-map-support": "^0.5.6",
"ts-node": "^10.9.1",
"typemoq": "^2.1.0",
"typescript": "~4.6.0"
"typescript": "~5.0.0"
},
"peerDependencies": {
"@itwin/appui-abstract": "^4.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

maybe you should update the core peers to the latest?

@hl662 hl662 marked this pull request as draft January 17, 2025 20:00
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.

3 participants