load theme list in site-form.tsx

This commit is contained in:
Felix Ableitner 2022-03-01 19:07:42 +01:00
parent 886a444e16
commit 7cd884ad92

View file

@ -6,7 +6,7 @@ import { WebSocketService } from "../../services";
import {
authField,
capitalizeFirstLetter,
themes,
fetchThemeList,
wsClient,
} from "../../utils";
import { Spinner } from "../common/icon";
@ -21,6 +21,7 @@ interface SiteFormProps {
interface SiteFormState {
siteForm: EditSite;
loading: boolean;
themeList: string[];
}
export class SiteForm extends Component<SiteFormProps, SiteFormState> {
@ -40,6 +41,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
auth: authField(),
},
loading: false,
themeList: [],
};
constructor(props: any, context: any) {
@ -78,6 +80,11 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
}
}
async componentDidMount() {
this.state.themeList = await fetchThemeList();
this.setState(this.state);
}
// Necessary to stop the loading
componentWillReceiveProps() {
this.state.loading = false;
@ -336,7 +343,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
class="custom-select w-auto"
>
<option value="browser">{i18n.t("browser_default")}</option>
{themes.map(theme => (
{this.state.themeList.map(theme => (
<option value={theme}>{theme}</option>
))}
</select>