Skip to content

Fix TokenCreated dialog for null tokens#6441

Merged
cstns merged 2 commits intoFlowFuse:mainfrom
GogoVega:fix-tokencreated-dialog
Feb 13, 2026
Merged

Fix TokenCreated dialog for null tokens#6441
cstns merged 2 commits intoFlowFuse:mainfrom
GogoVega:fix-tokencreated-dialog

Conversation

@GogoVega
Copy link
Copy Markdown
Contributor

Description

By default, token is null, which triggers an error when the default template is mounted due to the evaluation of the expression {{ token.token }}.

showToken is declared in setup and uses this which is theoretically not possible.

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production
  • Link to Changelog Entry PR, or note why one is not needed.

Labels

  • Includes a DB migration? -> add the area:migration label

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.65%. Comparing base (4b418dc) to head (49e852d).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6441   +/-   ##
=======================================
  Coverage   76.65%   76.65%           
=======================================
  Files         398      398           
  Lines       20108    20108           
  Branches     4844     4844           
=======================================
  Hits        15414    15414           
  Misses       4694     4694           
Flag Coverage Δ
backend 76.65% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

<ff-dialog ref="dialog" data-el="add-token-confirmation" header="Token Created">
<template #default>
<p>Your token is <code>{{ token.token }}</code></p>
<p>Your token is <code>{{ token?.token }}</code></p>
Copy link
Copy Markdown
Contributor

@AllanOricil AllanOricil Dec 22, 2025

Choose a reason for hiding this comment

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

Component is called TokenCreated because it means there should exist a token already when the component is created. If you add "?." It means, semantically, that this component could possibly display "Your token is ", which isn't right. A proper fix is to ensure that the whole TokenCreated is rendered only if token is set. I believe the error occurs because TokenCreated is created and mounted when Token isn't even available, which triggers 1 rendering cycle and the evaluation of the {{ token.token }} expression. This is a waste of rendering cycle. Could you check if it is possible to create TokenCreated only when token is available?

Copy link
Copy Markdown
Contributor

@AllanOricil AllanOricil Dec 27, 2025

Choose a reason for hiding this comment

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

@GogoVega

The issue is that TokenCreated is created and mounted to the dom when it isn't even needed, wasting a rendering cycle for nothing

https://github.com/FlowFuse/flowfuse/blob/main/frontend%2Fsrc%2Fpages%2Faccount%2FSecurity%2FTokens.vue#L28

It would be more efficient to just create and mount the component with a v-if in this case, since it is a very small component Users wouldn't notice the time spent rendering and mounting a small template to the dom. You can define a new state variable called "showCreatedToken", and use it in v-if. When the following method is called, you could set showCreatedToken to true, then call showToken. If calling showToken in the same tick doesn't work, put it on the nextTick callback.

https://github.com/FlowFuse/flowfuse/blob/main/frontend%2Fsrc%2Fpages%2Faccount%2FSecurity%2FTokens.vue#L81-L84

Another solution is to control the rendering of the component inside its own template. In other words add v-if inside of it instead of in the parent, then trigger the rendering when calling showToken from the parent. The trade-off is that vue will again spend time mounting something that isn't used yet.

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.

Agreed, we don't have the best state management when it comes to dialogs, mainly because we're using a mix of vue and the built in html5 dialog api.

@knolleary knolleary requested a review from cstns January 6, 2026 09:03
Copy link
Copy Markdown
Contributor

@cstns cstns left a comment

Choose a reason for hiding this comment

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

I couldn't open the dialog without a token, but the changes seem safe for existing functionality (and for the specific niche case it must have been opened).

Long-term, I plan to centralize our modal logic in Vue rather than using scattered HTML5 behaviors, but I'm pushing that back due to other priorities. I agree with @AllanOricil’s approach in principle, but I'm approving this now to avoid further delays. We'll revisit this during the eventual refactor.

Thanks for the PR!

PS: apologies for the late review, it managed to slip through the cracks

<ff-dialog ref="dialog" data-el="add-token-confirmation" header="Token Created">
<template #default>
<p>Your token is <code>{{ token.token }}</code></p>
<p>Your token is <code>{{ token?.token }}</code></p>
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.

Agreed, we don't have the best state management when it comes to dialogs, mainly because we're using a mix of vue and the built in html5 dialog api.

@cstns cstns merged commit 79c9fd9 into FlowFuse:main Feb 13, 2026
31 of 34 checks passed
@GogoVega GogoVega deleted the fix-tokencreated-dialog branch February 13, 2026 20:06
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.

3 participants