Skip to content

Commit a2b4fbc

Browse files
committed
Basis for Certificate modal
1 parent df33db2 commit a2b4fbc

File tree

9 files changed

+121
-4
lines changed

9 files changed

+121
-4
lines changed

frontend/check-locales.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const ignoreUnused = [
2020
/^type\..*$/,
2121
];
2222

23+
const ignoreMissing = [/^acmesh\..*$/];
24+
2325
const { spawnSync } = require("child_process");
2426
const fs = require("fs");
2527

@@ -53,6 +55,8 @@ const langList = require("./src/locale/src/lang-list.json");
5355

5456
// store a list of all validation errors
5557
const allErrors = [];
58+
const allWarnings = [];
59+
const allKeys = [];
5660

5761
const checkLangList = (fullCode) => {
5862
const key = "locale-" + fullCode;
@@ -103,6 +107,34 @@ const compareLocale = (locale) => {
103107
);
104108
}
105109
}
110+
111+
// Add this key to allKeys
112+
if (allKeys.indexOf(key) === -1) {
113+
allKeys.push(key);
114+
}
115+
return null;
116+
});
117+
};
118+
119+
// Checks for any keys missing from this locale, that
120+
// have been defined in any other locales
121+
const checkForMissing = (locale) => {
122+
allKeys.forEach((key) => {
123+
if (typeof locale.data[key] === "undefined") {
124+
let ignored = false;
125+
ignoreMissing.map((regex) => {
126+
if (key.match(regex)) {
127+
ignored = true;
128+
}
129+
return null;
130+
});
131+
132+
if (!ignored) {
133+
allWarnings.push(
134+
"WARN: `" + locale[0] + "` does not contain item: `" + key + "`",
135+
);
136+
}
137+
}
106138
return null;
107139
});
108140
};
@@ -117,6 +149,7 @@ allLocales.map((locale, idx) => {
117149
// Verify all locale data
118150
allLocales.map((locale) => {
119151
compareLocale(locale);
152+
checkForMissing(locale);
120153
return null;
121154
});
122155

@@ -125,7 +158,15 @@ if (allErrors.length) {
125158
console.log("\x1b[31m%s\x1b[0m", err);
126159
return null;
127160
});
161+
}
162+
if (allWarnings.length) {
163+
allWarnings.map((err) => {
164+
console.log("\x1b[33m%s\x1b[0m", err);
165+
return null;
166+
});
167+
}
128168

169+
if (allErrors.length) {
129170
process.exit(1);
130171
}
131172

frontend/src/locale/src/de.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,30 @@
347347
"theme.to-light": {
348348
"defaultMessage": "Wechseln Sie zum Lichtdesign"
349349
},
350+
"type.custom": {
351+
"defaultMessage": "Custom"
352+
},
353+
"type.dead": {
354+
"defaultMessage": "404 Host"
355+
},
356+
"type.dns": {
357+
"defaultMessage": "DNS"
358+
},
359+
"type.http": {
360+
"defaultMessage": "HTTP"
361+
},
362+
"type.proxy": {
363+
"defaultMessage": "Proxy Host"
364+
},
365+
"type.redirect": {
366+
"defaultMessage": "Redirection"
367+
},
368+
"type.stream": {
369+
"defaultMessage": "Stream"
370+
},
371+
"type.upstream": {
372+
"defaultMessage": "Upstream"
373+
},
350374
"unhealthy.body": {
351375
"defaultMessage": "Wir werden weiterhin den Zustand überprüfen und hoffen, bald wieder einsatzbereit zu sein!"
352376
},

frontend/src/locale/src/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@
626626
"theme.to-light": {
627627
"defaultMessage": "Switch to light theme"
628628
},
629+
"type.custom": {
630+
"defaultMessage": "Custom"
631+
},
629632
"type.dead": {
630633
"defaultMessage": "404 Host"
631634
},

frontend/src/locale/src/fa.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,30 @@
350350
"theme.to-light": {
351351
"defaultMessage": "به طرح زمینه روشن تغییر دهید"
352352
},
353+
"type.custom": {
354+
"defaultMessage": "Custom"
355+
},
356+
"type.dead": {
357+
"defaultMessage": "404 Host"
358+
},
359+
"type.dns": {
360+
"defaultMessage": "DNS"
361+
},
362+
"type.http": {
363+
"defaultMessage": "HTTP"
364+
},
365+
"type.proxy": {
366+
"defaultMessage": "Proxy Host"
367+
},
368+
"type.redirect": {
369+
"defaultMessage": "Redirection"
370+
},
371+
"type.stream": {
372+
"defaultMessage": "Stream"
373+
},
374+
"type.upstream": {
375+
"defaultMessage": "Upstream"
376+
},
353377
"unhealthy.body": {
354378
"defaultMessage": "ما همچنان به بررسی وضعیت سلامتی خود ادامه خواهیم داد و امیدواریم به زودی دوباره راه اندازی شده و کار کنیم!"
355379
},

frontend/src/modals/CertificateCreateModal.tsx renamed to frontend/src/modals/CertificateCreateModal/CertificateCreateModal.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { useSetCertificate } from "hooks";
2424
import { intl } from "locale";
2525
import { validateString } from "modules/Validations";
2626

27+
import HTTPForm from "./HTTPForm";
28+
2729
interface CertificateCreateModalProps {
2830
isOpen: boolean;
2931
onClose: () => void;
@@ -104,13 +106,18 @@ function CertificateCreateModal({
104106
<ButtonGroup style={{ width: "100%" }}>
105107
<Button
106108
onClick={() => setCertType("http")}
107-
style={{ width: "50%" }}>
108-
HTTP
109+
style={{ width: "33%" }}>
110+
{intl.formatMessage({ id: "type.http" })}
109111
</Button>
110112
<Button
111113
onClick={() => setCertType("dns")}
112-
style={{ width: "50%" }}>
113-
DNS
114+
style={{ width: "34%" }}>
115+
{intl.formatMessage({ id: "type.dns" })}
116+
</Button>
117+
<Button
118+
onClick={() => setCertType("custom")}
119+
style={{ width: "33%" }}>
120+
{intl.formatMessage({ id: "type.custom" })}
114121
</Button>
115122
</ButtonGroup>
116123
</FormControl>
@@ -143,6 +150,8 @@ function CertificateCreateModal({
143150
</Field>
144151
</Stack>
145152
) : null}
153+
154+
{certType === "http" ? <HTTPForm /> : null}
146155
</ModalBody>
147156
<ModalFooter>
148157
{certType !== "" ? (
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function CustomForm() {
2+
return <p>Custom form</p>;
3+
}
4+
5+
export default CustomForm;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function DNSForm() {
2+
return <p>DNS form</p>;
3+
}
4+
5+
export default DNSForm;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function HTTPForm() {
2+
return <p>Http form</p>;
3+
}
4+
5+
export default HTTPForm;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./CertificateCreateModal";

0 commit comments

Comments
 (0)