Skip to content
This repository was archived by the owner on Mar 23, 2019. It is now read-only.

Issue #124 Logging in/out should refetch queries #156

Merged
merged 20 commits into from
Oct 10, 2018

Conversation

mike44441
Copy link
Contributor

These changes will refetch the queries when the user signs in or out. The changes will only apply when the user signs out from the dashboard and when the user would sign into the website from either the initial start or while navigating. The site will not refresh when the user cancels from the credentials and only applies when they successfully log in.

Currenty adding the list item to the sidebar of the dasboard. Currnetly using the PulseIcon as a filler for Purge Caches Icon.
Simple implemenetation of placing the cache purges and is currently using the pulse icon for the time being.
Adding Dashboard icon with unique icon

Created the new icon within the list of avaialble dashboard icons with a unique icon

For Issue taskcluster#122
Adding Dashboard icon with unique icon

Created the new icon within the list of avaialble dashboard icons with a unique icon. And not modifiying the .DS_Store files.

For Issue taskcluster#122
Changing src/views/.DS_Store to .DS_Store.
Removing the .DS_Store files.
Removing purges caches icon and replacing caches

Replacing Caches with Purge Caches and changing Purges Caches icon to the BackupRestoreIcon.
…terminated

Using the snackbar tools, added snackbar session when EC2 is terminated

Placing a snackbar instance when the user interacts with the Terminate Instance at the bottom center of the screen and will eventully disappate with a given message.

For Enhancement taskcluster#121
During the implemenation of the implementation of Snackbar, I wanted to try to see if I could change the buttons at the AWS section of the website and came up with this solutions.
This will reload the page both when the user signs in and signs out

The request is to refetch queries to make it so that the page will update once the user signs in or out.

For issue 124
For testing and based on attempting to create the snackbar. Familiarizing the variables avaialbe in the table. This would remove the terminate all if there are no instances in the EC2 tab
Updated to reload page when user signs in, but not when they cancel during sign in process

This will have it so that hte user can cancel the sign in during the credentials and not have the page reload. As to where before, if the user canceled, the page would reload

Update for taskcluster#124
Removing .DS_Store from the original
This will make it so the pull request will only be changing the two files invovled with the issue.
@mike44441 mike44441 requested a review from helfi92 as a code owner October 10, 2018 16:47
@djmitche
Copy link
Contributor

Hi @mike44441 - I'm curious if you're making this contribution as part of an Outreachy application? If so, please remember to include the contribution on your application at outreachy.org!

@mike44441
Copy link
Contributor Author

mike44441 commented Oct 10, 2018

Hey @djmitche, I am doing these issues as a part of my coursework and also because I want to participate in open source projects. Also, after spending time on this project, I have developed an interest to contribute more to it if I am able to.

@djmitche
Copy link
Contributor

Got it -- that's great! Let @helfi92 or me know if we can be helpful!

@mike44441
Copy link
Contributor Author

Awesome! Thanks, hope that this fixes the issue

Copy link
Contributor

@helfi92 helfi92 left a comment

Choose a reason for hiding this comment

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

Your solution works :) I think we can enhance the user experience by not reloading the page. Apollo provides a nice way of doing it: https://www.apollographql.com/docs/react/recipes/authentication.html#login-logout. We just need to replace window.location.reload by this.props.client.resetStore() and add some comments:

diff --git a/src/components/Dashboard/UserMenu.jsx b/src/components/Dashboard/UserMenu.jsx
index 15ea96a..3ff85f3 100644
--- a/src/components/Dashboard/UserMenu.jsx
+++ b/src/components/Dashboard/UserMenu.jsx
@@ -1,5 +1,6 @@
 import { Component, Fragment } from 'react';
 import { Link } from 'react-router-dom';
+import { withApollo } from 'react-apollo';
 import { withStyles } from '@material-ui/core/styles';
 import Avatar from '@material-ui/core/Avatar';
 import Menu from '@material-ui/core/Menu';
@@ -35,6 +36,7 @@ import SignInDialog from '../SignInDialog';
   },
 }))
 @withAuth
+@withApollo
 export default class UserMenu extends Component {
   state = {
     anchorEl: null,
@@ -60,7 +62,9 @@ export default class UserMenu extends Component {
   handleClickSignOut = () => {
     this.handleMenuClose();
     this.props.onUnauthorize();
-    window.location.reload();
+    // Since Apollo caches query results, it’s important to get rid of them
+    // when the login state changes.
+    this.props.client.resetStore();
   };
 
   render() {
diff --git a/src/components/SignInDialog/index.jsx b/src/components/SignInDialog/index.jsx
index b5daade..80983fd 100644
--- a/src/components/SignInDialog/index.jsx
+++ b/src/components/SignInDialog/index.jsx
@@ -1,4 +1,5 @@
 import { Component } from 'react';
+import { withApollo } from 'react-apollo';
 import { bool, func } from 'prop-types';
 import Avatar from '@material-ui/core/Avatar';
 import Dialog from '@material-ui/core/Dialog';
@@ -14,6 +15,7 @@ import { withAuth } from '../../utils/Auth';
 import CredentialsDialog from './CredentialsDialog';
 
 @withAuth
+@withApollo
 export default class SignInDialog extends Component {
   static propTypes = {
     open: bool.isRequired,
@@ -55,7 +57,9 @@ export default class SignInDialog extends Component {
         displayName: credentials.clientId,
       },
     });
-    window.location.reload();
+    // Since Apollo caches query results, it’s important to get rid of them
+    // when the login state changes.
+    this.props.client.resetStore();
     this.props.onClose();
   };

Changing from a reload to using withApollo for the handling of the refetching of queries during the sign in and sign-out

Update for Issue 124
@mike44441
Copy link
Contributor Author

Alright I'll do that right now, would you want me to leave the comments or remove them?

@helfi92
Copy link
Contributor

helfi92 commented Oct 10, 2018

You can leave the comments to make it more readable :)

@mike44441
Copy link
Contributor Author

I just pushed with the changes requested. =)

Copy link
Contributor

@helfi92 helfi92 left a comment

Choose a reason for hiding this comment

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

🥇

@helfi92 helfi92 merged commit 1ddf896 into taskcluster:master Oct 10, 2018
@helfi92
Copy link
Contributor

helfi92 commented Oct 11, 2018

@mike44441 #158 might be of interest to you. I can provide help as always :) Let me know if you're interested.

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.

3 participants