Skip to content

Add logged-in state to WIP new top nav - #3332

Merged
rosslovas merged 2 commits into
mainfrom
ross/logged-in-top-nav
Aug 11, 2026
Merged

Add logged-in state to WIP new top nav#3332
rosslovas merged 2 commits into
mainfrom
ross/logged-in-top-nav

Conversation

@rosslovas

@rosslovas rosslovas commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds an avatar component from our design system ported to Astro, and displays it in the new TopNav (in place of the Sign in and Start for free buttons) when the user is signed in on octopus.com.

Results

When signed in:

Light mode
image

Dark mode
image

(In production, if you have an avatar image set up, that should be displayed in place of the placeholder initials.)

See in action at https://stoctodocspr3332.z22.web.core.windows.net/components#avatar. Because this isn't actually live on octopus.com yet, you can't actually sign in on the staging site. However, you can test the logged in state on the staging site by populating the cookie with fake data, by running the following JS via the browser console:

document.cookie = 'OctopusSignedInUser=' + encodeURIComponent(JSON.stringify({fullName: 'John Doe'})) + ';path=/';
window.dispatchEvent(new CustomEvent('octopus:user-changed'));

To reset:

document.cookie = 'OctopusSignedInUser=;path=/;max-age=0';
window.dispatchEvent(new CustomEvent('octopus:user-changed'));

Comment thread src/lib/avatar.ts
return value === 'small' || value === 'medium' || value === 'large';
}

export function generateFallbackText(text: string): string {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This logic is ported from how Octopus Server generates the fallback initials for avatars.

Comment thread src/lib/signedInUser.ts

function readCookie(): string | null {
const match = document.cookie.match(
new RegExp(`(^|;\\s*)${USER_COOKIE}=([^;]+)`)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is ported from how octopus.com itself reads from the cookie

@rosslovas
rosslovas force-pushed the ross/logged-in-top-nav branch from ae99082 to deb2579 Compare August 11, 2026 02:18
@team-marketing-branch-protections

Copy link
Copy Markdown

Pull request environment is available at https://stoctodocspr3332.z22.web.core.windows.net.

You can view the ephemeral environment status in Octopus Deploy.

This environment will be automatically deprovisioned when the pull request is closed, or after 7 days of inactivity.

import { test, expect } from '@playwright/test';
import { generateFallbackText } from '../src/lib/avatar';

const cases: [string, string][] = [

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a simplified version of the tests we have for Octopus Server's generateFallbackText.

@rosslovas
rosslovas force-pushed the ross/logged-in-top-nav branch from deb2579 to 8b8b3a9 Compare August 11, 2026 02:22
@rosslovas
rosslovas marked this pull request as ready for review August 11, 2026 03:33

@ellen-octopus ellen-octopus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks excellent 👏🏻 thanks @rosslovas!

Comment thread dictionary-octopus.txt Outdated
agentic
allatclaims
ALLUSERSPROFILE
andré

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding the names of fake people used in the unit tests to our dictionary doesn't feel like the right way to solve this problem. IIRC the spell check has an exclude list, can we add the tests folder to it? It really makes no sense to spellcheck unit tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done! I didn't really mind as I like not having typos lying around but it makes sense that the intention of this particular spellcheck is really the markdown :)

@borland borland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Spellchecking unit tests feels a bit naff, but otherwise all the code looks good to me and I would approve

@rosslovas
rosslovas force-pushed the ross/logged-in-top-nav branch from 8b8b3a9 to 656542a Compare August 11, 2026 05:07
@rosslovas
rosslovas merged commit a6ea80a into main Aug 11, 2026
7 checks passed
@rosslovas
rosslovas deleted the ross/logged-in-top-nav branch August 11, 2026 05:20
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.

4 participants