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

Add remove app button #989

Merged
merged 12 commits into from Nov 4, 2021
Merged

Add remove app button #989

merged 12 commits into from Nov 4, 2021

Conversation

joshri
Copy link
Contributor

@joshri joshri commented Oct 29, 2021

Closes: #904

The biggest changes here are in the ApplicationDetail page, where a remove app button has been added along with error handling for a failed GitHub authentication. You can see the functionality below!

Screen.Recording.2021-10-28.at.8.26.14.PM.mov

NOTE: I already fixed the wonky spacing of the Error Alert since the creation of the video -__-

Some additional styling changes to get things looking right: addition of topRight prop to the breadcrumbs section to add remove button, size adjustments in Layout to prevent content from overflowing horizontally, and customPadding and customMargin options added to Spacer.

The other big change is in the backend to include the namespace as part of the DELETE request.

One big thing I want to change: I'd like to tie the github authentication success to clearing the authentication error on the first modal. My solution for now is to close the first modal on clicking the authenticate with github button, but that requires the user to make an extra click after returning from github - Jordan I think you managed to do this on the Add Application button - do you think it's possible here as well? I also need to change the ugliness of the loading circle within the button.

@joshri joshri added the area/ui Issues that require front-end work label Oct 29, 2021
@jpellizzari
Copy link
Contributor

@joshri Can you edit the title of this PR to read like a commit message/release note? Here are some examples: https://github.com/weaveworks/weave-gitops/releases/tag/v0.3.3

@joshri joshri changed the title 904 remove app button Add remove app button Oct 29, 2021
@jpellizzari
Copy link
Contributor

@joshri What about if we created a RemoveApp page to handle all the authentication state? Maybe we are forcing too much on the ApplicationDetail page.

So clicking the Remove Application button would navigate to the remove app page, where we can do all the GH auth stuff without losing the context.

WDYT (what do you think)?

Copy link
Contributor

@jpellizzari jpellizzari left a comment

Choose a reason for hiding this comment

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

Looks like some other branch or commit made it into this one. LMK if you need help getting your git state corrected.

@@ -134,7 +134,7 @@ jobs:

acceptance-tests-0:
runs-on: ubuntu-latest
needs: [lint, build, test]
needs: [lint, build]
Copy link
Contributor

Choose a reason for hiding this comment

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

? Whats up with these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't know what I'm doing 😦 not sure how I caused that!

Makefile Outdated
@@ -169,10 +169,10 @@ coverage/merged.lcov: coverage/lcov.info coverage/golang.info
##@ Utilities

.PHONY: help
# Thanks to https://www.thapaliya.com/en/writings/well-documented-makefiles/
# Thanks to https://www.thapaliya.com/en/writings/well-documented-s/
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The node_modules thing I'm almost positive we did on purpose - the parts where makefile is deleted are certainly........suspicious

README.md Show resolved Hide resolved
@@ -1,4 +1,4 @@
package add
package app
Copy link
Contributor

Choose a reason for hiding this comment

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

? It looks like some other changes leaked into your branch

height: 100%;
margin: 0 auto;
padding: 0;
background-color: ${negativeSpaceColor};
`;

const NavContainer = styled.div`
width: 240px;
min-width: 200px;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't have expected layout params to change. This side-bar being variable width will cause some issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NavContainer was a set width, but ContentContainer was not - which caused weird interactions with elements inside ContentContainer being able to overflow ContentContainer itself. I found that setting the x-overflow on AppContainer kept ContentContainer and NavContainer in check, and got the percentages working as I expected them too - this might be possible without making changes in Layout but I thought that we wouldn't want x-overflow in almost all situations anyway. Now the min-width...I can't exactly remember WHY I did it that way but I'm sure I had a brilliant and well-thought-out reason - will revert it and see what happens

Copy link
Contributor

Choose a reason for hiding this comment

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

Please take another look at this. I would really like this to be a fixed width, media queries notwithstanding

