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
17813df1
Unverified
Commit
17813df1
authored
1 year ago
by
Ryan Laurie
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix permissions breadcrumbs for schemaless dbs (#37733)
* fix breadcrumbs for schemaless dbs * fix types
parent
56c70724
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/admin/permissions/selectors/data-permissions/breadcrumbs.unit.spec.ts
+99
-0
99 additions, 0 deletions
...sions/selectors/data-permissions/breadcrumbs.unit.spec.ts
frontend/src/metabase/lib/types.ts
+2
-2
2 additions, 2 deletions
frontend/src/metabase/lib/types.ts
with
101 additions
and
2 deletions
frontend/src/metabase/admin/permissions/selectors/data-permissions/breadcrumbs.unit.spec.ts
0 → 100644
+
99
−
0
View file @
17813df1
import
{
createMockDatabase
,
createMockSchema
,
createMockTable
,
}
from
"
metabase-types/api/mocks
"
;
import
{
createMockMetadata
}
from
"
__support__/metadata
"
;
import
{
getGroupsDataEditorBreadcrumbs
}
from
"
./breadcrumbs
"
;
describe
(
"
admin > permissions > data > breadcrumbs
"
,
()
=>
{
describe
(
"
getGroupsDataEditorBreadcrumbs
"
,
()
=>
{
const
schema
=
createMockSchema
({
id
:
"
100:myschema
"
,
name
:
"
myschema
"
,
});
const
schema2
=
createMockSchema
({
id
:
"
100:myschema2
"
,
name
:
"
myschema2
"
,
});
const
metadata
=
createMockMetadata
({
databases
:
[
createMockDatabase
({
id
:
100
,
name
:
"
myDatabase
"
,
// @ts-expect-error - we have to set this manually for this test to work due to circular object nonsense
schemas
:
[
schema
,
schema2
],
}),
createMockDatabase
({
id
:
101
,
name
:
"
mySchemalessDatabase
"
,
engine
:
"
mysql
"
,
}),
],
schemas
:
[
schema
,
schema2
],
tables
:
[
createMockTable
({
id
:
300
,
db_id
:
100
,
display_name
:
"
myTable
"
}),
createMockTable
({
id
:
301
,
db_id
:
101
,
display_name
:
"
mySchemalessTable
"
,
}),
],
});
it
(
"
should return breadcrumbs for a database with schema
"
,
()
=>
{
const
breadcrumbs
=
getGroupsDataEditorBreadcrumbs
(
{
databaseId
:
100
,
schemaName
:
"
public
"
,
tableId
:
300
,
},
metadata
,
);
expect
(
breadcrumbs
).
toEqual
([
{
text
:
"
myDatabase
"
,
id
:
100
,
url
:
"
/admin/permissions/data/database/100
"
,
},
{
text
:
"
public
"
,
id
:
"
100:public
"
,
url
:
"
/admin/permissions/data/database/100/schema/public
"
,
},
{
text
:
"
myTable
"
,
id
:
300
,
},
]);
});
// from metabase's metadata perspective, there's no such thing as a schemaless database
// even mysql has a single unnamed schema
it
(
"
should return breadcrumbs for a database with only 1 schema
"
,
()
=>
{
const
breadcrumbs
=
getGroupsDataEditorBreadcrumbs
(
{
databaseId
:
101
,
schemaName
:
"
public
"
,
tableId
:
301
,
},
metadata
,
);
expect
(
breadcrumbs
).
toEqual
([
{
text
:
"
mySchemalessDatabase
"
,
id
:
101
,
url
:
"
/admin/permissions/data/database/101
"
,
},
{
text
:
"
mySchemalessTable
"
,
id
:
301
,
},
]);
});
});
});
This diff is collapsed.
Click to expand it.
frontend/src/metabase/lib/types.ts
+
2
−
2
View file @
17813df1
...
...
@@ -3,9 +3,9 @@ export const isNotNull = <T>(value: T | null | undefined): value is T => {
};
export
const
isNotFalsy
=
<
T
>
(
value
:
T
|
null
|
undefined
|
false
,
value
:
T
|
null
|
undefined
|
false
|
""
,
):
value
is
T
=>
{
return
value
!=
null
;
return
value
!=
null
&&
value
!==
false
&&
value
!==
""
;
};
export
const
isNumber
=
(
value
:
unknown
):
value
is
number
=>
{
...
...
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