-
Notifications
You must be signed in to change notification settings - Fork 60
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 feedback button #962
Add feedback button #962
Changes from 1 commit
7869e40
f229b26
5dc81c5
6b8e0fd
fa7c8cd
1bbb612
93480a9
2ec741f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ hand-in-hand. | |
*/ | ||
|
||
import { START_LOCATION } from 'vue-router'; | ||
import { inject, onBeforeUnmount } from 'vue'; | ||
import { computed, inject, onBeforeUnmount, provide } from 'vue'; | ||
|
||
import { afterNextNavigation, forceReplace } from './router'; | ||
import { apiPaths, isProblem, requestAlertMessage } from './request'; | ||
|
@@ -194,13 +194,28 @@ const logOutAfterStorageChange = (container) => (event) => { | |
|
||
export const useSessions = () => { | ||
const container = inject('container'); | ||
const id = setInterval(logOutBeforeSessionExpires(container), 15000); | ||
const handler = logOutAfterStorageChange(container); | ||
window.addEventListener('storage', handler); | ||
const intervalId = setInterval(logOutBeforeSessionExpires(container), 15000); | ||
const storageHandler = logOutAfterStorageChange(container); | ||
window.addEventListener('storage', storageHandler); | ||
onBeforeUnmount(() => { | ||
clearInterval(id); | ||
window.removeEventListener('storage', handler); | ||
clearInterval(intervalId); | ||
window.removeEventListener('storage', storageHandler); | ||
}); | ||
|
||
/* visiblyLoggedIn.value is `true` if the user not only has all the data from | ||
login, but is also visibly logged in. An example of when the user has data, | ||
but isn't visibly logged in is if the user has submitted the login form and is | ||
being redirected to outside Frontend (which isn't instant). In that case, they | ||
will remain on /login until the redirect is complete, and the navbar will not | ||
change to reflect their login. */ | ||
const { router, requestData } = container; | ||
const { currentUser } = requestData; | ||
const visiblyLoggedIn = computed(() => currentUser.dataExists && | ||
router.currentRoute.value !== START_LOCATION && | ||
router.currentRoute.value.path !== '/login'); | ||
Comment on lines
+213
to
+215
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I adapted |
||
provide('visiblyLoggedIn', visiblyLoggedIn); | ||
|
||
return { visiblyLoggedIn }; | ||
}; | ||
|
||
export const restoreSession = (session) => | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,23 @@ | ||
import sinon from 'sinon'; | ||
|
||
import Navbar from '../../../src/components/navbar.vue'; | ||
import NavbarActions from '../../../src/components/navbar/actions.vue'; | ||
|
||
import { load } from '../../util/http'; | ||
import { mockLogin } from '../../util/session'; | ||
import { mockRouter } from '../../util/router'; | ||
import { mount } from '../../util/lifecycle'; | ||
|
||
describe('NavbarActions', () => { | ||
it('indicates if the user is not logged in', () => { | ||
const navbar = mount(Navbar, { | ||
container: { router: mockRouter('/login') }, | ||
global: { | ||
// Stubbing AnalyticsIntroduction because of its custom <router-link> | ||
stubs: { AnalyticsIntroduction: true } | ||
} | ||
}); | ||
const text = navbar.getComponent(NavbarActions).get('a').text(); | ||
text.should.equal('Not logged in'); | ||
}); | ||
it('indicates if the user is not logged in', () => | ||
load('/login') | ||
Comment on lines
-12
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also could have patched the test by injecting |
||
.restoreSession(false) | ||
.afterResponses(app => { | ||
const text = app.getComponent(NavbarActions).get('a').text(); | ||
text.should.equal('Not logged in'); | ||
})); | ||
|
||
it("shows the user's display name", async () => { | ||
mockLogin({ displayName: 'Alice Allison' }); | ||
const navbar = mount(Navbar, { | ||
container: { router: mockRouter('/') }, | ||
global: { | ||
stubs: { AnalyticsIntroduction: true } | ||
} | ||
}); | ||
const a = navbar.getComponent(NavbarActions).get('a'); | ||
const app = await load('/'); | ||
const a = app.getComponent(NavbarActions).get('a'); | ||
a.text().should.equal('Alice Allison'); | ||
await a.get('span:nth-child(2)').should.have.textTooltip(); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, nice!