Skip to content

Fix Templates Banner on home page#2103

Merged
rSnapkoOpenOps merged 4 commits intomainfrom
fix/tamplates-banner
Mar 11, 2026
Merged

Fix Templates Banner on home page#2103
rSnapkoOpenOps merged 4 commits intomainfrom
fix/tamplates-banner

Conversation

@rSnapkoOpenOps
Copy link
Collaborator

@rSnapkoOpenOps rSnapkoOpenOps commented Mar 11, 2026

Fixes OPS-3843

The banner is not visible in the templates dialog so I copied the check from there

const { isConnectedToCloudTemplates } = useCloudProfile();
const { createPollingInterval } = useUserInfoPolling();
const useCloudTemplates = flagsHooks.useShouldFetchCloudTemplates();
const { checkAccess } = useAuthorization();
const hasWriteFlowPermission = checkAccess(Permission.WRITE_FLOW);
const isFullCatalog =
!isTemplatePreselected &&
(isConnectedToCloudTemplates || !useCloudTemplates);

@linear
Copy link

linear bot commented Mar 11, 2026

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the home page onboarding experience so the “Connect templates” banner and template filters use the same “cloud templates connected + flags” logic as the templates dialog, fixing cases where the banner was incorrectly hidden.

Changes:

  • Replace cloudUser-based UI conditions with a derived isCloudUser based on useCloudProfile() and flagsHooks.useShouldFetchCloudTemplates().
  • Update the templates carousel filter visibility and onboarding panels to use isCloudUser.
  • Adjust the templates refetch/reset effect to trigger based on the new isCloudUser signal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +65 to +69
const { isConnectedToCloudTemplates } = useCloudProfile();
const useCloudTemplates = flagsHooks.useShouldFetchCloudTemplates();
const isCloudUser = useMemo(() => {
return isConnectedToCloudTemplates && useCloudTemplates;
}, [isConnectedToCloudTemplates, useCloudTemplates]);
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

isCloudUser depends on isConnectedToCloudTemplates from useCloudProfile(). In use-cloud-profile.ts, isConnectedToCloudTemplates is computed as data !== null, which evaluates to true while the React Query data is still undefined (initial/pending or when the query is disabled). That can incorrectly treat users as connected (hiding the connect banner / enabling filters) until the query resolves. Consider fixing useCloudProfile to treat undefined as not-connected (e.g., data != null plus isSuccess), or guard here by deriving connection from a value that cannot be undefined.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the same logic as used in the templates dialog, so it's fine

…ding-view.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@rSnapkoOpenOps rSnapkoOpenOps marked this pull request as ready for review March 11, 2026 08:05
@alexandrudanpop
Copy link
Contributor

alexandrudanpop commented Mar 11, 2026

this logic is really hard to follow, if it's common we should extract it and improve the code so the logic behind is more readable

@sonarqubecloud
Copy link

@rSnapkoOpenOps
Copy link
Collaborator Author

I extracted the common logic to reusable hook

@rSnapkoOpenOps rSnapkoOpenOps merged commit 486deaf into main Mar 11, 2026
21 checks passed
@rSnapkoOpenOps rSnapkoOpenOps deleted the fix/tamplates-banner branch March 11, 2026 09:35
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