Skip to content
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

Remove old js components: Card, Table #6560

Merged
merged 61 commits into from
Aug 10, 2023

Conversation

antgamdia
Copy link
Contributor

@antgamdia antgamdia commented Aug 3, 2023

Description of the change

This PR is following up #6554 (and requires it to get merged first). In this final one, the focus is on:

  • Transform the Card and its sub-components to tsx.
  • Transform the Table to tsx
  • Remove the remaining test snapshots

Benefits

No cool before/after pics this time :P Here we have just migrated js-based code to typescript.
However, after this PR we will able to say we finally got rid of the legacy js-components!!

Possible drawbacks

N/A - hopefully.

Applicable issues

Related to #6563

Additional information

While transforming the Card to tsx I also had a look at the CdsCard from Clarity. Unfortunately, there is no drop-in replacement; a migration would require plenty of style-related changes. Besides, the "native" style differs a bit from the general style we have in Kubeapps. Below are some examples:

Example from the Clarity website

image

Quick/dirty replacement, it does not look good

image

Our current custom card

image

Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>

Conflicts:
	dashboard/src/components/AppList/AppListItem.tsx
	dashboard/src/components/AppView/AccessURLTable/AccessURLTable.tsx
	dashboard/src/components/AppView/AppControls/RollbackButton/RollbackDialog.test.tsx
	dashboard/src/components/Config/PkgRepoList/PkgRepoList.tsx
	dashboard/src/components/SearchFilter/SearchFilter.tsx
	dashboard/src/components/hooks/useOutsideClick/useOutsideClick.test.tsx
	dashboard/src/components/js/hooks/useOutsideClick/useOutsideClick.test.js
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
@netlify
Copy link

netlify bot commented Aug 3, 2023

Deploy Preview for kubeapps-dev canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 6e92f1b
🔍 Latest deploy log https://app.netlify.com/sites/kubeapps-dev/deploys/64d368965504180008ec36b0

Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
@antgamdia antgamdia changed the title Remove js components 3 Remove old js components: Card, Table Aug 3, 2023
Signed-off-by: Antonio Gamez Diaz <[email protected]>

Conflicts:
	dashboard/src/components/AppView/AppView.tsx
	dashboard/src/components/Catalog/Catalog.tsx
	dashboard/src/components/DeploymentForm/DeploymentForm.tsx
	dashboard/src/components/OperatorInstance/OperatorInstance.tsx
	dashboard/src/components/OperatorList/OperatorList.tsx
	dashboard/src/components/OperatorNew/OperatorNew.tsx
	dashboard/src/components/OperatorView/OperatorView.tsx
	dashboard/src/components/PackageHeader/PackageView.test.tsx
	dashboard/src/containers/ConfigLoaderContainer/ConfigLoaderContainer.ts
	dashboard/src/containers/RoutesContainer/Routes.test.tsx
	dashboard/src/containers/RoutesContainer/Routes.tsx
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>

Conflicts:
	dashboard/src/components/AppView/AppView.tsx
	dashboard/src/components/Catalog/Catalog.tsx
	dashboard/src/components/ConfigLoader/ConfigLoader.tsx
	dashboard/src/components/DeploymentForm/DeploymentForm.tsx
	dashboard/src/components/Header/ContextSelector.test.tsx
	dashboard/src/components/OperatorInstance/OperatorInstance.tsx
	dashboard/src/components/OperatorInstanceForm/OperatorInstanceForm.tsx
	dashboard/src/components/OperatorInstanceUpdateForm/OperatorInstanceUpdateForm.test.tsx
	dashboard/src/components/OperatorInstanceUpdateForm/OperatorInstanceUpdateForm.tsx
	dashboard/src/components/OperatorList/OperatorList.tsx
	dashboard/src/components/OperatorNew/OperatorNew.test.tsx
	dashboard/src/components/OperatorNew/OperatorNew.tsx
	dashboard/src/components/OperatorView/OperatorView.test.tsx
	dashboard/src/components/OperatorView/OperatorView.tsx
	dashboard/src/components/PackageHeader/PackageView.test.tsx
	dashboard/src/components/PackageHeader/PackageView.tsx
	dashboard/src/components/UpgradeForm/UpgradeForm.tsx
	dashboard/src/components/js/Button/Button.test.js
	dashboard/src/containers/ConfigLoaderContainer/ConfigLoaderContainer.ts
Signed-off-by: Antonio Gamez Diaz <[email protected]>

