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

AppRepoList v2 #1915

Merged
merged 2 commits into from
Aug 20, 2020
Merged

AppRepoList v2 #1915

merged 2 commits into from
Aug 20, 2020

Conversation

andresmgot
Copy link
Contributor

@andresmgot andresmgot commented Jul 31, 2020

Description of the change

First PR for adding support for the App Repo list management view:

Screenshot from 2020-08-18 17-16-57

Since this view is quite complex, this PR only contains the code related to the repository table and the different buttons. I will send other PRs for:

Note that the buttons in the table are "outlined" rather than "flat" because I found a weird behavior: it's not possible to set the color to red ("danger") for flat buttons, the parameter gets ignored.

@andresmgot andresmgot changed the title Draft: WIP for AppRepoList v2 AppRepoList v2 Aug 18, 2020
@andresmgot andresmgot marked this pull request as ready for review August 18, 2020 15:50
@andresmgot andresmgot requested a review from absoludity August 19, 2020 07:26
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.

Great, just a few questions, no blockers.

const closeModal = () => setModalOpen(false);
const { errors } = useSelector((state: IStoreState) => state.repos);
// Primary by default
const isPrimary = primary !== false;
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it's handling the possibility of an undefined for primary as it's optional. In which case, why not just define the default above in the function args as primary = true, ... (see https://stackoverflow.com/a/32596200 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right

<Modal showModal={modalIsOpen} onModalClose={closeModal}>
{errors.create && (
<Alert theme="danger">
Found an error creating the repository: {errors.create.message}
Copy link
Contributor

Choose a reason for hiding this comment

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

"An error occurred while creating the repository: {...}"?

<>
{errors.fetch && (
<Alert theme="danger">
Found an error fetching repositories: {errors.fetch.message}
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 guessing you're just re-using the existing messages, so fine to leave as is, but normally an application doesn't find an error, an error occurs... hence suggesting "An error occurred while fetching repositories: {...}" etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Yes, I have been using this form of Error found in all places. I'll open a new PR to fix all.

const dispatch = useDispatch();

const handleResyncAllClick = async () => {
// Fake timeout to show progress
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we faking showing progress when the actual repo is being refreshed? IMO either we shouldn't pretend and instead just use a user info "Repository refresh requested. It may take x minutes to complete.", or it should show actual progress? Again, fine without, just wondering what the longer-term plan is for this "progress".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just a hot fix because right now, there is no feedback for this button so if you click, it seems that nothing happens. Ideally, this should report information back and show the real progress but we don't have that info. Another option would be to disable the button while sending the request to resync the repo but that is so fast that people won't be able to notice. That's why I think adding this feedback is better from a UX. In any case, will add a comment with the desirable behavior.

@@ -31,7 +36,7 @@ export const defaultStore = mockStore(initialState);
// getStore returns a store initialised with a merge of
// the initial state with any passed extra state.
export const getStore = (extraState: object) => {
const state = { ...initialState };
const state = cloneDeep(initialState);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ouch - did you find that by tests writing state then seen in other tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, {...object} only performs a shallow copy, keeping references to inner objects:

> a = {a: 1, b: {c: 2}}
{ a: 1, b: { c: 2 } }
> b = {...a}
{ a: 1, b: { c: 2 } }
> b.b.c = 3
3
> a
{ a: 1, b: { c: 3 } }

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep yep, I realise, but also realised that I wrote that code the other week and was saying "ouch" because you may have had to find that bug the hard way (ie. tests failing because of contaminated test data)... hopefully you just noticed it while passing by and didn't suffer as a result :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, I found this with weird test results :P but it was easy to spot

@andresmgot andresmgot merged commit 6d0d39d into master Aug 20, 2020
alexandredantas pushed a commit to alexandredantas/kubeapps that referenced this pull request Aug 26, 2020
* AppRepoList v2

* Review
@andresmgot andresmgot deleted the appRepoListV2 branch September 8, 2020 08:57
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