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

feat(stark-ui): implementation of a session timeout warning #876

Conversation

Mallikki
Copy link
Contributor

@Mallikki Mallikki commented Nov 21, 2018

ISSUES CLOSED: #719

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

Issue Number: #119 #719

What is the new behavior?

A new SessionTimeoutWarning dialog will be displayed when the user is inactive for too long, along with a timer.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 93.606% when pulling 7e82c3b on Mallikki:feature/session-timeout-warning into c414f9b on NationalBankBelgium:master.

@coveralls
Copy link

coveralls commented Nov 21, 2018

Coverage Status

Coverage increased (+0.08%) to 93.646% when pulling 578b8a2 on Mallikki:feature/session-timeout-warning into 962e0fb on NationalBankBelgium:master.

@Mallikki
Copy link
Contributor Author

Hey guys, I still need to look after the translation problem, but I've made the pull request anyway so you can already have a look at the change ;)

Copy link
Collaborator

@christophercr christophercr left a comment

Choose a reason for hiding this comment

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

Some changes... one of them might solve the issue with the translations :)

@@ -0,0 +1,43 @@
# Session Timeout Warning configuration

If you wish your project to warn the user that its session is about to end, you can use our `SessionTimeoutWarningDialogComponent`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can re-phrase this like:

"Stark provides a nice feature when it comes to session expiration handling: in case the user's session is about to end due to inactivity (the user is idle for some time) and you want to warn him about this. This is what the SessionTimeoutWarningDialogComponent does and also asks the user whether to keep his session alive."

What do you think?


If you wish your project to warn the user that its session is about to end, you can use our `SessionTimeoutWarningDialogComponent`.

To do so, you'll have to modifiy the `app.module.ts` file of your application.
Copy link
Collaborator

Choose a reason for hiding this comment

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

"To use this feature, you'll have to modify the app.module.ts file of your application."

```
import {
StarkSessionUiModule
} from "@nationalbankbelgium/stark-ui";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you put this import in one single line to make it more readable?

StarkSessionUiModule
} from "@nationalbankbelgium/stark-ui";

//the timeoutWarningDialogEffects won't be used
Copy link
Collaborator

Choose a reason for hiding this comment

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

??

@NgModule({
imports: [
StarkSessionUiModule.forRoot({
enableTimeoutWarningDialogEffects: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

As we discussed, can you rename this option to "timeoutWarningDialogDisabled" so we keep consistency with the way the options in stark-app-config are named?

);

/**
* Definition of the configuration object for the Stark Session service
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Stark Session UI module"

*/
export class StarkSessionUiConfig {
/**
* Router state for the Login page where the user can choose a profile and use it to impersonate himself as someone else.
Copy link
Collaborator

Choose a reason for hiding this comment

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

??

* Router state for the Login page where the user can choose a profile and use it to impersonate himself as someone else.
* This state is only used in DEVELOPMENT.
*/
public enableTimeoutWarningDialogEffects?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As we discussed, can you rename this option to "timeoutWarningDialogDisabled" so we keep consistency with the way the options in stark-app-config are named?

const english: StarkLocale = { languageCode: "en", translations: translationsEn };
const french: StarkLocale = { languageCode: "fr", translations: translationsFr };
const dutch: StarkLocale = { languageCode: "nl", translations: translationsNl };
mergeUiTranslations(translateService, english, french, dutch);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is why the translations are not working anymore in the Session UI module :p Maybe a rebase problem?

@@ -235,7 +235,9 @@ export const metaReducers: MetaReducer<State>[] = ENV !== "production" ? [logger
position: "top right",
actionClasses: []
}),
StarkSessionUiModule.forRoot(),
StarkSessionUiModule.forRoot({
enableTimeoutWarningDialogEffects: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can revert this change when you rename this option to "timeoutWarningDialogDisabled" as I mentioned in my comments above ;)

@christophercr christophercr added this to the 10.0.0-beta.2 milestone Nov 21, 2018
@Mallikki Mallikki force-pushed the feature/session-timeout-warning branch 2 times, most recently from 2f03dba to 7887ba6 Compare November 22, 2018 10:31
Copy link
Collaborator

@christophercr christophercr left a comment

Choose a reason for hiding this comment

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

Some small changes to do.
Also be careful with the fit in the unit tests. You can easily notice this by checking the comments from Coveralls, in this case your PR decreased the coverage in almost 30%! So obviously this indicates there is an fit somewhere

@NgModule({
imports: [
StarkSessionUiModule.forRoot({
timeoutWarningDialogDisabled: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

This option should not be defined if they want the dialog to be shown. In fact this should be put in the code example below :p

@NgModule({
imports: [
StarkSessionUiModule.forRoot(),
...
Copy link
Collaborator

Choose a reason for hiding this comment

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

The option should be passed here :p

})
```

To indicate that you don't wish to use this effect, just set `timeoutWarningDialogDisabled` value to true.
Copy link
Collaborator

Choose a reason for hiding this comment

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

"To indicate that you don't wish to display such warning dialog, "


