mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
🐛 Fixed marketplace theme installation route (#21616)
no issue - Fixes a potential regression that caused the marketplace install route not to route correctly.
This commit is contained in:
parent
5a3b1d6cf8
commit
e254ddbd17
3 changed files with 18 additions and 6 deletions
|
@ -6,8 +6,7 @@ import type {ModalName} from './routing/modals';
|
|||
export const modalPaths: {[key: string]: ModalName} = {
|
||||
'design/change-theme': 'DesignAndThemeModal',
|
||||
'design/edit': 'DesignAndThemeModal',
|
||||
// this is a special route, because it can install a theme directly from the Ghost Marketplace
|
||||
'design/change-theme/install': 'DesignAndThemeModal',
|
||||
'theme/install': 'DesignAndThemeModal', // this is a special route, because it can install a theme directly from the Ghost Marketplace
|
||||
'navigation/edit': 'NavigationModal',
|
||||
'staff/invite': 'InviteUserModal',
|
||||
'staff/:slug': 'UserDetailModal',
|
||||
|
@ -43,7 +42,7 @@ export const loadModals = () => import('./routing/modals');
|
|||
const SettingsRouter: React.FC = () => {
|
||||
const {updateNavigatedSection, scrollToSection} = useScrollSectionContext();
|
||||
const {route} = useRouting();
|
||||
|
||||
// get current route
|
||||
useRouteChangeCallback((newPath, oldPath) => {
|
||||
if (newPath === oldPath) {
|
||||
scrollToSection(newPath.split('/')[0]);
|
||||
|
|
|
@ -10,13 +10,11 @@ const DesignAndThemeModal: React.FC<RoutingModalProps> = ({pathName}) => {
|
|||
return <DesignModal />;
|
||||
} else if (pathName === 'design/change-theme') {
|
||||
return <ChangeThemeModal />;
|
||||
} else if (pathName === 'design/change-theme/install') {
|
||||
} else if (pathName === 'theme/install') {
|
||||
const url = window.location.href;
|
||||
const fragment = url.split('#')[1];
|
||||
const queryParams = fragment.split('?')[1];
|
||||
|
||||
const searchParams = new URLSearchParams(queryParams);
|
||||
|
||||
const ref = searchParams.get('ref') || null;
|
||||
const source = searchParams.get('source') || null;
|
||||
|
||||
|
|
|
@ -237,4 +237,19 @@ test.describe('Theme settings', async () => {
|
|||
|
||||
await expect(page.getByTestId('confirmation-modal')).toHaveText(/Upload failed/);
|
||||
});
|
||||
|
||||
test('fires Install Theme modal when redirected from markerplace url', async ({page}) => {
|
||||
await mockApi({page, requests: {
|
||||
...globalDataRequests,
|
||||
browseThemes: {method: 'GET', path: '/themes/', response: responseFixtures.themes}
|
||||
}});
|
||||
await page.goto('/#/settings/theme/install?source=github&ref=TryGhost/Taste');
|
||||
|
||||
await page.waitForSelector('[data-testid="theme-modal"]');
|
||||
|
||||
const confirmation = page.getByTestId('confirmation-modal');
|
||||
|
||||
await expect(confirmation).toHaveText(/Install Theme/);
|
||||
await expect(confirmation).toHaveText(/By clicking below, Taste will automatically be activated as the theme for your site/);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue