Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ interface CreditHistoryItemData {
isPositive: boolean
}

const { buildDocsUrl } = useExternalLink()
const { buildDocsUrl, docsPaths } = useExternalLink()
const dialogService = useDialogService()
const authStore = useFirebaseAuthStore()
const authActions = useFirebaseAuthActions()
Expand Down Expand Up @@ -194,9 +194,7 @@ const handleFaqClick = () => {

const handleOpenPartnerNodesInfo = () => {
window.open(
buildDocsUrl('/tutorials/api-nodes/overview#api-nodes', {
includeLocale: true
}),
buildDocsUrl(docsPaths.partnerNodesPricing, { includeLocale: true }),
'_blank'
)
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/topbar/CurrentUserPopover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ vi.mock('@/base/credits/comfyCredits', () => ({
// Mock useExternalLink
vi.mock('@/composables/useExternalLink', () => ({
useExternalLink: vi.fn(() => ({
buildDocsUrl: vi.fn((path) => `https://docs.comfy.org${path}`)
buildDocsUrl: vi.fn((path) => `https://docs.comfy.org${path}`),
docsPaths: {
partnerNodesPricing: '/tutorials/partner-nodes/pricing'
}
}))
}))

Expand Down
6 changes: 2 additions & 4 deletions src/components/topbar/CurrentUserPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const emit = defineEmits<{
close: []
}>()

const { buildDocsUrl } = useExternalLink()
const { buildDocsUrl, docsPaths } = useExternalLink()

const planSettingsLabel = isCloud
? 'settingsCategories.PlanCredits'
Expand Down Expand Up @@ -205,9 +205,7 @@ const handleTopUp = () => {

const handleOpenPartnerNodesInfo = () => {
window.open(
buildDocsUrl('/tutorials/partner-nodes/pricing', {
includeLocale: true
}),
buildDocsUrl(docsPaths.partnerNodesPricing, { includeLocale: true }),
'_blank'
)
emit('close')
Expand Down
8 changes: 7 additions & 1 deletion src/composables/useExternalLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ export function useExternalLink() {
comfyOrg: 'https://www.comfy.org/'
}

/** Common doc paths for use with buildDocsUrl */
const docsPaths = {
partnerNodesPricing: '/tutorials/partner-nodes/pricing'
}
Comment on lines +95 to +98
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider adding a TypeScript type for better type safety.

The new docsPaths constant is well-documented and follows the same pattern as staticUrls. However, adding an explicit TypeScript type would improve type safety and make it easier to extend in the future.

+/** Common doc paths for use with buildDocsUrl */
+const docsPaths = {
+  partnerNodesPricing: '/tutorials/partner-nodes/pricing'
+} as const
+
+type DocsPaths = typeof docsPaths

This ensures the paths are treated as literal string types and provides better autocomplete for consumers.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/** Common doc paths for use with buildDocsUrl */
const docsPaths = {
partnerNodesPricing: '/tutorials/partner-nodes/pricing'
}
/** Common doc paths for use with buildDocsUrl */
const docsPaths = {
partnerNodesPricing: '/tutorials/partner-nodes/pricing'
} as const
type DocsPaths = typeof docsPaths
🤖 Prompt for AI Agents
In src/composables/useExternalLink.ts around lines 95-98, the docsPaths constant
should have an explicit TypeScript type so its keys and values are treated as
literal string types for stronger type safety and better autocomplete; declare a
narrow type for the mapping (or use a readonly literal assertion) and annotate
docsPaths with that type (or apply the readonly assertion) so the
partnerNodesPricing key is typed as the exact '/tutorials/partner-nodes/pricing'
string rather than a general string.


return {
buildDocsUrl,
staticUrls
staticUrls,
docsPaths
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ type TierKey = (typeof TIER_TO_I18N_KEY)[SubscriptionTier]

const DEFAULT_TIER_KEY: TierKey = 'standard'

const { buildDocsUrl } = useExternalLink()
const { buildDocsUrl, docsPaths } = useExternalLink()
const authActions = useFirebaseAuthActions()
const { t } = useI18n()

Expand Down Expand Up @@ -469,9 +469,7 @@ const {

const handleOpenPartnerNodesInfo = () => {
window.open(
buildDocsUrl('/tutorials/api-nodes/overview#api-nodes', {
includeLocale: true
}),
buildDocsUrl(docsPaths.partnerNodesPricing, { includeLocale: true }),
'_blank'
)
}
Expand Down