Conflicts:
	dashboard/src/components/AppList/AppListGrid.tsx
	dashboard/src/components/AppUpgrade/AppUpgrade.test.tsx
	dashboard/src/components/AppUpgrade/AppUpgrade.tsx
	dashboard/src/components/AppView/AppControls/RollbackButton/RollbackDialog.tsx
	dashboard/src/components/AppView/AppView.tsx
	dashboard/src/components/Catalog/Catalog.tsx
	dashboard/src/components/ConfirmDialog/ConfirmDialog.tsx
	dashboard/src/components/DeploymentForm/DeploymentForm.tsx
	dashboard/src/components/Header/ContextSelector.tsx
	dashboard/src/components/OperatorInstance/OperatorInstance.tsx
	dashboard/src/components/OperatorInstanceForm/OperatorInstanceForm.tsx
	dashboard/src/components/OperatorInstanceUpdateForm/OperatorInstanceUpdateForm.tsx
	dashboard/src/components/OperatorList/OperatorList.tsx
	dashboard/src/components/OperatorNew/OperatorNew.tsx
	dashboard/src/components/OperatorView/OperatorView.tsx
	dashboard/src/components/PackageHeader/PackageReadme.tsx
	dashboard/src/components/PackageHeader/PackageView.tsx
	dashboard/src/components/SelectRepoForm/SelectRepoForm.tsx
	dashboard/src/components/UpgradeForm/UpgradeForm.tsx
	dashboard/src/components/js/Button/Button.test.js
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>

Conflicts:
	dashboard/src/components/Config/PkgRepoList/PkgRepoList.tsx
	dashboard/src/components/FilterGroup/__snapshots__/FilterGroup.test.tsx.snap
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>
Signed-off-by: Antonio Gamez Diaz <[email protected]>

Conflicts:
	dashboard/src/components/Config/PkgRepoList/PkgRepoList.test.tsx
	dashboard/src/components/Config/PkgRepoList/PkgRepoList.tsx
	dashboard/src/components/OperatorInstanceUpdateForm/OperatorInstanceUpdateForm.tsx
@antgamdia antgamdia marked this pull request as ready for review August 7, 2023 08:41
Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

Sorry, I'd missed that this one was still waiting for a review.

Comment on lines +1 to +17
// Copyright 2020-2023 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0

export interface ICardImageProps {
src: string;
alt: string;
}

const CardImage = ({ src, alt }: ICardImageProps) => {
return (
<div className="card-img">
<img src={src} alt={alt} />
</div>
);
};

export default CardImage;
Copy link
Contributor

Choose a reason for hiding this comment

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

Almost doesn't seem worth a separate component?

Comment on lines +1 to +14
// Copyright 2020-2023 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0

import React from "react";

export interface ICardTextProps {
children: React.ReactNode;
}

const CardText = ({ children }: ICardTextProps) => {
return <div className="card-text">{children}</div>;
};

export default CardText;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Is it a react thing to break the elements up like this? Seems like a /InfoCard/Card could just have the text and image without splitting those out into separate components?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100% agree, no actual benefits, especially if we ever plan to use the card from clarity at some point in the future. I thought the same while moving the code to tsx. I'll make a follow-up PR with the changes shortly.

@antgamdia antgamdia merged commit 9f12c5a into vmware-tanzu:main Aug 10, 2023
38 checks passed
@antgamdia antgamdia deleted the remove-js-components-3 branch August 10, 2023 07:22
antgamdia added a commit that referenced this pull request Aug 14, 2023
### Description of the change

As pointed out
#6560 (comment),
we were using plenty of sub-components with no clear motivation. This is
to simplify the `InfoCard` component in a single one, as it is just
`<div>` and CSS classes.

### Benefits

No unused or with extra complexity code.

### Possible drawbacks

N/A

### Applicable issues

- related #6563

### Additional information

Before/after pics, they look exactly the same, which is what is intended
here.


![image](https://github.com/vmware-tanzu/kubeapps/assets/11535726/03bc0a9d-256b-4a42-81fd-98159a181b63)


Extra: I'm also squeezing two minor CSS changes: 1) I [ran a tool for
detecting unused
code](https://www.npmjs.com/package/webpack-deadcode-plugin), and
noticed there were some CSS files being inconsistently imported; 2) the
secrets view was badly positioned, see below:

<details><summary>Secrets view</summary>


![image](https://github.com/vmware-tanzu/kubeapps/assets/11535726/c87e8689-ec1f-4454-91bb-fcfe1a2cdb04)

</details>

---------

Signed-off-by: Antonio Gamez Diaz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants