Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

feat(metadata): Metadata configuration UI #1951

Merged
merged 2 commits into from
Jun 16, 2023
Merged

Conversation

igarashitm
Copy link
Contributor

@igarashitm igarashitm commented Jun 12, 2023

Fixes: #1722

BeansUI.mp4

@igarashitm igarashitm requested a review from a team June 12, 2023 20:35
@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Merging #1951 (6087322) into main (f0a988f) will increase coverage by 3.78%.
The diff coverage is 92.36%.

@@            Coverage Diff             @@
##             main    #1951      +/-   ##
==========================================
+ Coverage   60.72%   64.50%   +3.78%     
==========================================
  Files          78       87       +9     
  Lines        2546     2820     +274     
  Branches      576      649      +73     
==========================================
+ Hits         1546     1819     +273     
  Misses        956      956              
- Partials       44       45       +1     
Impacted Files Coverage Δ
src/api/apiService.ts 29.89% <75.00%> (+6.24%) ⬆️
src/components/metadata/MetadataEditorBridge.tsx 85.71% <85.71%> (ø)
src/components/metadata/PropertyPlaceholderRow.tsx 87.50% <87.50%> (ø)
src/components/metadata/PropertyRow.tsx 88.63% <88.63%> (ø)
src/components/metadata/MetadataEditorModal.tsx 92.30% <92.30%> (ø)
src/components/metadata/PropertiesField.tsx 92.98% <92.98%> (ø)
src/components/metadata/MetadataToolbarItems.tsx 96.15% <96.15%> (ø)
src/components/metadata/ToopmostArrayTable.tsx 96.77% <96.77%> (ø)
src/components/KaotoToolbar.tsx 54.95% <100.00%> (+3.13%) ⬆️
src/components/Visualization.tsx 74.52% <100.00%> (+0.99%) ⬆️
... and 3 more

... and 3 files with indirect coverage changes

@igarashitm igarashitm force-pushed the 1722 branch 2 times, most recently from eb7f8fb to c666ebd Compare June 12, 2023 21:26
@lordrip
Copy link
Collaborator

lordrip commented Jun 13, 2023

There's an exception in the console, but I don't where is coming from yet.

image

@igarashitm
Copy link
Contributor Author

@lordrip yes that's annoying, it appears with patternfly selectable table (left side). It adds <outout class="pf-screen-reader"> element next to every <tr>, right under the <tbody>. Even the patternfly official example shows the same error.

@@ -57,7 +57,7 @@ export const SourceCodeEditor = (props: ISourceCodeEditor) => {
} else {
fetchTheSourceCode({ flows, properties, metadata }, settings);
}
}, [flows, properties]);
}, [flows, properties, metadata]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Note for the future ourselves]: After #1927 is merged, we would need to add this property to the new location.

@@ -20,3 +20,4 @@ export * from './VisualizationControls';
export * from './VisualizationStepViews';
export * from './Visualization';
export * from './VisualizationStep';
export { MetadataToolbarItems } from './metadata/MetadataToolbarItems';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content of this file is only exporting one single function, in which case, wouldn't be enough to do something like below?

Suggested change
export { MetadataToolbarItems } from './metadata/MetadataToolbarItems';
export * from './metadata/MetadataToolbarItems';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if it's preferred in typescript? Generally the wildcard is not preferred in Java coding standards I know

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, it's ok as we're exposing tokens and not necessarily mean that they will be incorporated in the final bundle, is mostly convenience I would say.

src/components/metadata/AddPropertyButton.tsx Outdated Show resolved Hide resolved
expect(element).not.toBeInTheDocument();
});

