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

CDPT-1939: Splash page #800

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

EmilyHazlehurst
Copy link
Contributor

  • Redirect users to a simplified version of the agency switcher when they don't have a cookie set.
  • Allow users access to the accessibility and privacy policy pages before setting a cookie, but use the simplified header

- Redirect users to a simplified version of the agency switcher when they don't have a cookie set.
- Allow users access to the accessibility and privacy policy pages before setting a cookie, but use the simplified header
- Redirect users to a simplified version of the agency switcher when they don't have a cookie set.
- Allow users access to the accessibility and privacy policy pages before setting a cookie, but use the simplified header
- Redirect users to a simplified version of the agency switcher when they don't have a cookie set.
- Allow users access to the accessibility and privacy policy pages before setting a cookie, but use the simplified header
Copy link
Contributor

@EarthlingDavey EarthlingDavey left a comment

Choose a reason for hiding this comment

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

This works really nicely locally, I've added a few comments.

In addition to those, do you think it would be worth bringing an extra feature into the scope of the ticket? ...

The user could be redirected to their page after selecting an agency on their first visit.

This could be useful if a link to a specific intranet page is circulated via email. Otherwise, after opening a link, a new intranet user will always land on the homepage.


It could work similarly to what happens when a specific admin page is accessed by a logged out user.

e.g.

http://intranet.docker/wp/wp-admin/edit.php?post_type=page

redirects to

http://intranet.docker/wp/wp-login.php?redirect_to=http%3A%2F%2Fintranet.docker%2Fwp%2Fwp-admin%2Fedit.php%3Fpost_type%3Dpage&reauth=1

and after a successful login, the user is redirected to their original page.

{
$agencyCookie = $_COOKIE['dw_agency'] ?? '';
return (bool)$agencyCookie;
}
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 opinionated, just for your consideration :)

empty() might be a good alternative to use here, as it matches an unset value or an empty string.

e.g. return !empty($_COOKIE['dw_agency'])

@@ -38,10 +38,22 @@
// a dw_agency cookie does not exist
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry if this is really annoying...

I think this is a good opportunity to make this function easier to read.

What do you think about the following pattern?

  • returning around line 37.
  • removing the else clause.

// And the user isn't logged in
!is_user_logged_in() &&
// And we're not in the admin area
$_SERVER['PHP_SELF'] != '/wp-admin/admin-ajax.php'
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 a good check to have, but I don't think it's working as intended, because our admin paths start with wp/wp-admin....

You could use some WP functions to be more robust, there are three that might be worth using in this Stack Overflow comment.

is_admin, wp_doing_ajax & wp_doing_cron.

@EmilyHazlehurst
Copy link
Contributor Author

This works really nicely locally, I've added a few comments.

In addition to those, do you think it would be worth bringing an extra feature into the scope of the ticket? ...

The user could be redirected to their page after selecting an agency on their first visit.

This could be useful if a link to a specific intranet page is circulated via email. Otherwise, after opening a link, a new intranet user will always land on the homepage.

It could work similarly to what happens when a specific admin page is accessed by a logged out user.

e.g.

http://intranet.docker/wp/wp-admin/edit.php?post_type=page

redirects to

http://intranet.docker/wp/wp-login.php?redirect_to=http%3A%2F%2Fintranet.docker%2Fwp%2Fwp-admin%2Fedit.php%3Fpost_type%3Dpage&reauth=1

and after a successful login, the user is redirected to their original page.

Thanks for reviewing @EarthlingDavey!

I did consider this. The reason I decided against it in the end was because of the way agency branding works on the intranet.

Just as an example, I'm a new hire who hasn't accessed the intranet before:

  • I get a link to a generic HR page on the HQ intranet but I'm in HMCTS.
  • When I click that link, select my agency then get sent back to the link I see the HQ page with the HMCTS branding at the top.
  • I then click HR and can't find that page anymore because it's not part of the HMCTS intranet.

I suppose they're going to have that confusion anyway though once they go back to the link that was shared originally...

Maybe this can stay as is for now, but I'll make an improvement ticket? There might be a bigger discussion to be had around how shared content is handled on the intranet.

@EarthlingDavey
Copy link
Contributor

Hey @EmilyHazlehurst , I see that there probably isn't a perfect solution to this - especially while there is the underlying issue/feature of an agency's page being branded as whichever one has been selected in the agency picker.

I do think that we should be cautious that, while aiming to improve the UX, we in fact degrade it for a subset of users.


In terms of new users clicking a link in Slack or an email:

Currently:

Pro: they will get to the correct page
Con: it will always have the default agency of HQ.

With this PR:

Pro: the user will pick an agency
Con: but they will land on the homepage.

This could be confusing to the user, best case scenario they will re-click the link, worst-case scenario they assume that the link is broken.

With a redirect:

Pro: the user will pick an agency and land on the correct page
Con: In cases where the picked agency is not the same as the agency that published the content, we could see the issue that you described, i.e. navigation will not make sense.

I feel like the downside in this case is the lesser of all 3. As the end result is that the user finds the content that was linked.

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