-
-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathProvider.tsx
More file actions
89 lines (80 loc) · 3.38 KB
/
Copy pathProvider.tsx
File metadata and controls
89 lines (80 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import type { HostingProvider, ProviderType } from "@site/src/types/providers";
import ReactMarkdown from "react-markdown";
import Admonition from '@theme/Admonition';
import React, { useState } from 'react';
import Translate, { translate } from "@docusaurus/Translate";
import { providersData } from "../data/providers";
export const noP = (props: { children: any; }) => {
const { children } = props;
return children;
}
export const Provider = ({ type }) => {
const hostingProviders: HostingProvider[] = providersData[type as ProviderType]
return (
<table>
<thead>
<tr>
<th>Provider</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{hostingProviders.map((provider: HostingProvider) => (
<tr>
<td>
<a href={provider.url}>{provider.name}</a>
</td>
<td>
{provider.description != null ? (
<ReactMarkdown children={provider.description} components={{ p: noP }} />
) : (
''
)}
</td>
</tr>
))}
</tbody>
</table>
)
}
export const ProviderSelector = () => {
const providers: HostingProvider[] = [
...Object.values(providersData.built_in),
...Object.values(providersData.support),
...Object.values(providersData.no_support)
].flat().sort((a, b) => a.name.localeCompare(b.name));
providers.unshift({
name: 'Not listed',
description: translate({
id: 'providers.provider.not_listed.description',
message: "If your hosting provider is not listed, try enabling the `clone-remote-port` option in the config. Then, restart the server, and try connecting with the same IP and port as on Java Edition. <br> If this does not work, ask your server hosting provider for a UDP port, and use that. For VPS/KVM servers please follow the self-hosting steps."
})
} as HostingProvider);
const [selectedProvider, setSelectedProvider] = useState(null);
const handleSelectionChange = (event) => {
const selectedName = event.target.value;
const provider = providers.find(p => p.name === selectedName);
setSelectedProvider(provider);
}
return (
<div className="host-select">
<select onChange={handleSelectionChange}>
<option value="none">Select a provider</option>
{providers.map((provider) => (
<option key={provider.name} value={provider.name}>
{provider.name}
</option>
))}
</select>
<Admonition type="tip" title={<Translate id='components.provider.instructions'>Provider Instructions</Translate>}>
{selectedProvider ? (
<ReactMarkdown>{selectedProvider.description}</ReactMarkdown>
) : (
<p>
<Translate id='components.provider.select'>Select a provider to see specific installation instructions</Translate>
</p>
)}
</Admonition>
</div>
);
}