-
Notifications
You must be signed in to change notification settings - Fork 1
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
add import mode to update datasets without deleting existing data #308
base: development
Are you sure you want to change the base?
Conversation
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.
Is this PR still a draft?
The feature works (just added a note about the default behavior). And just some very minor things we can check before merging, inline.
src/data/InstanceDhisRepository.ts
Outdated
public async importDataPackage(dataPackage: DataPackage): Promise<SynchronizationResult[]> { | ||
public async importDataPackage( | ||
dataPackage: DataPackage, | ||
createAndUpdate: boolean |
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.
Typically, it's better to use an options
argument that wraps boolean options. This way, calls to the method are more declarative.
return true; | ||
} else { | ||
return false; | ||
} |
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.
Equivalent return strategy === "IMPORT"
@@ -45,7 +40,7 @@ export default function ImportTemplatePage({ settings }: RouteComponentProps) { | |||
const [orgUnitTreeFilter, setOrgUnitTreeFilter] = useState<string[]>([]); | |||
const [importState, setImportState] = useState<ImportState>(); | |||
const [messages, setMessages] = useState<string[]>([]); | |||
const [dialogProps, updateDialog] = useState<ConfirmationDialogProps | null>(null); | |||
const [dialogProps, updateDialog] = useState<ModalDialogProps | null>(null); |
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.
It's more idiomatic to use undefined
as initial empty value of a useState. Then we can simply write: useState<ConfirmationDialogProps>();
"IMPORT ONLY NEW DATA VALUES, WITHOUT UPDATING OR DELETING CURRENT ONES" | ||
), | ||
updateTooltipText: i18n.t( | ||
"IMPORT AND UPDATE DATA VALUES WITHOUT DELETING THE REMAINING EXISTING DATA" |
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.
Typically, we use standard case for texts (and the CSS decides how it's shown).
switch (dataPackage.type) { | ||
case "dataSets": { | ||
const result = await this.importAggregatedData("CREATE_AND_UPDATE", dataPackage); | ||
const result = await this.importAggregatedData( | ||
createAndUpdate ? "CREATE_AND_UPDATE" : "CREATE", |
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.
[note] When Duplicate detection is not enabled, duplicateStrategy is "ERROR" so the default importStrategy is now CREATE instead of CREATE_AND_UPDATE. That's possibly a feature, not a bug, but I wanted to note it as it will change our default behavior for everyone.
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.
All good (functional testing). Waiting for feedback from @tokland before merging this.
@eperedo Is the base branch correct? or maybe development merge pending? |
d1e120e
to
e989446
Compare
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.
[code-only review] All good.
📌 References
📝 Implementation
🔥 Notes for the reviewer
📹 Screenshots/Screen capture
Help Message
DELETE AND IMPORT help message (previous "PROCEED")
IMPORT ONLY NEW DATA VALUES help message
📑 Others