React.useEffect(() => {
if (!removeRes) return;
//if app is succesfully removed, redirect to applications page
history.push(defaultLinkResolver(PageRoute.Applications));
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to pull the linkResolver from AppContext. That way, if another context provider gives a different linkResolver, the navigation will work.

const RemoveAppAuthError = (
<div>
{removeError?.code === 16 ? (
!authSuccess && (
Copy link
Contributor

Choose a reason for hiding this comment

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

This is confusing. It would be better to build this into the above conditional.

Suggested change
!authSuccess && (
removeError?.code === 16 && !authSuccess && ()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah...this was my solution to not being able to reset the error - I have to still display an error that's not authentication related, but if authentication has actually happened but the error still exists, display nothing. That probably sounds like nonsense.

ui/pages/ApplicationDetail.tsx Outdated Show resolved Hide resolved
ui/pages/ApplicationDetail.tsx Outdated Show resolved Hide resolved
<Flex align wide between>
<TitleBar>
<Flex align between>
<TitleBar style={{ width: "25%" }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Re inline styles:
https://c.tenor.com/PLpe-LYpJUcAAAAC/shame-gameofthrones.gif

Not sure if this is left over, but it probably won't work for us. Why wouldn't this be full width?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having it full width ends up wrapping the button text. I kind of wish everything had a width prop or something like that where I don't have to make a whole class or component to change one style (usually width or height) you know?

Copy link
Contributor

Choose a reason for hiding this comment

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

Something else is going on if the text inside the button is wrapping because of another component's width.

I kind of wish everything had a width prop

That would be inline styles...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow did I just invent inline styles? Great minds. What's the best way for me to add one line of style to something? The TitleBar width is initially 100% and the Button isn't set so it takes up the minimum amount of space.

Copy link
Contributor

Choose a reason for hiding this comment

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

Inline style would be fine here, but I disagree with the 25% value. I would have to play around and figure out the right values. Maybe <Flex align end /> instead of <Flex align between /> would give you what you want?

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 think it's the Link component that is limiting the width of the button - made a class for it.

@joshri
Copy link
Contributor Author

joshri commented Oct 29, 2021

@jpellizzari Here's an updated vid from the latest commit featuring an upgraded UX!

Screen.Recording.2021-10-29.at.5.09.53.PM.mov

@jpellizzari
Copy link
Contributor

@joshri How does it know you are not authenticated BEFORE you click remove?

@joshri
Copy link
Contributor Author

joshri commented Nov 2, 2021

It knows because of the 'authSuccess' state variable we're using to check the auth for commit history. I'm just reusing that variable!

@jpellizzari
Copy link
Contributor

It knows because of the 'authSuccess' state variable we're using to check the auth for commit history. I'm just reusing that variable!

Oh very slick...

@joshri joshri marked this pull request as ready for review November 2, 2021 17:05
@joshri joshri requested a review from bia November 2, 2021 17:05
Copy link
Contributor

@jpellizzari jpellizzari left a comment

Choose a reason for hiding this comment

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

LGTM, no major issues. Nice work! This was a hard one.

height: 100%;
margin: 0 auto;
padding: 0;
background-color: ${negativeSpaceColor};
`;

const NavContainer = styled.div`
width: 240px;
min-width: 200px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please take another look at this. I would really like this to be a fixed width, media queries notwithstanding

ui/components/Page.tsx Outdated Show resolved Hide resolved
ui/pages/ApplicationDetail.tsx Outdated Show resolved Hide resolved
ui/pages/ApplicationDetail.tsx Outdated Show resolved Hide resolved
open={removeAppModalOpen}
onClose={() => setRemoveAppModalOpen(false)}
title="Are You Sure?"
description={`You are about to remove ${application.name} from Weave GitOps!`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description={`You are about to remove ${application.name} from Weave GitOps!`}
description={`You are about to remove ${application.name} from Weave GitOps`}

@joshri
Copy link
Contributor Author

joshri commented Nov 2, 2021

@jpellizzari Got all those fixes in the latest commit! Thanks!

Copy link

@bia bia left a comment

Choose a reason for hiding this comment

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

LGTM @joshri 🚀
Thank you for the videos, they are very helpful.

Just 2 comments :

  • Is the pink colour of the remove app button used anywhere else in weave-gitops so far? I know that it is a material design recommendation, but I would prefer Weave Cloud's orange800

  • The second dialog ('Authenticate with GitHub') shifts down in position while it is loading, maybe it could just have the same y position as the first one ('Are You Sure?')

Screenshot 2021-11-03 at 12 47 51

@joshri
Copy link
Contributor Author

joshri commented Nov 3, 2021

orange800 is looking a little dark -
image

Here's orange600 -Screen Shot 2021-11-03 at 1 50 55 PM

Here's orange500 -
Screen Shot 2021-11-03 at 1 52 55 PM

@bia what do you think?

@bia
Copy link

bia commented Nov 3, 2021

Good catch! I like orange600

…ded modal and circular progress height to avoid jittering when removing app
@@ -117,7 +117,7 @@ function GithubDeviceAuthModal({

<Flex wide center>
{codeLoading || !codeRes ? (
<CircularProgress />
<CircularProgress size={143} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Sort of a random value here. Can we pick some sizes that will keep things consistent? Small, Medium, Large?

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 the value only because that's the exact size of the text that replaces it - I could wrap both in a div with a set size which would definitely be better

ui/components/Layout.tsx Show resolved Hide resolved
background-color: ${(props) => props.theme.colors.white};
margin: 0 auto;
height: 400px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want ALL Modals to have this height?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah...the github auth and remove app modals need to be the same height. I could make a class for the two of them which again, is probably better

applicationsClient.RemoveApplication({
name: application.name,
namespace: application.namespace,
//CAN'T FIND AUTOMERGE IN APPLICATION OBJECT
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this comment yelling at me? 😉

Can you phrase this as a note for the next person to come across this code?

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 wrote that so I would remember and then I forgot about it which is an absolute classic. Will do.

ui/pages/ApplicationDetail.tsx Show resolved Hide resolved
…d added option to position alerts icenter rather than flex-start
@joshri joshri merged commit a7a1fa4 into main Nov 4, 2021
@joshri joshri deleted the 904-remove-app-button branch November 4, 2021 15:42
joshri added a commit that referenced this pull request Nov 4, 2021
* Allow for body to be passed in HTTP delete method for RemoveApplication

* Add Remove App button

* Update README with command npm run test -- -u to update css snapshots

* reverted Spacer and Makefile, and changed Remove App confirm text

* Reorganize remove app modal display to improve ux and actually revert Makefile

* removed inline style on Application TitleBar

* update snapshots

* small cleanup - text changes, nav bar width, and rremoving extra button variable

* added orange600 as the value for secondary in the mui theme, chard coded modal and circular progress height to avoid jittering when removing app

* update snapshots

* adjusted modal size to account for error alert in GithubAuthModal, and added option to position alerts icenter rather than flex-start

Co-authored-by: Jordan Pellizzari <jordan@weave.works>
Co-authored-by: Joshua Israel <joshua.israel@weave.works>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui Issues that require front-end work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a "Remove App" button to the UI
3 participants