mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Added theme management apis in adminX
refs https://github.com/TryGhost/Team/issues/3432
This commit is contained in:
parent
778e9a5f96
commit
5cc1c43257
@ -126,3 +126,14 @@ export type CustomThemeSetting = CustomThemeSettingData & {
|
||||
// homepage and post are the only two groups we handle, but technically theme authors can put other things in package.json
|
||||
group?: 'homepage' | 'post' | string
|
||||
}
|
||||
|
||||
export type Theme = {
|
||||
active: boolean;
|
||||
name: string;
|
||||
package: {
|
||||
name?: string;
|
||||
description?: string;
|
||||
version?: string;
|
||||
};
|
||||
templates?: string[];
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {CustomThemeSetting, Label, Offer, Post, Setting, SiteData, Tier, User, UserRole} from '../types/api';
|
||||
import {CustomThemeSetting, Label, Offer, Post, Setting, SiteData, Theme, Tier, User, UserRole} from '../types/api';
|
||||
import {getGhostPaths} from './helpers';
|
||||
|
||||
interface Meta {
|
||||
@ -90,6 +90,10 @@ export interface PasswordUpdateResponseType {
|
||||
}];
|
||||
}
|
||||
|
||||
export interface ThemesResponseType {
|
||||
themes: Theme[];
|
||||
}
|
||||
|
||||
interface RequestOptions {
|
||||
method?: string;
|
||||
body?: string | FormData;
|
||||
@ -160,6 +164,12 @@ interface API {
|
||||
offers: {
|
||||
browse: () => Promise<OffersResponseType>
|
||||
};
|
||||
themes: {
|
||||
browse: () => Promise<ThemesResponseType>;
|
||||
activate: (themeName: string) => Promise<ThemesResponseType>;
|
||||
delete: (themeName: string) => Promise<void>;
|
||||
upload: ({file}: {file: File}) => Promise<ThemesResponseType>;
|
||||
};
|
||||
}
|
||||
|
||||
interface GhostApiOptions {
|
||||
@ -386,6 +396,38 @@ function setupGhostApi({ghostVersion}: GhostApiOptions): API {
|
||||
const data: OffersResponseType = await response.json();
|
||||
return data;
|
||||
}
|
||||
},
|
||||
themes: {
|
||||
browse: async () => {
|
||||
const response = await fetcher('/themes/');
|
||||
const data: ThemesResponseType = await response.json();
|
||||
return data;
|
||||
},
|
||||
activate: async (themeName: string) => {
|
||||
const response = await fetcher(`/themes/${themeName}/activate/`, {
|
||||
method: 'PUT'
|
||||
});
|
||||
const data: ThemesResponseType = await response.json();
|
||||
return data;
|
||||
},
|
||||
delete: async (themeName: string) => {
|
||||
await fetcher(`/themes/${themeName}/`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
return;
|
||||
},
|
||||
upload: async ({file}: {file: File}) => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
const response = await fetcher(`/themes/upload/`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
headers: {}
|
||||
});
|
||||
const data: ThemesResponseType = await response.json();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user