Skip to content

refactor(regions): Split regions to separate manager#617

Merged
mergify[bot] merged 4 commits intobox:masterfrom
ConradJChan:move-region-list
Oct 8, 2020
Merged

refactor(regions): Split regions to separate manager#617
mergify[bot] merged 4 commits intobox:masterfrom
ConradJChan:move-region-list

Conversation

@ConradJChan
Copy link
Contributor

@ConradJChan ConradJChan commented Oct 6, 2020

TODO

  • unit tests

@ConradJChan ConradJChan marked this pull request as ready for review October 7, 2020 06:06
@ConradJChan ConradJChan requested a review from a team as a code owner October 7, 2020 06:06
rootLayerEl.classList.add('ba-Layer--region');
rootLayerEl.dataset.testid = 'ba-Layer--region';
rootLayerEl.classList.add('ba-Layer--regionCreation');
rootLayerEl.dataset.testid = 'ba-Layer--regionCreation';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this going to cause issues for our automated test suites?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll update the e2e tests. QA doesn't use this testid so we should be good there

rectRef?: RegionRectRef;
};

export default class RegionCreation extends React.PureComponent<Props, State> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we convert this to a function component now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather do that in a follow up PR

instance.handleAnnotationActive('123');
(getWrapper()
.find(RegionList)
.prop('onSelect') as Function)('123');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we avoid these casts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed because onSelect is an optional prop

const parentEl = referenceEl.parentNode || documentEl;

// Construct a layer element where we can inject a root React component
const rootLayerEl = documentEl.createElement('div');
Copy link
Collaborator

Choose a reason for hiding this comment

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

We're not seeing as much variation between managers as I expected, which is leading to a lot of duplicate code. We should consider extracting it to a base class or a helper function or something. It can wait for a future change, though.

if (this.managers.size === 0) {
this.managers.add(new PopupManager({ referenceEl }));
this.managers.add(new RegionManager({ referenceEl }));
this.managers.add(new RegionListManager({ referenceEl }));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the order of these be flipped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because if we do that then when the mode is region the existing regions won't receive pointer events

@jstoffan
Copy link
Collaborator

jstoffan commented Oct 7, 2020

Should probably be a fix or refactor commit.

@ConradJChan ConradJChan changed the title chore(regions): Split regions to separate manager refactor(regions): Split regions to separate manager Oct 7, 2020
@mingzexiao6
Copy link
Contributor

Mergify will use the first commit message as the final commit message. So you also need to amend the first commit message to refactor.

@mergify mergify bot merged commit dc9deea into box:master Oct 8, 2020
@ConradJChan ConradJChan deleted the move-region-list branch October 8, 2020 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants