Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
176ded67
Unverified
Commit
176ded67
authored
1 year ago
by
Emmad Usmani
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fix url bug in sandbox editor (#33469)
parent
e33b06fc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/hoc/ModalRoute.tsx
+18
-1
18 additions, 1 deletion
frontend/src/metabase/hoc/ModalRoute.tsx
frontend/src/metabase/hoc/ModalRoute.unit.spec.js
+40
-1
40 additions, 1 deletion
frontend/src/metabase/hoc/ModalRoute.unit.spec.js
with
58 additions
and
2 deletions
frontend/src/metabase/hoc/ModalRoute.tsx
+
18
−
1
View file @
176ded67
...
...
@@ -5,6 +5,7 @@ import { push } from "react-router-redux";
import
{
connect
}
from
"
react-redux
"
;
import
type
{
LocationDescriptor
}
from
"
history
"
;
import
MetabaseSettings
from
"
metabase/lib/settings
"
;
import
Modal
from
"
metabase/components/Modal
"
;
type
IRoute
=
{
...
...
@@ -12,7 +13,23 @@ type IRoute = {
};
export
const
getParentPath
=
(
route
:
IRoute
,
location
:
Location
)
=>
{
const
fullPathSegments
=
location
.
pathname
.
split
(
"
/
"
);
// If instance has a custom url we need to exclude its subpath
const
siteUrlSegments
=
(
MetabaseSettings
.
get
(
"
site-url
"
)
??
""
).
split
(
"
/
"
);
const
subPath
=
siteUrlSegments
.
slice
(
3
).
join
(
"
/
"
);
let
pathName
:
string
;
if
(
subPath
)
{
const
subPathSplit
=
location
.
pathname
.
split
(
subPath
);
pathName
=
subPathSplit
.
length
===
1
?
subPathSplit
[
0
]
:
subPathSplit
.
slice
(
1
).
join
(
subPath
);
}
else
{
pathName
=
location
.
pathname
;
}
const
fullPathSegments
=
pathName
.
split
(
"
/
"
);
const
routeSegments
=
route
.
path
.
split
(
"
/
"
);
fullPathSegments
.
splice
(
-
routeSegments
.
length
);
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase/hoc/ModalRoute.unit.spec.js
+
40
−
1
View file @
176ded67
import
{
mockSettings
}
from
"
__support__/settings
"
;
import
{
getParentPath
}
from
"
./ModalRoute
"
;
const
setup
=
(
routePath
,
locationPath
)
=>
{
const
setup
=
(
routePath
,
locationPath
,
siteURL
=
undefined
)
=>
{
if
(
siteURL
)
{
mockSettings
({
"
site-url
"
:
siteURL
});
}
return
getParentPath
({
path
:
routePath
},
{
pathname
:
locationPath
});
};
...
...
@@ -33,5 +38,39 @@ describe("getParentPath", () => {
expect
(
parentPath
).
toEqual
(
"
/a/b
"
);
});
it
(
"
without single segment site url subpath
"
,
()
=>
{
const
parentPath
=
setup
(
"
c
"
,
"
metabase/a/b/c
"
,
"
https://somesite.com/metabase
"
,
);
expect
(
parentPath
).
toEqual
(
"
/a/b
"
);
});
it
(
"
without multi segment site url subpath
"
,
()
=>
{
const
parentPath
=
setup
(
"
c
"
,
"
meta/base/a/b/c
"
,
"
https://somesite.com/meta/base
"
,
);
expect
(
parentPath
).
toEqual
(
"
/a/b
"
);
});
// This is to handle the edge case where someone uses a subpath name
// like "data" that is also used within Metabase's routes
// e.g. If the site-url is "https://corp.com/data", it should not
// remove the second "data" from the path in "https://corp.com/data/admin/permissions/data/groups"
it
(
"
without leading url subpath while preserving later occurances
"
,
()
=>
{
const
parentPath
=
setup
(
"
groups
"
,
"
data/admin/permissions/data/groups
"
,
"
https://corp.com/data
"
,
);
expect
(
parentPath
).
toEqual
(
"
/admin/permissions/data
"
);
});
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment