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
875137b6
Unverified
Commit
875137b6
authored
2 years ago
by
Alexander Polyankin
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove metabase-lib dependency on redux (#25893)
parent
cf364378
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-lib/lib/Question.ts
+0
-34
0 additions, 34 deletions
frontend/src/metabase-lib/lib/Question.ts
frontend/src/metabase/query_builder/actions/core/core.js
+39
-10
39 additions, 10 deletions
frontend/src/metabase/query_builder/actions/core/core.js
with
39 additions
and
44 deletions
frontend/src/metabase-lib/lib/Question.ts
+
0
−
34
View file @
875137b6
...
...
@@ -45,7 +45,6 @@ import {
maybeUsePivotEndpoint
,
MetabaseApi
,
}
from
"
metabase/services
"
;
import
Questions
from
"
metabase/entities/questions
"
;
import
{
Parameter
as
ParameterObject
,
ParameterValues
,
...
...
@@ -1167,39 +1166,6 @@ class QuestionInner {
}
}
// NOTE: prefer `reduxCreate` so the store is automatically updated
async
apiCreate
()
{
const
createdCard
=
await
Questions
.
api
.
create
(
this
.
card
());
return
this
.
setCard
(
createdCard
);
}
// NOTE: prefer `reduxUpdate` so the store is automatically updated
async
apiUpdate
()
{
const
updatedCard
=
await
Questions
.
api
.
update
(
this
.
card
());
return
this
.
setCard
(
updatedCard
);
}
async
reduxCreate
(
dispatch
)
{
const
action
=
await
dispatch
(
Questions
.
actions
.
create
(
this
.
card
()));
return
this
.
setCard
(
Questions
.
HACK_getObjectFromAction
(
action
));
}
async
reduxUpdate
(
dispatch
,
{
excludeDatasetQuery
=
false
}
=
{})
{
const
fullCard
=
this
.
card
();
const
card
=
excludeDatasetQuery
?
_
.
omit
(
fullCard
,
"
dataset_query
"
)
:
fullCard
;
const
action
=
await
dispatch
(
Questions
.
actions
.
update
(
{
id
:
this
.
id
(),
},
card
,
),
);
return
this
.
setCard
(
Questions
.
HACK_getObjectFromAction
(
action
));
}
setParameters
(
parameters
)
{
return
this
.
setCard
(
assoc
(
this
.
card
(),
"
parameters
"
,
parameters
));
}
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase/query_builder/actions/core/core.js
+
39
−
10
View file @
875137b6
import
{
createAction
}
from
"
redux-actions
"
;
import
_
from
"
underscore
"
;
import
*
as
MetabaseAnalytics
from
"
metabase/lib/analytics
"
;
import
{
loadCard
}
from
"
metabase/lib/card
"
;
import
{
shouldOpenInBlankWindow
}
from
"
metabase/lib/dom
"
;
...
...
@@ -181,10 +182,13 @@ export const apiCreateQuestion = question => {
:
question
;
const
resultsMetadata
=
getResultsMetadata
(
getState
());
const
createdQuestion
=
await
questionWithVizSettings
const
questionToCreate
=
questionWithVizSettings
.
setQuery
(
question
.
query
().
clean
())
.
setResultsMetadata
(
resultsMetadata
)
.
reduxCreate
(
dispatch
);
.
setResultsMetadata
(
resultsMetadata
);
const
createdQuestion
=
await
reduxCreateQuestion
(
questionToCreate
,
dispatch
,
);
const
databases
=
Databases
.
selectors
.
getList
(
getState
());
if
(
databases
&&
!
databases
.
some
(
d
=>
d
.
is_saved_questions
))
{
...
...
@@ -226,15 +230,20 @@ export const apiUpdateQuestion = (question, { rerunQuery } = {}) => {
:
question
;
const
resultsMetadata
=
getResultsMetadata
(
getState
());
const
updatedQuestion
=
await
questionWithVizSettings
const
questionToUpdate
=
questionWithVizSettings
.
setQuery
(
question
.
query
().
clean
())
.
setResultsMetadata
(
resultsMetadata
)
// When viewing a dataset, its dataset_query is swapped with a clean query using the dataset as a source table
// (it's necessary for datasets to behave like tables opened in simple mode)
// When doing updates like changing name, description, etc., we need to omit the dataset_query in the request body
.
reduxUpdate
(
dispatch
,
{
.
setResultsMetadata
(
resultsMetadata
);
// When viewing a dataset, its dataset_query is swapped with a clean query using the dataset as a source table
// (it's necessary for datasets to behave like tables opened in simple mode)
// When doing updates like changing name, description, etc., we need to omit the dataset_query in the request body
const
updatedQuestion
=
await
reduxUpdateQuestion
(
questionToUpdate
,
dispatch
,
{
excludeDatasetQuery
:
isAdHocModelQuestion
(
question
,
originalQuestion
),
});
},
);
// reload the question alerts for the current question
// (some of the old alerts might be removed during update)
...
...
@@ -274,3 +283,23 @@ export const revertToRevision = createThunkAction(
};
},
);
async
function
reduxCreateQuestion
(
question
,
dispatch
)
{
const
action
=
await
dispatch
(
Questions
.
actions
.
create
(
question
.
card
()));
return
question
.
setCard
(
Questions
.
HACK_getObjectFromAction
(
action
));
}
async
function
reduxUpdateQuestion
(
question
,
dispatch
,
{
excludeDatasetQuery
=
false
},
)
{
const
fullCard
=
question
.
card
();
const
card
=
excludeDatasetQuery
?
_
.
omit
(
fullCard
,
"
dataset_query
"
)
:
fullCard
;
const
action
=
await
dispatch
(
Questions
.
actions
.
update
({
id
:
question
.
id
()
},
card
),
);
return
question
.
setCard
(
Questions
.
HACK_getObjectFromAction
(
action
));
}
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