Skip to content

Commit 654daa5

Browse files
fix: Change "choose library" phrasing depending on contentType (#2276)
* fix: change library dialog phrasing depending on contentType * fix: separate i18n messages * fix: i18n improvements
1 parent bd18e87 commit 654daa5

4 files changed

Lines changed: 35 additions & 7 deletions

File tree

src/library-authoring/component-picker/ComponentPicker.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ describe('<ComponentPicker />', () => {
271271
await screen.findByText(/Change Library/i);
272272
fireEvent.click(screen.getByText(/Change Library/i));
273273

274-
await screen.findByText('Select which Library would you like to reference components from.');
274+
await screen.findByText('Choose a library to browse components.');
275275
});
276276

277277
it('should pick multiple components using the component card button', async () => {

src/library-authoring/component-picker/ComponentPicker.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ export const ComponentPicker: React.FC<ComponentPickerProps> = ({
114114
activeKey={currentStep}
115115
>
116116
<Stepper.Step eventKey="select-library" title="Select a library">
117-
<SelectLibrary selectedLibrary={selectedLibrary} setSelectedLibrary={handleLibrarySelection} />
117+
<SelectLibrary
118+
selectedLibrary={selectedLibrary}
119+
setSelectedLibrary={handleLibrarySelection}
120+
itemType={visibleTabs.length === 1 ? visibleTabs[0] : ContentType.components}
121+
/>
118122
</Stepper.Step>
119123

120124
<Stepper.Step eventKey="pick-components" title="Pick some components">

src/library-authoring/component-picker/SelectLibrary.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Loading from '../../generic/Loading';
1313
import AlertError from '../../generic/alert-error';
1414
import { useContentLibraryV2List } from '../data/apiHooks';
1515
import messages from './messages';
16+
import { ContentType } from '../routes';
1617

1718
interface EmptyStateProps {
1819
hasSearchQuery: boolean;
@@ -40,9 +41,10 @@ const EmptyState = ({ hasSearchQuery }: EmptyStateProps) => (
4041
interface SelectLibraryProps {
4142
selectedLibrary: string;
4243
setSelectedLibrary: (libraryKey: string) => void;
44+
itemType: ContentType;
4345
}
4446

45-
const SelectLibrary = ({ selectedLibrary, setSelectedLibrary }: SelectLibraryProps) => {
47+
const SelectLibrary = ({ selectedLibrary, setSelectedLibrary, itemType }: SelectLibraryProps) => {
4648
const intl = useIntl();
4749

4850
const [searchQuery, setSearchQuery] = useState('');
@@ -75,7 +77,9 @@ const SelectLibrary = ({ selectedLibrary, setSelectedLibrary }: SelectLibraryPro
7577
return (
7678
<Stack gap={2} className="p-5">
7779
<small className="text-primary-700">
78-
{intl.formatMessage(messages.selectLibraryInfo)}
80+
<FormattedMessage
81+
{...messages[`selectLibraryInfo.${itemType}`]}
82+
/>
7983
</small>
8084
<SearchField
8185
onSubmit={handleSearch}

src/library-authoring/component-picker/messages.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
import { defineMessages } from '@edx/frontend-platform/i18n';
22

33
const messages = defineMessages({
4-
selectLibraryInfo: {
5-
id: 'course-authoring.library-authoring.pick-components.select-library.info',
6-
defaultMessage: 'Select which Library would you like to reference components from.',
4+
'selectLibraryInfo.components': {
5+
id: 'course-authoring.library-authoring.pick-components.select-library.info.components',
6+
defaultMessage: 'Choose a library to browse components.',
77
description: 'The info text for the select library component',
88
},
9+
'selectLibraryInfo.units': {
10+
id: 'course-authoring.library-authoring.pick-components.select-library.info.units',
11+
defaultMessage: 'Choose a library to browse units.',
12+
description: 'The info text for the select library for units',
13+
},
14+
'selectLibraryInfo.sections': {
15+
id: 'course-authoring.library-authoring.pick-components.select-library.info.sections',
16+
defaultMessage: 'Choose a library to browse sections.',
17+
description: 'The info text for the select library for sections',
18+
},
19+
'selectLibraryInfo.subsections': {
20+
id: 'course-authoring.library-authoring.pick-components.select-library.info.subsections',
21+
defaultMessage: 'Choose a library to browse subsections.',
22+
description: 'The info text for the select library for subsections',
23+
},
24+
'selectLibraryInfo.collections': {
25+
id: 'course-authoring.library-authoring.pick-components.select-library.info.collections',
26+
defaultMessage: 'Choose a library to browse collections.',
27+
description: 'The info text for the select library for collections',
28+
},
929
selectLibrarySearchPlaceholder: {
1030
id: 'course-authoring.library-authoring.pick-components.select-library.search-placeholder',
1131
defaultMessage: 'Search for a library',

0 commit comments

Comments
 (0)