argoproj / argo-ui

Argoproj shared React components
Apache License 2.0
220 stars 178 forks source link

Conflict `theme` key in local storage when Argo CD runs subpath mode. #547

Open atuk721 opened 4 months ago

atuk721 commented 4 months ago

When Argo CD runs subpath mode and share origin with multiple applications and uses same local storage key, it became not to work.

As my experience, external application uses theme key in local storage and save "DARK" or "LIGHT" to it.
After that, when I access to Argo CD, it outputs a following error in a browser.

VM172:1 Uncaught SyntaxError: Unexpected token 'D', "DARK" is not valid JSON
    at JSON.parse (<anonymous>)
    at 10180 (main.9ecae91d8fd1deedf944.js:2:1501193)
    at i (main.9ecae91d8fd1deedf944.js:2:2463187)
    at 58535 (main.9ecae91d8fd1deedf944.js:2:2104618)
    at i (main.9ecae91d8fd1deedf944.js:2:2463187)
    at main.9ecae91d8fd1deedf944.js:2:2468811
    at main.9ecae91d8fd1deedf944.js:2:2468821
10180 @ main.9ecae91d8fd1deedf944.js:2
i @ main.9ecae91d8fd1deedf944.js:2
58535 @ main.9ecae91d8fd1deedf944.js:2
i @ main.9ecae91d8fd1deedf944.js:2
(anonymous) @ main.9ecae91d8fd1deedf944.js:2
(anonymous) @ main.9ecae91d8fd1deedf944.js:2

I think it occurs below because theme item is not JSON.

https://github.com/argoproj/argo-ui/blob/master/v2/shared/context/theme.tsx#L10

So I think this should change key name more specific like "argo-ui-theme" because Argo CD can run by subpath mode.
Or should add error handlings to it.