Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

20.2 KB
Raw Blame

1. i18n infrastructure

  • 1.1 Add i18next 26, react-i18next 17 and eslint-plugin-i18next 6 to frontend/package.json, and verify pnpm install succeeds and pnpm build still passes
  • 1.2 Create shared/i18n/locales/en.ts as a single object literal with the top-level namespaces (common, status, errors, language holding nativeName, plus one per domain), and verify pnpm build passes
  • 1.3 Add the i18next module augmentation typing resources as typeof en, export TranslationKey as an alias of i18next's ParseKeys, and verify that t('does.not.exist') and a TranslationKey holding an unknown key both fail pnpm build while real keys pass
  • 1.4 Create shared/i18n/locales/ru.ts as a single object literal typed const ru: typeof en, and verify that deleting one key and adding one stray key each make pnpm build fail with that key named
  • 1.5 Configure the i18next instance with inline resources, nsSeparator: false, interpolation.escapeValue: false, fallbackLng: 'en', react.transKeepBasicHtmlNodesFor: [] and react.transDefaultProps escaping Trans values (shouldUnescape: true, tOptions.interpolation.escapeValue: true), and verify t() is typed string at call sites and pnpm build passes
  • 1.6 Add the placeholder parity test, which asserts for every key of en that each other dictionary uses the same {{…}} names and the same Trans tags, and verify pnpm test passes and fails when a placeholder is removed from a ru.ts value
  • 1.7 Add a unit test that renders, through react-dom/server with the project's i18next configuration, translated sentences containing the names <img src=x onerror=alert(1)>, <strong>bold</strong> and a {{name}} b: from t() as React text, through Trans values, and through Trans with the name as the child of a supplied element for a self-closing dictionary tag. Include a dictionary sentence with a <strong> the component does not supply. Verify pnpm test passes; that every name is shown as text; that the element route shows each name exactly as entered; that the only elements produced are the ones the component supplies; and that the <strong> cases fail when react.transDefaultProps or react.transKeepBasicHtmlNodesFor from 1.5 is removed
  • 1.8 Add LocalizedText ({ key: TranslationKey; params? }) in its own file in shared/i18n together with the way components render it, and verify pnpm build rejects a LocalizedText with an unknown key
  • 1.9 Add resolveInitialLocale({ storedLocale, browserLanguages, supportedLocales }) in shared/i18n, and verify with pnpm test that ["de", "ru"] resolves to ru, a list with no supported language resolves to en, zh-TW and zh-HK resolve to zh and pt-PT to pt when those are supported, a stored supported value outranks the browser list, and a stored unsupported value is ignored
  • 1.10 Add LocaleProvider and useLocale in shared/i18n, mirroring shared/theme/ThemeProvider.tsx: the supported list is the dictionaries that exist (en and ru for now), databasus-locale is read from localStorage during initialization and resolved with resolveInitialLocale, and a switch updates dayjs.locale and i18n.changeLanguage before publishing the new locale. Verify pnpm build and pnpm test pass
  • 1.11 Wrap the tree in LocaleProvider in App.tsx and pass the matching AntD locale to ConfigProvider. With databasus-locale set to ru in localStorage, verify that on first paint table pagination, an empty table and the month and weekday names in a DatePicker are already Russian, with no flash of English
  • 1.12 Set document.documentElement.lang and the document title from the selected locale at runtime, keeping lang="en" and the English <title> in frontend/index.html as the values shown before the script runs. With databasus-locale set to ru, verify the tab title is Russian and the reported language is ru once the page has loaded
  • 1.13 Add formatNumber and formatRelativeTime in shared/i18n, exposed through useLocale(), and verify with unit tests that an English browser with French selected groups digits the French way, that Chinese groups Western-style rather than in the 万 form, that unit words are not the formatter's concern, and that a relative time comes out in Russian when Russian is selected
  • 1.14 Confirm that shared/time/getUserTimeFormat.ts:4,44 and shared/time/utils.ts:5 keep deriving clock format and date order from navigator.language, and record in frontend/AGENTS.md why those three reads are correct where a bare toLocaleString() is not, so a later reader does not "fix" them
  • 1.15 Build LanguageSelectorComponent and LanguageThemeControlComponent in shared/ui, keeping ThemeToggleComponent as the theme half with split styling. The language half shows the current language and opens, on hover, a list of the supported languages, each named by its own dictionary's language.nativeName; the list is an AntD Dropdown opening on hover and click, whose leave delay keeps it open while the pointer crosses from the button to the list. Verify the list stays open while the pointer moves onto it
  • 1.16 Render LanguageThemeControlComponent instead of ThemeToggleComponent at all three call sites (widgets/main/MainScreenComponent.tsx:254, widgets/main/SidebarComponent.tsx:132, features/users/ui/AuthNavbarComponent.tsx:49) and verify the control renders in the navbar, in the narrow-viewport sidebar and on the authentication screen
  • 1.17 Add WEBSITE_PAGES and getWebsitePageUrl(page, locale) in shared/i18n, allow .. in server.fs.allow in frontend/vitest.config.ts, and add the test that compares the table with TRANSLATED_PATHS read from website/app/i18n.ts?raw. Verify pnpm test passes and fails when an untranslated page such as notifiers/mattermost is marked translated, and that pnpm build passes in a copy of frontend/ with no website/ beside it, as in the Docker build
  • 1.18 Verify end to end with English and Russian that a language chosen before signing in survives the sign-in, that a browser preferring German and then Russian starts in Russian, that a browser with no supported language starts in English, that an explicit choice outranks the browser preference on later visits, and that switching the language keeps the unsaved input in a form on the page and keeps the narrow-viewport sidebar open when the switch is made from it
  • 1.19 Change description in shared/ui/ConfirmationComponent.tsx from an HTML string rendered with dangerouslySetInnerHTML (:27) to a ReactNode rendered as a child, and turn the description at features/restores/ui/RestoresComponent.tsx:366 into a Trans key with <bold> plus a second key for the question after the line breaks. Verify pnpm build passes, the restore cancellation dialog still shows the bold warning and the question on its own paragraph, and the other confirmation dialogs show their text unchanged

