Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix #77: added Panel component #148

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

Merged

Conversation

halkosajtarevic
Copy link
Contributor

@hpehl is there any place where i could add tests? or how would i add them? didn't find any besides the showcase, and will add a PR there too, after this one

@@ -55,7 +55,7 @@ protected <C extends BaseComponent<E1, B1>, E1 extends HTMLElement, B1 extends T

protected <C extends BaseComponent<E1, B1>, E1 extends HTMLElement, B1 extends TypedBuilder<E1, B1>> C lookupComponent(
boolean lenient) {
return ComponentStore.lookup(componentType, element, false);
return ComponentStore.lookup(componentType, element, lenient);
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 noticed this one during random code reading - hope the fix as part of this commit is fine

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix!

@hpehl
Copy link
Contributor

hpehl commented Jan 8, 2024

I usually test new components using the showcase. I only write unit test for non-ui related code. If necessary I use mockito to mock UI code (see

private void mockLogger(Runnable block) {
)

Copy link
Contributor

@hpehl hpehl left a comment

Choose a reason for hiding this comment

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

First of all thanks for your contribution! I left some comments on PR. Please feel free to ask further questions or raise concerns if you have a different opinion.

import static org.patternfly.core.Aria.labelledBy;
import static org.patternfly.style.Classes.*;

public class Panel extends BaseComponentFlat<HTMLDivElement, Panel> implements Attachable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add a minimal Javadoc comment. I usually copy/paste from the PatternFly component page and add a link to the PatternFly component.

import static org.patternfly.core.Aria.labelledBy;
import static org.patternfly.style.Classes.*;

public class Panel extends BaseComponentFlat<HTMLDivElement, Panel> implements Attachable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please re-arrange the code sections, so that it matches the TemplateComponent? Static factories should go first, then the instance methods, then add methods, then modifiers, and so on.

}

public Panel add(PanelHeader header) {
if (this.header != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we should throw an exception here. I prefer not adding a second header and log an error/warning. Something like Logger.unsupported(ComponentType, Element, String). Same for body and footer.

}

@Override
public void attach(MutationRecord mutationRecord) {
Copy link
Contributor

@hpehl hpehl Jan 8, 2024

Choose a reason for hiding this comment

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

Attachable is not necessary here. Please remove implements Attachable and remove this empty method.

}
this.header = header;
element().appendChild(header.element());
element().appendChild(hr().css(divider).element());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't add a divider implicitly. Instead add a addDivider() method like in https://github.com/patternfly-java/patternfly-java/blob/main/src/main/java/org/patternfly/component/menu/Menu.java#L147

return this;
}

public Panel addBody(String body) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the addBody() methods should be renamed to addMain(). That aligns more to the PatternFly component IMO. And the PanelBody sub component should be renamed to PanelMain. But I like the usage of ElementDelegate<>.

@hpehl
Copy link
Contributor

hpehl commented Jan 9, 2024

LGTM! Thanks for your contribution @halkosajtarevic

Welcome to PatternFly Java πŸŽ‰
I'm looking forward to your next contribution. The choice is yours #125 πŸ˜‰

@hpehl hpehl merged commit 8c4d9aa into patternfly-java:main Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants