-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
feat: add confirmation dialog for imports #11983
Conversation
08636e1
to
4ac8cdd
Compare
bc29d02
to
8feaed6
Compare
Codecov Report
@@ Coverage Diff @@
## master #11983 +/- ##
==========================================
+ Coverage 67.04% 67.86% +0.81%
==========================================
Files 948 948
Lines 46193 46229 +36
Branches 4405 4418 +13
==========================================
+ Hits 30972 31374 +402
+ Misses 15095 14748 -347
+ Partials 126 107 -19
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
While this works, we may want to look for other confirmation prompts in the future once i18n becomes more serious. |
Sorry, what do you mean? I just wrote #11987 to improve DELETE, but it would be nice to have more hints for translators to indicate that the strings should match. |
I mean we shouldn't ask non-English speaking users to type English words. #11987 seems like a right step, but as you noted, the translation may not match. What we should have been doing for a long time is to add unique translation keys for each UI piece and let English reads from the translation file, too. |
4ac8cdd
to
60b15bb
Compare
8feaed6
to
f3a8165
Compare
@@ -399,6 +439,7 @@ export function useImportResource<D extends object = any>( | |||
state: { | |||
loading: state.loading, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: deconstruct these vars
const { loading, passwordsNeeded, alreadyExists } = state;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we're returning state
:
return {
state: {
loading: state.loading,
passwordsNeeded: state.passwordsNeeded,
alreadyExists: state.alreadyExists,
},
importResource,
};
So I think we could just return:
return {
state,
importResource,
}
But I think we want to return a copy of state here, which is why we redefine it — I followed the same logic from useSingleViewResource
:
@riahk any thoughts here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was discussing this with @nytai who originally wrote this logic for useListViewResource
. I think the original intent was explicitly defining the state variables because some of that hook's state variables are strictly internal. However, in useSingleViewResource
we're returning all the state variables, so it should be fine to just import the entire state
object (I will probably refactor the hook to do this at some point).
It looks like that's the case here as well so you can easily just import the entire state
object like you suggested above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @riahk! I've updated the code.
@@ -581,6 +581,9 @@ function ChartList(props: ChartListProps) { | |||
'the database configuration are not present in export files, and ' + | |||
'should be added manually after the import if they are needed.', | |||
)} | |||
confirmOverwriteMessage={t( | |||
'One or more charts to be imported already exist.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could make this more modular by making the message live in the component and change the resource name. For example, One or more {resourceName} to be imported already exist.
then we wouldn't have to pass the message through the props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that we need to use plural here ("charts") and resourceLabel
is singular, and we can't build the plural programmatically. For example, we could try to do this:
t('One or more %ss to be imported already exist.', resourceLabel);
But in Italian (eg) the plural of chart — grafico — is "grafici", and it would break.
We could change the constructor to receive resourceName
and resourcePluralName
, but I thought it would be better to have components define the error message, since it allows for customization.
a98afaf
to
683a78c
Compare
SUMMARY
Confirm overwrite before importing an assert that already exists.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
Tested importing an already existing database.
ADDITIONAL INFORMATION