2. Lint enforcement and conventions

  • 2.1 Define the i18next/no-literal-string options in frontend/eslint.config.js as one shared object, not yet applied to any directory: all mode and the exclusion lists for the report classes in design.md (JSX attributes, callees, object properties, URL and path words, *.test.ts and api/ segments). Verify by applying it temporarily that pnpm lint reports the message.success texts at features/settings/ui/SettingsComponent.tsx:77,253 and the fallback strings at :46 and :79, reports the placeholder attributes in features/storages, and reports none of the excluded classes in either; then remove the temporary entries and verify pnpm lint passes
  • 2.2 Amend the "Language in code" section of the root AGENTS.md to permit target-language text in frontend/src/shared/i18n/locales/<locale>.ts and nowhere else under frontend/src/, and verify the amended wording still forbids translated fallback copy and error messages outside that directory. Do not start section 5 until this task is done and approved
  • 2.3 Document the i18n convention in frontend/AGENTS.md: keys are domain-scoped; English is the key source of truth; each dictionary is one object literal in one file; code outside components holds keys, not text; label tables are named <TYPE>_LABEL_KEYS and sit next to the type they label; sentences stay whole, with Trans for inline markup and interpolation instead of concatenation; a user-entered value in a Trans sentence is a self-closing tag whose supplied element holds the value, never a values entry; counts are phrased without plural forms; translated text is never rendered as HTML; locale-dependent output is read through useTranslation or useLocale, including relative times through formatRelativeTime; API errors are shown through translateApiError; technical strings stay literal. Scope the plain-hyphen rule to en.ts and point the other dictionaries to website/AGENTS.md - Translation quality. Verify the section states each rule and links to that section
  • 2.4 In website/AGENTS.md, state that "Translation quality" also governs the frontend dictionaries, and add to the TRANSLATED_PATHS rule that a frontend test checks the application's links to website pages against that list, so adding or removing a translated path can fail it. Verify both notes are present

3. Error handling contract

  • 3.1 Add an errors namespace keyed by error code. In shared/api/apiHelper.ts, make ApiError.message hold only the backend's message, add a status field set on every ApiError from an error response, and give the failures the backend does not describe frontend-side codes: wrap only the rejection of the fetch call at :59 as an ApiError with network_unreachable, letting the ApiErrors that reach the catch at :62 pass through unchanged, and throw request_failed for HTTP 502 and 504 at :20-21 and for an error response without a JSON body at :44-46. Delete the dead response.text() fallback at :37-41. Switch describeRestoreError (PhysicalRestoreComponent.tsx:34-44) to deciding by status alone, dropping its search of the message for 409, 422, in progress and gap, and turn the hints it appends into keys. Add translateApiError(error, t) in shared/i18n/translateApiError.ts, which resolves a known code to its translation, otherwise shows the backend's message, otherwise a general translated message, and never shows the message of an error that is not an ApiError. Verify with unit tests. For translateApiError: a known code, an unknown code with a message, an unknown code without a message, no code with a message, network_unreachable, request_failed with its status, and a plain TypeError. For apiHelper, with globalThis.fetch stubbed: a rejection gives network_unreachable, a 502 gives request_failed with status 502, a non-JSON 500 gives request_failed with status 500, and a JSON error with a code keeps its code, message and status. Cover both the default path, where the first try is the last, and a call made with isRetryOnError, which is retried up to 30 times at 3-second intervals (apiHelper.ts:6-7,76,88) and needs fake timers
  • 3.2 Convert the text in physicalConnectionErrorContent to keys while keeping its lookup by ConnectionErrorCode: titles and summaries become keys, each note becomes one key rendered through Trans with <bold> tags instead of text runs, managedNote becomes a key with {{username}}, and commands stay literal. Route every other code in EditPostgreSqlPhysicalSpecificDataComponent.tsx through translateApiError. Verify pnpm test passes and that each physical connection error still shows its specific copy

4. Enum labels

  • 4.1 Add a status namespace and a <TYPE>_LABEL_KEYS table next to each of the six status enums in entity/ that are shown as labels (AddMemberStatusEnum is never shown, so it gets none), moving the label parts of physicalBackupStatus.ts and restoreVerificationStatus.ts there (with NOT_VERIFIED: null replacing the Partial), and convert AGENT_STATUS_LABELS to AGENT_STATUS_LABEL_KEYS in place. Verify that adding an enum member without a label fails pnpm build
  • 4.2 Replace the four status render functions (VerificationDetailDrawer.tsx:51, VerificationsComponent.tsx:58, LogicalBackupsComponent.tsx:386, PhysicalBackupsComponent.tsx:55) with lookups against the shared tables, keeping each component's own markup, and verify the four screens show the same English labels as before, and Russian labels when Russian is selected
  • 4.3 Add <TYPE>_LABEL_KEYS tables next to the other labelled types: storage and notifier types, database types, SSH tunnel auth types, notification types, intervals, periods, retention policies, user and workspace roles, and one weekday table in entity/intervals. This task only adds the tables; the old sources (getStorageNameFromType, getNotifierNameFromType, the getRoleDisplayText switches, the six weekday copies and the other text tables) are deleted by the section 5 task that migrates their last consumer. Verify that adding an enum member without a label fails pnpm build

5. Slice migration (English and Russian together)

Ordering is deliberate and not by size alone. features/settings comes first to prove the infrastructure on the smallest slice. features/databases comes second, out of size order, because it is the largest and most varied slice: if the key namespace design breaks anywhere it breaks there, and finding that out after nine migrated slices would mean reworking all of them. The cost is doing the hardest slice before the pattern is fluent. The rest then run ascending.

