Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Backups sheet: the exercise's name title-cased, as everywhere else

Duarte Santosd2f3352b0f3c
diff --git a/frontend/src/sheets.backups.test.jsx b/frontend/src/sheets.backups.test.jsx
index 8028d129d..2118090df 100644
--- a/frontend/src/sheets.backups.test.jsx
+++ b/frontend/src/sheets.backups.test.jsx
@@ -7,6 +7,7 @@ import { useStore } from './store/useStore.js'
import { useUI } from './store/useUI.js'
import { exConfigSheet, exercisePicker } from './sheets.jsx'
import { exerciseNameFor } from './lib/i18n.js'
+import { exerciseNameText } from './lib/format.js'
/* Planned substitutes (Discord "Substitutions for a routine"): picked in the routine editor's
exercise sheet, offered first by the swap picker, kept by every sheet that saves the slot. */
@@ -54,7 +55,9 @@ describe('the routine editor\'s exercise sheet', () => {
const host = render(useUI.getState().sheets.at(-1))
act(() => row(host, 'Backups').click())
const sheet = render(useUI.getState().sheets.at(-1))
- expect(sheet.querySelector('h3').textContent).toBe('Backups for ' + exerciseNameFor(ex))
+ // The name in a sentence is title-cased like everywhere else it is shown (QA v1.4.2).
+ expect(sheet.querySelector('h3').textContent).toBe('Backups for ' + exerciseNameText(ex))
+ expect(sheet.querySelector('h3').textContent).toBe('Backups for Barbell Bench Press')
act(() => [...sheet.querySelectorAll('button')].find(b => b.textContent === 'Add a backup').click())
const picker = render(useUI.getState().sheets.at(-1))
const name = exerciseNameFor(EXIDX['0289'])
@@ -66,7 +69,7 @@ describe('the routine editor\'s exercise sheet', () => {
})
const pick = [...picker.querySelectorAll('.item')].find(el => el.querySelector('.tt')?.textContent === name)
act(() => pick.click())
- act(() => [...sheet.querySelectorAll('button')].find(b => b.getAttribute('aria-label') === 'Remove “' + exerciseNameFor(EXIDX['0047']) + '”').click())
+ act(() => [...sheet.querySelectorAll('button')].find(b => b.getAttribute('aria-label') === 'Remove “' + exerciseNameText(EXIDX['0047']) + '”').click())
act(() => save(host))
expect(onSave.mock.calls[0][0].subs).toEqual(['0289'])
})
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index b92908acb..39b4c1023 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -1287,8 +1287,8 @@ function ExercisePicker({ onPick, title, close, like, actionIcon, backups }) {
const isSwap = !!like || title === t('Swap exercise') || title === t('Replace exercise') || title === 'Swap exercise' || title === 'Replace exercise'
const quickIcon = actionIcon || (isSwap ? 'swap' : 'plus')
const quickLabel = e => isSwap
- ? (title ? `${title}: ${exerciseNameFor(e)}` : `${t('Swap exercise')}: ${exerciseNameFor(e)}`)
- : t('Add “{0}”', exerciseNameFor(e))
+ ? (title ? `${title}: ${exerciseNameText(e)}` : `${t('Swap exercise')}: ${exerciseNameText(e)}`)
+ : t('Add “{0}”', exerciseNameText(e))
const usage = usageMap(st)
const [q, setQ] = useState('')
const backupList = (Array.isArray(backups) ? backups : []).map(id => EXIDX[id]).filter(Boolean)
@@ -1683,11 +1683,11 @@ function BackupsSheet({ ex, subs: initial, onChange, close }) {
}, { title: t('Add a backup'), like: ex.id })
}
return <>
- <h3>{t('Backups for {0}', exerciseNameFor(ex))}</h3>
+ <h3>{t('Backups for {0}', exerciseNameText(ex))}</h3>
<div className="muted small" style={{ marginBottom: 12 }}>{t('Machine taken? Pick what you’d do instead, and a swap mid-workout offers these first.')}</div>
{subs.length > 0 && <div className="sect-b" style={{ marginBottom: 12 }}>
- {subs.map(id => EXIDX[id]).filter(Boolean).map(b => <Row key={b.id} title={exerciseNameFor(b)} subtitle={t(b.eq)}>
- <button type="button" className="iconbtn" aria-label={t('Remove “{0}”', exerciseNameFor(b))} onClick={() => set(subs.filter(x => x !== b.id))}><Icon name="xmark" /></button>
+ {subs.map(id => EXIDX[id]).filter(Boolean).map(b => <Row key={b.id} title={exerciseNameText(b)} subtitle={t(b.eq)}>
+ <button type="button" className="iconbtn" aria-label={t('Remove “{0}”', exerciseNameText(b))} onClick={() => set(subs.filter(x => x !== b.id))}><Icon name="xmark" /></button>
</Row>)}
</div>}
{subs.length < MAX_BACKUPS