Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import messages from './i18n';
import {
LibraryAndComponentPicker,
CreateLibrary,
CreateLegacyLibrary,
LibraryLayout,
PreviewChangesEmbed,
} from './library-authoring';
Expand Down Expand Up @@ -75,9 +74,8 @@ const App = () => {
<Route>
<Route path="/home" element={<StudioHome />} />
<Route path="/libraries" element={<StudioHome />} />
<Route path="/libraries-v1" element={<StudioHome />} />

<Route path="/libraries-v1/migrate" element={<LegacyLibMigrationPage />} />
<Route path="/libraries-v1/create" element={<CreateLegacyLibrary />} />
<Route path="/library/create" element={<CreateLibrary />} />
Comment on lines 75 to 79
<Route path="/library/:libraryId/*" element={<LibraryLayout />} />
<Route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ describe('<LegacyLibMigrationPage />', () => {

cancelButton.click();

// Should navigate to legacy libraries tab on studio home
// Should navigate to libraries tab on studio home
expect(await screen.findByText('Exit Migration?')).toBeInTheDocument();
const exitButton = screen.getByRole('button', { name: /exit/i });
exitButton.click();

await waitFor(() => {
expect(mockNavigate).toHaveBeenCalledWith('/libraries-v1');
expect(mockNavigate).toHaveBeenCalledWith('/libraries');
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/legacy-libraries-migration/LegacyLibMigrationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const ExitModal = ({
<ModalDialog.CloseButton variant="tertiary">
<FormattedMessage {...messages.exitModalCancelText} />
</ModalDialog.CloseButton>
<Button onClick={() => navigate('/libraries-v1')}>
<Button onClick={() => navigate('/libraries')}>
<FormattedMessage {...messages.exitModalConfirmText} />
</Button>
</ActionRow>
Expand Down
37 changes: 0 additions & 37 deletions src/studio-home/StudioHome.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
fireEvent,
render,
screen,
waitFor,
initializeMocks,
within,
} from '@src/testUtils';
Expand Down Expand Up @@ -126,25 +125,9 @@ describe('<StudioHome />', () => {
});

describe('render new library button', () => {
it('should navigate to legacy library creation when libraries-v2 disabled', async () => {
mockUseSelector.mockReturnValue({
...studioHomeMock,
courseCreatorStatus: COURSE_CREATOR_STATES.granted,
librariesV2Enabled: false,
});
render(<StudioHome />, { path: '/home' });
await waitFor(() => {
const createNewLibraryButton = screen.getByRole('button', { name: 'New library' });

fireEvent.click(createNewLibraryButton);
expect(mockNavigate).toHaveBeenCalledWith('/libraries-v1/create');
});
});

it('should navigate to the library authoring page in course authoring', async () => {
mockUseSelector.mockReturnValue({
...studioHomeMock,
librariesV1Enabled: false,
});
render(<StudioHome />, { path: '/home' });
const createNewLibraryButton = screen.getByRole('button', { name: 'New library' });
Expand All @@ -153,26 +136,6 @@ describe('<StudioHome />', () => {
});
});

it('does not render new library button for "v1 only" mode if showNewLibraryButton is False', () => {
mockUseSelector.mockReturnValue({
...studioHomeMock,
showNewLibraryButton: false,
librariesV2Enabled: false,
});
render(<StudioHome />, { path: '/home' });
expect(screen.queryByRole('button', { name: 'New library' })).not.toBeInTheDocument();
});

it('render new library button for "v2 only" mode even if showNewLibraryButton is False', () => {
mockUseSelector.mockReturnValue({
...studioHomeMock,
showNewLibraryButton: false,
librariesV1Enabled: false,
});
render(<StudioHome />, { path: '/home' });
expect(screen.queryByRole('button', { name: 'New library' })).toBeInTheDocument();
});

it('should render "create new course" container', async () => {
mockUseSelector.mockReturnValue({
...studioHomeMock,
Expand Down
14 changes: 2 additions & 12 deletions src/studio-home/StudioHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,15 @@ const StudioHome = () => {
hasAbilityToCreateNewCourse,
isFiltered,
setShowNewCourseContainer,
librariesV1Enabled,
librariesV2Enabled,
} = useStudioHome();

const adminConsoleUrl = `${getConfig().ADMIN_CONSOLE_URL}/authz`;

const v1LibraryTab = librariesV1Enabled && location?.pathname.split('/').pop() === 'libraries-v1';
const showV2LibraryURL = librariesV2Enabled && !v1LibraryTab;

const {
userIsActive,
studioShortName,
studioRequestEmail,
showNewLibraryButton,
showNewLibraryV2Button,
} = studioHomeData;

Expand Down Expand Up @@ -103,13 +98,9 @@ const StudioHome = () => {
);
}

if ((showNewLibraryButton && !showV2LibraryURL) || (showV2LibraryURL && showNewLibraryV2Button)) {
if (librariesV2Enabled && showNewLibraryV2Button) {
const newLibraryClick = () => {
if (showV2LibraryURL) {
navigate('/library/create');
} else {
navigate('/libraries-v1/create');
}
navigate('/library/create');
};

headerButtons.push(
Expand Down Expand Up @@ -167,7 +158,6 @@ const StudioHome = () => {
showNewCourseContainer={showNewCourseContainer}
onClickNewCourse={() => setShowNewCourseContainer(true)}
isShowProcessing={Boolean(isShowProcessing) && !isFiltered}
librariesV1Enabled={librariesV1Enabled}
librariesV2Enabled={librariesV2Enabled}
/>
</section>
Expand Down
2 changes: 0 additions & 2 deletions src/studio-home/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const useStudioHome = () => {
studioRequestEmail,
inProcessCourseActions,
courseCreatorStatus,
librariesV1Enabled,
librariesV2Enabled,
} = studioHomeData;

Expand Down Expand Up @@ -113,7 +112,6 @@ const useStudioHome = () => {
hasAbilityToCreateNewCourse,
isFiltered,
setShowNewCourseContainer,
librariesV1Enabled,
librariesV2Enabled,
};
};
Expand Down
Loading