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

Fix isNavigationAllowed #38703

Merged
merged 11 commits into from
Feb 13, 2024
Merged

Fix isNavigationAllowed #38703

merged 11 commits into from
Feb 13, 2024

Conversation

kamilmielnik
Copy link
Contributor

@kamilmielnik kamilmielnik commented Feb 13, 2024

Prerequisite for #37357

Description

I got confused when working on #37357 as some of the existing things didn't make any sense. Blame me.
Luckily, nothing was really broken. More details below and in PR comments.

  • Removed unused /model/notebook route
  • Removed/updated invalid test cases
  • Used Question.prototype.type instead Question.prototype.isDataset
  • Ensured navigating to /model/:id/notebook is not prevented
    • This worked accidentally thanks to getShouldShowUnsavedChangesWarning
    • Added tests for it

@kamilmielnik kamilmielnik changed the title Fix/is navigation allowed Fix isNavigationAllowed Feb 13, 2024
@@ -208,7 +208,6 @@ export const getRoutes = store => {
title={t`New Model`}
component={NewModelOptions}
/>
<Route path="notebook" component={QueryBuilder} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/model/notebook route is never used.
However /model/:id/notebook is.

@@ -243,14 +244,6 @@ describe("isNavigationAllowed", () => {
).toBe(true);
});

it("allows to run a model", () => {
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 test was invalid (copy-paste remnants) - it's for a model, but the describe is for a question

`/model/${slug}`,
`/model/${slug}/query`,
`/model/${slug}/metadata`,
`/model/${slug}/notebook`,
Copy link
Contributor Author

@kamilmielnik kamilmielnik Feb 13, 2024

Choose a reason for hiding this comment

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

Added this route

).toBe(true);
});

it("allows to run the model and then edit it again", () => {
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 test was invalid (non-existing route).

).toBe(true);
});

it("allows to run the model and then edit it again", () => {
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 test was invalid (non-existing route).

hash: `#${serializeCardForUrl(nativeModelCard)}`,
});

const runModelEditNotebookLocation = createMockLocation({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Non-existing route.

const runModelEditNotebookLocation = createMockLocation({
pathname: "/model/notebook",
const runNewModelLocation = createMockLocation({
pathname: "/model/query",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated pathname to correct one

@kamilmielnik kamilmielnik added the no-backport Do not backport this PR to any branch label Feb 13, 2024
@kamilmielnik kamilmielnik marked this pull request as ready for review February 13, 2024 11:46
@kamilmielnik kamilmielnik requested a review from a team February 13, 2024 11:46
Copy link

replay-io bot commented Feb 13, 2024

Status Complete ↗︎
Commit 94c591f
Results
⚠️ 2 Flaky
2308 Passed

@kamilmielnik kamilmielnik merged commit b98fa2b into master Feb 13, 2024
107 checks passed
@kamilmielnik kamilmielnik deleted the fix/is-navigation-allowed branch February 13, 2024 13:46
Copy link

@kamilmielnik Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

@kamilmielnik
Copy link
Contributor Author

@metabase-bot backport release-x.49.x

github-actions bot pushed a commit that referenced this pull request Feb 13, 2024
* Removed unused route

* Remove invalid test

* Remove invalid routes from isNavigationAllowed, update tests

* Remove invalid route

* Handle /model/:id/notebook route

* Migrate Question.prototype.isDataset to Question.prototype.type

* Consolidate code

* Add missing attribute

* Type cards and questions for extra safety

* Fix running edited models

* Improve diff
@kamilmielnik kamilmielnik added this to the 0.49 milestone Feb 13, 2024
metabase-bot bot added a commit that referenced this pull request Feb 13, 2024
* Removed unused route

* Remove invalid test

* Remove invalid routes from isNavigationAllowed, update tests

* Remove invalid route

* Handle /model/:id/notebook route

* Migrate Question.prototype.isDataset to Question.prototype.type

* Consolidate code

* Add missing attribute

* Type cards and questions for extra safety

* Fix running edited models

* Improve diff

Co-authored-by: Kamil Mielnik <kamil@kamilmielnik.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport Do not backport this PR to any branch .Team/QueryingComponents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants