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} = {
|
export const modalPaths: {[key: string]: ModalName} = {
|
||||||
'design/change-theme': 'DesignAndThemeModal',
|
'design/change-theme': 'DesignAndThemeModal',
|
||||||
'design/edit': 'DesignAndThemeModal',
|
'design/edit': 'DesignAndThemeModal',
|
||||||
// this is a special route, because it can install a theme directly from the Ghost Marketplace
|
'theme/install': 'DesignAndThemeModal', // this is a special route, because it can install a theme directly from the Ghost Marketplace
|
||||||
'design/change-theme/install': 'DesignAndThemeModal',
|
|
||||||
'navigation/edit': 'NavigationModal',
|
'navigation/edit': 'NavigationModal',
|
||||||
'staff/invite': 'InviteUserModal',
|
'staff/invite': 'InviteUserModal',
|
||||||
'staff/:slug': 'UserDetailModal',
|
'staff/:slug': 'UserDetailModal',
|
||||||
|
@ -43,7 +42,7 @@ export const loadModals = () => import('./routing/modals');
|
||||||
const SettingsRouter: React.FC = () => {
|
const SettingsRouter: React.FC = () => {
|
||||||
const {updateNavigatedSection, scrollToSection} = useScrollSectionContext();
|
const {updateNavigatedSection, scrollToSection} = useScrollSectionContext();
|
||||||
const {route} = useRouting();
|
const {route} = useRouting();
|
||||||
|
// get current route
|
||||||
useRouteChangeCallback((newPath, oldPath) => {
|
useRouteChangeCallback((newPath, oldPath) => {
|
||||||
if (newPath === oldPath) {
|
if (newPath === oldPath) {
|
||||||
scrollToSection(newPath.split('/')[0]);
|
scrollToSection(newPath.split('/')[0]);
|
||||||
|
|
|
@ -10,13 +10,11 @@ const DesignAndThemeModal: React.FC<RoutingModalProps> = ({pathName}) => {
|
||||||
return <DesignModal />;
|
return <DesignModal />;
|
||||||
} else if (pathName === 'design/change-theme') {
|
} else if (pathName === 'design/change-theme') {
|
||||||
return <ChangeThemeModal />;
|
return <ChangeThemeModal />;
|
||||||
} else if (pathName === 'design/change-theme/install') {
|
} else if (pathName === 'theme/install') {
|
||||||
const url = window.location.href;
|
const url = window.location.href;
|
||||||
const fragment = url.split('#')[1];
|
const fragment = url.split('#')[1];
|
||||||
const queryParams = fragment.split('?')[1];
|
const queryParams = fragment.split('?')[1];
|
||||||
|
|
||||||
const searchParams = new URLSearchParams(queryParams);
|
const searchParams = new URLSearchParams(queryParams);
|
||||||
|
|
||||||
const ref = searchParams.get('ref') || null;
|
const ref = searchParams.get('ref') || null;
|
||||||
const source = searchParams.get('source') || 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/);
|
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