Repository navigation
fix(i18n): localize the integration card status pills #12208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
smwbev
wants to merge
2
commits into
stablyai:main
from
smwbev:fix/localize-integration-card-statuses
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/renderer/src/components/settings/token-source-control-status.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { translate } from '@/i18n/i18n' | ||
| import type { AzureDevOpsStatus, BitbucketStatus, GiteaStatus } from './integrations-pane-status' | ||
|
|
||
| /** | ||
| * Card status as the pane computes it: the provider's own state, or | ||
| * `'unavailable'` when the runtime cannot report on it at all. | ||
| */ | ||
| export type TokenProviderStatus = BitbucketStatus | AzureDevOpsStatus | GiteaStatus | 'unavailable' | ||
|
|
||
| const NS = 'auto.components.settings.token.source.control.integration.cards' | ||
|
|
||
| /** | ||
| * Status copy for the token-configured source-control cards (Bitbucket, Azure | ||
| * DevOps, Gitea). They share the same states, so the labels live in one place. | ||
| */ | ||
| export function tokenProviderStatusLabel(input: { | ||
| /** Credentials present for the provider. */ | ||
| configured: boolean | ||
| /** An account was resolved with those credentials. */ | ||
| hasAccount?: boolean | ||
| status: TokenProviderStatus | ||
| /** Gitea works read-only without a token, so its unconfigured state is softer. */ | ||
| optional?: boolean | ||
| }): string { | ||
| if (input.configured) { | ||
| return input.hasAccount === false | ||
| ? translate(`${NS}.statusConfigured`, 'Configured') | ||
| : translate(`${NS}.statusConnected`, 'Connected') | ||
| } | ||
| if (input.status === 'unavailable') { | ||
| return translate(`${NS}.statusUnavailable`, 'Unavailable') | ||
| } | ||
| if (input.status === 'not-configured') { | ||
| return input.optional | ||
| ? translate(`${NS}.statusOptionalSetup`, 'Optional setup') | ||
| : translate(`${NS}.statusNotConfigured`, 'Not configured') | ||
| } | ||
| return translate(`${NS}.statusAuthFailed`, 'Auth failed') | ||
| } | ||
44 changes: 44 additions & 0 deletions
44
src/renderer/src/i18n/integration-card-status-localization.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * Integration cards build their status pill inside the JSX call, which the | ||
| * coverage audit does not inspect — it looks at JSX attributes and object | ||
| * properties, not conditional expressions passed to a prop. These assertions | ||
| * pin the catalog contract so a card that goes back to a bare literal fails here. | ||
| */ | ||
| import { describe, expect, it } from 'vitest' | ||
| import en from './locales/en.json' | ||
|
|
||
| function lookup(key: string): string | undefined { | ||
| const value = key | ||
| .split('.') | ||
| .reduce<unknown>( | ||
| (node, part) => | ||
| node && typeof node === 'object' ? (node as Record<string, unknown>)[part] : undefined, | ||
| en as unknown | ||
| ) | ||
| return typeof value === 'string' ? value : undefined | ||
| } | ||
|
|
||
| const REQUIRED_KEYS: Record<string, string> = { | ||
| // Linear and other task trackers | ||
| 'auto.components.settings.task.tracker.integration.cards.statusConnected': 'Connected', | ||
| 'auto.components.settings.task.tracker.integration.cards.statusNotConnected': 'Not connected', | ||
| // Jira | ||
| 'auto.components.settings.jira.integration.card.statusConnected': 'Connected', | ||
| 'auto.components.settings.jira.integration.card.statusNotConnected': 'Not connected', | ||
| // Bitbucket, Azure DevOps, Gitea | ||
| 'auto.components.settings.token.source.control.integration.cards.statusConnected': 'Connected', | ||
| 'auto.components.settings.token.source.control.integration.cards.statusConfigured': 'Configured', | ||
| 'auto.components.settings.token.source.control.integration.cards.statusUnavailable': | ||
| 'Unavailable', | ||
| 'auto.components.settings.token.source.control.integration.cards.statusNotConfigured': | ||
| 'Not configured', | ||
| 'auto.components.settings.token.source.control.integration.cards.statusOptionalSetup': | ||
| 'Optional setup', | ||
| 'auto.components.settings.token.source.control.integration.cards.statusAuthFailed': 'Auth failed' | ||
| } | ||
|
|
||
| describe('integration card status labels', () => { | ||
| it.each(Object.entries(REQUIRED_KEYS))('keeps %s in the English catalog', (key, expected) => { | ||
| expect(lookup(key)).toBe(expected) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.