A slice is done when:

  • its copy is in the dictionaries, following the frontend/AGENTS.md convention from 2.3;

  • its consumers of the section 4 tables use keys, and any old label function or copy whose last consumer it held is deleted;

  • its fromNow() calls go through formatRelativeTime, its toLocaleString() calls through formatNumber, and every place that shows an error's message, whether through alert(), message.error() or its own error state, through translateApiError;

  • its links to databasus.com pages go through getWebsitePageUrl;

  • it has a lint entry using the options from 2.1;

  • pnpm format leaves no changes, and pnpm lint, pnpm test and pnpm build pass;

  • the reviewer subagent has audited the slice's diff and every CHANGES REQUIRED finding is resolved.

  • 5.1 Migrate features/settings, and verify the slice is done and that the relative times in the audit log (AuditLogsComponent.tsx:160,198) re-render in the new language on a live switch

  • 5.2 Migrate features/databases, the largest slice. Then review whether the namespace design survived it and revise the key layout before continuing if it did not, and record the Russian canonical interface terms in website/AGENTS.md - Translation quality. Verify the slice is done

  • 5.3 Migrate features/restores, and verify the slice is done

  • 5.4 Migrate features/healthcheck, and verify the slice is done

  • 5.5 Migrate features/workspaces, phrasing the counts at WorkspaceMembershipComponent.tsx:517 and WorkspaceSettingsComponent.tsx:148 so one string fits every number, and verify the slice is done

  • 5.6 Migrate features/users, replacing the backend's success text shown at RequestResetPasswordComponent.tsx:54 with a frontend key, and verify the slice is done

  • 5.7 Migrate features/verification, including the bare toLocaleString() calls at VerificationDetailDrawer.tsx:45,48,157, and verify the slice is done

  • 5.8 Migrate features/notifiers, and verify the slice is done

  • 5.9 Migrate features/backups, including the bare toLocaleString() calls at LogicalBackupsComponent.tsx:513,515 and PhysicalBackupsComponent.tsx:49,52, and verify the slice is done

  • 5.10 Migrate features/storages, and verify the slice is done

  • 5.11 Migrate the remaining copy in entity/, widgets/, pages/ and shared/ui/, including the bare toLocaleString() at StarButtonComponent.tsx:56. The connection string parsers return { error: LocalizedText }, the parse-failure keys drop the thrown error's text that eleven messages append today (for example ConnectionStringParser.ts:137), and their tests (ConnectionStringParser.test.ts, MySqlConnectionStringParser.test.ts, MongodbConnectionStringParser.test.ts) assert keys instead of English words. Verify the slice is done

  • 5.12 Replace the per-directory lint entries with one entry over src/**/*.{ts,tsx}, delete the temporary eslint.i18n-check.js, and verify pnpm lint passes and fails when a literal label is added to any file under src, including inside a SCREAMING_SNAKE constant

  • 5.13 Fold the per-namespace files locales/en/*.ts and locales/ru/*.ts back into one object literal in locales/en.ts and one in locales/ru.ts, delete both folders, and verify pnpm build still names a missing and a stray key and pnpm test passes

6. Remaining languages

Each dictionary follows the locale conventions in website/AGENTS.md - Translation quality. Writing one includes adding the language to the supported list, the AntD locale map and the dayjs locale map, and recording its canonical interface terms next to the Russian ones. Like a slice, each ends with pnpm format leaving no changes, pnpm build and pnpm test passing (no missing or stray keys, placeholders in parity), and a reviewer audit with every CHANGES REQUIRED finding resolved.

  • 6.1 Confirm the key set has stopped changing after section 5, then write es.ts, and verify the checks above and that a first visit from a browser preferring Spanish starts in Spanish
  • 6.2 Write pt.ts (Brazilian Portuguese), and verify the checks above and that a first visit from a browser preferring pt-PT starts in Portuguese
  • 6.3 Write fr.ts, and verify the checks above and that a first visit from a browser preferring French starts in French
  • 6.4 Write zh.ts (Simplified), and verify the checks above and that a first visit from a browser preferring zh-TW starts in Simplified Chinese
  • 6.5 Verify the language list shows all six native names in every interface language and that each language renders end to end

7. Verification

  • 7.1 Walk every screen in Russian and French looking for clipped or wrapped labels in AntD forms with fixed labelCol, and fix the layouts that break
  • 7.2 Spot-check Chinese on the table-heavy screens (backups, databases, verification runs) for line height and CJK-Latin spacing
  • 7.3 Confirm in every language that command blocks, connection strings, cron expressions, engine names and the unit words in duration and size readouts are byte-identical to English, while the digits inside those readouts follow the selected language
  • 7.4 Confirm in every language that the browser tab title and the document language attribute match the selection, that grep -rn "toLocaleString()" frontend/src finds nothing, that grep -rn "\.fromNow()" frontend/src finds only the call inside formatRelativeTime, that grep -rnE "(\b(e|err)|[Ee]rror\)?)\.message\b" frontend/src finds nothing outside shared/i18n/translateApiError.ts and test files except EditS3StorageComponent.tsx, which reads an ApiError's message only to decide whether to open the advanced settings on a TLS certificate failure and never shows it (behavior that predates this change; a backend error code would replace it), and that grep -rn "dangerouslySetInnerHTML" frontend/src finds nothing
  • 7.5 Confirm in every language that each link to a databasus.com page opens that page in the selected language when the website publishes it and the English page otherwise, landing on its anchor, and that grep -rnF "databasus.com" frontend/src finds page URLs only in WEBSITE_PAGES, apart from the example icon URL in the Mattermost form
  • 7.6 Switch the language on a screen with a half-filled form, from the navbar and from the narrow-viewport sidebar, and confirm the input and the open sidebar stay as they were, now in the new language
  • 7.7 Run pnpm lint, pnpm format, pnpm test and pnpm build from frontend/ and confirm all pass
  • 7.8 Run the reviewer subagent over the change's full diff against develop and resolve every CHANGES REQUIRED finding