To indicate that you don't wish to use this effect, just set `timeoutWarningDialogDisabled` value to true.

If you don't pass this value (or if you set it to false), it will be set to false by default:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This text is a bit repetitive... I suggest to add in the line before: "This option is "false" by default.

@@ -20,7 +22,8 @@ import { StarkAppContainerComponent } from "./components";
StoreModule.forFeature("StarkSession", starkSessionReducers),
UIRouterModule.forChild({
states: SESSION_STATES
})
}),
EffectsModule.forFeature([StarkSettingsEffects])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change is wrong... I think this file got messed up with a rebase or something. Just revert these changes.


(<Spy>mockObserver.next).calls.reset();

// the effects should keep on running with any action other than the "stopping action"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the other than the "stopping action" part ;)


(<Spy>mockObserver.next).calls.reset();

// the effects should keep on running with any action other than the "stopping action"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the other than the "stopping action" part ;)

imports: [
CommonModule,
UIRouterModule.forChild({
states: SESSION_UI_STATES
}),
StarkSessionModule,
StarkLoggingModule,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove these two modules otherwise we are creating a hard link between the different modules of Stark.

Our goal is to have soft links, meaning that we just require the services (which the developer can provide by his own) but not the Stark modules themselves.

*/
export class StarkSessionUiConfig {
/**
* If the warning dialog effect is disabled or not
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's expand this description so that it is clear we use an effect for this. What about this?

"Whether the warning dialog should be displayed or not. If true, then the Ngrx Effects in charge of displaying the dialog won't be executed."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

much better

Stark provides a nice feature when it comes to session expiration handling: in case the user's session is about to end due
to inactivity (the user is idle for some time) and you want to warn him about this, a dialog will be displayed.

This is what the `SessionTimeoutWarningDialogComponent` does and also asks the user if its session should be kept alive.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add this in the same line to explain how we do this ;)

"This warning dialog is displayed by an NGRX Effect that triggers when a StarkSessionActionTypes.SESSION_TIMEOUT_COUNTDOWN_START action is dispatched (by the Session service when the user becomes idle)."

@Mallikki Mallikki force-pushed the feature/session-timeout-warning branch from 7887ba6 to e5e6436 Compare November 22, 2018 12:52
Copy link
Collaborator

@christophercr christophercr left a comment

Choose a reason for hiding this comment

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

I just noticed some other small changes to be done... sorry

STAY_CONNECTED: "Stay connected",
TITLE: "Session timeout warning",
WILL_EXPIRE_IN: "Your session will expire in ",
WISH_STAY_CONNECTED: "Do you wish to stay connected ?"
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a whitespace before the question mark ? :s

STAY_CONNECTED: "Rester connecté",
TITLE: "Avertissement d'expiration de session",
WILL_EXPIRE_IN: "Votre session va expirer dans ",
WISH_STAY_CONNECTED: "Voulez-vous rester connecté ?"
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a whitespace before the question mark ? :s

Copy link
Member

@SuperITMan SuperITMan Nov 22, 2018

Choose a reason for hiding this comment

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

In French, we have a whitespace before the question mark 😊

Copy link
Collaborator

Choose a reason for hiding this comment

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

WTF!! 😮

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact, if I remember well my typing lessons (yep, I've had that, boring as hell), the convention is not to put a white space before, to treat it like a regular point. Word, OpenOffice, etc, always try to put one before, but it is not the official convention ^^ So I do think Christopher is right, I'll remove it, my bad :(

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, I have no idea about this so you can do what think it is best 😉

STAY_CONNECTED: "Verbonden blijven",
TITLE: "Sessietime-out waarschuwing",
WILL_EXPIRE_IN: "Uw sessie zal binnen ",
WISH_STAY_CONNECTED: "Wilt u verbonden blijven ?"
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a whitespace before the question mark ? :s

@@ -0,0 +1,18 @@
<div class="stark-timeout-warning-dialog" role="alertdialog" aria-busy="true" aria-live="assertive">
<header><i></i></header>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this line is needed, there is nothing related to those elements in the CSS

@@ -0,0 +1,18 @@
<div class="stark-timeout-warning-dialog" role="alertdialog" aria-busy="true" aria-live="assertive">
<header><i></i></header>
<h2 translate>STARK.SESSION_TIMEOUT.TITLE</h2>
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should follow the API from Angular Material for Dialogs, basically we should add these directives except the MatDialogClose.

You can see how they are used in the example

@Mallikki Mallikki force-pushed the feature/session-timeout-warning branch 3 times, most recently from 2619f3d to 103b7a3 Compare November 23, 2018 16:00
@Mallikki Mallikki force-pushed the feature/session-timeout-warning branch from 103b7a3 to 578b8a2 Compare November 23, 2018 16:29
@christophercr christophercr merged commit cf7883a into NationalBankBelgium:master Nov 23, 2018
@christophercr christophercr mentioned this pull request Nov 23, 2018
6 tasks
@Mallikki Mallikki deleted the feature/session-timeout-warning branch December 11, 2018 11:39
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.

ui: session - implement Session Timeout Warning dialog
4 participants