test('editor works', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[friendly-suggestion]: This test might be more suited to an e2e test because if it fails, it might not be easy to determine the root cause as there are many expectations and also dependencies from the previous statement.

"Ideally" each test should have a couple expect() calls only. Notice how I quoted Ideally 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll try to split the test... I'd like to keep these tests here with mock schemas, as e2e test will only work with the real schema which will be retrieved from backend in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it makes sense to keep the test with mock schemas as you're doing right now, I was suggesting more like preparing the data that the component will need, then rendering it, and then ensuring that it looks like you would like to.

Pretty much as you have it right now, but instead of interacting with the UI to reach the desired point, already provide that data to the component and then make the assertions on top of it.

Copy link
Contributor Author

@igarashitm igarashitm Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So instead of testing everything, add/edit/delete in one place, test one action in one test, e.g. test add button and don't continue with the result of it, correct? I can do that.
Since this is an editor, just testing static rendering is not enough, rather need to verify actions work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test one action in one test, e.g. test add button and don't continue with the result of it, correct? I can do that.

Exactly, just prepare the stage for the test, execute the action, and then do the evaluation. As AAA suggests.

Arrange, Act, and Assert.

src/components/metadata/MetadataEditorModal.tsx Outdated Show resolved Hide resolved
src/store/FlowsStore.ts Show resolved Hide resolved
@lordrip
Copy link
Collaborator

lordrip commented Jun 13, 2023

LGTM, just a couple of pending details:

  • The console error
  • The panel width changing when empty

@lordrip
Copy link
Collaborator

lordrip commented Jun 13, 2023

LGTM, just a couple of pending details:

* The console error

* The panel width changing when empty

It seems that the console error is coming from the @patternfly/react library
https://codesandbox.io/s/ji85yx

@igarashitm
Copy link
Contributor Author

Discussed with @lordrip and now we think editing property name is important. Also the inline input for property value doesn't work with cursor key, so for now I'll remove the inline input and add "edit" button for the popover similar to "add new property".

@igarashitm igarashitm marked this pull request as draft June 13, 2023 15:22
@igarashitm
Copy link
Contributor Author

igarashitm commented Jun 13, 2023

Interestingly, while the following patternfly official doc also contains <output> under <tbody>, chrome doesn't show the warning in console
https://www.patternfly.org/v4/components/table/#composable-row-click-handler-hoverable--selected-rows
Although it does show once you open in the sandbox.

P.S. it's a known bug - patternfly/patternfly-react#7745

@igarashitm igarashitm force-pushed the 1722 branch 3 times, most recently from 72524de to 11eb9f1 Compare June 15, 2023 20:21
@igarashitm
Copy link
Contributor Author

igarashitm commented Jun 15, 2023

inlined property add/edit

2023-06-15_16-03-47.mp4

@igarashitm igarashitm force-pushed the 1722 branch 2 times, most recently from 23d5545 to d656f43 Compare June 16, 2023 03:54
@igarashitm igarashitm marked this pull request as ready for review June 16, 2023 03:54
@igarashitm
Copy link
Contributor Author

And fixed tests, should be ready now

* fix: Removed curly brackets for string literal attributes
* fix: Prevent resizing
* fix: Fixed cursor key behavior in property name/value input
* fix: Inlined property add/edit with placeholder, removed popover
* fix: Tests
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

No Coverage information No Coverage information
4.0% 4.0% Duplication

Copy link
Collaborator

@lordrip lordrip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, there are a couple of details that could be improved on the usability aspect but we could improve those along the way iteratively.

jest.mock('@kaoto/api', () => {
return {
__esModule: true,
...jest.requireActual('@kaoto/api'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm I wonder what happened here, since we're not mocking any API 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a "charm" I found at somewhere, without this the later spyOn didn't work - https://github.com/KaotoIO/kaoto-ui/pull/1951/files/608732269e75d09be304cd20e1d2468378a6ae04#diff-f37f26c5fb3f0d3c46bdfb42592db926f99f7d4db3bdc487958b5a7ac1c8c273R16
I barely remenber the post says __esModule: true is the key, not sure what it means 😅

@lordrip lordrip merged commit 3100ee1 into kaoto-archive:main Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bean configuration UI
2 participants