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
8cf7dd2c
Unverified
Commit
8cf7dd2c
authored
5 years ago
by
Paul Rosenzweig
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
only load membership if user is updating group_ids (#10815)
parent
75138e1a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/entities/users.js
+6
-5
6 additions, 5 deletions
frontend/src/metabase/entities/users.js
frontend/test/metabase/user/UserSettings.integ.spec.js
+23
-0
23 additions, 0 deletions
frontend/test/metabase/user/UserSettings.integ.spec.js
with
29 additions
and
5 deletions
frontend/src/metabase/entities/users.js
+
6
−
5
View file @
8cf7dd2c
...
...
@@ -89,11 +89,12 @@ const Users = createEntity({
...
result
,
};
},
update
:
thunkCreator
=>
(...
args
)
=>
async
(
dispatch
,
getState
)
=>
{
const
result
=
await
thunkCreator
(...
args
)(
dispatch
,
getState
);
// HACK: reload memberships when updating a user
// TODO: only do this if group_ids changes
dispatch
(
loadMemberships
());
update
:
thunkCreator
=>
user
=>
async
(
dispatch
,
getState
)
=>
{
const
result
=
await
thunkCreator
(
user
)(
dispatch
,
getState
);
if
(
user
.
group_ids
)
{
// group ids were just updated
dispatch
(
loadMemberships
());
}
return
result
;
},
},
...
...
This diff is collapsed.
Click to expand it.
frontend/test/metabase/user/UserSettings.integ.spec.js
+
23
−
0
View file @
8cf7dd2c
import
React
from
"
react
"
;
import
mock
from
"
xhr-mock
"
;
import
{
getFormValues
}
from
"
__support__/enzyme_utils
"
;
import
{
mountWithStore
}
from
"
__support__/integration_tests
"
;
import
UserSettings
from
"
metabase/user/components/UserSettings
"
;
import
Users
from
"
metabase/entities/users
"
;
const
MOCK_USER
=
{
first_name
:
"
Testy
"
,
...
...
@@ -12,6 +15,9 @@ const MOCK_USER = {
};
describe
(
"
UserSettings
"
,
()
=>
{
beforeEach
(()
=>
mock
.
setup
());
afterEach
(()
=>
mock
.
teardown
());
it
(
"
should show user info
"
,
async
()
=>
{
const
{
wrapper
}
=
mountWithStore
(
<
UserSettings
...
...
@@ -27,4 +33,21 @@ describe("UserSettings", () => {
expect
(
values
).
toEqual
(
MOCK_USER
);
});
it
(
"
should update the user without fetching memberships
"
,
async
()
=>
{
const
user
=
{
...
MOCK_USER
,
id
:
1
};
const
{
wrapper
,
store
}
=
mountWithStore
(
<
UserSettings
user
=
{
user
}
tab
=
"
details
"
/>
,
);
mock
.
put
(
"
/api/user/1
"
,
(
req
,
res
)
=>
res
.
json
(
user
));
const
getMemberships
=
jest
.
fn
();
mock
.
get
(
"
/api/permissions/membership
"
,
getMemberships
);
wrapper
.
find
(
"
button
"
).
simulate
(
"
submit
"
);
const
{
payload
}
=
await
store
.
waitForAction
(
Users
.
actionTypes
.
UPDATE
);
expect
(
payload
.
user
.
id
).
toBe
(
1
);
expect
(
getMemberships
).
not
.
toHaveBeenCalled
();
});
});
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