Skip to content

Commit 46fa17e

Browse files
authored
fix: UI fixes in legacy library migrator
- Keep state of all migration steps on nevigation - Reword alert in confirm dialog - Add scroll to help sidebar in migration - Keep the same migration filter
1 parent 9f16041 commit 46fa17e

File tree

6 files changed

+45
-13
lines changed

6 files changed

+45
-13
lines changed

src/legacy-libraries-migration/LegacyLibMigrationPage.test.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,20 @@ describe('<LegacyLibMigrationPage />', () => {
162162
});
163163

164164
it('should back to select legacy libraries', async () => {
165+
const user = userEvent.setup();
165166
renderPage();
166-
expect(await screen.findByText('Migrate Legacy Libraries')).toBeInTheDocument();
167+
// The filter is Unmigrated by default
168+
const filterButton = await screen.findByRole('button', { name: /unmigrated/i });
169+
expect(filterButton).toBeInTheDocument();
170+
171+
// Clear filter to show all
172+
await user.click(filterButton);
173+
const clearButton = await screen.findByRole('button', { name: /clear filter/i });
174+
await user.click(clearButton);
175+
167176
expect(await screen.findByText('MBA')).toBeInTheDocument();
177+
expect(await screen.findByText('Legacy library 1')).toBeInTheDocument();
178+
expect(await screen.findByText('MBA 1')).toBeInTheDocument();
168179

169180
const legacyLibrary = screen.getByRole('checkbox', { name: 'MBA' });
170181
legacyLibrary.click();
@@ -178,7 +189,13 @@ describe('<LegacyLibMigrationPage />', () => {
178189
const backButton = screen.getByRole('button', { name: /back/i });
179190
backButton.click();
180191

192+
// The selected legacy library remains checked
193+
expect(legacyLibrary).toBeChecked();
194+
195+
// The filter remains the same
181196
expect(await screen.findByText('MBA')).toBeInTheDocument();
197+
expect(await screen.findByText('Legacy library 1')).toBeInTheDocument();
198+
expect(await screen.findByText('MBA 1')).toBeInTheDocument();
182199
});
183200

184201
it('should select a library destination', async () => {
@@ -230,6 +247,8 @@ describe('<LegacyLibMigrationPage />', () => {
230247
backButton.click();
231248

232249
expect(await screen.findByText('Test Library 1')).toBeInTheDocument();
250+
// The selected v2 library remains checked
251+
expect(radioButton).toBeChecked();
233252
});
234253

235254
it('should open the create new library modal', async () => {

src/legacy-libraries-migration/LegacyLibMigrationPage.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export const LegacyLibMigrationPage = () => {
8080
const [currentStep, setCurrentStep] = useState<MigrationStep>('select-libraries');
8181
const [isExitModalOpen, openExitModal, closeExitModal] = useToggle(false);
8282
const [legacyLibraries, setLegacyLibraries] = useState<LibraryV1Data[]>([]);
83+
const [migrationFilter, setMigrationFilter] = useState<Filter[]>([Filter.unmigrated]);
8384
const [destinationLibrary, setDestination] = useState<ContentLibrary>();
8485
const [confirmationButtonState, setConfirmationButtonState] = useState('default');
8586
const migrate = useUpdateContainerCollections();
@@ -127,7 +128,6 @@ export const LegacyLibMigrationPage = () => {
127128
openExitModal();
128129
break;
129130
case 'select-destination':
130-
setDestination(undefined);
131131
setCurrentStep('select-libraries');
132132
break;
133133
case 'confirmation-view':
@@ -193,7 +193,8 @@ export const LegacyLibMigrationPage = () => {
193193
selectedIds={legacyLibrariesIds}
194194
handleCheck={handleUpdateLegacyLibraries}
195195
hideMigationAlert
196-
initialFilter={[Filter.unmigrated]}
196+
migrationFilter={migrationFilter}
197+
setMigrationFilter={setMigrationFilter}
197198
setSelectedLibraries={setLegacyLibraries}
198199
/>
199200
</Stepper.Step>
@@ -221,7 +222,7 @@ export const LegacyLibMigrationPage = () => {
221222
</Stepper>
222223
</div>
223224
</Container>
224-
<div className="content-buttons d-flex justify-content-between pl-6 pr-6 bg-white">
225+
<div className="content-buttons d-flex justify-content-between pl-6 pr-6 bg-white box-shadow-up-1">
225226
<Button className="mt-2 mb-2" variant="outline-primary" onClick={handleBack}>
226227
{currentStep === 'select-libraries'
227228
? intl.formatMessage(messages.cancel)

src/legacy-libraries-migration/index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
position: sticky;
5050
top: 0;
5151
right: 0;
52+
height: 100vh;
53+
overflow-y: auto;
5254

5355
hr {
5456
width: 100%;

src/legacy-libraries-migration/messages.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ const messages = defineMessages({
7272
confirmationViewAlert: {
7373
id: 'legacy-libraries-migration.select-destination.alert.text',
7474
defaultMessage: 'These {count, plural, one {{count} legacy library} other {{count} legacy libraries}}'
75-
+ ' will be migrated to <b>{libraryName}</b> and organized as collections. Any legacy libraries that are used in'
76-
+ ' problem banks will maintain their link with migrated content the first time they are migrated.',
75+
+ ' will be migrated to <b>{libraryName}</b> and organized as collections. Legacy library content used'
76+
+ ' in courses will continue to work as-is. To receive any future changes to migrated content,'
77+
+ ' you must update these references within your course.',
7778
description: 'Alert text in the confirmation step of the legacy libraries migration page.',
7879
},
7980
previouslyMigratedAlert: {

src/studio-home/tabs-section/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useNavigate, useLocation } from 'react-router-dom';
1414
import { RequestStatus } from '@src/data/constants';
1515
import { getLoadingStatuses, getStudioHomeData } from '../data/selectors';
1616
import messages from './messages';
17-
import { LibrariesList } from './libraries-tab';
17+
import { BaseFilterState, Filter, LibrariesList } from './libraries-tab';
1818
import LibrariesV2List from './libraries-v2-tab/index';
1919
import CoursesTab from './courses-tab';
2020
import { WelcomeLibrariesV2Alert } from './libraries-v2-tab/WelcomeLibrariesV2Alert';
@@ -29,6 +29,7 @@ const TabsSection = ({
2929
const intl = useIntl();
3030
const navigate = useNavigate();
3131
const { pathname } = useLocation();
32+
const [migrationFilter, setMigrationFilter] = useState<Filter[]>(BaseFilterState);
3233
const TABS_LIST = {
3334
courses: 'courses',
3435
libraries: 'libraries',
@@ -121,7 +122,10 @@ const TabsSection = ({
121122
: messages.librariesTabTitle,
122123
)}
123124
>
124-
<LibrariesList />
125+
<LibrariesList
126+
migrationFilter={migrationFilter}
127+
setMigrationFilter={setMigrationFilter}
128+
/>
125129
</Tab>,
126130
);
127131
}
@@ -137,7 +141,7 @@ const TabsSection = ({
137141
}
138142

139143
return tabs;
140-
}, [showNewCourseContainer, isLoadingCourses]);
144+
}, [showNewCourseContainer, isLoadingCourses, migrationFilter]);
141145

142146
const handleSelectTab = (tab: TabKeyType) => {
143147
if (tab === TABS_LIST.courses) {

src/studio-home/tabs-section/libraries-tab/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export enum Filter {
7070
unmigrated = 'unmigrated',
7171
}
7272

73-
const BaseFilterState = Object.values(Filter);
73+
export const BaseFilterState = Object.values(Filter);
7474

7575
interface MigrationFilterProps {
7676
filters: Filter[];
@@ -146,21 +146,26 @@ interface LibrariesListProps {
146146
handleCheck?: (library: LibraryV1Data, action: 'add' | 'remove') => void;
147147
setSelectedLibraries?: (libraries: LibraryV1Data[]) => void;
148148
hideMigationAlert?: boolean;
149-
initialFilter?: Filter[];
149+
// We lift `migrationFilter` and `setMigrationFilter` into props
150+
// so that the filter state is maintained consistently across different
151+
// steps of the legacy libraries migration flow, and to allow
152+
// parent components to control and persist the filter context.
153+
migrationFilter: Filter[];
154+
setMigrationFilter: React.Dispatch<React.SetStateAction<Filter[]>>;
150155
}
151156

152157
export const LibrariesList = ({
153158
selectedIds,
154159
handleCheck,
155160
setSelectedLibraries,
156161
hideMigationAlert = false,
157-
initialFilter = BaseFilterState,
162+
migrationFilter,
163+
setMigrationFilter,
158164
}: LibrariesListProps) => {
159165
const intl = useIntl();
160166
const { isPending, data, isError } = useLibrariesV1Data();
161167
const [currentPage, setCurrentPage] = useState<number>(1);
162168
const [search, setSearch] = useState<string>('');
163-
const [migrationFilter, setMigrationFilter] = useState<Filter[]>(initialFilter);
164169

165170
let filteredData = findInValues(data?.libraries, search || '') || [];
166171
if (migrationFilter.length === 1) {

0 commit comments

Comments
 (0)