-
Notifications
You must be signed in to change notification settings - Fork 191
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
kie-issues#208: Renaming any "NamedElement" on the DMN Editor should update all references to the old name #2760
base: main
Are you sure you want to change the base?
Conversation
…update all references to the old name
…update all references to the old name
f04b142
to
de7015e
Compare
|
||
const resetFormData = useCallback(() => { | ||
setExpressionName(selectedExpressionName); | ||
setDataType(selectedDataType); | ||
}, [selectedExpressionName, selectedDataType]); | ||
|
||
// onCancel doens't prevent the onHide call | ||
// onCancel doesn't prevent the onHide call |
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.
Just a typo.
Thank you for the PR @danielzhe. It's going to take me a few days to go over everything with the care it deserves. Will keep you posted! |
@danielzhe Storybook is pointing to code using |
03FYI, I didn't check this feature with the List expression because of apache/incubator-kie-issues#1635 |
06Is there a way to disable this feature? Committing the rename action starts to be slower, so I expect some user may ask to disable this feature in their environment. |
07During included models review, I found this apache/incubator-kie-issues#1636, however I think I didn't find issue related to changes of #2760. |
- Fixes includes to point to src - Some refactor to reduce nesting
Thank you for your review, @jomarko !
|
@danielzhe thank you for updates I think 1. and 2. works now pretty well.
|
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.
Hi Daniel,
Thanks for the PR - it looks great! Just a minor comment from my side regarding the message:
packages/dmn-editor/src/refactor/RefactorConfirmationDialog.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Kbowers <[email protected]>
Thank you for your suggestion! It's always good to have a native English speaker to improve our messages. I'll update the text of the buttons too to match the new message. |
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.
@danielzhe The code looks good. I still didn't finish reviewing all files and test the new feature, but I could see a few things. For the DMN Editor, I could see that many files have the same logic, so why not create a new hook that encapsulate the refactor
logic? For instance, the refactor modal and newName states and the applyRename
could be returned by this new hook.
const [isRefactorModalOpen, setIsRefactorModalOpen] = useState(false);
const [newName, setNewName] = useState("");
// Not sure if this could be add to the hook or not
const identifierId = useMemo(() => decision["@_id"], [decision]);
const oldName = useMemo(() => decision["@_label"] ?? decision["@_name"], [decision]);
const currentName = useMemo(() => {
return newName === "" ? oldName : newName;
}, [newName, oldName]);
// End
const applyRename = useCallback(
(args: {
definitions: Normalized<DMN15__tDefinitions>;
newName: string;
shouldRenameReferencedExpressions: boolean;
}) => {
renameDrgElement({
...args,
index,
externalDmnModelsByNamespaceMap,
});
},
[externalDmnModelsByNamespaceMap, index]
);
Another thing that caught my attention was the externalDmnModelsByNamespaceMap
creation in many places. Maybe this is the case to add it to the store
?
Additionally, I've made some comments inline.
@@ -23,7 +23,7 @@ import { ns as dmn15ns } from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts | |||
import { generateUuid } from "@kie-tools/boxed-expression-component/dist/api"; | |||
import { DMN15_SPEC } from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/Dmn15Spec"; | |||
import { DmnEditorWrapper, StorybookDmnEditorProps } from "../../dmnEditorStoriesWrapper"; | |||
import { DmnEditor, DmnEditorProps } from "../../../src/DmnEditor"; | |||
import { DmnEditor, DmnEditorProps } from "@kie-tools/dmn-editor/dist/DmnEditor"; |
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.
Nice!
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 not necessary to create a refactor
folder for this file as the name already tells what the file is about.
|
||
import { v4 as uuid } from "uuid"; | ||
|
||
export {}; |
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.
Why this is necessary?
...variable, | ||
"@_name": name, | ||
"@_typeRef": typeRef, | ||
const variableChangedArgs: ExpressionChangedArgs = { |
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.
On other files is used expressionChangedArgs
.
@@ -100,17 +108,36 @@ export function ExpressionVariableMenu({ | |||
}, [beeGwtService]); | |||
|
|||
const saveExpression = useCallback(() => { | |||
if (expressionName !== selectedExpressionName || dataType !== selectedDataType) { | |||
onVariableUpdated({ name: expressionName, typeRef: dataType }); | |||
const changes: ExpressionChangedArgs = { |
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.
On other files is used expressionChangedArgs
.
Closes: apache/incubator-kie-issues#208
Some comments about the changes:
Action.VariableChanged
;Renaming Data Types
Data.Types.mp4
Renaming BKMs and parameters
Bkm.and.Parameters.mp4
General rename
Some.Renames.mp4
Renaming Included Models name
It does not show the confirmation dialog, because doesn't make sense to not update the references in this case, since this already was the default behavior before this PR (when we renamed a included model, we already updated all the references except the expressions, now we update the expressions).
Included.Models.mp4