mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-01 21:26:46 +00:00
Compare commits
639 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5e92c6897 | ||
|
|
f1014a4810 | ||
|
|
1793424658 | ||
|
|
c94a5b948e | ||
|
|
107cabcd8b | ||
|
|
99bc769894 | ||
|
|
e8f1964941 | ||
|
|
1a491bec1c | ||
|
|
4ba63cdbf8 | ||
|
|
b2c2af3ebb | ||
|
|
9dca19fcb5 | ||
|
|
7c2dab43e1 | ||
|
|
a8c6d9b034 | ||
|
|
be0cb20fa2 | ||
|
|
2ac1025e9f | ||
|
|
27d79b574e | ||
|
|
1b82f42a33 | ||
|
|
f3f9eac67b | ||
|
|
2a86a0e540 | ||
|
|
d14aea708e | ||
|
|
12a05b422d | ||
|
|
a5abe9dbf2 | ||
|
|
07fcb4e016 | ||
|
|
e2cbb2713a | ||
|
|
706e00ace0 | ||
|
|
655fbf94c1 | ||
|
|
afc574aceb | ||
|
|
3da2b56426 | ||
|
|
5f91ad8819 | ||
|
|
131a745514 | ||
|
|
86349f1ad3 | ||
|
|
72e4a7b062 | ||
|
|
0a0165df45 | ||
|
|
992b22fd24 | ||
|
|
6fbe6c673b | ||
|
|
ff22e54b59 | ||
|
|
578365ab68 | ||
|
|
22905a2efc | ||
|
|
26bad75a1a | ||
|
|
04e1950591 | ||
|
|
340f4b8fb5 | ||
|
|
457458a894 | ||
|
|
f6334c3618 | ||
|
|
cf27de965e | ||
|
|
43b2926063 | ||
|
|
1d6464fefb | ||
|
|
927ab76dbd | ||
|
|
34cfe2077b | ||
|
|
4ebe23e89f | ||
|
|
8fa61a6301 | ||
|
|
96c20b36a5 | ||
|
|
a9af5163c1 | ||
|
|
b87b108e53 | ||
|
|
ddaec7c6ac | ||
|
|
4e8e16f16d | ||
|
|
9cefdb7977 | ||
|
|
a6d000714b | ||
|
|
54758272be | ||
|
|
8e9e2c5b61 | ||
|
|
934bf495a0 | ||
|
|
1d8189369c | ||
|
|
25aa9b9bd7 | ||
|
|
a1b879a5b4 | ||
|
|
b70724f7d6 | ||
|
|
a52f96f8e5 | ||
|
|
970c573a12 | ||
|
|
46749044e2 | ||
|
|
16d748800c | ||
|
|
3e698b045a | ||
|
|
999b21577a | ||
|
|
3be5126e2d | ||
|
|
2b14c49c80 | ||
|
|
bace2a10e8 | ||
|
|
006e6b30b7 | ||
|
|
4c5d0321d2 | ||
|
|
fa69c21fa2 | ||
|
|
95439e5602 | ||
|
|
bbd8d8ef4e | ||
|
|
ef269d565c | ||
|
|
8acf6dda6e | ||
|
|
d18219dc14 | ||
|
|
3f1718f4c5 | ||
|
|
825a749b45 | ||
|
|
c2eb09e664 | ||
|
|
adb670dd0c | ||
|
|
5e9ec071dc | ||
|
|
1f41f8da23 | ||
|
|
2a5480da79 | ||
|
|
7add854b40 | ||
|
|
e639cd0bd2 | ||
|
|
3503f1f580 | ||
|
|
853dcbd69a | ||
|
|
c54fff5472 | ||
|
|
699d3d3eaa | ||
|
|
0c91f488f0 | ||
|
|
d3a644877e | ||
|
|
aac2832eb7 | ||
|
|
487c832f5b | ||
|
|
98e2e57bb2 | ||
|
|
c5170df402 | ||
|
|
4be38dfd0c | ||
|
|
597f2b69e9 | ||
|
|
c078a5fb55 | ||
|
|
5db0326350 | ||
|
|
7f6c678eaa | ||
|
|
37ac6cebc1 | ||
|
|
27099aa7fb | ||
|
|
91f4d09608 | ||
|
|
d34b9b1233 | ||
|
|
2badd2b743 | ||
|
|
4517f38680 | ||
|
|
84f9727836 | ||
|
|
85452cde23 | ||
|
|
9b19113262 | ||
|
|
e1bb091363 | ||
|
|
732d664715 | ||
|
|
33498ce903 | ||
|
|
c25b74de84 | ||
|
|
1c39e3402b | ||
|
|
a3bd10bc82 | ||
|
|
d6d237fc52 | ||
|
|
9b7a169110 | ||
|
|
2b17a24206 | ||
|
|
a0d9bd6f09 | ||
|
|
cd33abd92d | ||
|
|
c83563c0ea | ||
|
|
79515ac960 | ||
|
|
8e8a5f3fd6 | ||
|
|
51283cc130 | ||
|
|
4023c077b3 | ||
|
|
f3cf21ba08 | ||
|
|
bec7b59abf | ||
|
|
3e0abe329f | ||
|
|
822fe3db9e | ||
|
|
408ec82a10 | ||
|
|
ced3fa00ef | ||
|
|
595b3c0450 | ||
|
|
1d1c8153e7 | ||
|
|
52f556eb2e | ||
|
|
35fcd20123 | ||
|
|
e518b94fba | ||
|
|
05553ba18a | ||
|
|
4a9e05cf17 | ||
|
|
60fc351344 | ||
|
|
815e06809a | ||
|
|
bfcdf703e8 | ||
|
|
ddb2c1e641 | ||
|
|
e790360de9 | ||
|
|
b00f6fadf8 | ||
|
|
1d6f4bf5db | ||
|
|
80cea91339 | ||
|
|
5942cd6fcf | ||
|
|
2859ba6cd2 | ||
|
|
b9285fd600 | ||
|
|
901df2b90d | ||
|
|
662573d940 | ||
|
|
a8dcd3cac7 | ||
|
|
0ac16a1626 | ||
|
|
5162fa2a13 | ||
|
|
73a3d1d50f | ||
|
|
afc272c4d9 | ||
|
|
f8bcaed3ad | ||
|
|
d1a1b7426e | ||
|
|
99485cc6d8 | ||
|
|
187fee46f4 | ||
|
|
90837546ab | ||
|
|
f4cf4850a3 | ||
|
|
4ef1e491bc | ||
|
|
170f45d46b | ||
|
|
37caa1ad19 | ||
|
|
0312a0911c | ||
|
|
cc88f7678c | ||
|
|
653b470fec | ||
|
|
2603f2f987 | ||
|
|
b106b3cd0a | ||
|
|
b2b6b3af18 | ||
|
|
f911f78c95 | ||
|
|
a7560443f3 | ||
|
|
ab757b2f67 | ||
|
|
261cc68624 | ||
|
|
dc2db3a463 | ||
|
|
ae625e4c8a | ||
|
|
6f5c5b122f | ||
|
|
5d712d7d78 | ||
|
|
1654784471 | ||
|
|
7d83e434e6 | ||
|
|
97a54d44c7 | ||
|
|
6694ca6918 | ||
|
|
8e61e94fba | ||
|
|
69b1c8039e | ||
|
|
5bd89efc09 | ||
|
|
e5185f2099 | ||
|
|
d2ebc880a0 | ||
|
|
165afa436d | ||
|
|
a3f5095dce | ||
|
|
7bda5769fb | ||
|
|
0bf859d485 | ||
|
|
b79dced185 | ||
|
|
e368e618f3 | ||
|
|
bc4c69f207 | ||
|
|
32f29a84f7 | ||
|
|
f0a6420ba9 | ||
|
|
cf91637848 | ||
|
|
9bdf55374c | ||
|
|
d21758c410 | ||
|
|
bc2c945fee | ||
|
|
db2853880d | ||
|
|
cb76c89a08 | ||
|
|
059fa37ca7 | ||
|
|
54cc99448b | ||
|
|
a5dd96805d | ||
|
|
1e155af948 | ||
|
|
dd9ee044eb | ||
|
|
bd8ea17c84 | ||
|
|
0236f5132d | ||
|
|
b8adf5f274 | ||
|
|
c4bce5ec0a | ||
|
|
5bfe7dd128 | ||
|
|
9b3bdebb28 | ||
|
|
7575387236 | ||
|
|
984a99b24e | ||
|
|
a0767417b3 | ||
|
|
790c69ba80 | ||
|
|
f7ba974d97 | ||
|
|
1eab5af5c7 | ||
|
|
3df0bf79f8 | ||
|
|
34aa156d5f | ||
|
|
a88ebc26a9 | ||
|
|
d800062159 | ||
|
|
e5afe4f767 | ||
|
|
ee7a091586 | ||
|
|
7add83f985 | ||
|
|
16bee43f12 | ||
|
|
ba48104c5c | ||
|
|
cc620ddf79 | ||
|
|
6103f6a89b | ||
|
|
4b2c3d2db7 | ||
|
|
dac69daf03 | ||
|
|
3e474a3f2d | ||
|
|
f81999a4fe | ||
|
|
fd80fd65c9 | ||
|
|
ab7c52d049 | ||
|
|
a3cc3d5fc2 | ||
|
|
a6ed0c811d | ||
|
|
8e6b9c5afb | ||
|
|
b9efdd69f1 | ||
|
|
3b96b89492 | ||
|
|
32f7374d92 | ||
|
|
c6eec8b266 | ||
|
|
634ae94542 | ||
|
|
5095a2c59e | ||
|
|
002d2ba8e6 | ||
|
|
d44fe945d8 | ||
|
|
6221f9ed05 | ||
|
|
2e0e24d87b | ||
|
|
a1d869900b | ||
|
|
d90f6c2019 | ||
|
|
ed4c03f154 | ||
|
|
7bfccafca8 | ||
|
|
ae49090bad | ||
|
|
979c16eb9c | ||
|
|
fe85291772 | ||
|
|
893c5ace6f | ||
|
|
89423737e8 | ||
|
|
f9bfb742da | ||
|
|
b7622b2b38 | ||
|
|
8cfb4cf1e1 | ||
|
|
b9e02cf344 | ||
|
|
033df3c3d6 | ||
|
|
692eaf7dc9 | ||
|
|
22b3794154 | ||
|
|
dbb08a6ce0 | ||
|
|
0571a4a88f | ||
|
|
648744f440 | ||
|
|
f8fc1245ca | ||
|
|
5ecc791b38 | ||
|
|
2183b09ffe | ||
|
|
085ab521c3 | ||
|
|
61b274bab9 | ||
|
|
4ca31fc162 | ||
|
|
ae1d39bede | ||
|
|
f803941fe4 | ||
|
|
f93bb88d35 | ||
|
|
ea199dbf8f | ||
|
|
526d7195bc | ||
|
|
cf4143e4e2 | ||
|
|
0f552ae6f4 | ||
|
|
830071278e | ||
|
|
d468fb1efe | ||
|
|
2a268de2cb | ||
|
|
77cbb8ebc4 | ||
|
|
bf84e4a2ed | ||
|
|
a316366ae9 | ||
|
|
50823003b4 | ||
|
|
7c61033bdf | ||
|
|
d588d8d9ef | ||
|
|
cd90d3e581 | ||
|
|
54407af980 | ||
|
|
a31cdcc9f0 | ||
|
|
10d4419387 | ||
|
|
6f67f7bbf0 | ||
|
|
90ef41b419 | ||
|
|
62ab86aefa | ||
|
|
1dd26fb76f | ||
|
|
4a95724425 | ||
|
|
f209fa2d58 | ||
|
|
85e2aab4df | ||
|
|
26c3ea19f4 | ||
|
|
a1e2cd7274 | ||
|
|
6363822ffd | ||
|
|
34f4411aa1 | ||
|
|
b6d08e2203 | ||
|
|
4fa6ae493d | ||
|
|
79645099ba | ||
|
|
18d478e16e | ||
|
|
da97b76563 | ||
|
|
d25dbd5ae6 | ||
|
|
88e8f3363b | ||
|
|
24483ec330 | ||
|
|
15a9fba091 | ||
|
|
73e2485e09 | ||
|
|
0d94879e49 | ||
|
|
6df12ce194 | ||
|
|
c3b60367f3 | ||
|
|
10d3deff37 | ||
|
|
3cb79c167e | ||
|
|
57a17d7e92 | ||
|
|
894934fd08 | ||
|
|
5a8aae3614 | ||
|
|
3dde1a5b05 | ||
|
|
e6c79c19c2 | ||
|
|
d64abeecdc | ||
|
|
da6d45a72c | ||
|
|
497a735d80 | ||
|
|
89f031b338 | ||
|
|
47630dbcd2 | ||
|
|
0d57684565 | ||
|
|
5880767ac3 | ||
|
|
14c4c29af3 | ||
|
|
9f5614446e | ||
|
|
d755e8ffc4 | ||
|
|
a7a968ab6e | ||
|
|
f5757c6081 | ||
|
|
29fa4fa34d | ||
|
|
d2de9fb669 | ||
|
|
e124cd2490 | ||
|
|
e76c9041b5 | ||
|
|
755ae23fdb | ||
|
|
90fde34a45 | ||
|
|
563c60668a | ||
|
|
3a657e1e2f | ||
|
|
4466d733b4 | ||
|
|
dadecdc674 | ||
|
|
a2440d3180 | ||
|
|
56e6a2a16d | ||
|
|
c918eaf903 | ||
|
|
324eda25e0 | ||
|
|
a46116d936 | ||
|
|
8fd419dc72 | ||
|
|
18b27dbd0c | ||
|
|
0c17818a24 | ||
|
|
b1749ee2ef | ||
|
|
27b82c56b1 | ||
|
|
f69bda351d | ||
|
|
4a92d0ff11 | ||
|
|
b37a983bde | ||
|
|
97cf3b26b0 | ||
|
|
c490835f9b | ||
|
|
a3ab2c6e1b | ||
|
|
ce5108937d | ||
|
|
9164db181c | ||
|
|
aa14a17ad6 | ||
|
|
d67b8c0530 | ||
|
|
d41c1a2a52 | ||
|
|
3b938251d9 | ||
|
|
b8aa068876 | ||
|
|
5d288de390 | ||
|
|
af851e708b | ||
|
|
72399e7ccd | ||
|
|
1ffd71e81f | ||
|
|
d627de8e83 | ||
|
|
fc4fdb4fc7 | ||
|
|
126537185b | ||
|
|
24de0773d8 | ||
|
|
cc77af6142 | ||
|
|
c16460af82 | ||
|
|
4c7bed90a3 | ||
|
|
491b2f2c07 | ||
|
|
a038f5e618 | ||
|
|
9ba74328ff | ||
|
|
90a643761a | ||
|
|
6236d36372 | ||
|
|
065c908153 | ||
|
|
a14e612a38 | ||
|
|
0b155b1d20 | ||
|
|
9b9cfd0543 | ||
|
|
3d067371d3 | ||
|
|
381eb5a502 | ||
|
|
4a88f30d13 | ||
|
|
bdf181adec | ||
|
|
f97fce873b | ||
|
|
879017ecca | ||
|
|
83150331e5 | ||
|
|
7249ec4968 | ||
|
|
3ac148f7cd | ||
|
|
a73472f7e5 | ||
|
|
08ca59f990 | ||
|
|
d07f7e757e | ||
|
|
cb13e82b9c | ||
|
|
fd7aa570ed | ||
|
|
c00053f6e1 | ||
|
|
2e0e7f361c | ||
|
|
21101d4da8 | ||
|
|
65f739499f | ||
|
|
91ee4a32cd | ||
|
|
498668929f | ||
|
|
935b12763b | ||
|
|
28b15e4a85 | ||
|
|
6af49a9945 | ||
|
|
c80ad70e3b | ||
|
|
1a20065053 | ||
|
|
edef36bae8 | ||
|
|
3cd25dc2df | ||
|
|
43840d7656 | ||
|
|
a1bdb75036 | ||
|
|
ac0107d450 | ||
|
|
d3d2cf72b9 | ||
|
|
eb9ec4ec31 | ||
|
|
3201830b27 | ||
|
|
58ddec6aff | ||
|
|
59fd58b824 | ||
|
|
efa07f0368 | ||
|
|
1dd6a8e2e4 | ||
|
|
bcd3fa8ce4 | ||
|
|
6ff3cf544b | ||
|
|
ab21f923c6 | ||
|
|
b75fd2e03a | ||
|
|
ec7c7d521f | ||
|
|
f9909713d9 | ||
|
|
59087ced8a | ||
|
|
84435714f5 | ||
|
|
6bd628712e | ||
|
|
997f4a6bdc | ||
|
|
b1fec831c5 | ||
|
|
54fe849efd | ||
|
|
8bf1a9d023 | ||
|
|
07cedd0bdb | ||
|
|
44a93ae556 | ||
|
|
72f790b28c | ||
|
|
a63f7e741a | ||
|
|
58f952df8a | ||
|
|
2acd0ec95d | ||
|
|
105254d053 | ||
|
|
e538f2a3bb | ||
|
|
98ea491469 | ||
|
|
10e50efb33 | ||
|
|
d60023f585 | ||
|
|
c0d5feb433 | ||
|
|
2451167296 | ||
|
|
4a70e4ecd3 | ||
|
|
a90c3da7b6 | ||
|
|
53e15b041d | ||
|
|
7669254a0c | ||
|
|
b450e4093e | ||
|
|
a012d6206f | ||
|
|
30f502a51b | ||
|
|
4defeaf017 | ||
|
|
7f35fb0ada | ||
|
|
cd1a926292 | ||
|
|
e46506b264 | ||
|
|
807c5c3fb4 | ||
|
|
64efb1d43d | ||
|
|
49e1f82b03 | ||
|
|
1bd8636c19 | ||
|
|
cfe84e1275 | ||
|
|
5dda4731a0 | ||
|
|
ce830ea6d3 | ||
|
|
b217b70dfe | ||
|
|
ceee26ad25 | ||
|
|
876018390d | ||
|
|
0366f3544b | ||
|
|
b964ba5317 | ||
|
|
494e36c842 | ||
|
|
9c611a5b13 | ||
|
|
357c478640 | ||
|
|
89f830d9bb | ||
|
|
56150e8707 | ||
|
|
1d60db25bd | ||
|
|
2cac1d9fd2 | ||
|
|
e70724f058 | ||
|
|
27a05e55c9 | ||
|
|
0a0de86ecd | ||
|
|
ec025b7d0f | ||
|
|
744cea1f11 | ||
|
|
073617b6d3 | ||
|
|
8d69945e8e | ||
|
|
3f34a1fb87 | ||
|
|
7bbc7250dd | ||
|
|
63433864d3 | ||
|
|
e53f90fc5c | ||
|
|
33adb08105 | ||
|
|
4a610d182c | ||
|
|
8655d9be87 | ||
|
|
9962ddcd36 | ||
|
|
e117429373 | ||
|
|
dd0f5f961c | ||
|
|
f0b5505770 | ||
|
|
c63b4f9f21 | ||
|
|
6ed19af295 | ||
|
|
46f7a67b14 | ||
|
|
6f2639fd1f | ||
|
|
f1568eb43b | ||
|
|
aefc632ed7 | ||
|
|
bd3555db94 | ||
|
|
ed366fa4cc | ||
|
|
30aeba0af2 | ||
|
|
b4c3bd16b1 | ||
|
|
4b97abaf72 | ||
|
|
e387706a7b | ||
|
|
a7cc8786c3 | ||
|
|
5c0573deb7 | ||
|
|
bc8956db4a | ||
|
|
d44be88b3f | ||
|
|
64ee9a39cc | ||
|
|
4999f982e4 | ||
|
|
f3f0dbac19 | ||
|
|
c2818645c4 | ||
|
|
b0a4aee175 | ||
|
|
67c45f444b | ||
|
|
a8c6e916cf | ||
|
|
f3570d0c9d | ||
|
|
653be14e77 | ||
|
|
71c8b596e7 | ||
|
|
ba45b6a7a6 | ||
|
|
cd311aeaa5 | ||
|
|
4f7a6d5c96 | ||
|
|
a4fb439dd4 | ||
|
|
3870752bba | ||
|
|
7f059c3f3b | ||
|
|
686fe5abbe | ||
|
|
1f47658c3c | ||
|
|
d582a0f9e5 | ||
|
|
b1d51a4103 | ||
|
|
fb0adf74f3 | ||
|
|
0b16300a70 | ||
|
|
43302ef5a8 | ||
|
|
3846ca293c | ||
|
|
00f154ef4e | ||
|
|
4ea826ed2c | ||
|
|
d327142d00 | ||
|
|
37adcb52cf | ||
|
|
fcbb9cda12 | ||
|
|
116c36febc | ||
|
|
43a409fb30 | ||
|
|
63f26d0089 | ||
|
|
218ea09d23 | ||
|
|
a322886710 | ||
|
|
29182ae349 | ||
|
|
bc3bc8dd8a | ||
|
|
e128b847be | ||
|
|
f72251c125 | ||
|
|
9784cbb3ac | ||
|
|
e6f9003fb6 | ||
|
|
e8a5eadd2b | ||
|
|
337bfc47c1 | ||
|
|
677f1da8df | ||
|
|
8918b1ac96 | ||
|
|
0de8eb1568 | ||
|
|
c00aaa9018 | ||
|
|
e837ee5225 | ||
|
|
fc589a0b29 | ||
|
|
b0769d1cf8 | ||
|
|
5befd67270 | ||
|
|
59bdeb67bc | ||
|
|
2d1de2cac8 | ||
|
|
d3f180f270 | ||
|
|
5482766d03 | ||
|
|
dfbe43ef02 | ||
|
|
ed7bb20bbb | ||
|
|
57a2a03469 | ||
|
|
df9c1a88fc | ||
|
|
c8b78d04e2 | ||
|
|
c516969686 | ||
|
|
fd4295ade8 | ||
|
|
39d4f8c73d | ||
|
|
d9b55f1d95 | ||
|
|
66d8a32f49 | ||
|
|
8b091a7b23 | ||
|
|
8edb3dc923 | ||
|
|
a93d1e821d | ||
|
|
9c5cad7571 | ||
|
|
b970b38c29 | ||
|
|
763ef207f1 | ||
|
|
a949ec9e8e | ||
|
|
9518ad9bb4 | ||
|
|
5a0d67e409 | ||
|
|
e6932e7353 | ||
|
|
ddb08f4d2e | ||
|
|
368f7acd2d | ||
|
|
6714f90c37 | ||
|
|
bbaa4d0f05 | ||
|
|
3aa990a1b0 | ||
|
|
464ee11d0d | ||
|
|
f909d38130 | ||
|
|
77e59c886d | ||
|
|
05254326cb | ||
|
|
932dec3bde | ||
|
|
e976a0c716 | ||
|
|
71b68562db | ||
|
|
460d2d23ce | ||
|
|
6aee08b866 | ||
|
|
271b19a4ec | ||
|
|
d5b1dc5bff | ||
|
|
965e69c525 | ||
|
|
bd549c8642 | ||
|
|
66edaed3a0 | ||
|
|
79831322fd | ||
|
|
ed1c5a2197 | ||
|
|
6d32379b67 | ||
|
|
56a62ae505 | ||
|
|
50072f5997 | ||
|
|
e875e05538 | ||
|
|
e2c8551baf | ||
|
|
1b0a2811e0 | ||
|
|
9cac4d23a7 | ||
|
|
b323ddbd33 | ||
|
|
98450ebec3 | ||
|
|
28a5166f56 | ||
|
|
4f128b3fe8 | ||
|
|
fd5060b996 | ||
|
|
a2df486280 | ||
|
|
4e9b19afd1 | ||
|
|
4d78949b8d | ||
|
|
13bafdc924 | ||
|
|
ea95e8e7b5 | ||
|
|
eaa1a2f2ca | ||
|
|
9d6121903e | ||
|
|
2795bf050e | ||
|
|
0e4e430673 |
@@ -1,5 +1,4 @@
|
|||||||
./.github
|
./.github
|
||||||
./.stryker-tmp
|
|
||||||
./build
|
./build
|
||||||
./coverage
|
./coverage
|
||||||
./node_modules
|
./node_modules
|
||||||
|
|||||||
20
.eslintrc
20
.eslintrc
@@ -1,24 +1,16 @@
|
|||||||
{
|
{
|
||||||
|
"root": true,
|
||||||
"extends": [
|
"extends": [
|
||||||
"@shlinkio/js-coding-standard"
|
"@shlinkio/js-coding-standard"
|
||||||
],
|
],
|
||||||
"plugins": ["jest"],
|
|
||||||
"env": {
|
|
||||||
"jest/globals": true
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"tsconfigRootDir": ".",
|
"project": "./tsconfig.json"
|
||||||
"createDefaultProgram": true
|
|
||||||
},
|
|
||||||
"globals": {
|
|
||||||
"process": true,
|
|
||||||
"setImmediate": true
|
|
||||||
},
|
},
|
||||||
"ignorePatterns": ["src/service*.ts"],
|
"ignorePatterns": ["src/service*.ts"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"complexity": "off",
|
"jsx-a11y/control-has-associated-label": "off",
|
||||||
"@typescript-eslint/no-unnecessary-type-assertion": "off",
|
"jsx-a11y/label-has-associated-control": "off",
|
||||||
"@typescript-eslint/no-unsafe-return": "off",
|
"jsx-a11y/click-events-have-key-events": "off",
|
||||||
"@typescript-eslint/no-unsafe-call": "off"
|
"jsx-a11y/no-static-element-interactions": "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -11,6 +11,6 @@ jobs:
|
|||||||
ci:
|
ci:
|
||||||
uses: shlinkio/github-actions/.github/workflows/web-app-ci.yml@main
|
uses: shlinkio/github-actions/.github/workflows/web-app-ci.yml@main
|
||||||
with:
|
with:
|
||||||
node-version: 16.13
|
node-version: 20.2
|
||||||
with-mutation-tests: true
|
|
||||||
publish-coverage: true
|
publish-coverage: true
|
||||||
|
force-install: true
|
||||||
|
|||||||
9
.github/workflows/deploy-preview.yml
vendored
9
.github/workflows/deploy-preview.yml
vendored
@@ -9,19 +9,18 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
ref: ${{ github.event.pull_request.head.ref }}
|
ref: ${{ github.event.pull_request.head.ref }}
|
||||||
- name: Use node.js
|
- name: Use node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16.13
|
node-version: 20.2
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
npm ci && \
|
npm ci --force && \
|
||||||
node ./scripts/set-homepage.js /shlink-web-client/${GITHUB_HEAD_REF#refs/heads/} && \
|
node ./scripts/set-homepage.js /shlink-web-client/${GITHUB_HEAD_REF#refs/heads/} && \
|
||||||
rm src/service-worker.ts && \
|
|
||||||
npm run build
|
npm run build
|
||||||
- name: Deploy preview
|
- name: Deploy preview
|
||||||
uses: shlinkio/deploy-preview-action@v1.0.1
|
uses: shlinkio/deploy-preview-action@v1.0.1
|
||||||
|
|||||||
27
.github/workflows/docker-image-build.yml
vendored
27
.github/workflows/docker-image-build.yml
vendored
@@ -1,28 +1,15 @@
|
|||||||
name: Build docker image
|
name: Build and publish docker image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- develop
|
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-20.04
|
uses: shlinkio/github-actions/.github/workflows/docker-build-and-publish.yml@main
|
||||||
steps:
|
secrets: inherit
|
||||||
- name: Checkout code
|
with:
|
||||||
uses: actions/checkout@v2
|
image-name: shlinkio/shlink-web-client
|
||||||
- name: Set up QEMU
|
version-arg-name: VERSION
|
||||||
uses: docker/setup-qemu-action@v1
|
platforms: 'linux/arm64/v8,linux/amd64'
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
- name: Login to docker hub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
||||||
- name: Build the image
|
|
||||||
run: bash ./scripts/docker/build
|
|
||||||
|
|||||||
8
.github/workflows/publish-release.yml
vendored
8
.github/workflows/publish-release.yml
vendored
@@ -10,13 +10,13 @@ jobs:
|
|||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Use node.js
|
- name: Use node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16.13
|
node-version: 20.2
|
||||||
- name: Generate release assets
|
- name: Generate release assets
|
||||||
run: npm ci && VERSION=${GITHUB_REF#refs/tags/v} npm run build:dist
|
run: npm ci --force && VERSION=${GITHUB_REF#refs/tags/v} npm run build:dist
|
||||||
- name: Publish release with assets
|
- name: Publish release with assets
|
||||||
uses: docker://antonyurchenko/git-release:latest
|
uses: docker://antonyurchenko/git-release:latest
|
||||||
env:
|
env:
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
/coverage
|
||||||
/.stryker-tmp
|
|
||||||
/reports
|
/reports
|
||||||
|
|
||||||
# production
|
# production
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"stylelint-config-adidas",
|
"@shlinkio/stylelint-config-css-coding-standard"
|
||||||
"stylelint-config-adidas-bem",
|
|
||||||
"stylelint-config-recommended-scss"
|
|
||||||
],
|
|
||||||
"syntax": "scss",
|
|
||||||
"plugins": [
|
|
||||||
"stylelint-scss"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
285
CHANGELOG.md
285
CHANGELOG.md
@@ -4,21 +4,13 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
|
|
||||||
## [3.6.0] - 2022-03-17
|
## [3.10.2] - 2023-07-09
|
||||||
### Added
|
### Added
|
||||||
* [#558](https://github.com/shlinkio/shlink-web-client/pull/558) Added dark text for tags where the generated background is too light, improving its legibility.
|
* *Nothing*
|
||||||
* [#570](https://github.com/shlinkio/shlink-web-client/pull/570) Added new section to load non-orphan visits all together when consuming Shlink 3.0.0.
|
|
||||||
* [#556](https://github.com/shlinkio/shlink-web-client/pull/556) Added support to filter short URLs list by "all" tags when consuming Shlink 3.0.0.
|
|
||||||
* [#549](https://github.com/shlinkio/shlink-web-client/pull/549) Allowed to export the list of short URLs as CSV.
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* [#543](https://github.com/shlinkio/shlink-web-client/pull/543) Redesigned settings section.
|
* [#781](https://github.com/shlinkio/shlink-web-client/issues/781) Migrate tests from jest to vitest.
|
||||||
* [#567](https://github.com/shlinkio/shlink-web-client/pull/567) Improved Shlink 3.0.0 compatibility by checking the `INVALID_SHORT_URL_DELETION` error code when deleting short URLs.
|
* [#843](https://github.com/shlinkio/shlink-web-client/issues/843) Build docker image only for new tags, making sure it always includes an actual version number.
|
||||||
* [#448](https://github.com/shlinkio/shlink-web-client/pull/448) Updated to bootstrap v5.
|
|
||||||
* [#524](https://github.com/shlinkio/shlink-web-client/pull/524) Updated to react-router v6.
|
|
||||||
* [#576](https://github.com/shlinkio/shlink-web-client/pull/576) Updated to fontawesome v6.
|
|
||||||
* [#579](https://github.com/shlinkio/shlink-web-client/pull/579) Replaced react-color with react-colorful.
|
|
||||||
* [#564](https://github.com/shlinkio/shlink-web-client/pull/564) Updated most of the dependencies.
|
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
* *Nothing*
|
* *Nothing*
|
||||||
@@ -27,7 +19,256 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
* *Nothing*
|
* *Nothing*
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* [#589](https://github.com/shlinkio/shlink-web-client/pull/589) Fixed alignment of shlink versions footer, by basing the logic on the presence of the sidebar instead of selected server.
|
* *Nothing*
|
||||||
|
|
||||||
|
|
||||||
|
## [3.10.1] - 2023-04-23
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#826](https://github.com/shlinkio/shlink-web-client/issues/826) Fix generated short URLs CSV so that it can be used to import on Shlink.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.10.0] - 2023-03-19
|
||||||
|
### Added
|
||||||
|
* [#807](https://github.com/shlinkio/shlink-web-client/issues/807) Add support for device-specific long-URLs when creating or editing short URLs.
|
||||||
|
* [#808](https://github.com/shlinkio/shlink-web-client/issues/808) Respect settings on excluding bots in the overview section, for visits cards.
|
||||||
|
* [#809](https://github.com/shlinkio/shlink-web-client/issues/809) Respect settings on excluding bots in the tags list.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* [#798](https://github.com/shlinkio/shlink-web-client/issues/798) Remove stryker and mutation testing.
|
||||||
|
* [#800](https://github.com/shlinkio/shlink-web-client/issues/800) Use `/tags/stats` endpoint to load tags stats, when the server supports it.
|
||||||
|
* Update to Vite 4.2
|
||||||
|
* Update to TypeScript 5
|
||||||
|
* Update to coding standard v2.1.0
|
||||||
|
* Decouple tests from RTK internals.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#799](https://github.com/shlinkio/shlink-web-client/issues/799) Fix fallback visits not taking into account configuration regarding excluding bots.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.9.1] - 2022-12-31
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#787](https://github.com/shlinkio/shlink-web-client/issues/787) Fixed wrong base path set in vite config when homepage is set as empty string.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.9.0] - 2022-12-31
|
||||||
|
### Added
|
||||||
|
* [#750](https://github.com/shlinkio/shlink-web-client/issues/750) Added new icon indicators telling if a short URL can be normally visited, it received the max amount of visits, is still not enabled, etc.
|
||||||
|
* [#764](https://github.com/shlinkio/shlink-web-client/issues/764) Added support to exclude visits from visits on short URLs list when consuming Shlink 3.4.0.
|
||||||
|
|
||||||
|
This feature also comes with a new setting to disable visits from bots by default, both on short URLs lists and visits sections.
|
||||||
|
|
||||||
|
* [#760](https://github.com/shlinkio/shlink-web-client/issues/760) Added support to exclude short URLs which have reached the maximum amount of visits, or are valid until a date in the past.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* [#753](https://github.com/shlinkio/shlink-web-client/issues/753) Migrated from react-scripts/webpack to vite.
|
||||||
|
* [#770](https://github.com/shlinkio/shlink-web-client/issues/770) Updated to latest dependencies.
|
||||||
|
* [#741](https://github.com/shlinkio/shlink-web-client/issues/741) Improved `visitsAsyncThunk`, making it wrap pending/fulfilled/rejected actions, as well as custom ones, in a type-safe way.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* [#736](https://github.com/shlinkio/shlink-web-client/issues/736) Removed cards mode in tags. Only table mode is supported now.
|
||||||
|
* [#774](https://github.com/shlinkio/shlink-web-client/issues/774) Dropped support for Shlink older than 2.8.0.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#715](https://github.com/shlinkio/shlink-web-client/issues/715) Fixed connection still failing on miss-configured servers, after editing their params to set proper values.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.8.2] - 2022-12-17
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#766](https://github.com/shlinkio/shlink-web-client/issues/766) Fixed visits query being lost when switching between sub-sections.
|
||||||
|
* [#765](https://github.com/shlinkio/shlink-web-client/issues/765) Added missing `"Content-Type": "application/json"` to requests with payload, making older Shlink versions fail.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.8.1] - 2022-12-06
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#756](https://github.com/shlinkio/shlink-web-client/issues/756) Fixed all visits interval not working unless switching to a different interval first.
|
||||||
|
* [#757](https://github.com/shlinkio/shlink-web-client/issues/757) Fixed visits fallback interval not working until the visits view has been loaded at least twice.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.8.0] - 2022-12-03
|
||||||
|
### Added
|
||||||
|
* [#708](https://github.com/shlinkio/shlink-web-client/issues/708) Added support for API v3.
|
||||||
|
* [#717](https://github.com/shlinkio/shlink-web-client/issues/717) Allowed to select time in 10 minute intervals when configuring "enabled since" and "enabled until" on short URLs.
|
||||||
|
* [#748](https://github.com/shlinkio/shlink-web-client/issues/748) Improved visits section to add filters to the query string, allowing to navigate to a specific state or bookmarking filters.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* [#713](https://github.com/shlinkio/shlink-web-client/issues/713) Updated dependencies.
|
||||||
|
* [#620](https://github.com/shlinkio/shlink-web-client/issues/620) Migrated all reducers to redux toolkit.
|
||||||
|
* [#721](https://github.com/shlinkio/shlink-web-client/issues/721) Migrated from axios to fetch.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#590](https://github.com/shlinkio/shlink-web-client/issues/590) Fixed position of the datepicker triangle.
|
||||||
|
* [#729](https://github.com/shlinkio/shlink-web-client/issues/729) Fixed wrong stats displayed in tags after renaming.
|
||||||
|
* [#737](https://github.com/shlinkio/shlink-web-client/issues/737) Fixed incorrect contrast in warning messages when using dark theme.
|
||||||
|
* [#726](https://github.com/shlinkio/shlink-web-client/issues/726) Fixed delete server and delete short URL modals getting removed from the DOM before finishing close transition.
|
||||||
|
* [#749](https://github.com/shlinkio/shlink-web-client/issues/749) Fixed broken short URLs table when some short URL has a too long custom slug.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.7.3] - 2022-09-13
|
||||||
|
### Added
|
||||||
|
* [#703](https://github.com/shlinkio/shlink-web-client/issues/703) Added support to publish docker image in GHCR.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#709](https://github.com/shlinkio/shlink-web-client/issues/709) Fixed visits not being displayed after a large loading has finished.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.7.2] - 2022-08-07
|
||||||
|
### Added
|
||||||
|
* [#671](https://github.com/shlinkio/shlink-web-client/issues/671) Added proper color-scheme in root element based on selected theme.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* [#688](https://github.com/shlinkio/shlink-web-client/issues/688) Finalized migration from enzyme to react-testing-library.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#695](https://github.com/shlinkio/shlink-web-client/issues/695) Fixed some warnings in tests.
|
||||||
|
* [#693](https://github.com/shlinkio/shlink-web-client/issues/693) Fixed tags, servers and domains search to make it case-insensitive.
|
||||||
|
* [#694](https://github.com/shlinkio/shlink-web-client/issues/694) Fixed editing and loading visits on short URLs with multi-segment slugs.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.7.1] - 2022-05-25
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* [#648](https://github.com/shlinkio/shlink-web-client/issues/648) Migrated some scripts to ESM and updated to chalk 5.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#653](https://github.com/shlinkio/shlink-web-client/issues/653) Fixed rendering values greater than 1000 in charts, when the browser has certain locales configured.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.7.0] - 2022-05-14
|
||||||
|
### Added
|
||||||
|
* [#622](https://github.com/shlinkio/shlink-web-client/issues/622) Added support to load domain visits when consuming Shlink 3.1.0 or newer.
|
||||||
|
* [#582](https://github.com/shlinkio/shlink-web-client/issues/582) Improved filtering short URLs by tag.
|
||||||
|
|
||||||
|
Now, a new full tags selector component is available, which allows selecting any of the existing tags and also composes a toggle to filter by "any" tag or "all" tags.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* [#616](https://github.com/shlinkio/shlink-web-client/issues/616) Updated to React 18.
|
||||||
|
* [#595](https://github.com/shlinkio/shlink-web-client/issues/595) Updated to react-chartjs-2 v4.1.0.
|
||||||
|
* [#594](https://github.com/shlinkio/shlink-web-client/issues/594) Updated to a new coding standard.
|
||||||
|
* [#627](https://github.com/shlinkio/shlink-web-client/issues/627) Updated to Jest 28.
|
||||||
|
* [#603](https://github.com/shlinkio/shlink-web-client/issues/603) Migrated to new and maintained dependencies to parse CSV<->JSON.
|
||||||
|
* [#610](https://github.com/shlinkio/shlink-web-client/issues/610) Migrated to a maintained coding style for CSS.
|
||||||
|
* [#619](https://github.com/shlinkio/shlink-web-client/issues/619) Introduced react testing library, to progressively replace enzyme.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* [#623](https://github.com/shlinkio/shlink-web-client/issues/623) Dropped support for Shlink older than 2.6.0.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
|
||||||
|
## [3.6.0] - 2022-03-17
|
||||||
|
### Added
|
||||||
|
* [#558](https://github.com/shlinkio/shlink-web-client/issues/558) Added dark text for tags where the generated background is too light, improving its legibility.
|
||||||
|
* [#570](https://github.com/shlinkio/shlink-web-client/issues/570) Added new section to load non-orphan visits all together when consuming Shlink 3.0.0.
|
||||||
|
* [#556](https://github.com/shlinkio/shlink-web-client/issues/556) Added support to filter short URLs list by "all" tags when consuming Shlink 3.0.0.
|
||||||
|
* [#549](https://github.com/shlinkio/shlink-web-client/issues/549) Allowed to export the list of short URLs as CSV.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* [#543](https://github.com/shlinkio/shlink-web-client/issues/543) Redesigned settings section.
|
||||||
|
* [#567](https://github.com/shlinkio/shlink-web-client/issues/567) Improved Shlink 3.0.0 compatibility by checking the `INVALID_SHORT_URL_DELETION` error code when deleting short URLs.
|
||||||
|
* [#448](https://github.com/shlinkio/shlink-web-client/issues/448) Updated to bootstrap v5.
|
||||||
|
* [#524](https://github.com/shlinkio/shlink-web-client/issues/524) Updated to react-router v6.
|
||||||
|
* [#576](https://github.com/shlinkio/shlink-web-client/issues/576) Updated to fontawesome v6.
|
||||||
|
* [#579](https://github.com/shlinkio/shlink-web-client/issues/579) Replaced react-color with react-colorful.
|
||||||
|
* [#564](https://github.com/shlinkio/shlink-web-client/issues/564) Updated most of the dependencies.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#589](https://github.com/shlinkio/shlink-web-client/issues/589) Fixed alignment of shlink versions footer, by basing the logic on the presence of the sidebar instead of selected server.
|
||||||
|
|
||||||
|
|
||||||
## [3.5.1] - 2022-01-08
|
## [3.5.1] - 2022-01-08
|
||||||
@@ -51,27 +292,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
|
|
||||||
## [3.5.0] - 2022-01-01
|
## [3.5.0] - 2022-01-01
|
||||||
### Added
|
### Added
|
||||||
* [#407](https://github.com/shlinkio/shlink-web-client/pull/407) Improved how visits (short URLs, tags and orphan) are loaded, to avoid ending up in a page with "There are no visits matching current filter".
|
* [#407](https://github.com/shlinkio/shlink-web-client/issues/407) Improved how visits (short URLs, tags and orphan) are loaded, to avoid ending up in a page with "There are no visits matching current filter".
|
||||||
|
|
||||||
Now, the app will try to load visits for the configured default interval, and in parallel, it will load the latest visit.
|
Now, the app will try to load visits for the configured default interval, and in parallel, it will load the latest visit.
|
||||||
|
|
||||||
If the resulting list for that interval is empty, it will try to infer the closest interval with visits, based on the latest visit's date, and reload visits for that interval.
|
If the resulting list for that interval is empty, it will try to infer the closest interval with visits, based on the latest visit's date, and reload visits for that interval.
|
||||||
|
|
||||||
* [#547](https://github.com/shlinkio/shlink-web-client/pull/547) Improved domains page, to tell which of the domains are not properly configured.
|
* [#547](https://github.com/shlinkio/shlink-web-client/issues/547) Improved domains page, to tell which of the domains are not properly configured.
|
||||||
|
|
||||||
Now, when this section is loaded, it tries to call the `GET /rest/health` endpoint for each one of the domains, and displays a warning icon on each one that failed.
|
Now, when this section is loaded, it tries to call the `GET /rest/health` endpoint for each one of the domains, and displays a warning icon on each one that failed.
|
||||||
|
|
||||||
The warning includes a link to the documentation, explaining what are the steps to get it fixed.
|
The warning includes a link to the documentation, explaining what are the steps to get it fixed.
|
||||||
|
|
||||||
* [#506](https://github.com/shlinkio/shlink-web-client/pull/506) Improved how servers are handled, displaying a warning when creating or importing servers that already exist.
|
* [#506](https://github.com/shlinkio/shlink-web-client/issues/506) Improved how servers are handled, displaying a warning when creating or importing servers that already exist.
|
||||||
* [#535](https://github.com/shlinkio/shlink-web-client/pull/535) Allowed editing default domain redirects when consuming Shlink 2.10 or newer.
|
* [#535](https://github.com/shlinkio/shlink-web-client/issues/535) Allowed editing default domain redirects when consuming Shlink 2.10 or newer.
|
||||||
* [#531](https://github.com/shlinkio/shlink-web-client/pull/531) Added custom slug field to the basic creation form in the Overview page.
|
* [#531](https://github.com/shlinkio/shlink-web-client/issues/531) Added custom slug field to the basic creation form in the Overview page.
|
||||||
* [#537](https://github.com/shlinkio/shlink-web-client/pull/537) Allowed to customize the ordering for every list in the app that supports it, being currently tags and short URLs.
|
* [#537](https://github.com/shlinkio/shlink-web-client/issues/537) Allowed to customize the ordering for every list in the app that supports it, being currently tags and short URLs.
|
||||||
* [#542](https://github.com/shlinkio/shlink-web-client/pull/542) Added ordering for short URLs to the query, so that it is consistent with the rest of the filtering params.
|
* [#542](https://github.com/shlinkio/shlink-web-client/issues/542) Added ordering for short URLs to the query, so that it is consistent with the rest of the filtering params.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* [#534](https://github.com/shlinkio/shlink-web-client/pull/534) Updated axios.
|
* [#534](https://github.com/shlinkio/shlink-web-client/issues/534) Updated axios.
|
||||||
* [#538](https://github.com/shlinkio/shlink-web-client/pull/538) Switched to the `<field>-<dir>` notation in `orderBy` param for short URLs list, in preparation for Shlink v3.0.0
|
* [#538](https://github.com/shlinkio/shlink-web-client/issues/538) Switched to the `<field>-<dir>` notation in `orderBy` param for short URLs list, in preparation for Shlink v3.0.0
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
* *Nothing*
|
* *Nothing*
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
FROM node:16.13-alpine as node
|
FROM node:20.2-alpine as node
|
||||||
COPY . /shlink-web-client
|
COPY . /shlink-web-client
|
||||||
ARG VERSION="latest"
|
ARG VERSION="latest"
|
||||||
ENV VERSION ${VERSION}
|
ENV VERSION ${VERSION}
|
||||||
RUN cd /shlink-web-client && npm ci && npm run build
|
RUN cd /shlink-web-client && npm ci --force && npm run build
|
||||||
|
|
||||||
FROM nginx:1.21-alpine
|
FROM nginx:1.23-alpine
|
||||||
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
|
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
|
||||||
RUN rm -r /usr/share/nginx/html && rm /etc/nginx/conf.d/default.conf
|
RUN rm -r /usr/share/nginx/html && rm /etc/nginx/conf.d/default.conf
|
||||||
COPY config/docker/nginx.conf /etc/nginx/conf.d/default.conf
|
COPY config/docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
# shlink-web-client
|
# shlink-web-client
|
||||||
|
|
||||||
[](https://github.com/shlinkio/shlink-web-client/actions?query=workflow%3A%22Continuous+integration%22)
|
[](https://github.com/shlinkio/shlink-web-client/actions/workflows/ci.yml?query=workflow%3A%22Continuous+integration%22)
|
||||||
[](https://app.codecov.io/gh/shlinkio/shlink-web-client)
|
[](https://app.codecov.io/gh/shlinkio/shlink-web-client)
|
||||||
[](https://github.com/shlinkio/shlink-web-client/releases/latest)
|
[](https://github.com/shlinkio/shlink-web-client/releases/latest)
|
||||||
[](https://hub.docker.com/r/shlinkio/shlink-web-client/)
|
[](https://hub.docker.com/r/shlinkio/shlink-web-client/)
|
||||||
[](https://github.com/shlinkio/shlink-web-client/blob/main/LICENSE)
|
[](https://github.com/shlinkio/shlink-web-client/blob/main/LICENSE)
|
||||||
[](https://twitter.com/shlinkio)
|
[](https://twitter.com/shlinkio)
|
||||||
|
[](https://fosstodon.org/@shlinkio)
|
||||||
[](https://slnk.to/donate)
|
[](https://slnk.to/donate)
|
||||||
|
|
||||||
A ReactJS-based progressive web application for [Shlink](https://shlink.io).
|
A ReactJS-based progressive web application for [Shlink](https://shlink.io).
|
||||||
@@ -53,7 +54,7 @@ Those servers can be exported and imported in other browsers, but if for some re
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "Main server",
|
"name": "Main server",
|
||||||
"url": "https://doma.in",
|
"url": "https://s.test",
|
||||||
"apiKey": "09c972b7-506b-49f1-a19a-d729e22e599c"
|
"apiKey": "09c972b7-506b-49f1-a19a-d729e22e599c"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -84,7 +85,7 @@ If you want to pre-configure a single server, you can provide its config via env
|
|||||||
docker run \
|
docker run \
|
||||||
--name shlink-web-client \
|
--name shlink-web-client \
|
||||||
-p 8000:80 \
|
-p 8000:80 \
|
||||||
-e SHLINK_SERVER_URL=https://doma.in \
|
-e SHLINK_SERVER_URL=https://s.test \
|
||||||
-e SHLINK_SERVER_API_KEY=6aeb82c6-e275-4538-a747-31f9abfba63c \
|
-e SHLINK_SERVER_API_KEY=6aeb82c6-e275-4538-a747-31f9abfba63c \
|
||||||
shlinkio/shlink-web-client
|
shlinkio/shlink-web-client
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'react-app',
|
|
||||||
{
|
|
||||||
runtime: 'automatic',
|
|
||||||
typescript: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
'@babel/plugin-proposal-optional-chaining',
|
|
||||||
'@babel/plugin-proposal-nullish-coalescing-operator',
|
|
||||||
],
|
|
||||||
};
|
|
||||||
101
config/env.js
101
config/env.js
@@ -1,101 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/promise-function-async, @typescript-eslint/prefer-optional-chain */
|
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const paths = require('./paths');
|
|
||||||
|
|
||||||
// Make sure that including paths.js after env.js will read .env variables.
|
|
||||||
delete require.cache[require.resolve('./paths')];
|
|
||||||
|
|
||||||
const { NODE_ENV } = process.env;
|
|
||||||
|
|
||||||
if (!NODE_ENV) {
|
|
||||||
throw new Error(
|
|
||||||
'The NODE_ENV environment variable is required but was not specified.',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
||||||
const dotenvFiles = [
|
|
||||||
`${paths.dotenv}.${NODE_ENV}.local`,
|
|
||||||
`${paths.dotenv}.${NODE_ENV}`,
|
|
||||||
|
|
||||||
// Don't include `.env.local` for `test` environment
|
|
||||||
// since normally you expect tests to produce the same
|
|
||||||
// results for everyone
|
|
||||||
NODE_ENV !== 'test' && `${paths.dotenv}.local`,
|
|
||||||
paths.dotenv,
|
|
||||||
].filter(Boolean);
|
|
||||||
|
|
||||||
// Load environment variables from .env* files. Suppress warnings using silent
|
|
||||||
// if this file is missing. dotenv will never modify any environment variables
|
|
||||||
// that have already been set. Variable expansion is supported in .env files.
|
|
||||||
// https://github.com/motdotla/dotenv
|
|
||||||
// https://github.com/motdotla/dotenv-expand
|
|
||||||
dotenvFiles.forEach((dotenvFile) => {
|
|
||||||
if (fs.existsSync(dotenvFile)) {
|
|
||||||
require('dotenv-expand')(
|
|
||||||
require('dotenv').config({
|
|
||||||
path: dotenvFile,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// We support resolving modules according to `NODE_PATH`.
|
|
||||||
// This lets you use absolute paths in imports inside large monorepos:
|
|
||||||
// https://github.com/facebook/create-react-app/issues/253.
|
|
||||||
// It works similar to `NODE_PATH` in Node itself:
|
|
||||||
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
|
|
||||||
// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
|
|
||||||
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
|
|
||||||
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
|
|
||||||
// We also resolve them to make sure all tools using them work consistently.
|
|
||||||
const appDirectory = fs.realpathSync(process.cwd());
|
|
||||||
|
|
||||||
process.env.NODE_PATH = (process.env.NODE_PATH || '')
|
|
||||||
.split(path.delimiter)
|
|
||||||
.filter((folder) => folder && !path.isAbsolute(folder))
|
|
||||||
.map((folder) => path.resolve(appDirectory, folder))
|
|
||||||
.join(path.delimiter);
|
|
||||||
|
|
||||||
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
|
|
||||||
// injected into the application via DefinePlugin in Webpack configuration.
|
|
||||||
const REACT_APP = /^REACT_APP_/i;
|
|
||||||
|
|
||||||
function getClientEnvironment(publicUrl) {
|
|
||||||
const raw = Object.keys(process.env)
|
|
||||||
.filter((key) => REACT_APP.test(key))
|
|
||||||
.reduce(
|
|
||||||
(env, key) => {
|
|
||||||
env[key] = process.env[key];
|
|
||||||
|
|
||||||
return env;
|
|
||||||
},
|
|
||||||
{
|
|
||||||
|
|
||||||
// Useful for determining whether we’re running in production mode.
|
|
||||||
// Most importantly, it switches React into the correct mode.
|
|
||||||
NODE_ENV: process.env.NODE_ENV || 'development',
|
|
||||||
|
|
||||||
// Useful for resolving the correct path to static assets in `public`.
|
|
||||||
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
|
|
||||||
// This should only be used as an escape hatch. Normally you would put
|
|
||||||
// images into the `src` and `import` them in code to get their paths.
|
|
||||||
PUBLIC_URL: publicUrl,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Stringify all values so we can feed into Webpack DefinePlugin
|
|
||||||
const stringified = {
|
|
||||||
'process.env': Object.keys(raw).reduce((env, key) => {
|
|
||||||
env[key] = JSON.stringify(raw[key]);
|
|
||||||
|
|
||||||
return env;
|
|
||||||
}, {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
return { raw, stringified };
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = getClientEnvironment;
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
// This is a custom Jest transformer turning file imports into filenames.
|
|
||||||
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
process(src, filename) {
|
|
||||||
const assetFilename = JSON.stringify(path.basename(filename));
|
|
||||||
|
|
||||||
if (filename.match(/\.svg$/)) {
|
|
||||||
return `module.exports = {
|
|
||||||
__esModule: true,
|
|
||||||
default: ${assetFilename},
|
|
||||||
ReactComponent: (props) => ({
|
|
||||||
$$typeof: Symbol.for('react.element'),
|
|
||||||
type: 'svg',
|
|
||||||
ref: null,
|
|
||||||
key: null,
|
|
||||||
props: Object.assign({}, props, {
|
|
||||||
children: ${assetFilename}
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
};`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `module.exports = ${assetFilename};`;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/promise-function-async, @typescript-eslint/prefer-optional-chain */
|
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
|
||||||
const url = require('url');
|
|
||||||
|
|
||||||
// Make sure any symlinks in the project folder are resolved:
|
|
||||||
// https://github.com/facebook/create-react-app/issues/637
|
|
||||||
const appDirectory = fs.realpathSync(process.cwd());
|
|
||||||
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
|
|
||||||
|
|
||||||
const envPublicUrl = process.env.PUBLIC_URL;
|
|
||||||
|
|
||||||
function ensureSlash(inputPath, needsSlash) {
|
|
||||||
const hasSlash = inputPath.endsWith('/');
|
|
||||||
|
|
||||||
if (hasSlash && !needsSlash) {
|
|
||||||
return inputPath.substr(0, inputPath.length - 1);
|
|
||||||
} else if (!hasSlash && needsSlash) {
|
|
||||||
return `${inputPath}/`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return inputPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
const getPublicUrl = (appPackageJson) =>
|
|
||||||
envPublicUrl || require(appPackageJson).homepage;
|
|
||||||
|
|
||||||
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
|
|
||||||
// "public path" at which the app is served.
|
|
||||||
// Webpack needs to know it to put the right <script> hrefs into HTML even in
|
|
||||||
// single-page apps that may serve index.html for nested URLs like /todos/42.
|
|
||||||
// We can't use a relative path in HTML because we don't want to load something
|
|
||||||
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
|
|
||||||
function getServedPath(appPackageJson) {
|
|
||||||
const publicUrl = getPublicUrl(appPackageJson);
|
|
||||||
const servedUrl =
|
|
||||||
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
|
|
||||||
|
|
||||||
return ensureSlash(servedUrl, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
const moduleFileExtensions = [
|
|
||||||
'web.mjs',
|
|
||||||
'mjs',
|
|
||||||
'web.js',
|
|
||||||
'js',
|
|
||||||
'web.ts',
|
|
||||||
'ts',
|
|
||||||
'web.tsx',
|
|
||||||
'tsx',
|
|
||||||
'json',
|
|
||||||
'web.jsx',
|
|
||||||
'jsx',
|
|
||||||
];
|
|
||||||
|
|
||||||
// Resolve file paths in the same order as webpack
|
|
||||||
const resolveModule = (resolveFn, filePath) => {
|
|
||||||
const extension = moduleFileExtensions.find((extension) =>
|
|
||||||
fs.existsSync(resolveFn(`${filePath}.${extension}`)));
|
|
||||||
|
|
||||||
if (extension) {
|
|
||||||
return resolveFn(`${filePath}.${extension}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolveFn(`${filePath}.js`);
|
|
||||||
};
|
|
||||||
|
|
||||||
// config after eject: we're in ./config/
|
|
||||||
module.exports = {
|
|
||||||
dotenv: resolveApp('.env'),
|
|
||||||
appPath: resolveApp('.'),
|
|
||||||
appBuild: resolveApp('build'),
|
|
||||||
appPublic: resolveApp('public'),
|
|
||||||
appHtml: resolveApp('public/index.html'),
|
|
||||||
appIndexJs: resolveModule(resolveApp, 'src/index'),
|
|
||||||
appPackageJson: resolveApp('package.json'),
|
|
||||||
appSrc: resolveApp('src'),
|
|
||||||
appTsConfig: resolveApp('tsconfig.json'),
|
|
||||||
yarnLockFile: resolveApp('yarn.lock'),
|
|
||||||
testsSetup: resolveModule(resolveApp, 'src/setupTests'),
|
|
||||||
proxySetup: resolveApp('src/setupProxy.js'),
|
|
||||||
appNodeModules: resolveApp('node_modules'),
|
|
||||||
publicUrl: getPublicUrl(resolveApp('package.json')),
|
|
||||||
servedPath: getServedPath(resolveApp('package.json')),
|
|
||||||
swSrc: resolveModule(resolveApp, 'src/service-worker'),
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.moduleFileExtensions = moduleFileExtensions;
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import Enzyme from 'enzyme';
|
|
||||||
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
|
||||||
|
|
||||||
Enzyme.configure({ adapter: new Adapter() });
|
|
||||||
27
config/test/setupTests.ts
Normal file
27
config/test/setupTests.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import 'vitest-canvas-mock';
|
||||||
|
import 'chart.js/auto';
|
||||||
|
import type { TestingLibraryMatchers } from '@testing-library/jest-dom/matchers';
|
||||||
|
import matchers from '@testing-library/jest-dom/matchers';
|
||||||
|
import { cleanup } from '@testing-library/react';
|
||||||
|
import ResizeObserver from 'resize-observer-polyfill';
|
||||||
|
import { afterEach, expect } from 'vitest';
|
||||||
|
|
||||||
|
// Workaround for TypeScript error: https://github.com/testing-library/jest-dom/issues/439#issuecomment-1536524120
|
||||||
|
declare module 'vitest' {
|
||||||
|
interface Assertion<T = any> extends jest.Matchers<void, T>, TestingLibraryMatchers<T, void> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extends Vitest's expect method with methods from react-testing-library
|
||||||
|
expect.extend(matchers);
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
// Clears all mocks after every test
|
||||||
|
vi.clearAllMocks();
|
||||||
|
// Run a cleanup after each test case (e.g. clearing jsdom)
|
||||||
|
cleanup();
|
||||||
|
});
|
||||||
|
|
||||||
|
(global as any).ResizeObserver = ResizeObserver;
|
||||||
|
(global as any).scrollTo = () => {};
|
||||||
|
(global as any).prompt = () => {};
|
||||||
|
(global as any).matchMedia = (media: string) => ({ matches: false, media });
|
||||||
@@ -1,674 +0,0 @@
|
|||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const webpack = require('webpack');
|
|
||||||
const resolve = require('resolve');
|
|
||||||
const PnpWebpackPlugin = require('pnp-webpack-plugin');
|
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
||||||
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
|
|
||||||
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
|
|
||||||
const TerserPlugin = require('terser-webpack-plugin');
|
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
||||||
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
||||||
const safePostCssParser = require('postcss-safe-parser');
|
|
||||||
const ManifestPlugin = require('webpack-manifest-plugin');
|
|
||||||
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
|
|
||||||
const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
|
|
||||||
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
|
|
||||||
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
|
||||||
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
|
|
||||||
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
|
|
||||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin-alt');
|
|
||||||
const typescriptFormatter = require('react-dev-utils/typescriptFormatter');
|
|
||||||
const getClientEnvironment = require('./env');
|
|
||||||
const paths = require('./paths');
|
|
||||||
|
|
||||||
// Source maps are resource heavy and can cause out of memory issue for large source files.
|
|
||||||
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
|
|
||||||
|
|
||||||
// Some apps do not need the benefits of saving a web request, so not inlining the chunk
|
|
||||||
// makes for a smoother build process.
|
|
||||||
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
|
|
||||||
|
|
||||||
// Check if TypeScript is setup
|
|
||||||
const useTypeScript = fs.existsSync(paths.appTsConfig);
|
|
||||||
|
|
||||||
// Get the path to the uncompiled service worker (if it exists).
|
|
||||||
const swSrc = paths.swSrc;
|
|
||||||
|
|
||||||
// style files regexes
|
|
||||||
const cssRegex = /\.css$/;
|
|
||||||
const cssModuleRegex = /\.module\.css$/;
|
|
||||||
const sassRegex = /\.(scss|sass)$/;
|
|
||||||
const sassModuleRegex = /\.module\.(scss|sass)$/;
|
|
||||||
|
|
||||||
// This is the production and development configuration.
|
|
||||||
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
|
|
||||||
/* eslint-disable complexity */
|
|
||||||
module.exports = (webpackEnv) => {
|
|
||||||
const isEnvDevelopment = webpackEnv === 'development';
|
|
||||||
const isEnvProduction = webpackEnv === 'production';
|
|
||||||
|
|
||||||
// Webpack uses `publicPath` to determine where the app is being served from.
|
|
||||||
// It requires a trailing slash, or the file assets will get an incorrect path.
|
|
||||||
// In development, we always serve from the root. This makes config easier.
|
|
||||||
const publicPath = isEnvProduction
|
|
||||||
? paths.servedPath
|
|
||||||
: isEnvDevelopment && '/';
|
|
||||||
|
|
||||||
// Some apps do not use client-side routing with pushState.
|
|
||||||
// For these, "homepage" can be set to "." to enable relative asset paths.
|
|
||||||
const shouldUseRelativeAssetPaths = publicPath === './';
|
|
||||||
|
|
||||||
// `publicUrl` is just like `publicPath`, but we will provide it to our app
|
|
||||||
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
|
|
||||||
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
|
|
||||||
const publicUrl = isEnvProduction
|
|
||||||
? publicPath.slice(0, -1)
|
|
||||||
: isEnvDevelopment && '';
|
|
||||||
|
|
||||||
// Get environment variables to inject into our app.
|
|
||||||
const env = getClientEnvironment(publicUrl);
|
|
||||||
|
|
||||||
// common function to get style loaders
|
|
||||||
const getStyleLoaders = (cssOptions, preProcessor) => {
|
|
||||||
const loaders = [
|
|
||||||
isEnvDevelopment && require.resolve('style-loader'),
|
|
||||||
isEnvProduction && {
|
|
||||||
loader: MiniCssExtractPlugin.loader,
|
|
||||||
options: Object.assign(
|
|
||||||
{},
|
|
||||||
shouldUseRelativeAssetPaths ? { publicPath: '../../' } : undefined,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: require.resolve('css-loader'),
|
|
||||||
options: cssOptions,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
|
|
||||||
// Options for PostCSS as we reference these options twice
|
|
||||||
// Adds vendor prefixing based on your specified browser support in
|
|
||||||
// package.json
|
|
||||||
loader: require.resolve('postcss-loader'),
|
|
||||||
options: {
|
|
||||||
|
|
||||||
// Necessary for external CSS imports to work
|
|
||||||
// https://github.com/facebook/create-react-app/issues/2677
|
|
||||||
ident: 'postcss',
|
|
||||||
plugins: () => [
|
|
||||||
require('postcss-flexbugs-fixes'),
|
|
||||||
require('postcss-preset-env')({
|
|
||||||
autoprefixer: {
|
|
||||||
flexbox: 'no-2009',
|
|
||||||
},
|
|
||||||
stage: 3,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
].filter(Boolean);
|
|
||||||
|
|
||||||
if (preProcessor) {
|
|
||||||
loaders.push({
|
|
||||||
loader: require.resolve(preProcessor),
|
|
||||||
options: {
|
|
||||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return loaders;
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
|
|
||||||
|
|
||||||
// Stop compilation early in production
|
|
||||||
bail: isEnvProduction,
|
|
||||||
devtool: isEnvProduction
|
|
||||||
? shouldUseSourceMap
|
|
||||||
? 'source-map'
|
|
||||||
: false
|
|
||||||
: isEnvDevelopment && 'cheap-module-source-map',
|
|
||||||
|
|
||||||
// These are the "entry points" to our application.
|
|
||||||
// This means they will be the "root" imports that are included in JS bundle.
|
|
||||||
entry: [
|
|
||||||
|
|
||||||
// Include an alternative client for WebpackDevServer. A client's job is to
|
|
||||||
// connect to WebpackDevServer by a socket and get notified about changes.
|
|
||||||
// When you save a file, the client will either apply hot updates (in case
|
|
||||||
// of CSS changes), or refresh the page (in case of JS changes). When you
|
|
||||||
// make a syntax error, this client will display a syntax error overlay.
|
|
||||||
// Note: instead of the default WebpackDevServer client, we use a custom one
|
|
||||||
// to bring better experience for Create React App users. You can replace
|
|
||||||
// the line below with these two lines if you prefer the stock client:
|
|
||||||
// require.resolve('webpack-dev-server/client') + '?/',
|
|
||||||
// require.resolve('webpack/hot/dev-server'),
|
|
||||||
isEnvDevelopment &&
|
|
||||||
require.resolve('react-dev-utils/webpackHotDevClient'),
|
|
||||||
|
|
||||||
// Finally, this is your app's code:
|
|
||||||
paths.appIndexJs,
|
|
||||||
|
|
||||||
// We include the app code last so that if there is a runtime error during
|
|
||||||
// initialization, it doesn't blow up the WebpackDevServer client, and
|
|
||||||
// changing JS code would still trigger a refresh.
|
|
||||||
].filter(Boolean),
|
|
||||||
output: {
|
|
||||||
|
|
||||||
// The build folder.
|
|
||||||
path: isEnvProduction ? paths.appBuild : undefined,
|
|
||||||
|
|
||||||
// Add /* filename */ comments to generated require()s in the output.
|
|
||||||
pathinfo: isEnvDevelopment,
|
|
||||||
|
|
||||||
// There will be one main bundle, and one file per asynchronous chunk.
|
|
||||||
// In development, it does not produce real files.
|
|
||||||
filename: isEnvProduction
|
|
||||||
? 'static/js/[name].[chunkhash:8].js'
|
|
||||||
: isEnvDevelopment && 'static/js/bundle.js',
|
|
||||||
|
|
||||||
// There are also additional JS chunk files if you use code splitting.
|
|
||||||
chunkFilename: isEnvProduction
|
|
||||||
? 'static/js/[name].[chunkhash:8].chunk.js'
|
|
||||||
: isEnvDevelopment && 'static/js/[name].chunk.js',
|
|
||||||
|
|
||||||
// We inferred the "public path" (such as / or /my-project) from homepage.
|
|
||||||
// We use "/" in development.
|
|
||||||
publicPath,
|
|
||||||
|
|
||||||
// Point sourcemap entries to original disk location (format as URL on Windows)
|
|
||||||
devtoolModuleFilenameTemplate: isEnvProduction
|
|
||||||
? (info) =>
|
|
||||||
path
|
|
||||||
.relative(paths.appSrc, info.absoluteResourcePath)
|
|
||||||
.replace(/\\/g, '/')
|
|
||||||
: isEnvDevelopment &&
|
|
||||||
((info) => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
|
|
||||||
},
|
|
||||||
optimization: {
|
|
||||||
minimize: isEnvProduction,
|
|
||||||
minimizer: [
|
|
||||||
|
|
||||||
// This is only used in production mode
|
|
||||||
new TerserPlugin({
|
|
||||||
terserOptions: {
|
|
||||||
parse: {
|
|
||||||
|
|
||||||
// we want terser to parse ecma 8 code. However, we don't want it
|
|
||||||
// to apply any minfication steps that turns valid ecma 5 code
|
|
||||||
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
||||||
// sections only apply transformations that are ecma 5 safe
|
|
||||||
// https://github.com/facebook/create-react-app/pull/4234
|
|
||||||
ecma: 8,
|
|
||||||
},
|
|
||||||
compress: {
|
|
||||||
ecma: 5,
|
|
||||||
warnings: false,
|
|
||||||
|
|
||||||
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
||||||
// https://github.com/facebook/create-react-app/issues/2376
|
|
||||||
// Pending further investigation:
|
|
||||||
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
||||||
comparisons: false,
|
|
||||||
|
|
||||||
// Disabled because of an issue with Terser breaking valid code:
|
|
||||||
// https://github.com/facebook/create-react-app/issues/5250
|
|
||||||
// Pending futher investigation:
|
|
||||||
// https://github.com/terser-js/terser/issues/120
|
|
||||||
inline: 2,
|
|
||||||
},
|
|
||||||
mangle: {
|
|
||||||
safari10: true,
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
ecma: 5,
|
|
||||||
comments: false,
|
|
||||||
|
|
||||||
// Turned on because emoji and regex is not minified properly using default
|
|
||||||
// https://github.com/facebook/create-react-app/issues/2488
|
|
||||||
ascii_only: true, // eslint-disable-line @typescript-eslint/camelcase
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
// Use multi-process parallel running to improve the build speed
|
|
||||||
// Default number of concurrent runs: os.cpus().length - 1
|
|
||||||
parallel: true,
|
|
||||||
|
|
||||||
// Enable file caching
|
|
||||||
cache: true,
|
|
||||||
sourceMap: shouldUseSourceMap,
|
|
||||||
}),
|
|
||||||
|
|
||||||
// This is only used in production mode
|
|
||||||
new OptimizeCSSAssetsPlugin({
|
|
||||||
cssProcessorOptions: {
|
|
||||||
parser: safePostCssParser,
|
|
||||||
map: shouldUseSourceMap
|
|
||||||
? {
|
|
||||||
|
|
||||||
// `inline: false` forces the sourcemap to be output into a
|
|
||||||
// separate file
|
|
||||||
inline: false,
|
|
||||||
|
|
||||||
// `annotation: true` appends the sourceMappingURL to the end of
|
|
||||||
// the css file, helping the browser find the sourcemap
|
|
||||||
annotation: true,
|
|
||||||
}
|
|
||||||
: false,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
|
|
||||||
// Automatically split vendor and commons
|
|
||||||
// https://twitter.com/wSokra/status/969633336732905474
|
|
||||||
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
||||||
splitChunks: {
|
|
||||||
chunks: 'all',
|
|
||||||
name: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
// Keep the runtime chunk separated to enable long term caching
|
|
||||||
// https://twitter.com/wSokra/status/969679223278505985
|
|
||||||
runtimeChunk: true,
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
|
|
||||||
// This allows you to set a fallback for where Webpack should look for modules.
|
|
||||||
// We placed these paths second because we want `node_modules` to "win"
|
|
||||||
// if there are any conflicts. This matches Node resolution mechanism.
|
|
||||||
// https://github.com/facebook/create-react-app/issues/253
|
|
||||||
modules: [ 'node_modules' ].concat(
|
|
||||||
|
|
||||||
// It is guaranteed to exist because we tweak it in `env.js`
|
|
||||||
process.env.NODE_PATH.split(path.delimiter).filter(Boolean),
|
|
||||||
),
|
|
||||||
|
|
||||||
// These are the reasonable defaults supported by the Node ecosystem.
|
|
||||||
// We also include JSX as a common component filename extension to support
|
|
||||||
// some tools, although we do not recommend using it, see:
|
|
||||||
// https://github.com/facebook/create-react-app/issues/290
|
|
||||||
// `web` extension prefixes have been added for better support
|
|
||||||
// for React Native Web.
|
|
||||||
extensions: paths.moduleFileExtensions
|
|
||||||
.map((ext) => `.${ext}`)
|
|
||||||
.filter((ext) => useTypeScript || !ext.includes('ts')),
|
|
||||||
alias: {
|
|
||||||
|
|
||||||
// Support React Native Web
|
|
||||||
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
|
|
||||||
'react-native': 'react-native-web',
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
|
|
||||||
// Adds support for installing with Plug'n'Play, leading to faster installs and adding
|
|
||||||
// guards against forgotten dependencies and such.
|
|
||||||
PnpWebpackPlugin,
|
|
||||||
|
|
||||||
// Prevents users from importing files from outside of src/ (or node_modules/).
|
|
||||||
// This often causes confusion because we only process files within src/ with babel.
|
|
||||||
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
|
|
||||||
// please link the files into your node_modules/ and let module-resolution kick in.
|
|
||||||
// Make sure your source files are compiled, as they will not be processed in any way.
|
|
||||||
new ModuleScopePlugin(paths.appSrc, [ paths.appPackageJson ]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
resolveLoader: {
|
|
||||||
plugins: [
|
|
||||||
|
|
||||||
// Also related to Plug'n'Play, but this time it tells Webpack to load its loaders
|
|
||||||
// from the current package.
|
|
||||||
PnpWebpackPlugin.moduleLoader(module),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
strictExportPresence: true,
|
|
||||||
rules: [
|
|
||||||
|
|
||||||
// Disable require.ensure as it's not a standard language feature.
|
|
||||||
{ parser: { requireEnsure: false } },
|
|
||||||
|
|
||||||
// First, run the linter.
|
|
||||||
// It's important to do this before Babel processes the JS.
|
|
||||||
{
|
|
||||||
test: /\.(js|mjs|jsx)$/,
|
|
||||||
enforce: 'pre',
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
options: {
|
|
||||||
formatter: require.resolve('react-dev-utils/eslintFormatter'),
|
|
||||||
eslintPath: require.resolve('eslint'),
|
|
||||||
|
|
||||||
},
|
|
||||||
loader: require.resolve('eslint-loader'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
include: paths.appSrc,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
|
|
||||||
// "oneOf" will traverse all following loaders until one will
|
|
||||||
// match the requirements. When no loader matches it will fall
|
|
||||||
// back to the "file" loader at the end of the loader list.
|
|
||||||
oneOf: [
|
|
||||||
|
|
||||||
// "url" loader works like "file" loader except that it embeds assets
|
|
||||||
// smaller than specified limit in bytes as data URLs to avoid requests.
|
|
||||||
// A missing `test` is equivalent to a match.
|
|
||||||
{
|
|
||||||
test: [ /\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/ ],
|
|
||||||
loader: require.resolve('url-loader'),
|
|
||||||
options: {
|
|
||||||
limit: 10000,
|
|
||||||
name: 'static/media/[name].[hash:8].[ext]',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
// Process application JS with Babel.
|
|
||||||
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
|
|
||||||
{
|
|
||||||
test: /\.(js|mjs|jsx|ts|tsx)$/,
|
|
||||||
include: paths.appSrc,
|
|
||||||
loader: require.resolve('babel-loader'),
|
|
||||||
options: {
|
|
||||||
customize: require.resolve(
|
|
||||||
'babel-preset-react-app/webpack-overrides',
|
|
||||||
),
|
|
||||||
|
|
||||||
plugins: [
|
|
||||||
[
|
|
||||||
require.resolve('babel-plugin-named-asset-import'),
|
|
||||||
{
|
|
||||||
loaderMap: {
|
|
||||||
svg: {
|
|
||||||
ReactComponent:
|
|
||||||
'@svgr/webpack?-prettier,-svgo![path]',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
||||||
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
||||||
// directory for faster rebuilds.
|
|
||||||
cacheDirectory: true,
|
|
||||||
cacheCompression: isEnvProduction,
|
|
||||||
compact: isEnvProduction,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
// Process any JS outside of the app with Babel.
|
|
||||||
// Unlike the application JS, we only compile the standard ES features.
|
|
||||||
{
|
|
||||||
test: /\.(js|mjs)$/,
|
|
||||||
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
|
||||||
loader: require.resolve('babel-loader'),
|
|
||||||
options: {
|
|
||||||
babelrc: false,
|
|
||||||
configFile: false,
|
|
||||||
compact: false,
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
require.resolve('babel-preset-react-app/dependencies'),
|
|
||||||
{ helpers: true },
|
|
||||||
],
|
|
||||||
],
|
|
||||||
cacheDirectory: true,
|
|
||||||
cacheCompression: isEnvProduction,
|
|
||||||
|
|
||||||
// If an error happens in a package, it's possible to be
|
|
||||||
// because it was compiled. Thus, we don't want the browser
|
|
||||||
// debugger to show the original code. Instead, the code
|
|
||||||
// being evaluated would be much more helpful.
|
|
||||||
sourceMaps: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
// "postcss" loader applies autoprefixer to our CSS.
|
|
||||||
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
|
||||||
// "style" loader turns CSS into JS modules that inject <style> tags.
|
|
||||||
// In production, we use MiniCSSExtractPlugin to extract that CSS
|
|
||||||
// to a file, but in development "style" loader enables hot editing
|
|
||||||
// of CSS.
|
|
||||||
// By default we support CSS Modules with the extension .module.css
|
|
||||||
{
|
|
||||||
test: cssRegex,
|
|
||||||
exclude: cssModuleRegex,
|
|
||||||
use: getStyleLoaders({
|
|
||||||
importLoaders: 1,
|
|
||||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Don't consider CSS imports dead code even if the
|
|
||||||
// containing package claims to have no side effects.
|
|
||||||
// Remove this when webpack adds a warning or an error for this.
|
|
||||||
// See https://github.com/webpack/webpack/issues/6571
|
|
||||||
sideEffects: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
// Adds support for CSS Modules (https://github.com/css-modules/css-modules)
|
|
||||||
// using the extension .module.css
|
|
||||||
{
|
|
||||||
test: cssModuleRegex,
|
|
||||||
use: getStyleLoaders({
|
|
||||||
importLoaders: 1,
|
|
||||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
|
||||||
modules: true,
|
|
||||||
getLocalIdent: getCSSModuleLocalIdent,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
|
|
||||||
// Opt-in support for SASS (using .scss or .sass extensions).
|
|
||||||
// By default we support SASS Modules with the
|
|
||||||
// extensions .module.scss or .module.sass
|
|
||||||
{
|
|
||||||
test: sassRegex,
|
|
||||||
exclude: sassModuleRegex,
|
|
||||||
use: getStyleLoaders(
|
|
||||||
{
|
|
||||||
importLoaders: 2,
|
|
||||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
|
||||||
},
|
|
||||||
'sass-loader',
|
|
||||||
),
|
|
||||||
|
|
||||||
// Don't consider CSS imports dead code even if the
|
|
||||||
// containing package claims to have no side effects.
|
|
||||||
// Remove this when webpack adds a warning or an error for this.
|
|
||||||
// See https://github.com/webpack/webpack/issues/6571
|
|
||||||
sideEffects: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
// Adds support for CSS Modules, but using SASS
|
|
||||||
// using the extension .module.scss or .module.sass
|
|
||||||
{
|
|
||||||
test: sassModuleRegex,
|
|
||||||
use: getStyleLoaders(
|
|
||||||
{
|
|
||||||
importLoaders: 2,
|
|
||||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
|
||||||
modules: true,
|
|
||||||
getLocalIdent: getCSSModuleLocalIdent,
|
|
||||||
},
|
|
||||||
'sass-loader',
|
|
||||||
),
|
|
||||||
},
|
|
||||||
|
|
||||||
// "file" loader makes sure those assets get served by WebpackDevServer.
|
|
||||||
// When you `import` an asset, you get its (virtual) filename.
|
|
||||||
// In production, they would get copied to the `build` folder.
|
|
||||||
// This loader doesn't use a "test" so it will catch all modules
|
|
||||||
// that fall through the other loaders.
|
|
||||||
{
|
|
||||||
loader: require.resolve('file-loader'),
|
|
||||||
|
|
||||||
// Exclude `js` files to keep "css" loader working as it injects
|
|
||||||
// its runtime that would otherwise be processed through "file" loader.
|
|
||||||
// Also exclude `html` and `json` extensions so they get processed
|
|
||||||
// by webpacks internal loaders.
|
|
||||||
exclude: [ /\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/ ],
|
|
||||||
options: {
|
|
||||||
name: 'static/media/[name].[hash:8].[ext]',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
// ** STOP ** Are you adding a new loader?
|
|
||||||
// Make sure to add the new loader(s) before the "file" loader.
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
|
|
||||||
// Generates an `index.html` file with the <script> injected.
|
|
||||||
new HtmlWebpackPlugin(
|
|
||||||
Object.assign(
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
inject: true,
|
|
||||||
template: paths.appHtml,
|
|
||||||
},
|
|
||||||
isEnvProduction
|
|
||||||
? {
|
|
||||||
minify: {
|
|
||||||
removeComments: true,
|
|
||||||
collapseWhitespace: true,
|
|
||||||
removeRedundantAttributes: true,
|
|
||||||
useShortDoctype: true,
|
|
||||||
removeEmptyAttributes: true,
|
|
||||||
removeStyleLinkTypeAttributes: true,
|
|
||||||
keepClosingSlash: true,
|
|
||||||
minifyJS: true,
|
|
||||||
minifyCSS: true,
|
|
||||||
minifyURLs: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Inlines the webpack runtime script. This script is too small to warrant
|
|
||||||
// a network request.
|
|
||||||
isEnvProduction &&
|
|
||||||
shouldInlineRuntimeChunk &&
|
|
||||||
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [ /runtime~.+[.]js/ ]),
|
|
||||||
|
|
||||||
// Makes some environment variables available in index.html.
|
|
||||||
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
|
|
||||||
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
|
||||||
// In production, it will be an empty string unless you specify "homepage"
|
|
||||||
// in `package.json`, in which case it will be the pathname of that URL.
|
|
||||||
// In development, this will be an empty string.
|
|
||||||
new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
|
|
||||||
|
|
||||||
// This gives some necessary context to module not found errors, such as
|
|
||||||
// the requesting resource.
|
|
||||||
new ModuleNotFoundPlugin(paths.appPath),
|
|
||||||
|
|
||||||
// Makes some environment variables available to the JS code, for example:
|
|
||||||
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
|
|
||||||
// It is absolutely essential that NODE_ENV is set to production
|
|
||||||
// during a production build.
|
|
||||||
// Otherwise React will be compiled in the very slow development mode.
|
|
||||||
new webpack.DefinePlugin(env.stringified),
|
|
||||||
|
|
||||||
// This is necessary to emit hot updates (currently CSS only):
|
|
||||||
isEnvDevelopment && new webpack.HotModuleReplacementPlugin(),
|
|
||||||
|
|
||||||
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
||||||
// a plugin that prints an error when you attempt to do this.
|
|
||||||
// See https://github.com/facebook/create-react-app/issues/240
|
|
||||||
isEnvDevelopment && new CaseSensitivePathsPlugin(),
|
|
||||||
|
|
||||||
// If you require a missing module and then `npm install` it, you still have
|
|
||||||
// to restart the development server for Webpack to discover it. This plugin
|
|
||||||
// makes the discovery automatic so you don't have to restart.
|
|
||||||
// See https://github.com/facebook/create-react-app/issues/186
|
|
||||||
isEnvDevelopment &&
|
|
||||||
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
|
|
||||||
isEnvProduction &&
|
|
||||||
new MiniCssExtractPlugin({
|
|
||||||
|
|
||||||
// Options similar to the same options in webpackOptions.output
|
|
||||||
// both options are optional
|
|
||||||
filename: 'static/css/[name].[contenthash:8].css',
|
|
||||||
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Generate a manifest file which contains a mapping of all asset filenames
|
|
||||||
// to their corresponding output file so that tools can pick it up without
|
|
||||||
// having to parse `index.html`.
|
|
||||||
new ManifestPlugin({
|
|
||||||
fileName: 'asset-manifest.json',
|
|
||||||
publicPath,
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Moment.js is an extremely popular library that bundles large locale files
|
|
||||||
// by default due to how Webpack interprets its code. This is a practical
|
|
||||||
// solution that requires the user to opt into importing specific locales.
|
|
||||||
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
|
||||||
// You can remove this if you don't use Moment.js:
|
|
||||||
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
|
||||||
|
|
||||||
// Generate a service worker script that will precache, and keep up to date,
|
|
||||||
// the HTML & assets that are part of the webpack build.
|
|
||||||
isEnvProduction && fs.existsSync(swSrc) && new WorkboxWebpackPlugin.InjectManifest({
|
|
||||||
swSrc,
|
|
||||||
dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
|
|
||||||
exclude: [ /\.map$/, /asset-manifest\.json$/, /LICENSE/ ],
|
|
||||||
// Bump up the default maximum size (2mb) that's precached,
|
|
||||||
// to make lazy-loading failure scenarios less likely.
|
|
||||||
// See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270
|
|
||||||
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
|
|
||||||
}),
|
|
||||||
|
|
||||||
// TypeScript type checking
|
|
||||||
useTypeScript &&
|
|
||||||
new ForkTsCheckerWebpackPlugin({
|
|
||||||
typescript: resolve.sync('typescript', {
|
|
||||||
basedir: paths.appNodeModules,
|
|
||||||
}),
|
|
||||||
async: false,
|
|
||||||
checkSyntacticErrors: true,
|
|
||||||
tsconfig: paths.appTsConfig,
|
|
||||||
compilerOptions: {
|
|
||||||
module: 'esnext',
|
|
||||||
moduleResolution: 'node',
|
|
||||||
resolveJsonModule: true,
|
|
||||||
isolatedModules: true,
|
|
||||||
noEmit: true,
|
|
||||||
jsx: 'preserve',
|
|
||||||
},
|
|
||||||
reportFiles: [
|
|
||||||
'**',
|
|
||||||
'!**/*.json',
|
|
||||||
'!**/__tests__/**',
|
|
||||||
'!**/?(*.)(spec|test).*',
|
|
||||||
'!**/src/setupProxy.*',
|
|
||||||
'!**/src/setupTests.*',
|
|
||||||
],
|
|
||||||
watch: paths.appSrc,
|
|
||||||
silent: true,
|
|
||||||
formatter: typescriptFormatter,
|
|
||||||
}),
|
|
||||||
].filter(Boolean),
|
|
||||||
|
|
||||||
// Some libraries import Node modules but don't use them in the browser.
|
|
||||||
// Tell Webpack to provide empty mocks for them so importing them works.
|
|
||||||
node: {
|
|
||||||
dgram: 'empty',
|
|
||||||
fs: 'empty',
|
|
||||||
net: 'empty',
|
|
||||||
tls: 'empty',
|
|
||||||
child_process: 'empty', // eslint-disable-line @typescript-eslint/camelcase
|
|
||||||
},
|
|
||||||
|
|
||||||
// Turn off performance processing because we utilize
|
|
||||||
// our own hints via the FileSizeReporter
|
|
||||||
performance: false,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
|
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
|
|
||||||
const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
|
|
||||||
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
|
|
||||||
const ignoredFiles = require('react-dev-utils/ignoredFiles');
|
|
||||||
const paths = require('./paths');
|
|
||||||
|
|
||||||
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
|
||||||
const host = process.env.HOST || '0.0.0.0';
|
|
||||||
|
|
||||||
module.exports = function(proxy, allowedHost) {
|
|
||||||
return {
|
|
||||||
|
|
||||||
// WebpackDevServer 2.4.3 introduced a security fix that prevents remote
|
|
||||||
// websites from potentially accessing local content through DNS rebinding:
|
|
||||||
// https://github.com/webpack/webpack-dev-server/issues/887
|
|
||||||
// https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
|
|
||||||
// However, it made several existing use cases such as development in cloud
|
|
||||||
// environment or subdomains in development significantly more complicated:
|
|
||||||
// https://github.com/facebook/create-react-app/issues/2271
|
|
||||||
// https://github.com/facebook/create-react-app/issues/2233
|
|
||||||
// While we're investigating better solutions, for now we will take a
|
|
||||||
// compromise. Since our WDS configuration only serves files in the `public`
|
|
||||||
// folder we won't consider accessing them a vulnerability. However, if you
|
|
||||||
// use the `proxy` feature, it gets more dangerous because it can expose
|
|
||||||
// remote code execution vulnerabilities in backends like Django and Rails.
|
|
||||||
// So we will disable the host check normally, but enable it if you have
|
|
||||||
// specified the `proxy` setting. Finally, we let you override it if you
|
|
||||||
// really know what you're doing with a special environment variable.
|
|
||||||
disableHostCheck:
|
|
||||||
!proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
|
|
||||||
|
|
||||||
// Enable gzip compression of generated files.
|
|
||||||
compress: true,
|
|
||||||
|
|
||||||
// Silence WebpackDevServer's own logs since they're generally not useful.
|
|
||||||
// It will still show compile warnings and errors with this setting.
|
|
||||||
clientLogLevel: 'none',
|
|
||||||
|
|
||||||
// By default WebpackDevServer serves physical files from current directory
|
|
||||||
// in addition to all the virtual build products that it serves from memory.
|
|
||||||
// This is confusing because those files won’t automatically be available in
|
|
||||||
// production build folder unless we copy them. However, copying the whole
|
|
||||||
// project directory is dangerous because we may expose sensitive files.
|
|
||||||
// Instead, we establish a convention that only files in `public` directory
|
|
||||||
// get served. Our build script will copy `public` into the `build` folder.
|
|
||||||
// In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
|
|
||||||
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
|
||||||
// In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
|
|
||||||
// Note that we only recommend to use `public` folder as an escape hatch
|
|
||||||
// for files like `favicon.ico`, `manifest.json`, and libraries that are
|
|
||||||
// for some reason broken when imported through Webpack. If you just want to
|
|
||||||
// use an image, put it in `src` and `import` it from JavaScript instead.
|
|
||||||
contentBase: paths.appPublic,
|
|
||||||
|
|
||||||
// By default files from `contentBase` will not trigger a page reload.
|
|
||||||
watchContentBase: true,
|
|
||||||
|
|
||||||
// Enable hot reloading server. It will provide /sockjs-node/ endpoint
|
|
||||||
// for the WebpackDevServer client so it can learn when the files were
|
|
||||||
// updated. The WebpackDevServer client is included as an entry point
|
|
||||||
// in the Webpack development configuration. Note that only changes
|
|
||||||
// to CSS are currently hot reloaded. JS changes will refresh the browser.
|
|
||||||
hot: true,
|
|
||||||
|
|
||||||
// It is important to tell WebpackDevServer to use the same "root" path
|
|
||||||
// as we specified in the config. In development, we always serve from /.
|
|
||||||
publicPath: '/',
|
|
||||||
|
|
||||||
// WebpackDevServer is noisy by default so we emit custom message instead
|
|
||||||
// by listening to the compiler events with `compiler.hooks[...].tap` calls above.
|
|
||||||
quiet: true,
|
|
||||||
|
|
||||||
// Reportedly, this avoids CPU overload on some systems.
|
|
||||||
// https://github.com/facebook/create-react-app/issues/293
|
|
||||||
// src/node_modules is not ignored to support absolute imports
|
|
||||||
// https://github.com/facebook/create-react-app/issues/1065
|
|
||||||
watchOptions: {
|
|
||||||
ignored: ignoredFiles(paths.appSrc),
|
|
||||||
},
|
|
||||||
|
|
||||||
// Enable HTTPS if the HTTPS environment variable is set to 'true'
|
|
||||||
https: protocol === 'https',
|
|
||||||
host,
|
|
||||||
overlay: false,
|
|
||||||
historyApiFallback: {
|
|
||||||
|
|
||||||
// Paths with dots should still use the history fallback.
|
|
||||||
// See https://github.com/facebook/create-react-app/issues/387.
|
|
||||||
disableDotRule: true,
|
|
||||||
},
|
|
||||||
public: allowedHost,
|
|
||||||
proxy,
|
|
||||||
before(app, server) {
|
|
||||||
if (fs.existsSync(paths.proxySetup)) {
|
|
||||||
// This registers user provided middleware for proxy reasons
|
|
||||||
require(paths.proxySetup)(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This lets us fetch source contents from webpack for the error overlay
|
|
||||||
app.use(evalSourceMapMiddleware(server));
|
|
||||||
|
|
||||||
// This lets us open files from the runtime error overlay.
|
|
||||||
app.use(errorOverlayMiddleware());
|
|
||||||
|
|
||||||
// This service worker file is effectively a 'no-op' that will reset any
|
|
||||||
// previous service worker registered for the same host:port combination.
|
|
||||||
// We do this in development to avoid hitting the production cache if
|
|
||||||
// it used the same host and port.
|
|
||||||
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
|
|
||||||
app.use(noopServiceWorkerMiddleware(paths.publicUrl));
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -3,11 +3,11 @@ version: '3'
|
|||||||
services:
|
services:
|
||||||
shlink_web_client_node:
|
shlink_web_client_node:
|
||||||
container_name: shlink_web_client_node
|
container_name: shlink_web_client_node
|
||||||
image: node:16.13-alpine
|
image: node:20.2-alpine
|
||||||
command: /bin/sh -c "cd /home/shlink/www && npm install && npm run start"
|
command: /bin/sh -c "cd /home/shlink/www && npm install --force && npm run start"
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/home/shlink/www
|
- ./:/home/shlink/www
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
- "56745:56745"
|
- "56745:56745"
|
||||||
- "5000:5000"
|
- "4173:4173"
|
||||||
|
|||||||
90
index.html
Normal file
90
index.html
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||||
|
<meta name="theme-color" content="#4696e5">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
manifest.json provides metadata used when your web app is added to the
|
||||||
|
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
||||||
|
-->
|
||||||
|
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
|
||||||
|
|
||||||
|
<!-- FavIcon itself -->
|
||||||
|
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" sizes="any">
|
||||||
|
<link rel="icon" type="image/png" href="/favicon.png">
|
||||||
|
<link rel="icon" type="image/gif" href="/favicon.gif">
|
||||||
|
<!-- Apple Touch -->
|
||||||
|
<link rel="apple-touch-icon" sizes="16x16" href="/icons/icon-16x16.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="24x24" href="/icons/icon-24x24.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="32x32" href="/icons/icon-32x32.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="40x40" href="/icons/icon-40x40.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="48x48" href="/icons/icon-48x48.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="60x60" href="/icons/icon-60x60.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="64x64" href="/icons/icon-64x64.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="72x72" href="/icons/icon-72x72.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="76x76" href="/icons/icon-76x76.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="96x96" href="/icons/icon-96x96.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="114x114" href="/icons/icon-114x114.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="120x120" href="/icons/icon-120x120.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="128x128" href="/icons/icon-128x128.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="144x144" href="/icons/icon-144x144.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="150x150" href="/icons/icon-150x150.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="152x152" href="/icons/icon-152x152.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="160x160" href="/icons/icon-160x160.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="167x167" href="/icons/icon-167x167.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/icons/icon-180x180.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="192x192" href="/icons/icon-192x192.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="196x196" href="/icons/icon-196x196.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="228x228" href="/icons/icon-228x228.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="256x256" href="/icons/icon-256x256.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="310x310" href="/icons/icon-310x310.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="384x384" href="/icons/icon-384x384.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="512x512" href="/icons/icon-512x512.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="1024x1024" href="/icons/icon-1024x1024.png">
|
||||||
|
<!-- Normal -->
|
||||||
|
<link rel="icon" type="image/png" sizes="1024x1024" href="/icons/icon-1024x1024.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="512x512" href="/icons/icon-512x512.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="384x384" href="/icons/icon-384x384.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="310x310" href="/icons/icon-310x310.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="256x256" href="/icons/icon-256x256.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="228x228" href="/icons/icon-228x228.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="196x196" href="/icons/icon-196x196.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="192x192" href="/icons/icon-192x192.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="180x180" href="/icons/icon-180x180.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="167x167" href="/icons/icon-167x167.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="160x160" href="/icons/icon-160x160.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="152x152" href="/icons/icon-152x152.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="150x150" href="/icons/icon-150x150.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="144x144" href="/icons/icon-144x144.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="128x128" href="/icons/icon-128x128.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="120x120" href="/icons/icon-120x120.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="114x114" href="/icons/icon-114x114.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="96x96" href="/icons/icon-96x96.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="76x76" href="/icons/icon-76x76.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="72x72" href="/icons/icon-72x72.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="64x64" href="/icons/icon-64x64.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="60x60" href="/icons/icon-60x60.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="48x48" href="/icons/icon-48x48.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="40x40" href="/icons/icon-40x40.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="/icons/icon-32x32.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="24x24" href="/icons/icon-24x24.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="/icons/icon-16x16.png">
|
||||||
|
<!-- MS -->
|
||||||
|
<meta name="msapplication-TileImage" content="/icons/icon-144x144.png">
|
||||||
|
<meta name="msapplication-square70x70logo" content="/icons/icon-70x70.png">
|
||||||
|
<meta name="msapplication-square144x144logo" content="/icons/icon-144x144.png">
|
||||||
|
<meta name="msapplication-square150x150logo" content="/icons/icon-150x150.png">
|
||||||
|
<meta name="msapplication-square310x310logo" content="/icons/icon-310x310.png">
|
||||||
|
<title>Shlink — The URL shortener</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
You need to enable JavaScript to run this app.
|
||||||
|
</noscript>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/index.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
coverageDirectory: '<rootDir>/coverage',
|
|
||||||
collectCoverageFrom: [
|
|
||||||
'src/**/*.{ts,tsx}',
|
|
||||||
'!src/*.{ts,tsx}',
|
|
||||||
'!src/reducers/index.ts',
|
|
||||||
'!src/**/provideServices.ts',
|
|
||||||
'!src/container/*.ts',
|
|
||||||
],
|
|
||||||
coverageThreshold: {
|
|
||||||
global: {
|
|
||||||
statements: 85,
|
|
||||||
branches: 80,
|
|
||||||
functions: 80,
|
|
||||||
lines: 85,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setupFiles: [ '<rootDir>/config/setupEnzyme.js' ],
|
|
||||||
testMatch: [ '<rootDir>/test/**/*.test.{ts,tsx}' ],
|
|
||||||
testEnvironment: 'jsdom',
|
|
||||||
testURL: 'http://localhost',
|
|
||||||
transform: {
|
|
||||||
'^.+\\.(ts|tsx|js)$': '<rootDir>/node_modules/babel-jest',
|
|
||||||
'^(?!.*\\.(ts|tsx|js|json)$)': '<rootDir>/config/jest/fileTransform.js',
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: [
|
|
||||||
'<rootDir>/.stryker-tmp',
|
|
||||||
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$',
|
|
||||||
'^.+\\.module\\.scss$',
|
|
||||||
],
|
|
||||||
moduleNameMapper: {
|
|
||||||
'^.+\\.module\\.scss$': 'identity-obj-proxy',
|
|
||||||
// Reactstrap module resolution does not work in jest for some reason. Manually mapping it solves the problem
|
|
||||||
'reactstrap': '<rootDir>/node_modules/reactstrap/dist/reactstrap.umd.js',
|
|
||||||
},
|
|
||||||
moduleFileExtensions: [ 'js', 'ts', 'tsx', 'json' ],
|
|
||||||
};
|
|
||||||
145
manifest.ts
Normal file
145
manifest.ts
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
export const manifest = {
|
||||||
|
short_name: 'Shlink',
|
||||||
|
name: 'Shlink',
|
||||||
|
start_url: '/',
|
||||||
|
display: 'standalone',
|
||||||
|
theme_color: '#4696e5',
|
||||||
|
background_color: '#4696e5',
|
||||||
|
icons: [
|
||||||
|
{
|
||||||
|
src: './icons/icon-16x16.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '16x16',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-24x24.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '24x24',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-32x32.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '32x32',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-40x40.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '40x40',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-48x48.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '48x48',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-60x60.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '60x60',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-64x64.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '64x64',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-72x72.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '72x72',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-76x76.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '76x76',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-96x96.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '96x96',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-114x114.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '114x114',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-120x120.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '120x120',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-128x128.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '128x128',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-144x144.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '144x144',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-150x150.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '150x150',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-152x152.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '152x152',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-160x160.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '160x160',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-167x167.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '167x167',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-180x180.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '180x180',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-192x192.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '192x192',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-196x196.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '196x196',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-228x228.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '228x228',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-256x256.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '256x256',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-310x310.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '310x310',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-384x384.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '384x384',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-512x512.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '512x512',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: './icons/icon-1024x1024.png',
|
||||||
|
type: 'image/png',
|
||||||
|
sizes: '1024x1024',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
54383
package-lock.json
generated
54383
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
194
package.json
194
package.json
@@ -12,137 +12,91 @@
|
|||||||
"lint:fix": "npm run lint:css:fix && npm run lint:js:fix",
|
"lint:fix": "npm run lint:css:fix && npm run lint:js:fix",
|
||||||
"lint:css:fix": "npm run lint:css -- --fix",
|
"lint:css:fix": "npm run lint:css -- --fix",
|
||||||
"lint:js:fix": "npm run lint:js -- --fix",
|
"lint:js:fix": "npm run lint:js -- --fix",
|
||||||
"start": "node scripts/start.js",
|
"types": "tsc",
|
||||||
"serve:build": "serve ./build",
|
"start": "vite serve --host=0.0.0.0",
|
||||||
"build": "node scripts/build.js && node scripts/replace-version.js",
|
"preview": "vite preview --host=0.0.0.0",
|
||||||
"build:dist": "npm run build && node scripts/create-dist-file.js",
|
"build": "npm run types && vite build && node scripts/replace-version.mjs",
|
||||||
"test": "node scripts/test.js --env=jsdom --colors --verbose",
|
"build:dist": "npm run build && node scripts/create-dist-file.mjs",
|
||||||
"test:coverage": "npm run test -- --coverage --coverageReporters=text --coverageReporters=text-summary",
|
"test": "vitest run --run",
|
||||||
"test:ci": "npm run test:coverage -- --coverageReporters=clover",
|
"test:watch": "vitest --watch",
|
||||||
"test:pretty": "npm run test:coverage -- --coverageReporters=html",
|
"test:ci": "npm run test -- --coverage",
|
||||||
"mutate": "./node_modules/.bin/stryker run --concurrency 4"
|
"test:verbose": "npm run test -- --verbose"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^6.0.0",
|
"@fortawesome/fontawesome-free": "^6.3.0",
|
||||||
"@fortawesome/fontawesome-svg-core": "^1.3.0",
|
"@fortawesome/fontawesome-svg-core": "^6.3.0",
|
||||||
"@fortawesome/free-regular-svg-icons": "^6.0.0",
|
"@fortawesome/free-brands-svg-icons": "^6.3.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^6.0.0",
|
"@fortawesome/free-regular-svg-icons": "^6.3.0",
|
||||||
"@fortawesome/react-fontawesome": "^0.1.17",
|
"@fortawesome/free-solid-svg-icons": "^6.3.0",
|
||||||
"axios": "^0.26.0",
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
||||||
"bootstrap": "^5.1.3",
|
"@json2csv/plainjs": "^6.1.2",
|
||||||
"bottlejs": "^2.0.0",
|
"@reduxjs/toolkit": "^1.9.1",
|
||||||
|
"bootstrap": "^5.2.3",
|
||||||
|
"bottlejs": "^2.0.1",
|
||||||
"bowser": "^2.11.0",
|
"bowser": "^2.11.0",
|
||||||
"chart.js": "^3.7.1",
|
"chart.js": "^4.1.1",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.2",
|
||||||
"compare-versions": "^4.1.3",
|
"compare-versions": "^5.0.3",
|
||||||
"csvjson": "^5.1.0",
|
"csvtojson": "^2.0.10",
|
||||||
"date-fns": "^2.28.0",
|
"date-fns": "^2.29.3",
|
||||||
"event-source-polyfill": "^1.0.25",
|
"event-source-polyfill": "^1.0.31",
|
||||||
"leaflet": "^1.7.1",
|
"history": "^5.3.0",
|
||||||
"qs": "^6.9.6",
|
"leaflet": "^1.9.3",
|
||||||
|
"qs": "^6.11.0",
|
||||||
"ramda": "^0.27.2",
|
"ramda": "^0.27.2",
|
||||||
"react": "^17.0.2",
|
"react": "^18.2.0",
|
||||||
"react-chartjs-2": "^3.3.0",
|
"react-chartjs-2": "^5.1.0",
|
||||||
"react-colorful": "^5.5.1",
|
"react-colorful": "^5.6.1",
|
||||||
"react-copy-to-clipboard": "^5.0.4",
|
"react-copy-to-clipboard": "^5.1.0",
|
||||||
"react-datepicker": "^4.7.0",
|
"react-datepicker": "^4.8.0",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^18.2.0",
|
||||||
"react-external-link": "^1.2.2",
|
"react-external-link": "^2.2.0",
|
||||||
"react-leaflet": "^3.2.5",
|
"react-leaflet": "^4.2.0",
|
||||||
"react-redux": "^7.2.6",
|
"react-redux": "^8.0.5",
|
||||||
"react-router-dom": "^6.2.2",
|
"react-router-dom": "^6.6.1",
|
||||||
"react-swipeable": "^6.2.0",
|
"react-swipeable": "^7.0.0",
|
||||||
"react-tag-autocomplete": "^6.3.0",
|
"react-tag-autocomplete": "^6.3.0",
|
||||||
"reactstrap": "^9.0.1",
|
"reactstrap": "^9.1.5",
|
||||||
"redux": "^4.1.2",
|
"redux-localstorage-simple": "^2.5.1",
|
||||||
"redux-localstorage-simple": "^2.4.1",
|
|
||||||
"redux-thunk": "^2.4.1",
|
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"workbox-core": "^6.5.1",
|
"workbox-core": "^6.5.4",
|
||||||
"workbox-expiration": "^6.5.1",
|
"workbox-expiration": "^6.5.4",
|
||||||
"workbox-precaching": "^6.5.1",
|
"workbox-precaching": "^6.5.4",
|
||||||
"workbox-routing": "^6.5.1",
|
"workbox-routing": "^6.5.4",
|
||||||
"workbox-strategies": "^6.5.1"
|
"workbox-strategies": "^6.5.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.17.5",
|
"@shlinkio/eslint-config-js-coding-standard": "~2.1.0",
|
||||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
|
"@shlinkio/stylelint-config-css-coding-standard": "~1.0.1",
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
"@shlinkio/eslint-config-js-coding-standard": "~1.2.2",
|
"@testing-library/react": "^14.0.0",
|
||||||
"@stryker-mutator/core": "^5.6.1",
|
"@testing-library/user-event": "^14.4.3",
|
||||||
"@stryker-mutator/jest-runner": "^5.6.1",
|
"@total-typescript/shoehorn": "^0.1.0",
|
||||||
"@stryker-mutator/typescript-checker": "^5.6.1",
|
"@types/json2csv": "^5.0.3",
|
||||||
"@svgr/webpack": "^5.5.0",
|
"@types/leaflet": "^1.9.0",
|
||||||
"@types/classnames": "^2.3.1",
|
|
||||||
"@types/enzyme": "^3.10.11",
|
|
||||||
"@types/jest": "^27.4.1",
|
|
||||||
"@types/leaflet": "^1.7.9",
|
|
||||||
"@types/qs": "^6.9.7",
|
"@types/qs": "^6.9.7",
|
||||||
"@types/ramda": "0.27.38",
|
"@types/ramda": "^0.28.15",
|
||||||
"@types/react": "^17.0.39",
|
"@types/react": "^18.0.26",
|
||||||
"@types/react-color": "^3.0.6",
|
"@types/react-color": "^3.0.6",
|
||||||
"@types/react-copy-to-clipboard": "^5.0.2",
|
"@types/react-copy-to-clipboard": "^5.0.4",
|
||||||
"@types/react-datepicker": "^4.3.4",
|
"@types/react-datepicker": "^4.8.0",
|
||||||
"@types/react-dom": "^17.0.13",
|
"@types/react-dom": "^18.0.10",
|
||||||
"@types/react-leaflet": "^2.8.2",
|
"@types/react-tag-autocomplete": "^6.3.0",
|
||||||
"@types/react-redux": "^7.1.23",
|
|
||||||
"@types/react-tag-autocomplete": "^6.1.1",
|
|
||||||
"@types/uuid": "^8.3.4",
|
"@types/uuid": "^8.3.4",
|
||||||
"@wojtekmaj/enzyme-adapter-react-17": "0.6.5",
|
"@vitejs/plugin-react": "^4.0.0",
|
||||||
"adm-zip": "^0.5.9",
|
"@vitest/coverage-v8": "^0.32.0",
|
||||||
"autoprefixer": "^10.4.2",
|
"adm-zip": "^0.5.10",
|
||||||
"babel-jest": "^27.5.1",
|
"chalk": "^5.2.0",
|
||||||
"babel-loader": "^8.2.3",
|
"eslint": "^8.30.0",
|
||||||
"babel-plugin-named-asset-import": "^0.3.8",
|
"jsdom": "^22.0.0",
|
||||||
"babel-preset-react-app": "10.0.0",
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"babel-runtime": "^6.26.0",
|
"sass": "^1.57.1",
|
||||||
"bfj": "^7.0.2",
|
"stylelint": "^15.10.1",
|
||||||
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
"typescript": "^5.0.2",
|
||||||
"chalk": "^4.1.2",
|
"vite": "^4.3.9",
|
||||||
"css-loader": "^5.0.1",
|
"vite-plugin-pwa": "^0.14.4",
|
||||||
"dart-sass": "^1.25.0",
|
"vitest": "^0.32.0",
|
||||||
"dotenv": "^8.2.0",
|
"vitest-canvas-mock": "^0.2.2"
|
||||||
"dotenv-expand": "^5.1.0",
|
|
||||||
"enzyme": "^3.11.0",
|
|
||||||
"eslint": "^7.13.0",
|
|
||||||
"eslint-loader": "^4.0.2",
|
|
||||||
"file-loader": "^6.2.0",
|
|
||||||
"fork-ts-checker-webpack-plugin-alt": "^0.4.14",
|
|
||||||
"fs-extra": "^9.0.1",
|
|
||||||
"html-webpack-plugin": "^4.5.0",
|
|
||||||
"identity-obj-proxy": "^3.0.0",
|
|
||||||
"jest": "^27.5.1",
|
|
||||||
"mini-css-extract-plugin": "^1.3.1",
|
|
||||||
"object-assign": "^4.1.1",
|
|
||||||
"optimize-css-assets-webpack-plugin": "^5.0.4",
|
|
||||||
"pnp-webpack-plugin": "^1.7.0",
|
|
||||||
"postcss": "^8.4.8",
|
|
||||||
"postcss-flexbugs-fixes": "^4.2.1",
|
|
||||||
"postcss-loader": "^3.0.0",
|
|
||||||
"postcss-preset-env": "^6.7.0",
|
|
||||||
"postcss-safe-parser": "^5.0.2",
|
|
||||||
"react-dev-utils": "^11.0.0",
|
|
||||||
"resolve": "^1.22.0",
|
|
||||||
"sass": "^1.49.9",
|
|
||||||
"sass-loader": "^10.1.0",
|
|
||||||
"serve": "^12.0.0",
|
|
||||||
"stryker-cli": "^1.0.2",
|
|
||||||
"style-loader": "^2.0.0",
|
|
||||||
"stylelint": "^13.7.2",
|
|
||||||
"stylelint-config-adidas": "^1.3.0",
|
|
||||||
"stylelint-config-adidas-bem": "^1.2.0",
|
|
||||||
"stylelint-config-recommended-scss": "^4.2.0",
|
|
||||||
"stylelint-scss": "^3.18.0",
|
|
||||||
"sw-precache-webpack-plugin": "^1.0.0",
|
|
||||||
"terser-webpack-plugin": "^4.2.3",
|
|
||||||
"ts-mockery": "^1.2.0",
|
|
||||||
"typescript": "^4.6.2",
|
|
||||||
"url-loader": "^4.1.1",
|
|
||||||
"webpack": "^4.46.0",
|
|
||||||
"webpack-dev-server": "^3.11.3",
|
|
||||||
"webpack-manifest-plugin": "^2.2.0",
|
|
||||||
"whatwg-fetch": "^3.6.2",
|
|
||||||
"workbox-webpack-plugin": "^6.5.1"
|
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
">0.2%",
|
">0.2%",
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
||||||
<meta name="theme-color" content="#4696e5">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
manifest.json provides metadata used when your web app is added to the
|
|
||||||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
|
||||||
-->
|
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" crossorigin="use-credentials">
|
|
||||||
|
|
||||||
<!-- FavIcon itself -->
|
|
||||||
<link rel="icon" type="image/x-icon" href="%PUBLIC_URL%/favicon.ico">
|
|
||||||
<link rel="icon" type="image/svg+xml" href="%PUBLIC_URL%/favicon.svg" sizes="any">
|
|
||||||
<link rel="icon" type="image/png" href="%PUBLIC_URL%/favicon.png">
|
|
||||||
<link rel="icon" type="image/gif" href="%PUBLIC_URL%/favicon.gif">
|
|
||||||
<!-- Apple Touch -->
|
|
||||||
<link rel="apple-touch-icon" sizes="16x16" href="%PUBLIC_URL%/icons/icon-16x16.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="24x24" href="%PUBLIC_URL%/icons/icon-24x24.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="32x32" href="%PUBLIC_URL%/icons/icon-32x32.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="40x40" href="%PUBLIC_URL%/icons/icon-40x40.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="48x48" href="%PUBLIC_URL%/icons/icon-48x48.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="60x60" href="%PUBLIC_URL%/icons/icon-60x60.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="64x64" href="%PUBLIC_URL%/icons/icon-64x64.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="72x72" href="%PUBLIC_URL%/icons/icon-72x72.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="76x76" href="%PUBLIC_URL%/icons/icon-76x76.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="96x96" href="%PUBLIC_URL%/icons/icon-96x96.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="114x114" href="%PUBLIC_URL%/icons/icon-114x114.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="120x120" href="%PUBLIC_URL%/icons/icon-120x120.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="128x128" href="%PUBLIC_URL%/icons/icon-128x128.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="144x144" href="%PUBLIC_URL%/icons/icon-144x144.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="150x150" href="%PUBLIC_URL%/icons/icon-150x150.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="152x152" href="%PUBLIC_URL%/icons/icon-152x152.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="160x160" href="%PUBLIC_URL%/icons/icon-160x160.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="167x167" href="%PUBLIC_URL%/icons/icon-167x167.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="%PUBLIC_URL%/icons/icon-180x180.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="192x192" href="%PUBLIC_URL%/icons/icon-192x192.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="196x196" href="%PUBLIC_URL%/icons/icon-196x196.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="228x228" href="%PUBLIC_URL%/icons/icon-228x228.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="256x256" href="%PUBLIC_URL%/icons/icon-256x256.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="310x310" href="%PUBLIC_URL%/icons/icon-310x310.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="384x384" href="%PUBLIC_URL%/icons/icon-384x384.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="512x512" href="%PUBLIC_URL%/icons/icon-512x512.png">
|
|
||||||
<link rel="apple-touch-icon" sizes="1024x1024" href="%PUBLIC_URL%/icons/icon-1024x1024.png">
|
|
||||||
<!-- Normal -->
|
|
||||||
<link rel="icon" type="image/png" sizes="1024x1024" href="%PUBLIC_URL%/icons/icon-1024x1024.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="512x512" href="%PUBLIC_URL%/icons/icon-512x512.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="384x384" href="%PUBLIC_URL%/icons/icon-384x384.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="310x310" href="%PUBLIC_URL%/icons/icon-310x310.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="256x256" href="%PUBLIC_URL%/icons/icon-256x256.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="228x228" href="%PUBLIC_URL%/icons/icon-228x228.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="196x196" href="%PUBLIC_URL%/icons/icon-196x196.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="192x192" href="%PUBLIC_URL%/icons/icon-192x192.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="180x180" href="%PUBLIC_URL%/icons/icon-180x180.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="167x167" href="%PUBLIC_URL%/icons/icon-167x167.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="160x160" href="%PUBLIC_URL%/icons/icon-160x160.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="152x152" href="%PUBLIC_URL%/icons/icon-152x152.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="150x150" href="%PUBLIC_URL%/icons/icon-150x150.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="144x144" href="%PUBLIC_URL%/icons/icon-144x144.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="128x128" href="%PUBLIC_URL%/icons/icon-128x128.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="120x120" href="%PUBLIC_URL%/icons/icon-120x120.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="114x114" href="%PUBLIC_URL%/icons/icon-114x114.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="96x96" href="%PUBLIC_URL%/icons/icon-96x96.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="76x76" href="%PUBLIC_URL%/icons/icon-76x76.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="72x72" href="%PUBLIC_URL%/icons/icon-72x72.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="64x64" href="%PUBLIC_URL%/icons/icon-64x64.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="60x60" href="%PUBLIC_URL%/icons/icon-60x60.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="48x48" href="%PUBLIC_URL%/icons/icon-48x48.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="40x40" href="%PUBLIC_URL%/icons/icon-40x40.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="%PUBLIC_URL%/icons/icon-32x32.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="24x24" href="%PUBLIC_URL%/icons/icon-24x24.png">
|
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="%PUBLIC_URL%/icons/icon-16x16.png">
|
|
||||||
<!-- MS -->
|
|
||||||
<meta name="msapplication-TileImage" content="%PUBLIC_URL%/icons/icon-144x144.png">
|
|
||||||
<meta name="msapplication-square70x70logo" content="%PUBLIC_URL%/icons/icon-70x70.png">
|
|
||||||
<meta name="msapplication-square144x144logo" content="%PUBLIC_URL%/icons/icon-144x144.png">
|
|
||||||
<meta name="msapplication-square150x150logo" content="%PUBLIC_URL%/icons/icon-150x150.png">
|
|
||||||
<meta name="msapplication-square310x310logo" content="%PUBLIC_URL%/icons/icon-310x310.png">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Notice the use of %PUBLIC_URL% in the tags above.
|
|
||||||
It will be replaced with the URL of the `public` folder during the build.
|
|
||||||
Only files inside the `public` folder can be referenced from the HTML.
|
|
||||||
|
|
||||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
||||||
work correctly both with client-side routing and a non-root public URL.
|
|
||||||
Learn how to configure a non-root public URL by running `npm run build`.
|
|
||||||
-->
|
|
||||||
<title>Shlink — The URL shortener</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<noscript>
|
|
||||||
You need to enable JavaScript to run this app.
|
|
||||||
</noscript>
|
|
||||||
<div id="root"></div>
|
|
||||||
<!--
|
|
||||||
This HTML file is a template.
|
|
||||||
If you open it directly in the browser, you will see an empty page.
|
|
||||||
|
|
||||||
You can add webfonts, meta tags, or analytics to this file.
|
|
||||||
The build step will place the bundled scripts into the <body> tag.
|
|
||||||
|
|
||||||
To begin the development, run `npm start` or `yarn start`.
|
|
||||||
To create a production bundle, use `npm run build` or `yarn build`.
|
|
||||||
-->
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
{
|
|
||||||
"short_name": "Shlink",
|
|
||||||
"name": "Shlink",
|
|
||||||
"start_url": "/",
|
|
||||||
"display": "standalone",
|
|
||||||
"theme_color": "#4696e5",
|
|
||||||
"background_color": "#4696e5",
|
|
||||||
"icons": [
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-16x16.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "16x16"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-24x24.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "24x24"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-32x32.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "32x32"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-40x40.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "40x40"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-48x48.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "48x48"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-60x60.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "60x60"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-64x64.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "64x64"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-72x72.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "72x72"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-76x76.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "76x76"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-96x96.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "96x96"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-114x114.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "114x114"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-120x120.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "120x120"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-128x128.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "128x128"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-144x144.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "144x144"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-150x150.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "150x150"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-152x152.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "152x152"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-160x160.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "160x160"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-167x167.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "167x167"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-180x180.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "180x180"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-192x192.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "192x192"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-196x196.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "196x196"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-228x228.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "228x228"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-256x256.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "256x256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-310x310.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "310x310"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-384x384.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "384x384"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-512x512.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "512x512"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icons/icon-1024x1024.png",
|
|
||||||
"type": "image/png",
|
|
||||||
"sizes": "1024x1024"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
182
scripts/build.js
182
scripts/build.js
@@ -1,182 +0,0 @@
|
|||||||
/* eslint-disable no-console, @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/promise-function-async, @typescript-eslint/prefer-optional-chain */
|
|
||||||
|
|
||||||
// Do this as the first thing so that any code reading it knows the right env.
|
|
||||||
process.env.BABEL_ENV = 'production';
|
|
||||||
process.env.NODE_ENV = 'production';
|
|
||||||
|
|
||||||
// Makes the script crash on unhandled rejections instead of silently
|
|
||||||
// ignoring them. In the future, promise rejections that are not handled will
|
|
||||||
// terminate the Node.js process with a non-zero exit code.
|
|
||||||
process.on('unhandledRejection', (err) => {
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Ensure environment variables are read.
|
|
||||||
require('../config/env');
|
|
||||||
|
|
||||||
const chalk = require('chalk');
|
|
||||||
const fs = require('fs-extra');
|
|
||||||
const webpack = require('webpack');
|
|
||||||
const bfj = require('bfj');
|
|
||||||
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
||||||
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
||||||
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
||||||
const printBuildError = require('react-dev-utils/printBuildError');
|
|
||||||
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
|
||||||
const paths = require('../config/paths');
|
|
||||||
const configFactory = require('../config/webpack.config');
|
|
||||||
|
|
||||||
const { measureFileSizesBeforeBuild, printFileSizesAfterBuild } = FileSizeReporter;
|
|
||||||
|
|
||||||
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
||||||
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024; // eslint-disable-line
|
|
||||||
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024; // eslint-disable-line
|
|
||||||
|
|
||||||
const isInteractive = process.stdout.isTTY;
|
|
||||||
|
|
||||||
// Warn and crash if required files are missing
|
|
||||||
if (!checkRequiredFiles([ paths.appHtml, paths.appIndexJs ])) {
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process CLI arguments
|
|
||||||
const argvSliceStart = 2;
|
|
||||||
const argv = process.argv.slice(argvSliceStart);
|
|
||||||
const writeStatsJson = argv.includes('--stats');
|
|
||||||
|
|
||||||
// Generate configuration
|
|
||||||
const config = configFactory('production');
|
|
||||||
|
|
||||||
checkBrowsers(paths.appPath, isInteractive)
|
|
||||||
.then(() =>
|
|
||||||
|
|
||||||
// First, read the current file sizes in build directory.
|
|
||||||
// This lets us display how much they changed later.
|
|
||||||
measureFileSizesBeforeBuild(paths.appBuild))
|
|
||||||
.then((previousFileSizes) => {
|
|
||||||
// Remove all content but keep the directory so that
|
|
||||||
// if you're in it, you don't end up in Trash
|
|
||||||
fs.emptyDirSync(paths.appBuild);
|
|
||||||
|
|
||||||
// Merge with the public folder
|
|
||||||
copyPublicFolder();
|
|
||||||
|
|
||||||
// Start the webpack build
|
|
||||||
return build(previousFileSizes);
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
({ stats, previousFileSizes, warnings }) => {
|
|
||||||
if (warnings.length) {
|
|
||||||
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
||||||
console.log(warnings.join('\n\n'));
|
|
||||||
console.log(
|
|
||||||
`\nSearch for the ${
|
|
||||||
chalk.underline(chalk.yellow('keywords'))
|
|
||||||
} to learn more about each warning.`,
|
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
`To ignore, add ${
|
|
||||||
chalk.cyan('// eslint-disable-next-line')
|
|
||||||
} to the line before.\n`,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
console.log(chalk.green('Compiled successfully.\n'));
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('File sizes after gzip:\n');
|
|
||||||
printFileSizesAfterBuild(
|
|
||||||
stats,
|
|
||||||
previousFileSizes,
|
|
||||||
paths.appBuild,
|
|
||||||
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
|
||||||
WARN_AFTER_CHUNK_GZIP_SIZE,
|
|
||||||
);
|
|
||||||
console.log();
|
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
console.log(chalk.red('Failed to compile.\n'));
|
|
||||||
printBuildError(err);
|
|
||||||
process.exit(1);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.catch((err) => {
|
|
||||||
if (err && err.message) {
|
|
||||||
console.log(err.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create the production build and print the deployment instructions.
|
|
||||||
function build(previousFileSizes) {
|
|
||||||
console.log('Creating an optimized production build...');
|
|
||||||
|
|
||||||
const compiler = webpack(config);
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
compiler.run((err, stats) => {
|
|
||||||
let messages;
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
if (!err.message) {
|
|
||||||
return reject(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
messages = formatWebpackMessages({
|
|
||||||
errors: [ err.message ],
|
|
||||||
warnings: [],
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
messages = formatWebpackMessages(
|
|
||||||
stats.toJson({ all: false, warnings: true, errors: true }),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (messages.errors.length) {
|
|
||||||
// Only keep the first error. Others are often indicative
|
|
||||||
// of the same problem, but confuse the reader with noise.
|
|
||||||
if (messages.errors.length > 1) {
|
|
||||||
messages.errors.length = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return reject(new Error(messages.errors.join('\n\n')));
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
process.env.CI &&
|
|
||||||
(typeof process.env.CI !== 'string' ||
|
|
||||||
process.env.CI.toLowerCase() !== 'false') &&
|
|
||||||
messages.warnings.length
|
|
||||||
) {
|
|
||||||
console.log(
|
|
||||||
chalk.yellow(
|
|
||||||
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
|
||||||
'Most CI servers set it automatically.\n',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return reject(new Error(messages.warnings.join('\n\n')));
|
|
||||||
}
|
|
||||||
|
|
||||||
const resolveArgs = {
|
|
||||||
stats,
|
|
||||||
previousFileSizes,
|
|
||||||
warnings: messages.warnings,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (writeStatsJson) {
|
|
||||||
return bfj // eslint-disable-line promise/no-promise-in-callback
|
|
||||||
.write(`${paths.appBuild}/bundle-stats.json`, stats.toJson())
|
|
||||||
.then(() => resolve(resolveArgs))
|
|
||||||
.catch((error) => reject(new Error(error)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolve(resolveArgs);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyPublicFolder() {
|
|
||||||
fs.copySync(paths.appPublic, paths.appBuild, {
|
|
||||||
dereference: true,
|
|
||||||
filter: (file) => file !== paths.appHtml,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
/* eslint-disable no-console, @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/promise-function-async, @typescript-eslint/prefer-optional-chain */
|
|
||||||
|
|
||||||
// Do this as the first thing so that any code reading it knows the right env.
|
// Do this as the first thing so that any code reading it knows the right env.
|
||||||
process.env.BABEL_ENV = 'production';
|
process.env.BABEL_ENV = 'production';
|
||||||
process.env.NODE_ENV = 'production';
|
process.env.NODE_ENV = 'production';
|
||||||
|
|
||||||
const chalk = require('chalk');
|
import chalk from 'chalk';
|
||||||
const AdmZip = require('adm-zip');
|
import AdmZip from 'adm-zip';
|
||||||
const fs = require('fs-extra');
|
import fs from 'fs';
|
||||||
|
|
||||||
function zipDist(version) {
|
function zipDist(version) {
|
||||||
const versionFileName = `./dist/shlink-web-client_${version}_dist.zip`;
|
const versionFileName = `./dist/shlink-web-client_${version}_dist.zip`;
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
PLATFORMS="linux/arm/v7,linux/arm64/v8,linux/amd64"
|
|
||||||
DOCKER_IMAGE="shlinkio/shlink-web-client"
|
|
||||||
|
|
||||||
if [[ "$GITHUB_REF" == *"develop"* ]]; then
|
|
||||||
docker buildx build --push \
|
|
||||||
--platform ${PLATFORMS} \
|
|
||||||
-t ${DOCKER_IMAGE}:latest .
|
|
||||||
|
|
||||||
# If ref is not develop, then this is a tag. Build that docker tag and also "stable"
|
|
||||||
else
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/v}
|
|
||||||
TAGS="-t ${DOCKER_IMAGE}:${VERSION}"
|
|
||||||
|
|
||||||
# Push stable tag only if this is not an alpha or beta release
|
|
||||||
[[ $GITHUB_REF != *"alpha"* && $GITHUB_REF != *"beta"* ]] && TAGS="${TAGS} -t ${DOCKER_IMAGE}:stable"
|
|
||||||
|
|
||||||
docker buildx build --push \
|
|
||||||
--build-arg VERSION=${VERSION} \
|
|
||||||
--platform ${PLATFORMS} \
|
|
||||||
${TAGS} .
|
|
||||||
fi
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
const fs = require('fs-extra');
|
import fs from 'fs';
|
||||||
|
|
||||||
function replaceVersionPlaceholder(version) {
|
function replaceVersionPlaceholder(version) {
|
||||||
const staticJsFilesPath = './build/static/js';
|
const staticJsFilesPath = './build/assets';
|
||||||
const versionPlaceholder = '%_VERSION_%';
|
const versionPlaceholder = '%_VERSION_%';
|
||||||
|
|
||||||
const isMainFile = (file) => file.startsWith('main.') && file.endsWith('.js');
|
const isMainFile = (file) => file.startsWith('index-') && file.endsWith('.js');
|
||||||
const [ mainJsFile ] = fs.readdirSync(staticJsFilesPath).filter(isMainFile);
|
const [mainJsFile] = fs.readdirSync(staticJsFilesPath).filter(isMainFile);
|
||||||
const filePath = `${staticJsFilesPath}/${mainJsFile}`;
|
const filePath = `${staticJsFilesPath}/${mainJsFile}`;
|
||||||
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
||||||
const replaced = fileContent.replace(versionPlaceholder, version);
|
const replaced = fileContent.replace(versionPlaceholder, version);
|
||||||
125
scripts/start.js
125
scripts/start.js
@@ -1,125 +0,0 @@
|
|||||||
/* eslint-disable no-console, @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/promise-function-async, @typescript-eslint/prefer-optional-chain */
|
|
||||||
|
|
||||||
// Do this as the first thing so that any code reading it knows the right env.
|
|
||||||
process.env.BABEL_ENV = 'development';
|
|
||||||
process.env.NODE_ENV = 'development';
|
|
||||||
|
|
||||||
// Makes the script crash on unhandled rejections instead of silently
|
|
||||||
// ignoring them. In the future, promise rejections that are not handled will
|
|
||||||
// terminate the Node.js process with a non-zero exit code.
|
|
||||||
process.on('unhandledRejection', (err) => {
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Ensure environment variables are read.
|
|
||||||
require('../config/env');
|
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const chalk = require('chalk');
|
|
||||||
const webpack = require('webpack');
|
|
||||||
const WebpackDevServer = require('webpack-dev-server');
|
|
||||||
const clearConsole = require('react-dev-utils/clearConsole');
|
|
||||||
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
||||||
const {
|
|
||||||
choosePort,
|
|
||||||
createCompiler,
|
|
||||||
prepareProxy,
|
|
||||||
prepareUrls,
|
|
||||||
} = require('react-dev-utils/WebpackDevServerUtils');
|
|
||||||
const openBrowser = require('react-dev-utils/openBrowser');
|
|
||||||
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
|
||||||
const paths = require('../config/paths');
|
|
||||||
const configFactory = require('../config/webpack.config');
|
|
||||||
const createDevServerConfig = require('../config/webpackDevServer.config');
|
|
||||||
|
|
||||||
const useYarn = fs.existsSync(paths.yarnLockFile);
|
|
||||||
const isInteractive = process.stdout.isTTY;
|
|
||||||
|
|
||||||
// Warn and crash if required files are missing
|
|
||||||
if (!checkRequiredFiles([ paths.appHtml, paths.appIndexJs ])) {
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tools like Cloud9 rely on this.
|
|
||||||
const DEFAULT_PORT = 3000;
|
|
||||||
const PORT = parseInt(process.env.PORT) || DEFAULT_PORT;
|
|
||||||
const HOST = process.env.HOST || '0.0.0.0';
|
|
||||||
|
|
||||||
if (process.env.HOST) {
|
|
||||||
console.log(
|
|
||||||
chalk.cyan(
|
|
||||||
`Attempting to bind to HOST environment variable: ${chalk.yellow(
|
|
||||||
chalk.bold(process.env.HOST),
|
|
||||||
)}`,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
'If this was unintentional, check that you haven\'t mistakenly set it in your shell.',
|
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
`Learn more here: ${chalk.yellow('http://bit.ly/CRA-advanced-config')}`,
|
|
||||||
);
|
|
||||||
console.log();
|
|
||||||
}
|
|
||||||
|
|
||||||
checkBrowsers(paths.appPath, isInteractive)
|
|
||||||
.then(() =>
|
|
||||||
|
|
||||||
// We attempt to use the default port but if it is busy, we offer the user to
|
|
||||||
// run on a different port. `choosePort()` Promise resolves to the next free port.
|
|
||||||
choosePort(HOST, PORT))
|
|
||||||
.then((port) => {
|
|
||||||
if (port === null) {
|
|
||||||
// We have not found a port.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const config = configFactory('development');
|
|
||||||
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
|
||||||
const appName = require(paths.appPackageJson).name;
|
|
||||||
|
|
||||||
const urls = prepareUrls(protocol, HOST, port);
|
|
||||||
|
|
||||||
// Create a webpack compiler that is configured with custom messages.
|
|
||||||
const compiler = createCompiler({ webpack, config, appName, urls, useYarn });
|
|
||||||
|
|
||||||
// Load proxy config
|
|
||||||
const proxySetting = require(paths.appPackageJson).proxy;
|
|
||||||
|
|
||||||
const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
|
|
||||||
|
|
||||||
// Serve webpack assets generated by the compiler over a web server.
|
|
||||||
const serverConfig = createDevServerConfig(
|
|
||||||
proxyConfig,
|
|
||||||
urls.lanUrlForConfig,
|
|
||||||
);
|
|
||||||
const devServer = new WebpackDevServer(compiler, serverConfig);
|
|
||||||
|
|
||||||
// Launch WebpackDevServer.
|
|
||||||
devServer.listen(port, HOST, (err) => {
|
|
||||||
if (err) {
|
|
||||||
return console.log(err);
|
|
||||||
}
|
|
||||||
if (isInteractive) {
|
|
||||||
clearConsole();
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(chalk.cyan('Starting the development server...\n'));
|
|
||||||
|
|
||||||
return openBrowser(urls.localUrlForBrowser);
|
|
||||||
});
|
|
||||||
|
|
||||||
[ 'SIGINT', 'SIGTERM' ].forEach((sig) => {
|
|
||||||
process.on(sig, () => {
|
|
||||||
devServer.close();
|
|
||||||
process.exit();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
if (err && err.message) {
|
|
||||||
console.log(err.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
|
|
||||||
// Do this as the first thing so that any code reading it knows the right env.
|
|
||||||
process.env.BABEL_ENV = 'test';
|
|
||||||
process.env.NODE_ENV = 'test';
|
|
||||||
process.env.PUBLIC_URL = '';
|
|
||||||
|
|
||||||
// Makes the script crash on unhandled rejections instead of silently
|
|
||||||
// ignoring them. In the future, promise rejections that are not handled will
|
|
||||||
// terminate the Node.js process with a non-zero exit code.
|
|
||||||
process.on('unhandledRejection', (err) => {
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Ensure environment variables are read.
|
|
||||||
require('../config/env');
|
|
||||||
|
|
||||||
// Make tests to be matched inside tests folder
|
|
||||||
const jest = require('jest');
|
|
||||||
|
|
||||||
const argumentsToRemove = 2;
|
|
||||||
const argv = process.argv.slice(argumentsToRemove);
|
|
||||||
|
|
||||||
jest.run(argv);
|
|
||||||
8
shlink-web-client.d.ts
vendored
8
shlink-web-client.d.ts
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
// eslint-disable-next-line max-classes-per-file
|
||||||
declare module 'event-source-polyfill' {
|
declare module 'event-source-polyfill' {
|
||||||
declare class EventSourcePolyfill {
|
declare class EventSourcePolyfill {
|
||||||
public onmessage?: ({ data }: { data: string }) => void;
|
public onmessage?: ({ data }: { data: string }) => void;
|
||||||
@@ -7,10 +8,9 @@ declare module 'event-source-polyfill' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'csvjson' {
|
declare module '@json2csv/plainjs' {
|
||||||
export declare class CsvJson {
|
export class Parser {
|
||||||
public toObject<T>(content: string): T[];
|
parse: <T>(data: T[]) => string;
|
||||||
public toCSV<T>(data: T[], options: { headers: 'full' | 'none' | 'relative' | 'key'; wrap?: true }): string;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ProblemDetailsError } from './types';
|
import type { ProblemDetailsError } from './types/errors';
|
||||||
import { isInvalidArgumentError } from './utils';
|
import { isInvalidArgumentError } from './utils';
|
||||||
|
|
||||||
export interface ShlinkApiErrorProps {
|
export interface ShlinkApiErrorProps {
|
||||||
@@ -9,8 +9,10 @@ export interface ShlinkApiErrorProps {
|
|||||||
export const ShlinkApiError = ({ errorData, fallbackMessage }: ShlinkApiErrorProps) => (
|
export const ShlinkApiError = ({ errorData, fallbackMessage }: ShlinkApiErrorProps) => (
|
||||||
<>
|
<>
|
||||||
{errorData?.detail ?? fallbackMessage}
|
{errorData?.detail ?? fallbackMessage}
|
||||||
{isInvalidArgumentError(errorData) &&
|
{isInvalidArgumentError(errorData) && (
|
||||||
<p className="mb-0">Invalid elements: [{errorData.invalidElements.join(', ')}]</p>
|
<p className="mb-0">
|
||||||
}
|
Invalid elements: [{errorData.invalidElements.join(', ')}]
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,137 +1,149 @@
|
|||||||
import { isEmpty, isNil, reject } from 'ramda';
|
import { isEmpty, isNil, reject } from 'ramda';
|
||||||
import { AxiosInstance, AxiosResponse, Method } from 'axios';
|
import type { HttpClient } from '../../common/services/HttpClient';
|
||||||
import { ShortUrl, ShortUrlData } from '../../short-urls/data';
|
import type { ShortUrl, ShortUrlData } from '../../short-urls/data';
|
||||||
import { OptionalString } from '../../utils/utils';
|
import { orderToString } from '../../utils/helpers/ordering';
|
||||||
import {
|
import { stringifyQuery } from '../../utils/helpers/query';
|
||||||
|
import type { OptionalString } from '../../utils/utils';
|
||||||
|
import type {
|
||||||
|
ShlinkDomainRedirects,
|
||||||
|
ShlinkDomainsResponse,
|
||||||
|
ShlinkEditDomainRedirects,
|
||||||
ShlinkHealth,
|
ShlinkHealth,
|
||||||
ShlinkMercureInfo,
|
ShlinkMercureInfo,
|
||||||
|
ShlinkShortUrlData,
|
||||||
|
ShlinkShortUrlsListNormalizedParams,
|
||||||
|
ShlinkShortUrlsListParams,
|
||||||
ShlinkShortUrlsResponse,
|
ShlinkShortUrlsResponse,
|
||||||
ShlinkTags,
|
ShlinkTags,
|
||||||
ShlinkTagsResponse,
|
ShlinkTagsResponse,
|
||||||
|
ShlinkTagsStatsResponse,
|
||||||
ShlinkVisits,
|
ShlinkVisits,
|
||||||
ShlinkVisitsParams,
|
|
||||||
ShlinkShortUrlData,
|
|
||||||
ShlinkDomainsResponse,
|
|
||||||
ShlinkVisitsOverview,
|
ShlinkVisitsOverview,
|
||||||
ShlinkEditDomainRedirects,
|
ShlinkVisitsParams,
|
||||||
ShlinkDomainRedirects,
|
|
||||||
ShlinkShortUrlsListParams,
|
|
||||||
ShlinkShortUrlsListNormalizedParams,
|
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { stringifyQuery } from '../../utils/helpers/query';
|
import { isRegularNotFound, parseApiError } from '../utils';
|
||||||
import { orderToString } from '../../utils/helpers/ordering';
|
|
||||||
|
|
||||||
const buildShlinkBaseUrl = (url: string) => url ? `${url}/rest/v2` : '';
|
const buildShlinkBaseUrl = (url: string, version: 2 | 3) => `${url}/rest/v${version}`;
|
||||||
const rejectNilProps = reject(isNil);
|
const rejectNilProps = reject(isNil);
|
||||||
const normalizeOrderByInParams = (params: ShlinkShortUrlsListParams): ShlinkShortUrlsListNormalizedParams => {
|
const normalizeListParams = (
|
||||||
const { orderBy = {}, ...rest } = params;
|
{ orderBy = {}, excludeMaxVisitsReached, excludePastValidUntil, ...rest }: ShlinkShortUrlsListParams,
|
||||||
|
): ShlinkShortUrlsListNormalizedParams => ({
|
||||||
|
...rest,
|
||||||
|
excludeMaxVisitsReached: excludeMaxVisitsReached === true ? 'true' : undefined,
|
||||||
|
excludePastValidUntil: excludePastValidUntil === true ? 'true' : undefined,
|
||||||
|
orderBy: orderToString(orderBy),
|
||||||
|
});
|
||||||
|
|
||||||
return { ...rest, orderBy: orderToString(orderBy) };
|
export class ShlinkApiClient {
|
||||||
};
|
private apiVersion: 2 | 3;
|
||||||
|
|
||||||
export default class ShlinkApiClient {
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private readonly axios: AxiosInstance,
|
private readonly httpClient: HttpClient,
|
||||||
private readonly baseUrl: string,
|
private readonly baseUrl: string,
|
||||||
private readonly apiKey: string,
|
private readonly apiKey: string,
|
||||||
) {
|
) {
|
||||||
|
this.apiVersion = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly listShortUrls = async (params: ShlinkShortUrlsListParams = {}): Promise<ShlinkShortUrlsResponse> =>
|
public readonly listShortUrls = async (params: ShlinkShortUrlsListParams = {}): Promise<ShlinkShortUrlsResponse> =>
|
||||||
this.performRequest<{ shortUrls: ShlinkShortUrlsResponse }>('/short-urls', 'GET', normalizeOrderByInParams(params))
|
this.performRequest<{ shortUrls: ShlinkShortUrlsResponse }>('/short-urls', 'GET', normalizeListParams(params))
|
||||||
.then(({ data }) => data.shortUrls);
|
.then(({ shortUrls }) => shortUrls);
|
||||||
|
|
||||||
public readonly createShortUrl = async (options: ShortUrlData): Promise<ShortUrl> => {
|
public readonly createShortUrl = async (options: ShortUrlData): Promise<ShortUrl> => {
|
||||||
const filteredOptions = reject((value) => isEmpty(value) || isNil(value), options as any);
|
const filteredOptions = reject((value) => isEmpty(value) || isNil(value), options as any);
|
||||||
|
return this.performRequest<ShortUrl>('/short-urls', 'POST', {}, filteredOptions);
|
||||||
return this.performRequest<ShortUrl>('/short-urls', 'POST', {}, filteredOptions)
|
|
||||||
.then((resp) => resp.data);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly getShortUrlVisits = async (shortCode: string, query?: ShlinkVisitsParams): Promise<ShlinkVisits> =>
|
public readonly getShortUrlVisits = async (shortCode: string, query?: ShlinkVisitsParams): Promise<ShlinkVisits> =>
|
||||||
this.performRequest<{ visits: ShlinkVisits }>(`/short-urls/${shortCode}/visits`, 'GET', query)
|
this.performRequest<{ visits: ShlinkVisits }>(`/short-urls/${shortCode}/visits`, 'GET', query)
|
||||||
.then(({ data }) => data.visits);
|
.then(({ visits }) => visits);
|
||||||
|
|
||||||
public readonly getTagVisits = async (tag: string, query?: Omit<ShlinkVisitsParams, 'domain'>): Promise<ShlinkVisits> =>
|
public readonly getTagVisits = async (tag: string, query?: Omit<ShlinkVisitsParams, 'domain'>): Promise<ShlinkVisits> =>
|
||||||
this.performRequest<{ visits: ShlinkVisits }>(`/tags/${tag}/visits`, 'GET', query)
|
this.performRequest<{ visits: ShlinkVisits }>(`/tags/${tag}/visits`, 'GET', query).then(({ visits }) => visits);
|
||||||
.then(({ data }) => data.visits);
|
|
||||||
|
public readonly getDomainVisits = async (domain: string, query?: Omit<ShlinkVisitsParams, 'domain'>): Promise<ShlinkVisits> =>
|
||||||
|
this.performRequest<{ visits: ShlinkVisits }>(`/domains/${domain}/visits`, 'GET', query).then(({ visits }) => visits);
|
||||||
|
|
||||||
public readonly getOrphanVisits = async (query?: Omit<ShlinkVisitsParams, 'domain'>): Promise<ShlinkVisits> =>
|
public readonly getOrphanVisits = async (query?: Omit<ShlinkVisitsParams, 'domain'>): Promise<ShlinkVisits> =>
|
||||||
this.performRequest<{ visits: ShlinkVisits }>('/visits/orphan', 'GET', query)
|
this.performRequest<{ visits: ShlinkVisits }>('/visits/orphan', 'GET', query).then(({ visits }) => visits);
|
||||||
.then(({ data }) => data.visits);
|
|
||||||
|
|
||||||
public readonly getNonOrphanVisits = async (query?: Omit<ShlinkVisitsParams, 'domain'>): Promise<ShlinkVisits> =>
|
public readonly getNonOrphanVisits = async (query?: Omit<ShlinkVisitsParams, 'domain'>): Promise<ShlinkVisits> =>
|
||||||
this.performRequest<{ visits: ShlinkVisits }>('/visits/non-orphan', 'GET', query)
|
this.performRequest<{ visits: ShlinkVisits }>('/visits/non-orphan', 'GET', query).then(({ visits }) => visits);
|
||||||
.then(({ data }) => data.visits);
|
|
||||||
|
|
||||||
public readonly getVisitsOverview = async (): Promise<ShlinkVisitsOverview> =>
|
public readonly getVisitsOverview = async (): Promise<ShlinkVisitsOverview> =>
|
||||||
this.performRequest<{ visits: ShlinkVisitsOverview }>('/visits', 'GET')
|
this.performRequest<{ visits: ShlinkVisitsOverview }>('/visits').then(({ visits }) => visits);
|
||||||
.then(({ data }) => data.visits);
|
|
||||||
|
|
||||||
public readonly getShortUrl = async (shortCode: string, domain?: OptionalString): Promise<ShortUrl> =>
|
public readonly getShortUrl = async (shortCode: string, domain?: OptionalString): Promise<ShortUrl> =>
|
||||||
this.performRequest<ShortUrl>(`/short-urls/${shortCode}`, 'GET', { domain })
|
this.performRequest<ShortUrl>(`/short-urls/${shortCode}`, 'GET', { domain });
|
||||||
.then(({ data }) => data);
|
|
||||||
|
|
||||||
public readonly deleteShortUrl = async (shortCode: string, domain?: OptionalString): Promise<void> =>
|
public readonly deleteShortUrl = async (shortCode: string, domain?: OptionalString): Promise<void> =>
|
||||||
this.performRequest(`/short-urls/${shortCode}`, 'DELETE', { domain })
|
this.performEmptyRequest(`/short-urls/${shortCode}`, 'DELETE', { domain });
|
||||||
.then(() => {});
|
|
||||||
|
|
||||||
// eslint-disable-next-line valid-jsdoc
|
|
||||||
/**
|
|
||||||
* @deprecated. If using Shlink 2.6.0 or greater, use updateShortUrl instead
|
|
||||||
*/
|
|
||||||
public readonly updateShortUrlTags = async (
|
|
||||||
shortCode: string,
|
|
||||||
domain: OptionalString,
|
|
||||||
tags: string[],
|
|
||||||
): Promise<string[]> =>
|
|
||||||
this.performRequest<{ tags: string[] }>(`/short-urls/${shortCode}/tags`, 'PUT', { domain }, { tags })
|
|
||||||
.then(({ data }) => data.tags);
|
|
||||||
|
|
||||||
public readonly updateShortUrl = async (
|
public readonly updateShortUrl = async (
|
||||||
shortCode: string,
|
shortCode: string,
|
||||||
domain: OptionalString,
|
domain: OptionalString,
|
||||||
data: ShlinkShortUrlData,
|
edit: ShlinkShortUrlData,
|
||||||
): Promise<ShortUrl> =>
|
): Promise<ShortUrl> =>
|
||||||
this.performRequest<ShortUrl>(`/short-urls/${shortCode}`, 'PATCH', { domain }, data)
|
this.performRequest<ShortUrl>(`/short-urls/${shortCode}`, 'PATCH', { domain }, edit);
|
||||||
.then(({ data }) => data);
|
|
||||||
|
|
||||||
public readonly listTags = async (): Promise<ShlinkTags> =>
|
public readonly listTags = async (): Promise<ShlinkTags> =>
|
||||||
this.performRequest<{ tags: ShlinkTagsResponse }>('/tags', 'GET', { withStats: 'true' })
|
this.performRequest<{ tags: ShlinkTagsResponse }>('/tags', 'GET', { withStats: 'true' })
|
||||||
.then((resp) => resp.data.tags)
|
.then(({ tags }) => tags)
|
||||||
.then(({ data, stats }) => ({ tags: data, stats }));
|
.then(({ data, stats }) => ({ tags: data, stats }));
|
||||||
|
|
||||||
|
public readonly tagsStats = async (): Promise<ShlinkTags> =>
|
||||||
|
this.performRequest<{ tags: ShlinkTagsStatsResponse }>('/tags/stats', 'GET')
|
||||||
|
.then(({ tags }) => tags)
|
||||||
|
.then(({ data }) => ({ tags: data.map(({ tag }) => tag), stats: data }));
|
||||||
|
|
||||||
public readonly deleteTags = async (tags: string[]): Promise<{ tags: string[] }> =>
|
public readonly deleteTags = async (tags: string[]): Promise<{ tags: string[] }> =>
|
||||||
this.performRequest('/tags', 'DELETE', { tags })
|
this.performEmptyRequest('/tags', 'DELETE', { tags }).then(() => ({ tags }));
|
||||||
.then(() => ({ tags }));
|
|
||||||
|
|
||||||
public readonly editTag = async (oldName: string, newName: string): Promise<{ oldName: string; newName: string }> =>
|
public readonly editTag = async (oldName: string, newName: string): Promise<{ oldName: string; newName: string }> =>
|
||||||
this.performRequest('/tags', 'PUT', {}, { oldName, newName })
|
this.performEmptyRequest('/tags', 'PUT', {}, { oldName, newName }).then(() => ({ oldName, newName }));
|
||||||
.then(() => ({ oldName, newName }));
|
|
||||||
|
|
||||||
public readonly health = async (): Promise<ShlinkHealth> =>
|
public readonly health = async (): Promise<ShlinkHealth> => this.performRequest<ShlinkHealth>('/health', 'GET');
|
||||||
this.performRequest<ShlinkHealth>('/health', 'GET')
|
|
||||||
.then((resp) => resp.data);
|
|
||||||
|
|
||||||
public readonly mercureInfo = async (): Promise<ShlinkMercureInfo> =>
|
public readonly mercureInfo = async (): Promise<ShlinkMercureInfo> =>
|
||||||
this.performRequest<ShlinkMercureInfo>('/mercure-info', 'GET')
|
this.performRequest<ShlinkMercureInfo>('/mercure-info', 'GET');
|
||||||
.then((resp) => resp.data);
|
|
||||||
|
|
||||||
public readonly listDomains = async (): Promise<ShlinkDomainsResponse> =>
|
public readonly listDomains = async (): Promise<ShlinkDomainsResponse> =>
|
||||||
this.performRequest<{ domains: ShlinkDomainsResponse }>('/domains', 'GET').then(({ data }) => data.domains);
|
this.performRequest<{ domains: ShlinkDomainsResponse }>('/domains').then(({ domains }) => domains);
|
||||||
|
|
||||||
public readonly editDomainRedirects = async (
|
public readonly editDomainRedirects = async (
|
||||||
domainRedirects: ShlinkEditDomainRedirects,
|
domainRedirects: ShlinkEditDomainRedirects,
|
||||||
): Promise<ShlinkDomainRedirects> =>
|
): Promise<ShlinkDomainRedirects> =>
|
||||||
this.performRequest<ShlinkDomainRedirects>('/domains/redirects', 'PATCH', {}, domainRedirects).then(({ data }) => data);
|
this.performRequest<ShlinkDomainRedirects>('/domains/redirects', 'PATCH', {}, domainRedirects);
|
||||||
|
|
||||||
private readonly performRequest = async <T>(url: string, method: Method = 'GET', query = {}, body = {}): Promise<AxiosResponse<T>> =>
|
private readonly performRequest = async <T>(url: string, method = 'GET', query = {}, body?: object): Promise<T> =>
|
||||||
this.axios({
|
this.httpClient.fetchJson<T>(...this.toFetchParams(url, method, query, body)).catch(
|
||||||
|
this.handleFetchError(() => this.httpClient.fetchJson<T>(...this.toFetchParams(url, method, query, body))),
|
||||||
|
);
|
||||||
|
|
||||||
|
private readonly performEmptyRequest = async (url: string, method = 'GET', query = {}, body?: object): Promise<void> =>
|
||||||
|
this.httpClient.fetchEmpty(...this.toFetchParams(url, method, query, body)).catch(
|
||||||
|
this.handleFetchError(() => this.httpClient.fetchEmpty(...this.toFetchParams(url, method, query, body))),
|
||||||
|
);
|
||||||
|
|
||||||
|
private readonly toFetchParams = (url: string, method: string, query = {}, body?: object): [string, RequestInit] => {
|
||||||
|
const normalizedQuery = stringifyQuery(rejectNilProps(query));
|
||||||
|
const stringifiedQuery = isEmpty(normalizedQuery) ? '' : `?${normalizedQuery}`;
|
||||||
|
|
||||||
|
return [`${buildShlinkBaseUrl(this.baseUrl, this.apiVersion)}${url}${stringifiedQuery}`, {
|
||||||
method,
|
method,
|
||||||
url: `${buildShlinkBaseUrl(this.baseUrl)}${url}`,
|
body: body && JSON.stringify(body),
|
||||||
headers: { 'X-Api-Key': this.apiKey },
|
headers: { 'X-Api-Key': this.apiKey },
|
||||||
params: rejectNilProps(query),
|
}];
|
||||||
data: body,
|
};
|
||||||
paramsSerializer: stringifyQuery,
|
|
||||||
});
|
private readonly handleFetchError = (retryFetch: Function) => (e: unknown) => {
|
||||||
|
if (!isRegularNotFound(parseApiError(e))) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we capture a not found error, let's assume this Shlink version does not support API v3, so we decrease to
|
||||||
|
// v2 and retry
|
||||||
|
this.apiVersion = 2;
|
||||||
|
return retryFetch();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,33 @@
|
|||||||
import { AxiosInstance } from 'axios';
|
import type { HttpClient } from '../../common/services/HttpClient';
|
||||||
import { prop } from 'ramda';
|
import type { GetState } from '../../container/types';
|
||||||
import { hasServerData, SelectedServer, ServerWithId } from '../../servers/data';
|
import type { ServerWithId } from '../../servers/data';
|
||||||
import { GetState } from '../../container/types';
|
import { hasServerData } from '../../servers/data';
|
||||||
import ShlinkApiClient from './ShlinkApiClient';
|
import { ShlinkApiClient } from './ShlinkApiClient';
|
||||||
|
|
||||||
const apiClients: Record<string, ShlinkApiClient> = {};
|
const apiClients: Record<string, ShlinkApiClient> = {};
|
||||||
|
|
||||||
const isGetState = (getStateOrSelectedServer: GetState | ServerWithId): getStateOrSelectedServer is GetState =>
|
const isGetState = (getStateOrSelectedServer: GetState | ServerWithId): getStateOrSelectedServer is GetState =>
|
||||||
typeof getStateOrSelectedServer === 'function';
|
typeof getStateOrSelectedServer === 'function';
|
||||||
const getSelectedServerFromState = (getState: GetState): SelectedServer => prop('selectedServer', getState());
|
const getSelectedServerFromState = (getState: GetState): ServerWithId => {
|
||||||
|
const { selectedServer } = getState();
|
||||||
export type ShlinkApiClientBuilder = (getStateOrSelectedServer: GetState | ServerWithId) => ShlinkApiClient;
|
if (!hasServerData(selectedServer)) {
|
||||||
|
|
||||||
const buildShlinkApiClient = (axios: AxiosInstance): ShlinkApiClientBuilder => (
|
|
||||||
getStateOrSelectedServer: GetState | ServerWithId,
|
|
||||||
) => {
|
|
||||||
const server = isGetState(getStateOrSelectedServer)
|
|
||||||
? getSelectedServerFromState(getStateOrSelectedServer)
|
|
||||||
: getStateOrSelectedServer;
|
|
||||||
|
|
||||||
if (!hasServerData(server)) {
|
|
||||||
throw new Error('There\'s no selected server or it is not found');
|
throw new Error('There\'s no selected server or it is not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { url, apiKey } = server;
|
return selectedServer;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const buildShlinkApiClient = (httpClient: HttpClient) => (getStateOrSelectedServer: GetState | ServerWithId) => {
|
||||||
|
const { url, apiKey } = isGetState(getStateOrSelectedServer)
|
||||||
|
? getSelectedServerFromState(getStateOrSelectedServer)
|
||||||
|
: getStateOrSelectedServer;
|
||||||
const clientKey = `${url}_${apiKey}`;
|
const clientKey = `${url}_${apiKey}`;
|
||||||
|
|
||||||
if (!apiClients[clientKey]) {
|
if (!apiClients[clientKey]) {
|
||||||
apiClients[clientKey] = new ShlinkApiClient(axios, url, apiKey);
|
apiClients[clientKey] = new ShlinkApiClient(httpClient, url, apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiClients[clientKey];
|
return apiClients[clientKey];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default buildShlinkApiClient;
|
export type ShlinkApiClientBuilder = ReturnType<typeof buildShlinkApiClient>;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import Bottle from 'bottlejs';
|
import type Bottle from 'bottlejs';
|
||||||
import buildShlinkApiClient from './ShlinkApiClientBuilder';
|
import { buildShlinkApiClient } from './ShlinkApiClientBuilder';
|
||||||
|
|
||||||
const provideServices = (bottle: Bottle) => {
|
export const provideServices = (bottle: Bottle) => {
|
||||||
bottle.serviceFactory('buildShlinkApiClient', buildShlinkApiClient, 'axios');
|
bottle.serviceFactory('buildShlinkApiClient', buildShlinkApiClient, 'HttpClient');
|
||||||
};
|
};
|
||||||
|
|
||||||
export default provideServices;
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
import { Action } from 'redux';
|
|
||||||
import { ProblemDetailsError } from './index';
|
|
||||||
|
|
||||||
export interface ApiErrorAction extends Action<string> {
|
|
||||||
errorData?: ProblemDetailsError;
|
|
||||||
}
|
|
||||||
54
src/api/types/errors.ts
Normal file
54
src/api/types/errors.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
export enum ErrorTypeV2 {
|
||||||
|
INVALID_ARGUMENT = 'INVALID_ARGUMENT',
|
||||||
|
INVALID_SHORT_URL_DELETION = 'INVALID_SHORT_URL_DELETION',
|
||||||
|
DOMAIN_NOT_FOUND = 'DOMAIN_NOT_FOUND',
|
||||||
|
FORBIDDEN_OPERATION = 'FORBIDDEN_OPERATION',
|
||||||
|
INVALID_URL = 'INVALID_URL',
|
||||||
|
INVALID_SLUG = 'INVALID_SLUG',
|
||||||
|
INVALID_SHORTCODE = 'INVALID_SHORTCODE',
|
||||||
|
TAG_CONFLICT = 'TAG_CONFLICT',
|
||||||
|
TAG_NOT_FOUND = 'TAG_NOT_FOUND',
|
||||||
|
MERCURE_NOT_CONFIGURED = 'MERCURE_NOT_CONFIGURED',
|
||||||
|
INVALID_AUTHORIZATION = 'INVALID_AUTHORIZATION',
|
||||||
|
INVALID_API_KEY = 'INVALID_API_KEY',
|
||||||
|
NOT_FOUND = 'NOT_FOUND',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ErrorTypeV3 {
|
||||||
|
INVALID_ARGUMENT = 'https://shlink.io/api/error/invalid-data',
|
||||||
|
INVALID_SHORT_URL_DELETION = 'https://shlink.io/api/error/invalid-short-url-deletion',
|
||||||
|
DOMAIN_NOT_FOUND = 'https://shlink.io/api/error/domain-not-found',
|
||||||
|
FORBIDDEN_OPERATION = 'https://shlink.io/api/error/forbidden-tag-operation',
|
||||||
|
INVALID_URL = 'https://shlink.io/api/error/invalid-url',
|
||||||
|
INVALID_SLUG = 'https://shlink.io/api/error/non-unique-slug',
|
||||||
|
INVALID_SHORTCODE = 'https://shlink.io/api/error/short-url-not-found',
|
||||||
|
TAG_CONFLICT = 'https://shlink.io/api/error/tag-conflict',
|
||||||
|
TAG_NOT_FOUND = 'https://shlink.io/api/error/tag-not-found',
|
||||||
|
MERCURE_NOT_CONFIGURED = 'https://shlink.io/api/error/mercure-not-configured',
|
||||||
|
INVALID_AUTHORIZATION = 'https://shlink.io/api/error/missing-authentication',
|
||||||
|
INVALID_API_KEY = 'https://shlink.io/api/error/invalid-api-key',
|
||||||
|
NOT_FOUND = 'https://shlink.io/api/error/not-found',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProblemDetailsError {
|
||||||
|
type: string;
|
||||||
|
detail: string;
|
||||||
|
title: string;
|
||||||
|
status: number;
|
||||||
|
[extraProps: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InvalidArgumentError extends ProblemDetailsError {
|
||||||
|
type: ErrorTypeV2.INVALID_ARGUMENT | ErrorTypeV3.INVALID_ARGUMENT;
|
||||||
|
invalidElements: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InvalidShortUrlDeletion extends ProblemDetailsError {
|
||||||
|
type: 'INVALID_SHORTCODE_DELETION' | ErrorTypeV2.INVALID_SHORT_URL_DELETION | ErrorTypeV3.INVALID_SHORT_URL_DELETION;
|
||||||
|
threshold: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegularNotFound extends ProblemDetailsError {
|
||||||
|
type: ErrorTypeV2.NOT_FOUND | ErrorTypeV3.NOT_FOUND;
|
||||||
|
status: 404;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Visit } from '../../visits/types';
|
import type { ShortUrl, ShortUrlMeta } from '../../short-urls/data';
|
||||||
import { OptionalString } from '../../utils/utils';
|
import type { Order } from '../../utils/helpers/ordering';
|
||||||
import { ShortUrl, ShortUrlMeta, ShortUrlsOrder } from '../../short-urls/data';
|
import type { OptionalString } from '../../utils/utils';
|
||||||
|
import type { Visit } from '../../visits/types';
|
||||||
|
|
||||||
export interface ShlinkShortUrlsResponse {
|
export interface ShlinkShortUrlsResponse {
|
||||||
data: ShortUrl[];
|
data: ShortUrl[];
|
||||||
@@ -17,9 +18,12 @@ export interface ShlinkHealth {
|
|||||||
version: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ShlinkTagsStats {
|
export interface ShlinkTagsStats {
|
||||||
tag: string;
|
tag: string;
|
||||||
shortUrlsCount: number;
|
shortUrlsCount: number;
|
||||||
|
visitsSummary?: ShlinkVisitsSummary; // Optional only before Shlink 3.5.0
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
visitsCount: number;
|
visitsCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,23 +34,39 @@ export interface ShlinkTags {
|
|||||||
|
|
||||||
export interface ShlinkTagsResponse {
|
export interface ShlinkTagsResponse {
|
||||||
data: string[];
|
data: string[];
|
||||||
|
/** @deprecated Present only when withStats=true is provided, which is deprecated */
|
||||||
stats: ShlinkTagsStats[];
|
stats: ShlinkTagsStats[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ShlinkTagsStatsResponse {
|
||||||
|
data: ShlinkTagsStats[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface ShlinkPaginator {
|
export interface ShlinkPaginator {
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
pagesCount: number;
|
pagesCount: number;
|
||||||
totalItems: number;
|
totalItems: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ShlinkVisitsSummary {
|
||||||
|
total: number;
|
||||||
|
nonBots: number;
|
||||||
|
bots: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ShlinkVisits {
|
export interface ShlinkVisits {
|
||||||
data: Visit[];
|
data: Visit[];
|
||||||
pagination: ShlinkPaginator;
|
pagination: ShlinkPaginator;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShlinkVisitsOverview {
|
export interface ShlinkVisitsOverview {
|
||||||
|
nonOrphanVisits?: ShlinkVisitsSummary; // Optional only before Shlink 3.5.0
|
||||||
|
orphanVisits?: ShlinkVisitsSummary; // Optional only before Shlink 3.5.0
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
visitsCount: number;
|
visitsCount: number;
|
||||||
orphanVisitsCount?: number; // Optional only for versions older than 2.6.0
|
/** @deprecated */
|
||||||
|
orphanVisitsCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShlinkVisitsParams {
|
export interface ShlinkVisitsParams {
|
||||||
@@ -88,35 +108,26 @@ export interface ShlinkDomainsResponse {
|
|||||||
|
|
||||||
export type TagsFilteringMode = 'all' | 'any';
|
export type TagsFilteringMode = 'all' | 'any';
|
||||||
|
|
||||||
|
type ShlinkShortUrlsOrderableFields = 'dateCreated' | 'shortCode' | 'longUrl' | 'title' | 'visits' | 'nonBotVisits';
|
||||||
|
|
||||||
|
export type ShlinkShortUrlsOrder = Order<ShlinkShortUrlsOrderableFields>;
|
||||||
|
|
||||||
export interface ShlinkShortUrlsListParams {
|
export interface ShlinkShortUrlsListParams {
|
||||||
page?: string;
|
page?: string;
|
||||||
itemsPerPage?: number;
|
itemsPerPage?: number;
|
||||||
tags?: string[];
|
|
||||||
searchTerm?: string;
|
searchTerm?: string;
|
||||||
|
tags?: string[];
|
||||||
|
tagsMode?: TagsFilteringMode;
|
||||||
|
orderBy?: ShlinkShortUrlsOrder;
|
||||||
startDate?: string;
|
startDate?: string;
|
||||||
endDate?: string;
|
endDate?: string;
|
||||||
orderBy?: ShortUrlsOrder;
|
excludeMaxVisitsReached?: boolean;
|
||||||
tagsMode?: TagsFilteringMode;
|
excludePastValidUntil?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShlinkShortUrlsListNormalizedParams extends Omit<ShlinkShortUrlsListParams, 'orderBy'> {
|
export interface ShlinkShortUrlsListNormalizedParams extends
|
||||||
|
Omit<ShlinkShortUrlsListParams, 'orderBy' | 'excludeMaxVisitsReached' | 'excludePastValidUntil'> {
|
||||||
orderBy?: string;
|
orderBy?: string;
|
||||||
}
|
excludeMaxVisitsReached?: 'true';
|
||||||
|
excludePastValidUntil?: 'true';
|
||||||
export interface ProblemDetailsError {
|
|
||||||
type: string;
|
|
||||||
detail: string;
|
|
||||||
title: string;
|
|
||||||
status: number;
|
|
||||||
[extraProps: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface InvalidArgumentError extends ProblemDetailsError {
|
|
||||||
type: 'INVALID_ARGUMENT';
|
|
||||||
invalidElements: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface InvalidShortUrlDeletion extends ProblemDetailsError {
|
|
||||||
type: 'INVALID_SHORTCODE_DELETION' | 'INVALID_SHORT_URL_DELETION';
|
|
||||||
threshold: number;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
import { AxiosError } from 'axios';
|
import type {
|
||||||
import { InvalidArgumentError, InvalidShortUrlDeletion, ProblemDetailsError } from '../types';
|
InvalidArgumentError,
|
||||||
|
InvalidShortUrlDeletion,
|
||||||
|
ProblemDetailsError,
|
||||||
|
RegularNotFound } from '../types/errors';
|
||||||
|
import {
|
||||||
|
ErrorTypeV2,
|
||||||
|
ErrorTypeV3,
|
||||||
|
} from '../types/errors';
|
||||||
|
|
||||||
export const parseApiError = (e: AxiosError<ProblemDetailsError>) => e.response?.data;
|
const isProblemDetails = (e: unknown): e is ProblemDetailsError =>
|
||||||
|
!!e && typeof e === 'object' && ['type', 'detail', 'title', 'status'].every((prop) => prop in e);
|
||||||
|
|
||||||
|
export const parseApiError = (e: unknown): ProblemDetailsError | undefined => (isProblemDetails(e) ? e : undefined);
|
||||||
|
|
||||||
export const isInvalidArgumentError = (error?: ProblemDetailsError): error is InvalidArgumentError =>
|
export const isInvalidArgumentError = (error?: ProblemDetailsError): error is InvalidArgumentError =>
|
||||||
error?.type === 'INVALID_ARGUMENT';
|
error?.type === ErrorTypeV2.INVALID_ARGUMENT || error?.type === ErrorTypeV3.INVALID_ARGUMENT;
|
||||||
|
|
||||||
export const isInvalidDeletionError = (error?: ProblemDetailsError): error is InvalidShortUrlDeletion =>
|
export const isInvalidDeletionError = (error?: ProblemDetailsError): error is InvalidShortUrlDeletion =>
|
||||||
error?.type === 'INVALID_SHORTCODE_DELETION' || error?.type === 'INVALID_SHORT_URL_DELETION';
|
error?.type === 'INVALID_SHORTCODE_DELETION'
|
||||||
|
|| error?.type === ErrorTypeV2.INVALID_SHORT_URL_DELETION
|
||||||
|
|| error?.type === ErrorTypeV3.INVALID_SHORT_URL_DELETION;
|
||||||
|
|
||||||
|
export const isRegularNotFound = (error?: ProblemDetailsError): error is RegularNotFound =>
|
||||||
|
(error?.type === ErrorTypeV2.NOT_FOUND || error?.type === ErrorTypeV3.NOT_FOUND) && error?.status === 404;
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { useEffect, FC } from 'react';
|
|
||||||
import { Route, Routes, useLocation } from 'react-router-dom';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import NotFound from '../common/NotFound';
|
import type { FC } from 'react';
|
||||||
import { ServersMap } from '../servers/data';
|
import { useEffect } from 'react';
|
||||||
import { Settings } from '../settings/reducers/settings';
|
import { Route, Routes, useLocation } from 'react-router-dom';
|
||||||
import { changeThemeInMarkup } from '../utils/theme';
|
|
||||||
import { AppUpdateBanner } from '../common/AppUpdateBanner';
|
import { AppUpdateBanner } from '../common/AppUpdateBanner';
|
||||||
|
import { NotFound } from '../common/NotFound';
|
||||||
|
import type { ServersMap } from '../servers/data';
|
||||||
|
import type { Settings } from '../settings/reducers/settings';
|
||||||
import { forceUpdate } from '../utils/helpers/sw';
|
import { forceUpdate } from '../utils/helpers/sw';
|
||||||
|
import { changeThemeInMarkup } from '../utils/theme';
|
||||||
import './App.scss';
|
import './App.scss';
|
||||||
|
|
||||||
interface AppProps {
|
interface AppProps {
|
||||||
@@ -17,13 +18,13 @@ interface AppProps {
|
|||||||
appUpdated: boolean;
|
appUpdated: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const App = (
|
export const App = (
|
||||||
MainHeader: FC,
|
MainHeader: FC,
|
||||||
Home: FC,
|
Home: FC,
|
||||||
MenuLayout: FC,
|
MenuLayout: FC,
|
||||||
CreateServer: FC,
|
CreateServer: FC,
|
||||||
EditServer: FC,
|
EditServer: FC,
|
||||||
Settings: FC,
|
SettingsComp: FC,
|
||||||
ManageServers: FC,
|
ManageServers: FC,
|
||||||
ShlinkVersionsContainer: FC,
|
ShlinkVersionsContainer: FC,
|
||||||
) => ({ fetchServers, servers, settings, appUpdated, resetAppUpdate }: AppProps) => {
|
) => ({ fetchServers, servers, settings, appUpdated, resetAppUpdate }: AppProps) => {
|
||||||
@@ -47,7 +48,7 @@ const App = (
|
|||||||
<div className={classNames('shlink-wrapper', { 'd-flex d-md-block align-items-center': isHome })}>
|
<div className={classNames('shlink-wrapper', { 'd-flex d-md-block align-items-center': isHome })}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route index element={<Home />} />
|
<Route index element={<Home />} />
|
||||||
<Route path="/settings/*" element={<Settings />} />
|
<Route path="/settings/*" element={<SettingsComp />} />
|
||||||
<Route path="/manage-servers" element={<ManageServers />} />
|
<Route path="/manage-servers" element={<ManageServers />} />
|
||||||
<Route path="/server/create" element={<CreateServer />} />
|
<Route path="/server/create" element={<CreateServer />} />
|
||||||
<Route path="/server/:serverId/edit" element={<EditServer />} />
|
<Route path="/server/:serverId/edit" element={<EditServer />} />
|
||||||
@@ -65,5 +66,3 @@ const App = (
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default App;
|
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
import { Action } from 'redux';
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
import { buildActionCreator, buildReducer } from '../../utils/helpers/redux';
|
|
||||||
|
|
||||||
/* eslint-disable padding-line-between-statements */
|
const { actions, reducer } = createSlice({
|
||||||
export const APP_UPDATE_AVAILABLE = 'shlink/appUpdates/APP_UPDATE_AVAILABLE';
|
name: 'shlink/appUpdates',
|
||||||
export const RESET_APP_UPDATE = 'shlink/appUpdates/RESET_APP_UPDATE';
|
initialState: false,
|
||||||
/* eslint-enable padding-line-between-statements */
|
reducers: {
|
||||||
|
appUpdateAvailable: () => true,
|
||||||
|
resetAppUpdate: () => false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const initialState = false;
|
export const { appUpdateAvailable, resetAppUpdate } = actions;
|
||||||
|
|
||||||
export default buildReducer<boolean, Action<string>>({
|
export const appUpdatesReducer = reducer;
|
||||||
[APP_UPDATE_AVAILABLE]: () => true,
|
|
||||||
[RESET_APP_UPDATE]: () => false,
|
|
||||||
}, initialState);
|
|
||||||
|
|
||||||
export const appUpdateAvailable = buildActionCreator(APP_UPDATE_AVAILABLE);
|
|
||||||
|
|
||||||
export const resetAppUpdate = buildActionCreator(RESET_APP_UPDATE);
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import Bottle from 'bottlejs';
|
import type Bottle from 'bottlejs';
|
||||||
|
import type { ConnectDecorator } from '../../container/types';
|
||||||
|
import { App } from '../App';
|
||||||
import { appUpdateAvailable, resetAppUpdate } from '../reducers/appUpdates';
|
import { appUpdateAvailable, resetAppUpdate } from '../reducers/appUpdates';
|
||||||
import App from '../App';
|
|
||||||
import { ConnectDecorator } from '../../container/types';
|
|
||||||
|
|
||||||
const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
||||||
// Components
|
// Components
|
||||||
bottle.serviceFactory(
|
bottle.serviceFactory(
|
||||||
'App',
|
'App',
|
||||||
@@ -17,11 +17,9 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
|||||||
'ManageServers',
|
'ManageServers',
|
||||||
'ShlinkVersionsContainer',
|
'ShlinkVersionsContainer',
|
||||||
);
|
);
|
||||||
bottle.decorator('App', connect([ 'servers', 'settings', 'appUpdated' ], [ 'fetchServers', 'resetAppUpdate' ]));
|
bottle.decorator('App', connect(['servers', 'settings', 'appUpdated'], ['fetchServers', 'resetAppUpdate']));
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
bottle.serviceFactory('appUpdateAvailable', () => appUpdateAvailable);
|
bottle.serviceFactory('appUpdateAvailable', () => appUpdateAvailable);
|
||||||
bottle.serviceFactory('resetAppUpdate', () => resetAppUpdate);
|
bottle.serviceFactory('resetAppUpdate', () => resetAppUpdate);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default provideServices;
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { FC, MouseEventHandler } from 'react';
|
|
||||||
import { Alert, Button } from 'reactstrap';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
||||||
import { faSyncAlt as reloadIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faSyncAlt as reloadIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { SimpleCard } from '../utils/SimpleCard';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import type { FC, MouseEventHandler } from 'react';
|
||||||
|
import { Alert, Button } from 'reactstrap';
|
||||||
import { useToggle } from '../utils/helpers/hooks';
|
import { useToggle } from '../utils/helpers/hooks';
|
||||||
|
import { SimpleCard } from '../utils/SimpleCard';
|
||||||
import './AppUpdateBanner.scss';
|
import './AppUpdateBanner.scss';
|
||||||
|
|
||||||
interface AppUpdateBannerProps {
|
interface AppUpdateBannerProps {
|
||||||
@@ -13,7 +13,7 @@ interface AppUpdateBannerProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const AppUpdateBanner: FC<AppUpdateBannerProps> = ({ isOpen, toggle, forceUpdate }) => {
|
export const AppUpdateBanner: FC<AppUpdateBannerProps> = ({ isOpen, toggle, forceUpdate }) => {
|
||||||
const [ isUpdating,, setUpdating ] = useToggle();
|
const [isUpdating,, setUpdating] = useToggle();
|
||||||
const update = () => {
|
const update = () => {
|
||||||
setUpdating();
|
setUpdating();
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
@@ -24,7 +24,7 @@ export const AppUpdateBanner: FC<AppUpdateBannerProps> = ({ isOpen, toggle, forc
|
|||||||
<h4 className="mb-4">This app has just been updated!</h4>
|
<h4 className="mb-4">This app has just been updated!</h4>
|
||||||
<p className="mb-0">
|
<p className="mb-0">
|
||||||
Restart it to enjoy the new features.
|
Restart it to enjoy the new features.
|
||||||
<Button disabled={isUpdating} className="ms-2" color="secondary" size="sm" onClick={update}>
|
<Button role="button" disabled={isUpdating} className="ms-2" color="secondary" size="sm" onClick={update}>
|
||||||
{!isUpdating && <>Restart now <FontAwesomeIcon icon={reloadIcon} className="ms-1" /></>}
|
{!isUpdating && <>Restart now <FontAwesomeIcon icon={reloadIcon} className="ms-1" /></>}
|
||||||
{isUpdating && <>Restarting...</>}
|
{isUpdating && <>Restarting...</>}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
.aside-menu {
|
.aside-menu {
|
||||||
width: $asideMenuWidth;
|
width: $asideMenuWidth;
|
||||||
background-color: var(--primary-color);
|
background-color: var(--primary-color);
|
||||||
box-shadow: rgba(0, 0, 0, .05) 0 8px 15px;
|
box-shadow: rgb(0 0 0 / .05) 0 8px 15px;
|
||||||
position: fixed !important;
|
position: fixed !important;
|
||||||
padding-top: 13px;
|
padding-top: 13px;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
@media (max-width: $smMax) {
|
@media (max-width: $smMax) {
|
||||||
transition: left 300ms;
|
transition: left 300ms;
|
||||||
top: $headerHeight - 3px;
|
top: $headerHeight - 3px;
|
||||||
box-shadow: -10px 0 50px 11px rgba(0, 0, 0, .55);
|
box-shadow: -10px 0 50px 11px rgb(0 0 0 / .55);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,29 @@
|
|||||||
import {
|
import {
|
||||||
faList as listIcon,
|
|
||||||
faLink as createIcon,
|
|
||||||
faTags as tagsIcon,
|
|
||||||
faPen as editIcon,
|
|
||||||
faHome as overviewIcon,
|
|
||||||
faGlobe as domainsIcon,
|
faGlobe as domainsIcon,
|
||||||
|
faHome as overviewIcon,
|
||||||
|
faLink as createIcon,
|
||||||
|
faList as listIcon,
|
||||||
|
faPen as editIcon,
|
||||||
|
faTags as tagsIcon,
|
||||||
} from '@fortawesome/free-solid-svg-icons';
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { FC } from 'react';
|
|
||||||
import { NavLink, NavLinkProps, useLocation } from 'react-router-dom';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { DeleteServerButtonProps } from '../servers/DeleteServerButton';
|
import type { FC } from 'react';
|
||||||
import { isServerWithId, SelectedServer } from '../servers/data';
|
import type { NavLinkProps } from 'react-router-dom';
|
||||||
import { supportsDomainRedirects } from '../utils/helpers/features';
|
import { NavLink, useLocation } from 'react-router-dom';
|
||||||
|
import type { SelectedServer } from '../servers/data';
|
||||||
|
import { isServerWithId } from '../servers/data';
|
||||||
|
import type { DeleteServerButtonProps } from '../servers/DeleteServerButton';
|
||||||
import './AsideMenu.scss';
|
import './AsideMenu.scss';
|
||||||
|
|
||||||
export interface AsideMenuProps {
|
export interface AsideMenuProps {
|
||||||
selectedServer: SelectedServer;
|
selectedServer: SelectedServer;
|
||||||
className?: string;
|
|
||||||
showOnMobile?: boolean;
|
showOnMobile?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AsideMenuItemProps extends NavLinkProps {
|
interface AsideMenuItemProps extends NavLinkProps {
|
||||||
to: string;
|
to: string;
|
||||||
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AsideMenuItem: FC<AsideMenuItemProps> = ({ children, to, className, ...rest }) => (
|
const AsideMenuItem: FC<AsideMenuItemProps> = ({ children, to, className, ...rest }) => (
|
||||||
@@ -35,13 +36,12 @@ const AsideMenuItem: FC<AsideMenuItemProps> = ({ children, to, className, ...res
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
);
|
);
|
||||||
|
|
||||||
const AsideMenu = (DeleteServerButton: FC<DeleteServerButtonProps>) => (
|
export const AsideMenu = (DeleteServerButton: FC<DeleteServerButtonProps>) => (
|
||||||
{ selectedServer, showOnMobile = false }: AsideMenuProps,
|
{ selectedServer, showOnMobile = false }: AsideMenuProps,
|
||||||
) => {
|
) => {
|
||||||
const hasId = isServerWithId(selectedServer);
|
const hasId = isServerWithId(selectedServer);
|
||||||
const serverId = hasId ? selectedServer.id : '';
|
const serverId = hasId ? selectedServer.id : '';
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
const addManageDomainsLink = supportsDomainRedirects(selectedServer);
|
|
||||||
const asideClass = classNames('aside-menu', {
|
const asideClass = classNames('aside-menu', {
|
||||||
'aside-menu--hidden': !showOnMobile,
|
'aside-menu--hidden': !showOnMobile,
|
||||||
});
|
});
|
||||||
@@ -69,12 +69,10 @@ const AsideMenu = (DeleteServerButton: FC<DeleteServerButtonProps>) => (
|
|||||||
<FontAwesomeIcon fixedWidth icon={tagsIcon} />
|
<FontAwesomeIcon fixedWidth icon={tagsIcon} />
|
||||||
<span className="aside-menu__item-text">Manage tags</span>
|
<span className="aside-menu__item-text">Manage tags</span>
|
||||||
</AsideMenuItem>
|
</AsideMenuItem>
|
||||||
{addManageDomainsLink && (
|
<AsideMenuItem to={buildPath('/manage-domains')}>
|
||||||
<AsideMenuItem to={buildPath('/manage-domains')}>
|
<FontAwesomeIcon fixedWidth icon={domainsIcon} />
|
||||||
<FontAwesomeIcon fixedWidth icon={domainsIcon} />
|
<span className="aside-menu__item-text">Manage domains</span>
|
||||||
<span className="aside-menu__item-text">Manage domains</span>
|
</AsideMenuItem>
|
||||||
</AsideMenuItem>
|
|
||||||
)}
|
|
||||||
<AsideMenuItem to={buildPath('/edit')} className="aside-menu__item--push">
|
<AsideMenuItem to={buildPath('/edit')} className="aside-menu__item--push">
|
||||||
<FontAwesomeIcon fixedWidth icon={editIcon} />
|
<FontAwesomeIcon fixedWidth icon={editIcon} />
|
||||||
<span className="aside-menu__item-text">Edit this server</span>
|
<span className="aside-menu__item-text">Edit this server</span>
|
||||||
@@ -90,5 +88,3 @@ const AsideMenu = (DeleteServerButton: FC<DeleteServerButtonProps>) => (
|
|||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AsideMenu;
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Component, ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
|
import { Component } from 'react';
|
||||||
import { Button } from 'reactstrap';
|
import { Button } from 'reactstrap';
|
||||||
import { SimpleCard } from '../utils/SimpleCard';
|
import { SimpleCard } from '../utils/SimpleCard';
|
||||||
|
|
||||||
@@ -6,10 +7,10 @@ interface ErrorHandlerState {
|
|||||||
hasError: boolean;
|
hasError: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ErrorHandler = (
|
export const ErrorHandler = (
|
||||||
{ location }: Window,
|
{ location }: Window,
|
||||||
{ error }: Console,
|
{ error }: Console,
|
||||||
) => class ErrorHandler extends Component<any, ErrorHandlerState> {
|
) => class extends Component<any, ErrorHandlerState> {
|
||||||
public constructor(props: object) {
|
public constructor(props: object) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { hasError: false };
|
this.state = { hasError: false };
|
||||||
@@ -26,7 +27,8 @@ const ErrorHandler = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
public render(): ReactNode {
|
public render(): ReactNode {
|
||||||
if (this.state.hasError) {
|
const { hasError } = this.state;
|
||||||
|
if (hasError) {
|
||||||
return (
|
return (
|
||||||
<div className="home">
|
<div className="home">
|
||||||
<SimpleCard className="p-4">
|
<SimpleCard className="p-4">
|
||||||
@@ -39,8 +41,7 @@ const ErrorHandler = (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.props.children;
|
const { children } = this.props;
|
||||||
|
return children;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ErrorHandler;
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { useEffect } from 'react';
|
import { faExternalLinkAlt, faPlus } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { isEmpty, values } from 'ramda';
|
import { isEmpty, values } from 'ramda';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
import { ExternalLink } from 'react-external-link';
|
||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
import { Card, Row } from 'reactstrap';
|
import { Card, Row } from 'reactstrap';
|
||||||
import { ExternalLink } from 'react-external-link';
|
import type { ServersMap } from '../servers/data';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { ServersListGroup } from '../servers/ServersListGroup';
|
||||||
import { faExternalLinkAlt, faPlus } from '@fortawesome/free-solid-svg-icons';
|
|
||||||
import ServersListGroup from '../servers/ServersListGroup';
|
|
||||||
import { ServersMap } from '../servers/data';
|
|
||||||
import { ShlinkLogo } from './img/ShlinkLogo';
|
import { ShlinkLogo } from './img/ShlinkLogo';
|
||||||
import './Home.scss';
|
import './Home.scss';
|
||||||
|
|
||||||
export interface HomeProps {
|
interface HomeProps {
|
||||||
servers: ServersMap;
|
servers: ServersMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Home = ({ servers }: HomeProps) => {
|
export const Home = ({ servers }: HomeProps) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const serversList = values(servers);
|
const serversList = values(servers);
|
||||||
const hasServers = !isEmpty(serversList);
|
const hasServers = !isEmpty(serversList);
|
||||||
@@ -22,7 +22,6 @@ const Home = ({ servers }: HomeProps) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Try to redirect to the first server marked as auto-connect
|
// Try to redirect to the first server marked as auto-connect
|
||||||
const autoConnectServer = serversList.find(({ autoConnect }) => autoConnect);
|
const autoConnectServer = serversList.find(({ autoConnect }) => autoConnect);
|
||||||
|
|
||||||
autoConnectServer && navigate(`/server/${autoConnectServer.id}`);
|
autoConnectServer && navigate(`/server/${autoConnectServer.id}`);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -66,5 +65,3 @@ const Home = ({ servers }: HomeProps) => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Home;
|
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
import { faChevronDown as arrowIcon, faCogs as cogsIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faChevronDown as arrowIcon, faCogs as cogsIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { FC, useEffect } from 'react';
|
import classNames from 'classnames';
|
||||||
|
import type { FC } from 'react';
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { Link, useLocation } from 'react-router-dom';
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
import { Collapse, Nav, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
|
import { Collapse, Nav, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
|
||||||
import classNames from 'classnames';
|
|
||||||
import { useToggle } from '../utils/helpers/hooks';
|
import { useToggle } from '../utils/helpers/hooks';
|
||||||
import { ShlinkLogo } from './img/ShlinkLogo';
|
import { ShlinkLogo } from './img/ShlinkLogo';
|
||||||
import './MainHeader.scss';
|
import './MainHeader.scss';
|
||||||
|
|
||||||
const MainHeader = (ServersDropdown: FC) => () => {
|
export const MainHeader = (ServersDropdown: FC) => () => {
|
||||||
const [ isOpen, toggleOpen, , close ] = useToggle();
|
const [isOpen, toggleOpen, , close] = useToggle();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { pathname } = location;
|
const { pathname } = location;
|
||||||
|
|
||||||
useEffect(close, [ location ]);
|
useEffect(close, [location]);
|
||||||
|
|
||||||
const settingsPath = '/settings';
|
const settingsPath = '/settings';
|
||||||
const toggleClass = classNames('main-header__toggle-icon', { 'main-header__toggle-icon--opened': isOpen });
|
const toggleClass = classNames('main-header__toggle-icon', { 'main-header__toggle-icon--opened': isOpen });
|
||||||
@@ -41,5 +42,3 @@ const MainHeader = (ServersDropdown: FC) => () => {
|
|||||||
</Navbar>
|
</Navbar>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MainHeader;
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
z-index: 1035;
|
z-index: 1035;
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: rgba(255, 255, 255, .5);
|
color: rgb(255 255 255 / .5);
|
||||||
|
|
||||||
@media (max-width: $smMax) {
|
@media (max-width: $smMax) {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import { FC, useEffect } from 'react';
|
|
||||||
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
|
|
||||||
import { faBars as burgerIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faBars as burgerIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { withSelectedServer } from '../servers/helpers/withSelectedServer';
|
import type { FC } from 'react';
|
||||||
import { useSwipeable, useToggle } from '../utils/helpers/hooks';
|
import { useEffect } from 'react';
|
||||||
import { supportsDomainRedirects, supportsNonOrphanVisits, supportsOrphanVisits } from '../utils/helpers/features';
|
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
|
||||||
import { isReachableServer } from '../servers/data';
|
import { isReachableServer } from '../servers/data';
|
||||||
import NotFound from './NotFound';
|
import { withSelectedServer } from '../servers/helpers/withSelectedServer';
|
||||||
import { AsideMenuProps } from './AsideMenu';
|
import { useFeature } from '../utils/helpers/features';
|
||||||
|
import { useSwipeable, useToggle } from '../utils/helpers/hooks';
|
||||||
|
import type { AsideMenuProps } from './AsideMenu';
|
||||||
|
import { NotFound } from './NotFound';
|
||||||
import './MenuLayout.scss';
|
import './MenuLayout.scss';
|
||||||
|
|
||||||
interface MenuLayoutProps {
|
interface MenuLayoutProps {
|
||||||
@@ -16,13 +17,14 @@ interface MenuLayoutProps {
|
|||||||
sidebarNotPresent: Function;
|
sidebarNotPresent: Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MenuLayout = (
|
export const MenuLayout = (
|
||||||
TagsList: FC,
|
TagsList: FC,
|
||||||
ShortUrlsList: FC,
|
ShortUrlsList: FC,
|
||||||
AsideMenu: FC<AsideMenuProps>,
|
AsideMenu: FC<AsideMenuProps>,
|
||||||
CreateShortUrl: FC,
|
CreateShortUrl: FC,
|
||||||
ShortUrlVisits: FC,
|
ShortUrlVisits: FC,
|
||||||
TagVisits: FC,
|
TagVisits: FC,
|
||||||
|
DomainVisits: FC,
|
||||||
OrphanVisits: FC,
|
OrphanVisits: FC,
|
||||||
NonOrphanVisits: FC,
|
NonOrphanVisits: FC,
|
||||||
ServerError: FC,
|
ServerError: FC,
|
||||||
@@ -31,13 +33,12 @@ const MenuLayout = (
|
|||||||
ManageDomains: FC,
|
ManageDomains: FC,
|
||||||
) => withSelectedServer<MenuLayoutProps>(({ selectedServer, sidebarNotPresent, sidebarPresent }) => {
|
) => withSelectedServer<MenuLayoutProps>(({ selectedServer, sidebarNotPresent, sidebarPresent }) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const [ sidebarVisible, toggleSidebar, showSidebar, hideSidebar ] = useToggle();
|
const [sidebarVisible, toggleSidebar, showSidebar, hideSidebar] = useToggle();
|
||||||
const showContent = isReachableServer(selectedServer);
|
const showContent = isReachableServer(selectedServer);
|
||||||
|
|
||||||
useEffect(() => hideSidebar(), [ location ]);
|
useEffect(() => hideSidebar(), [location]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
showContent && sidebarPresent();
|
showContent && sidebarPresent();
|
||||||
|
|
||||||
return () => sidebarNotPresent();
|
return () => sidebarNotPresent();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -45,9 +46,8 @@ const MenuLayout = (
|
|||||||
return <ServerError />;
|
return <ServerError />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const addOrphanVisitsRoute = supportsOrphanVisits(selectedServer);
|
const addNonOrphanVisitsRoute = useFeature('nonOrphanVisits', selectedServer);
|
||||||
const addNonOrphanVisitsRoute = supportsNonOrphanVisits(selectedServer);
|
const addDomainVisitsRoute = useFeature('domainVisits', selectedServer);
|
||||||
const addManageDomainsRoute = supportsDomainRedirects(selectedServer);
|
|
||||||
const burgerClasses = classNames('menu-layout__burger-icon', { 'menu-layout__burger-icon--active': sidebarVisible });
|
const burgerClasses = classNames('menu-layout__burger-icon', { 'menu-layout__burger-icon--active': sidebarVisible });
|
||||||
const swipeableProps = useSwipeable(showSidebar, hideSidebar);
|
const swipeableProps = useSwipeable(showSidebar, hideSidebar);
|
||||||
|
|
||||||
@@ -68,10 +68,11 @@ const MenuLayout = (
|
|||||||
<Route path="/short-code/:shortCode/visits/*" element={<ShortUrlVisits />} />
|
<Route path="/short-code/:shortCode/visits/*" element={<ShortUrlVisits />} />
|
||||||
<Route path="/short-code/:shortCode/edit" element={<EditShortUrl />} />
|
<Route path="/short-code/:shortCode/edit" element={<EditShortUrl />} />
|
||||||
<Route path="/tag/:tag/visits/*" element={<TagVisits />} />
|
<Route path="/tag/:tag/visits/*" element={<TagVisits />} />
|
||||||
{addOrphanVisitsRoute && <Route path="/orphan-visits/*" element={<OrphanVisits />} />}
|
{addDomainVisitsRoute && <Route path="/domain/:domain/visits/*" element={<DomainVisits />} />}
|
||||||
|
<Route path="/orphan-visits/*" element={<OrphanVisits />} />
|
||||||
{addNonOrphanVisitsRoute && <Route path="/non-orphan-visits/*" element={<NonOrphanVisits />} />}
|
{addNonOrphanVisitsRoute && <Route path="/non-orphan-visits/*" element={<NonOrphanVisits />} />}
|
||||||
<Route path="/manage-tags" element={<TagsList />} />
|
<Route path="/manage-tags" element={<TagsList />} />
|
||||||
{addManageDomainsRoute && <Route path="/manage-domains" element={<ManageDomains />} />}
|
<Route path="/manage-domains" element={<ManageDomains />} />
|
||||||
<Route
|
<Route
|
||||||
path="*"
|
path="*"
|
||||||
element={<NotFound to={`/server/${selectedServer.id}/list-short-urls/1`}>List short URLs</NotFound>}
|
element={<NotFound to={`/server/${selectedServer.id}/list-short-urls/1`}>List short URLs</NotFound>}
|
||||||
@@ -84,5 +85,3 @@ const MenuLayout = (
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}, ServerError);
|
}, ServerError);
|
||||||
|
|
||||||
export default MenuLayout;
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { FC } from 'react';
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
import './NoMenuLayout.scss';
|
import './NoMenuLayout.scss';
|
||||||
|
|
||||||
export const NoMenuLayout: FC = ({ children }) => <div className="no-menu-wrapper container-xl">{children}</div>;
|
export const NoMenuLayout: FC<PropsWithChildren<unknown>> = ({ children }) => (
|
||||||
|
<div className="no-menu-wrapper container-xl">{children}</div>
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { FC } from 'react';
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { SimpleCard } from '../utils/SimpleCard';
|
import { SimpleCard } from '../utils/SimpleCard';
|
||||||
|
|
||||||
interface NotFoundProps {
|
type NotFoundProps = PropsWithChildren<{ to?: string }>;
|
||||||
to?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NotFound: FC<NotFoundProps> = ({ to = '/', children = 'Home' }) => (
|
export const NotFound: FC<NotFoundProps> = ({ to = '/', children = 'Home' }) => (
|
||||||
<div className="home">
|
<div className="home">
|
||||||
<SimpleCard className="p-4">
|
<SimpleCard className="p-4">
|
||||||
<h2>Oops! We could not find requested route.</h2>
|
<h2>Oops! We could not find requested route.</h2>
|
||||||
@@ -19,5 +17,3 @@ const NotFound: FC<NotFoundProps> = ({ to = '/', children = 'Home' }) => (
|
|||||||
</SimpleCard>
|
</SimpleCard>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default NotFound;
|
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { FC, useEffect } from 'react';
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
const ScrollToTop = (): FC => ({ children }) => {
|
export const ScrollToTop: FC<PropsWithChildren<unknown>> = ({ children }) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
scrollTo(0, 0);
|
scrollTo(0, 0);
|
||||||
}, [ location ]);
|
}, [location]);
|
||||||
|
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ScrollToTop;
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { pipe } from 'ramda';
|
import { pipe } from 'ramda';
|
||||||
import { ExternalLink } from 'react-external-link';
|
import { ExternalLink } from 'react-external-link';
|
||||||
|
import type { SelectedServer } from '../servers/data';
|
||||||
|
import { isReachableServer } from '../servers/data';
|
||||||
import { versionToPrintable, versionToSemVer } from '../utils/helpers/version';
|
import { versionToPrintable, versionToSemVer } from '../utils/helpers/version';
|
||||||
import { isReachableServer, SelectedServer } from '../servers/data';
|
|
||||||
|
|
||||||
const SHLINK_WEB_CLIENT_VERSION = '%_VERSION_%';
|
const SHLINK_WEB_CLIENT_VERSION = '%_VERSION_%';
|
||||||
const normalizeVersion = pipe(versionToSemVer(), versionToPrintable);
|
const normalizeVersion = pipe(versionToSemVer(), versionToPrintable);
|
||||||
@@ -17,17 +18,15 @@ const VersionLink = ({ project, version }: { project: 'shlink' | 'shlink-web-cli
|
|||||||
</ExternalLink>
|
</ExternalLink>
|
||||||
);
|
);
|
||||||
|
|
||||||
const ShlinkVersions = ({ selectedServer, clientVersion = SHLINK_WEB_CLIENT_VERSION }: ShlinkVersionsProps) => {
|
export const ShlinkVersions = ({ selectedServer, clientVersion = SHLINK_WEB_CLIENT_VERSION }: ShlinkVersionsProps) => {
|
||||||
const normalizedClientVersion = normalizeVersion(clientVersion);
|
const normalizedClientVersion = normalizeVersion(clientVersion);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<small className="text-muted">
|
<small className="text-muted">
|
||||||
{isReachableServer(selectedServer) &&
|
{isReachableServer(selectedServer) && (
|
||||||
<>Server: <VersionLink project="shlink" version={selectedServer.printableVersion} /> - </>
|
<>Server: <VersionLink project="shlink" version={selectedServer.printableVersion} /> - </>
|
||||||
}
|
)}
|
||||||
Client: <VersionLink project="shlink-web-client" version={normalizedClientVersion} />
|
Client: <VersionLink project="shlink-web-client" version={normalizedClientVersion} />
|
||||||
</small>
|
</small>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ShlinkVersions;
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { SelectedServer } from '../servers/data';
|
import type { SelectedServer } from '../servers/data';
|
||||||
import ShlinkVersions from './ShlinkVersions';
|
import type { Sidebar } from './reducers/sidebar';
|
||||||
import { Sidebar } from './reducers/sidebar';
|
import { ShlinkVersions } from './ShlinkVersions';
|
||||||
import './ShlinkVersionsContainer.scss';
|
import './ShlinkVersionsContainer.scss';
|
||||||
|
|
||||||
export interface ShlinkVersionsContainerProps {
|
export interface ShlinkVersionsContainerProps {
|
||||||
@@ -9,7 +9,7 @@ export interface ShlinkVersionsContainerProps {
|
|||||||
sidebar: Sidebar;
|
sidebar: Sidebar;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ShlinkVersionsContainer = ({ selectedServer, sidebar }: ShlinkVersionsContainerProps) => {
|
export const ShlinkVersionsContainer = ({ selectedServer, sidebar }: ShlinkVersionsContainerProps) => {
|
||||||
const classes = classNames('text-center', {
|
const classes = classNames('text-center', {
|
||||||
'shlink-versions-container--with-sidebar': sidebar.sidebarPresent,
|
'shlink-versions-container--with-sidebar': sidebar.sidebarPresent,
|
||||||
});
|
});
|
||||||
@@ -20,5 +20,3 @@ const ShlinkVersionsContainer = ({ selectedServer, sidebar }: ShlinkVersionsCont
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ShlinkVersionsContainer;
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { FC } from 'react';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import type { FC } from 'react';
|
||||||
import { Pagination, PaginationItem, PaginationLink } from 'reactstrap';
|
import { Pagination, PaginationItem, PaginationLink } from 'reactstrap';
|
||||||
|
import type {
|
||||||
|
NumberOrEllipsis } from '../utils/helpers/pagination';
|
||||||
import {
|
import {
|
||||||
pageIsEllipsis,
|
|
||||||
keyForPage,
|
keyForPage,
|
||||||
NumberOrEllipsis,
|
pageIsEllipsis,
|
||||||
progressivePagination,
|
|
||||||
prettifyPageNumber,
|
prettifyPageNumber,
|
||||||
|
progressivePagination,
|
||||||
} from '../utils/helpers/pagination';
|
} from '../utils/helpers/pagination';
|
||||||
import './SimplePaginator.scss';
|
import './SimplePaginator.scss';
|
||||||
|
|
||||||
@@ -17,7 +18,9 @@ interface SimplePaginatorProps {
|
|||||||
centered?: boolean;
|
centered?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SimplePaginator: FC<SimplePaginatorProps> = ({ pagesCount, currentPage, setCurrentPage, centered = true }) => {
|
export const SimplePaginator: FC<SimplePaginatorProps> = (
|
||||||
|
{ pagesCount, currentPage, setCurrentPage, centered = true },
|
||||||
|
) => {
|
||||||
if (pagesCount < 2) {
|
if (pagesCount < 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -35,7 +38,9 @@ const SimplePaginator: FC<SimplePaginatorProps> = ({ pagesCount, currentPage, se
|
|||||||
disabled={pageIsEllipsis(pageNumber)}
|
disabled={pageIsEllipsis(pageNumber)}
|
||||||
active={currentPage === pageNumber}
|
active={currentPage === pageNumber}
|
||||||
>
|
>
|
||||||
<PaginationLink tag="span" onClick={onClick(pageNumber)}>{prettifyPageNumber(pageNumber)}</PaginationLink>
|
<PaginationLink role="link" tag="span" onClick={onClick(pageNumber)}>
|
||||||
|
{prettifyPageNumber(pageNumber)}
|
||||||
|
</PaginationLink>
|
||||||
</PaginationItem>
|
</PaginationItem>
|
||||||
))}
|
))}
|
||||||
<PaginationItem disabled={currentPage >= pagesCount}>
|
<PaginationItem disabled={currentPage >= pagesCount}>
|
||||||
@@ -44,5 +49,3 @@ const SimplePaginator: FC<SimplePaginatorProps> = ({ pagesCount, currentPage, se
|
|||||||
</Pagination>
|
</Pagination>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SimplePaginator;
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
.react-tags {
|
.react-tags {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 5px 0 0 6px;
|
padding: 5px 0 0 6px;
|
||||||
border-radius: .3rem;
|
border-radius: .5rem;
|
||||||
background-color: var(--input-color);
|
background-color: var(--primary-color);
|
||||||
border: 1px solid var(--input-border-color);
|
border: 1px solid var(--input-border-color);
|
||||||
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
||||||
|
|
||||||
@@ -16,6 +16,16 @@
|
|||||||
cursor: text;
|
cursor: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-group > .react-tags {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
width: 1%;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .react-tags {
|
||||||
|
background-color: var(--input-color);
|
||||||
|
}
|
||||||
|
|
||||||
.react-tags.is-focused {
|
.react-tags.is-focused {
|
||||||
box-shadow: 0 0 0 .2rem rgb(70 150 229 / 25%);
|
box-shadow: 0 0 0 .2rem rgb(70 150 229 / 25%);
|
||||||
}
|
}
|
||||||
@@ -76,7 +86,7 @@
|
|||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
line-height: inherit;
|
line-height: inherit;
|
||||||
color: var(--input-text-color);
|
color: var(--input-text-color);
|
||||||
background-color: var(--input-color);
|
background-color: inherit;
|
||||||
|
|
||||||
/* prevent autoresize overflowing the container */
|
/* prevent autoresize overflowing the container */
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
@@ -88,6 +98,10 @@
|
|||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.react-tags__search-input::placeholder {
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
|
||||||
.react-tags__search-input::-ms-clear {
|
.react-tags__search-input::-ms-clear {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -113,7 +127,7 @@
|
|||||||
background: var(--primary-color);
|
background: var(--primary-color);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: .25rem;
|
border-radius: .25rem;
|
||||||
box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
|
box-shadow: 0 2px 6px rgb(0 0 0 / .2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.react-tags__suggestions li {
|
.react-tags__suggestions li {
|
||||||
|
|||||||
@@ -1,27 +1,22 @@
|
|||||||
import { Action } from 'redux';
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
import { buildActionCreator, buildReducer } from '../../utils/helpers/redux';
|
|
||||||
|
|
||||||
/* eslint-disable padding-line-between-statements */
|
|
||||||
export const SIDEBAR_PRESENT = 'shlink/common/SIDEBAR_PRESENT';
|
|
||||||
export const SIDEBAR_NOT_PRESENT = 'shlink/common/SIDEBAR_NOT_PRESENT';
|
|
||||||
/* eslint-enable padding-line-between-statements */
|
|
||||||
|
|
||||||
export interface Sidebar {
|
export interface Sidebar {
|
||||||
sidebarPresent: boolean;
|
sidebarPresent: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type SidebarRenderedAction = Action<string>;
|
|
||||||
type SidebarNotRenderedAction = Action<string>;
|
|
||||||
|
|
||||||
const initialState: Sidebar = {
|
const initialState: Sidebar = {
|
||||||
sidebarPresent: false,
|
sidebarPresent: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default buildReducer<Sidebar, SidebarRenderedAction & SidebarNotRenderedAction>({
|
const { actions, reducer } = createSlice({
|
||||||
[SIDEBAR_PRESENT]: () => ({ sidebarPresent: true }),
|
name: 'shlink/sidebar',
|
||||||
[SIDEBAR_NOT_PRESENT]: () => ({ sidebarPresent: false }),
|
initialState,
|
||||||
}, initialState);
|
reducers: {
|
||||||
|
sidebarPresent: () => ({ sidebarPresent: true }),
|
||||||
|
sidebarNotPresent: () => ({ sidebarPresent: false }),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const sidebarPresent = buildActionCreator(SIDEBAR_PRESENT);
|
export const { sidebarPresent, sidebarNotPresent } = actions;
|
||||||
|
|
||||||
export const sidebarNotPresent = buildActionCreator(SIDEBAR_NOT_PRESENT);
|
export const sidebarReducer = reducer;
|
||||||
|
|||||||
42
src/common/services/HttpClient.ts
Normal file
42
src/common/services/HttpClient.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import type { Fetch } from '../../utils/types';
|
||||||
|
|
||||||
|
const applicationJsonHeader = { 'Content-Type': 'application/json' };
|
||||||
|
const withJsonContentType = (options?: RequestInit): RequestInit | undefined => {
|
||||||
|
if (!options?.body) {
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
return options ? {
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
...(options.headers ?? {}),
|
||||||
|
...applicationJsonHeader,
|
||||||
|
},
|
||||||
|
} : {
|
||||||
|
headers: applicationJsonHeader,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export class HttpClient {
|
||||||
|
constructor(private readonly fetch: Fetch) {}
|
||||||
|
|
||||||
|
public readonly fetchJson = <T>(url: string, options?: RequestInit): Promise<T> =>
|
||||||
|
this.fetch(url, withJsonContentType(options)).then(async (resp) => {
|
||||||
|
const json = await resp.json();
|
||||||
|
|
||||||
|
if (!resp.ok) {
|
||||||
|
throw json;
|
||||||
|
}
|
||||||
|
|
||||||
|
return json as T;
|
||||||
|
});
|
||||||
|
|
||||||
|
public readonly fetchEmpty = (url: string, options?: RequestInit): Promise<void> =>
|
||||||
|
this.fetch(url, withJsonContentType(options)).then(async (resp) => {
|
||||||
|
if (!resp.ok) {
|
||||||
|
throw await resp.json();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
public readonly fetchBlob = (url: string): Promise<Blob> => this.fetch(url).then((resp) => resp.blob());
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { AxiosInstance } from 'axios';
|
|
||||||
import { saveUrl } from '../../utils/helpers/files';
|
import { saveUrl } from '../../utils/helpers/files';
|
||||||
|
import type { HttpClient } from './HttpClient';
|
||||||
|
|
||||||
export class ImageDownloader {
|
export class ImageDownloader {
|
||||||
public constructor(private readonly axios: AxiosInstance, private readonly window: Window) {}
|
public constructor(private readonly httpClient: HttpClient, private readonly window: Window) {}
|
||||||
|
|
||||||
public async saveImage(imgUrl: string, filename: string): Promise<void> {
|
public async saveImage(imgUrl: string, filename: string): Promise<void> {
|
||||||
const { data } = await this.axios.get(imgUrl, { responseType: 'blob' });
|
const data = await this.httpClient.fetchBlob(imgUrl);
|
||||||
const url = URL.createObjectURL(data);
|
const url = URL.createObjectURL(data);
|
||||||
|
|
||||||
saveUrl(this.window, url, filename);
|
saveUrl(this.window, url, filename);
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import { CsvJson } from 'csvjson';
|
import type { ExportableShortUrl } from '../../short-urls/data';
|
||||||
import { NormalizedVisit } from '../../visits/types';
|
import type { JsonToCsv } from '../../utils/helpers/csvjson';
|
||||||
import { ExportableShortUrl } from '../../short-urls/data';
|
|
||||||
import { saveCsv } from '../../utils/helpers/files';
|
import { saveCsv } from '../../utils/helpers/files';
|
||||||
|
import type { NormalizedVisit } from '../../visits/types';
|
||||||
|
|
||||||
export class ReportExporter {
|
export class ReportExporter {
|
||||||
public constructor(
|
public constructor(private readonly window: Window, private readonly jsonToCsv: JsonToCsv) {}
|
||||||
private readonly window: Window,
|
|
||||||
private readonly csvjson: CsvJson,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
public readonly exportVisits = (filename: string, visits: NormalizedVisit[]) => {
|
public readonly exportVisits = (filename: string, visits: NormalizedVisit[]) => {
|
||||||
if (!visits.length) {
|
if (!visits.length) {
|
||||||
@@ -26,8 +23,7 @@ export class ReportExporter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private readonly exportCsv = (filename: string, rows: object[]) => {
|
private readonly exportCsv = (filename: string, rows: object[]) => {
|
||||||
const csv = this.csvjson.toCSV(rows, { headers: 'key', wrap: true });
|
const csv = this.jsonToCsv(rows);
|
||||||
|
|
||||||
saveCsv(this.window, csv, filename);
|
saveCsv(this.window, csv, filename);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,36 @@
|
|||||||
import axios from 'axios';
|
import type Bottle from 'bottlejs';
|
||||||
import Bottle from 'bottlejs';
|
import type { ConnectDecorator } from '../../container/types';
|
||||||
import ScrollToTop from '../ScrollToTop';
|
|
||||||
import MainHeader from '../MainHeader';
|
|
||||||
import Home from '../Home';
|
|
||||||
import MenuLayout from '../MenuLayout';
|
|
||||||
import AsideMenu from '../AsideMenu';
|
|
||||||
import ErrorHandler from '../ErrorHandler';
|
|
||||||
import ShlinkVersionsContainer from '../ShlinkVersionsContainer';
|
|
||||||
import { ConnectDecorator } from '../../container/types';
|
|
||||||
import { withoutSelectedServer } from '../../servers/helpers/withoutSelectedServer';
|
import { withoutSelectedServer } from '../../servers/helpers/withoutSelectedServer';
|
||||||
|
import { AsideMenu } from '../AsideMenu';
|
||||||
|
import { ErrorHandler } from '../ErrorHandler';
|
||||||
|
import { Home } from '../Home';
|
||||||
|
import { MainHeader } from '../MainHeader';
|
||||||
|
import { MenuLayout } from '../MenuLayout';
|
||||||
import { sidebarNotPresent, sidebarPresent } from '../reducers/sidebar';
|
import { sidebarNotPresent, sidebarPresent } from '../reducers/sidebar';
|
||||||
|
import { ScrollToTop } from '../ScrollToTop';
|
||||||
|
import { ShlinkVersionsContainer } from '../ShlinkVersionsContainer';
|
||||||
|
import { HttpClient } from './HttpClient';
|
||||||
import { ImageDownloader } from './ImageDownloader';
|
import { ImageDownloader } from './ImageDownloader';
|
||||||
import { ReportExporter } from './ReportExporter';
|
import { ReportExporter } from './ReportExporter';
|
||||||
|
|
||||||
const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
||||||
// Services
|
// Services
|
||||||
bottle.constant('window', (global as any).window);
|
bottle.constant('window', window);
|
||||||
bottle.constant('console', global.console);
|
bottle.constant('console', console);
|
||||||
bottle.constant('axios', axios);
|
bottle.constant('fetch', window.fetch.bind(window));
|
||||||
|
|
||||||
bottle.service('ImageDownloader', ImageDownloader, 'axios', 'window');
|
bottle.service('HttpClient', HttpClient, 'fetch');
|
||||||
bottle.service('ReportExporter', ReportExporter, 'window', 'csvjson');
|
bottle.service('ImageDownloader', ImageDownloader, 'HttpClient', 'window');
|
||||||
|
bottle.service('ReportExporter', ReportExporter, 'window', 'jsonToCsv');
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
bottle.serviceFactory('ScrollToTop', ScrollToTop);
|
bottle.serviceFactory('ScrollToTop', () => ScrollToTop);
|
||||||
|
|
||||||
bottle.serviceFactory('MainHeader', MainHeader, 'ServersDropdown');
|
bottle.serviceFactory('MainHeader', MainHeader, 'ServersDropdown');
|
||||||
|
|
||||||
bottle.serviceFactory('Home', () => Home);
|
bottle.serviceFactory('Home', () => Home);
|
||||||
bottle.decorator('Home', withoutSelectedServer);
|
bottle.decorator('Home', withoutSelectedServer);
|
||||||
bottle.decorator('Home', connect([ 'servers' ], [ 'resetSelectedServer' ]));
|
bottle.decorator('Home', connect(['servers'], ['resetSelectedServer']));
|
||||||
|
|
||||||
bottle.serviceFactory(
|
bottle.serviceFactory(
|
||||||
'MenuLayout',
|
'MenuLayout',
|
||||||
@@ -40,6 +41,7 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
|||||||
'CreateShortUrl',
|
'CreateShortUrl',
|
||||||
'ShortUrlVisits',
|
'ShortUrlVisits',
|
||||||
'TagVisits',
|
'TagVisits',
|
||||||
|
'DomainVisits',
|
||||||
'OrphanVisits',
|
'OrphanVisits',
|
||||||
'NonOrphanVisits',
|
'NonOrphanVisits',
|
||||||
'ServerError',
|
'ServerError',
|
||||||
@@ -47,12 +49,12 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
|||||||
'EditShortUrl',
|
'EditShortUrl',
|
||||||
'ManageDomains',
|
'ManageDomains',
|
||||||
);
|
);
|
||||||
bottle.decorator('MenuLayout', connect([ 'selectedServer' ], [ 'selectServer', 'sidebarPresent', 'sidebarNotPresent' ]));
|
bottle.decorator('MenuLayout', connect(['selectedServer'], ['selectServer', 'sidebarPresent', 'sidebarNotPresent']));
|
||||||
|
|
||||||
bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton');
|
bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton');
|
||||||
|
|
||||||
bottle.serviceFactory('ShlinkVersionsContainer', () => ShlinkVersionsContainer);
|
bottle.serviceFactory('ShlinkVersionsContainer', () => ShlinkVersionsContainer);
|
||||||
bottle.decorator('ShlinkVersionsContainer', connect([ 'selectedServer', 'sidebar' ]));
|
bottle.decorator('ShlinkVersionsContainer', connect(['selectedServer', 'sidebar']));
|
||||||
|
|
||||||
bottle.serviceFactory('ErrorHandler', ErrorHandler, 'window', 'console');
|
bottle.serviceFactory('ErrorHandler', ErrorHandler, 'window', 'console');
|
||||||
|
|
||||||
@@ -60,5 +62,3 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
|||||||
bottle.serviceFactory('sidebarPresent', () => sidebarPresent);
|
bottle.serviceFactory('sidebarPresent', () => sidebarPresent);
|
||||||
bottle.serviceFactory('sidebarNotPresent', () => sidebarNotPresent);
|
bottle.serviceFactory('sidebarNotPresent', () => sidebarNotPresent);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default provideServices;
|
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
import Bottle, { IContainer } from 'bottlejs';
|
import type { IContainer } from 'bottlejs';
|
||||||
import { connect as reduxConnect } from 'react-redux';
|
import Bottle from 'bottlejs';
|
||||||
import { pick } from 'ramda';
|
import { pick } from 'ramda';
|
||||||
import provideApiServices from '../api/services/provideServices';
|
import { connect as reduxConnect } from 'react-redux';
|
||||||
import provideCommonServices from '../common/services/provideServices';
|
import { provideServices as provideApiServices } from '../api/services/provideServices';
|
||||||
import provideShortUrlsServices from '../short-urls/services/provideServices';
|
import { provideServices as provideAppServices } from '../app/services/provideServices';
|
||||||
import provideServersServices from '../servers/services/provideServices';
|
import { provideServices as provideCommonServices } from '../common/services/provideServices';
|
||||||
import provideVisitsServices from '../visits/services/provideServices';
|
import { provideServices as provideDomainsServices } from '../domains/services/provideServices';
|
||||||
import provideTagsServices from '../tags/services/provideServices';
|
import { provideServices as provideMercureServices } from '../mercure/services/provideServices';
|
||||||
import provideUtilsServices from '../utils/services/provideServices';
|
import { provideServices as provideServersServices } from '../servers/services/provideServices';
|
||||||
import provideMercureServices from '../mercure/services/provideServices';
|
import { provideServices as provideSettingsServices } from '../settings/services/provideServices';
|
||||||
import provideSettingsServices from '../settings/services/provideServices';
|
import { provideServices as provideShortUrlsServices } from '../short-urls/services/provideServices';
|
||||||
import provideDomainsServices from '../domains/services/provideServices';
|
import { provideServices as provideTagsServices } from '../tags/services/provideServices';
|
||||||
import provideAppServices from '../app/services/provideServices';
|
import { provideServices as provideUtilsServices } from '../utils/services/provideServices';
|
||||||
import { ConnectDecorator } from './types';
|
import { provideServices as provideVisitsServices } from '../visits/services/provideServices';
|
||||||
|
import type { ConnectDecorator } from './types';
|
||||||
|
|
||||||
type LazyActionMap = Record<string, Function>;
|
type LazyActionMap = Record<string, Function>;
|
||||||
|
|
||||||
@@ -20,8 +21,8 @@ const bottle = new Bottle();
|
|||||||
|
|
||||||
export const { container } = bottle;
|
export const { container } = bottle;
|
||||||
|
|
||||||
const lazyService = <T extends Function, K>(container: IContainer, serviceName: string) =>
|
const lazyService = <T extends Function, K>(cont: IContainer, serviceName: string) =>
|
||||||
(...args: any[]) => (container[serviceName] as T)(...args) as K;
|
(...args: any[]) => (cont[serviceName] as T)(...args) as K;
|
||||||
const mapActionService = (map: LazyActionMap, actionName: string): LazyActionMap => ({
|
const mapActionService = (map: LazyActionMap, actionName: string): LazyActionMap => ({
|
||||||
...map,
|
...map,
|
||||||
// Wrap actual action service in a function so that it is lazily created the first time it is called
|
// Wrap actual action service in a function so that it is lazily created the first time it is called
|
||||||
|
|||||||
@@ -1,21 +1,26 @@
|
|||||||
import ReduxThunk from 'redux-thunk';
|
import { configureStore } from '@reduxjs/toolkit';
|
||||||
import { applyMiddleware, compose, createStore } from 'redux';
|
import type { IContainer } from 'bottlejs';
|
||||||
import { save, load, RLSOptions } from 'redux-localstorage-simple';
|
import type { RLSOptions } from 'redux-localstorage-simple';
|
||||||
import reducers from '../reducers';
|
import { load, save } from 'redux-localstorage-simple';
|
||||||
|
import { initReducers } from '../reducers';
|
||||||
import { migrateDeprecatedSettings } from '../settings/helpers';
|
import { migrateDeprecatedSettings } from '../settings/helpers';
|
||||||
import { ShlinkState } from './types';
|
import type { ShlinkState } from './types';
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV !== 'production';
|
|
||||||
const composeEnhancers: Function = !isProduction && (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
|
||||||
|
|
||||||
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
const localStorageConfig: RLSOptions = {
|
const localStorageConfig: RLSOptions = {
|
||||||
states: [ 'settings', 'servers' ],
|
states: ['settings', 'servers'],
|
||||||
namespace: 'shlink',
|
namespace: 'shlink',
|
||||||
namespaceSeparator: '.',
|
namespaceSeparator: '.',
|
||||||
debounce: 300,
|
debounce: 300,
|
||||||
};
|
};
|
||||||
const preloadedState = migrateDeprecatedSettings(load(localStorageConfig) as ShlinkState);
|
const preloadedState = migrateDeprecatedSettings(load(localStorageConfig) as ShlinkState);
|
||||||
|
|
||||||
export const store = createStore(reducers, preloadedState, composeEnhancers(
|
export const setUpStore = (container: IContainer) => configureStore({
|
||||||
applyMiddleware(save(localStorageConfig), ReduxThunk),
|
devTools: !isProduction,
|
||||||
));
|
reducer: initReducers(container),
|
||||||
|
preloadedState,
|
||||||
|
middleware: (defaultMiddlewaresIncludingReduxThunk) =>
|
||||||
|
defaultMiddlewaresIncludingReduxThunk({ immutableCheck: false, serializableCheck: false }) // State is too big for these
|
||||||
|
.prepend(container.selectServerListener.middleware)
|
||||||
|
.concat(save(localStorageConfig)),
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,30 +1,32 @@
|
|||||||
import { MercureInfo } from '../mercure/reducers/mercureInfo';
|
import type { Sidebar } from '../common/reducers/sidebar';
|
||||||
import { SelectedServer, ServersMap } from '../servers/data';
|
import type { DomainsList } from '../domains/reducers/domainsList';
|
||||||
import { Settings } from '../settings/reducers/settings';
|
import type { MercureInfo } from '../mercure/reducers/mercureInfo';
|
||||||
import { ShortUrlCreation } from '../short-urls/reducers/shortUrlCreation';
|
import type { SelectedServer, ServersMap } from '../servers/data';
|
||||||
import { ShortUrlDeletion } from '../short-urls/reducers/shortUrlDeletion';
|
import type { Settings } from '../settings/reducers/settings';
|
||||||
import { ShortUrlEdition } from '../short-urls/reducers/shortUrlEdition';
|
import type { ShortUrlCreation } from '../short-urls/reducers/shortUrlCreation';
|
||||||
import { ShortUrlsList } from '../short-urls/reducers/shortUrlsList';
|
import type { ShortUrlDeletion } from '../short-urls/reducers/shortUrlDeletion';
|
||||||
import { TagDeletion } from '../tags/reducers/tagDelete';
|
import type { ShortUrlDetail } from '../short-urls/reducers/shortUrlDetail';
|
||||||
import { TagEdition } from '../tags/reducers/tagEdit';
|
import type { ShortUrlEdition } from '../short-urls/reducers/shortUrlEdition';
|
||||||
import { TagsList } from '../tags/reducers/tagsList';
|
import type { ShortUrlsList } from '../short-urls/reducers/shortUrlsList';
|
||||||
import { ShortUrlDetail } from '../short-urls/reducers/shortUrlDetail';
|
import type { TagDeletion } from '../tags/reducers/tagDelete';
|
||||||
import { ShortUrlVisits } from '../visits/reducers/shortUrlVisits';
|
import type { TagEdition } from '../tags/reducers/tagEdit';
|
||||||
import { TagVisits } from '../visits/reducers/tagVisits';
|
import type { TagsList } from '../tags/reducers/tagsList';
|
||||||
import { DomainsList } from '../domains/reducers/domainsList';
|
import type { DomainVisits } from '../visits/reducers/domainVisits';
|
||||||
import { VisitsOverview } from '../visits/reducers/visitsOverview';
|
import type { ShortUrlVisits } from '../visits/reducers/shortUrlVisits';
|
||||||
import { VisitsInfo } from '../visits/types';
|
import type { TagVisits } from '../visits/reducers/tagVisits';
|
||||||
import { Sidebar } from '../common/reducers/sidebar';
|
import type { VisitsInfo } from '../visits/reducers/types';
|
||||||
|
import type { VisitsOverview } from '../visits/reducers/visitsOverview';
|
||||||
|
|
||||||
export interface ShlinkState {
|
export interface ShlinkState {
|
||||||
servers: ServersMap;
|
servers: ServersMap;
|
||||||
selectedServer: SelectedServer;
|
selectedServer: SelectedServer;
|
||||||
shortUrlsList: ShortUrlsList;
|
shortUrlsList: ShortUrlsList;
|
||||||
shortUrlCreationResult: ShortUrlCreation;
|
shortUrlCreation: ShortUrlCreation;
|
||||||
shortUrlDeletion: ShortUrlDeletion;
|
shortUrlDeletion: ShortUrlDeletion;
|
||||||
shortUrlEdition: ShortUrlEdition;
|
shortUrlEdition: ShortUrlEdition;
|
||||||
shortUrlVisits: ShortUrlVisits;
|
shortUrlVisits: ShortUrlVisits;
|
||||||
tagVisits: TagVisits;
|
tagVisits: TagVisits;
|
||||||
|
domainVisits: DomainVisits;
|
||||||
orphanVisits: VisitsInfo;
|
orphanVisits: VisitsInfo;
|
||||||
nonOrphanVisits: VisitsInfo;
|
nonOrphanVisits: VisitsInfo;
|
||||||
shortUrlDetail: ShortUrlDetail;
|
shortUrlDetail: ShortUrlDetail;
|
||||||
|
|||||||
@@ -1,24 +1,20 @@
|
|||||||
import { FC, useEffect } from 'react';
|
import { faDotCircle as defaultDomainIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { Button, UncontrolledTooltip } from 'reactstrap';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import {
|
import type { FC } from 'react';
|
||||||
faBan as forbiddenIcon,
|
import { useEffect } from 'react';
|
||||||
faDotCircle as defaultDomainIcon,
|
import { UncontrolledTooltip } from 'reactstrap';
|
||||||
faEdit as editIcon,
|
import type { ShlinkDomainRedirects } from '../api/types';
|
||||||
} from '@fortawesome/free-solid-svg-icons';
|
import type { SelectedServer } from '../servers/data';
|
||||||
import { ShlinkDomainRedirects } from '../api/types';
|
import type { OptionalString } from '../utils/utils';
|
||||||
import { useToggle } from '../utils/helpers/hooks';
|
import type { Domain } from './data';
|
||||||
import { OptionalString } from '../utils/utils';
|
import { DomainDropdown } from './helpers/DomainDropdown';
|
||||||
import { SelectedServer } from '../servers/data';
|
|
||||||
import { supportsDefaultDomainRedirectsEdition } from '../utils/helpers/features';
|
|
||||||
import { EditDomainRedirectsModal } from './helpers/EditDomainRedirectsModal';
|
|
||||||
import { Domain } from './data';
|
|
||||||
import { DomainStatusIcon } from './helpers/DomainStatusIcon';
|
import { DomainStatusIcon } from './helpers/DomainStatusIcon';
|
||||||
|
import type { EditDomainRedirects } from './reducers/domainRedirects';
|
||||||
|
|
||||||
interface DomainRowProps {
|
interface DomainRowProps {
|
||||||
domain: Domain;
|
domain: Domain;
|
||||||
defaultRedirects?: ShlinkDomainRedirects;
|
defaultRedirects?: ShlinkDomainRedirects;
|
||||||
editDomainRedirects: (domain: string, redirects: Partial<ShlinkDomainRedirects>) => Promise<void>;
|
editDomainRedirects: (redirects: EditDomainRedirects) => Promise<void>;
|
||||||
checkDomainHealth: (domain: string) => void;
|
checkDomainHealth: (domain: string) => void;
|
||||||
selectedServer: SelectedServer;
|
selectedServer: SelectedServer;
|
||||||
}
|
}
|
||||||
@@ -39,9 +35,7 @@ const DefaultDomain: FC = () => (
|
|||||||
export const DomainRow: FC<DomainRowProps> = (
|
export const DomainRow: FC<DomainRowProps> = (
|
||||||
{ domain, editDomainRedirects, checkDomainHealth, defaultRedirects, selectedServer },
|
{ domain, editDomainRedirects, checkDomainHealth, defaultRedirects, selectedServer },
|
||||||
) => {
|
) => {
|
||||||
const [ isOpen, toggle ] = useToggle();
|
|
||||||
const { domain: authority, isDefault, redirects, status } = domain;
|
const { domain: authority, isDefault, redirects, status } = domain;
|
||||||
const canEditDomain = !isDefault || supportsDefaultDomainRedirectsEdition(selectedServer);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
checkDomainHealth(domain.domain);
|
checkDomainHealth(domain.domain);
|
||||||
@@ -64,25 +58,8 @@ export const DomainRow: FC<DomainRowProps> = (
|
|||||||
<DomainStatusIcon status={status} />
|
<DomainStatusIcon status={status} />
|
||||||
</td>
|
</td>
|
||||||
<td className="responsive-table__cell text-end">
|
<td className="responsive-table__cell text-end">
|
||||||
<span id={!canEditDomain ? 'defaultDomainBtn' : undefined}>
|
<DomainDropdown domain={domain} editDomainRedirects={editDomainRedirects} selectedServer={selectedServer} />
|
||||||
<Button outline size="sm" disabled={!canEditDomain} onClick={!canEditDomain ? undefined : toggle}>
|
|
||||||
<FontAwesomeIcon fixedWidth icon={!canEditDomain ? forbiddenIcon : editIcon} />
|
|
||||||
</Button>
|
|
||||||
</span>
|
|
||||||
{!canEditDomain && (
|
|
||||||
<UncontrolledTooltip target="defaultDomainBtn" placement="left">
|
|
||||||
Redirects for default domain cannot be edited here.
|
|
||||||
<br />
|
|
||||||
Use config options or env vars directly on the server.
|
|
||||||
</UncontrolledTooltip>
|
|
||||||
)}
|
|
||||||
</td>
|
</td>
|
||||||
<EditDomainRedirectsModal
|
|
||||||
domain={domain}
|
|
||||||
isOpen={isOpen}
|
|
||||||
toggle={toggle}
|
|
||||||
editDomainRedirects={editDomainRedirects}
|
|
||||||
/>
|
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { useEffect } from 'react';
|
|
||||||
import { Button, DropdownItem, Input, InputGroup, UncontrolledTooltip, InputProps } from 'reactstrap';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
||||||
import { faUndo } from '@fortawesome/free-solid-svg-icons';
|
import { faUndo } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { isEmpty, pipe } from 'ramda';
|
import { isEmpty, pipe } from 'ramda';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
import type { InputProps } from 'reactstrap';
|
||||||
|
import { Button, DropdownItem, Input, InputGroup, UncontrolledTooltip } from 'reactstrap';
|
||||||
import { DropdownBtn } from '../utils/DropdownBtn';
|
import { DropdownBtn } from '../utils/DropdownBtn';
|
||||||
import { useToggle } from '../utils/helpers/hooks';
|
import { useToggle } from '../utils/helpers/hooks';
|
||||||
import { DomainsList } from './reducers/domainsList';
|
import type { DomainsList } from './reducers/domainsList';
|
||||||
import './DomainSelector.scss';
|
import './DomainSelector.scss';
|
||||||
|
|
||||||
export interface DomainSelectorProps extends Omit<InputProps, 'onChange'> {
|
export interface DomainSelectorProps extends Omit<InputProps, 'onChange'> {
|
||||||
@@ -19,7 +20,7 @@ interface DomainSelectorConnectProps extends DomainSelectorProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const DomainSelector = ({ listDomains, value, domainsList, onChange }: DomainSelectorConnectProps) => {
|
export const DomainSelector = ({ listDomains, value, domainsList, onChange }: DomainSelectorConnectProps) => {
|
||||||
const [ inputDisplayed,, showInput, hideInput ] = useToggle();
|
const [inputDisplayed,, showInput, hideInput] = useToggle();
|
||||||
const { domains } = domainsList;
|
const { domains } = domainsList;
|
||||||
const valueIsEmpty = isEmpty(value);
|
const valueIsEmpty = isEmpty(value);
|
||||||
const unselectDomain = () => onChange('');
|
const unselectDomain = () => onChange('');
|
||||||
@@ -40,6 +41,7 @@ export const DomainSelector = ({ listDomains, value, domainsList, onChange }: Do
|
|||||||
outline
|
outline
|
||||||
type="button"
|
type="button"
|
||||||
className="domains-dropdown__back-btn"
|
className="domains-dropdown__back-btn"
|
||||||
|
aria-label="Back to domains list"
|
||||||
onClick={pipe(unselectDomain, hideInput)}
|
onClick={pipe(unselectDomain, hideInput)}
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={faUndo} />
|
<FontAwesomeIcon icon={faUndo} />
|
||||||
@@ -56,7 +58,7 @@ export const DomainSelector = ({ listDomains, value, domainsList, onChange }: Do
|
|||||||
{domains.map(({ domain, isDefault }) => (
|
{domains.map(({ domain, isDefault }) => (
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
key={domain}
|
key={domain}
|
||||||
active={value === domain || isDefault && valueIsEmpty}
|
active={(value === domain || isDefault) && valueIsEmpty}
|
||||||
onClick={() => onChange(domain)}
|
onClick={() => onChange(domain)}
|
||||||
>
|
>
|
||||||
{domain}
|
{domain}
|
||||||
|
|||||||
@@ -1,24 +1,25 @@
|
|||||||
import { FC, useEffect } from 'react';
|
import type { FC } from 'react';
|
||||||
import Message from '../utils/Message';
|
import { useEffect } from 'react';
|
||||||
import { Result } from '../utils/Result';
|
|
||||||
import { ShlinkApiError } from '../api/ShlinkApiError';
|
import { ShlinkApiError } from '../api/ShlinkApiError';
|
||||||
|
import type { SelectedServer } from '../servers/data';
|
||||||
|
import { Message } from '../utils/Message';
|
||||||
|
import { Result } from '../utils/Result';
|
||||||
|
import { SearchField } from '../utils/SearchField';
|
||||||
import { SimpleCard } from '../utils/SimpleCard';
|
import { SimpleCard } from '../utils/SimpleCard';
|
||||||
import SearchField from '../utils/SearchField';
|
|
||||||
import { ShlinkDomainRedirects } from '../api/types';
|
|
||||||
import { SelectedServer } from '../servers/data';
|
|
||||||
import { DomainsList } from './reducers/domainsList';
|
|
||||||
import { DomainRow } from './DomainRow';
|
import { DomainRow } from './DomainRow';
|
||||||
|
import type { EditDomainRedirects } from './reducers/domainRedirects';
|
||||||
|
import type { DomainsList } from './reducers/domainsList';
|
||||||
|
|
||||||
interface ManageDomainsProps {
|
interface ManageDomainsProps {
|
||||||
listDomains: Function;
|
listDomains: Function;
|
||||||
filterDomains: (searchTerm: string) => void;
|
filterDomains: (searchTerm: string) => void;
|
||||||
editDomainRedirects: (domain: string, redirects: Partial<ShlinkDomainRedirects>) => Promise<void>;
|
editDomainRedirects: (redirects: EditDomainRedirects) => Promise<void>;
|
||||||
checkDomainHealth: (domain: string) => void;
|
checkDomainHealth: (domain: string) => void;
|
||||||
domainsList: DomainsList;
|
domainsList: DomainsList;
|
||||||
selectedServer: SelectedServer;
|
selectedServer: SelectedServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const headers = [ '', 'Domain', 'Base path redirect', 'Regular 404 redirect', 'Invalid short URL redirect', '', '' ];
|
const headers = ['', 'Domain', 'Base path redirect', 'Regular 404 redirect', 'Invalid short URL redirect', '', ''];
|
||||||
|
|
||||||
export const ManageDomains: FC<ManageDomainsProps> = (
|
export const ManageDomains: FC<ManageDomainsProps> = (
|
||||||
{ listDomains, domainsList, filterDomains, editDomainRedirects, checkDomainHealth, selectedServer },
|
{ listDomains, domainsList, filterDomains, editDomainRedirects, checkDomainHealth, selectedServer },
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ShlinkDomain } from '../../api/types';
|
import type { ShlinkDomain } from '../../api/types';
|
||||||
|
|
||||||
export type DomainStatus = 'validating' | 'valid' | 'invalid';
|
export type DomainStatus = 'validating' | 'valid' | 'invalid';
|
||||||
|
|
||||||
|
|||||||
51
src/domains/helpers/DomainDropdown.tsx
Normal file
51
src/domains/helpers/DomainDropdown.tsx
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { faChartPie as pieChartIcon, faEdit as editIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import type { FC } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { DropdownItem } from 'reactstrap';
|
||||||
|
import type { SelectedServer } from '../../servers/data';
|
||||||
|
import { getServerId } from '../../servers/data';
|
||||||
|
import { useFeature } from '../../utils/helpers/features';
|
||||||
|
import { useToggle } from '../../utils/helpers/hooks';
|
||||||
|
import { RowDropdownBtn } from '../../utils/RowDropdownBtn';
|
||||||
|
import { DEFAULT_DOMAIN } from '../../visits/reducers/domainVisits';
|
||||||
|
import type { Domain } from '../data';
|
||||||
|
import type { EditDomainRedirects } from '../reducers/domainRedirects';
|
||||||
|
import { EditDomainRedirectsModal } from './EditDomainRedirectsModal';
|
||||||
|
|
||||||
|
interface DomainDropdownProps {
|
||||||
|
domain: Domain;
|
||||||
|
editDomainRedirects: (redirects: EditDomainRedirects) => Promise<void>;
|
||||||
|
selectedServer: SelectedServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DomainDropdown: FC<DomainDropdownProps> = ({ domain, editDomainRedirects, selectedServer }) => {
|
||||||
|
const [isModalOpen, toggleModal] = useToggle();
|
||||||
|
const { isDefault } = domain;
|
||||||
|
const canBeEdited = !isDefault || useFeature('defaultDomainRedirectsEdition', selectedServer);
|
||||||
|
const withVisits = useFeature('domainVisits', selectedServer);
|
||||||
|
const serverId = getServerId(selectedServer);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RowDropdownBtn>
|
||||||
|
{withVisits && (
|
||||||
|
<DropdownItem
|
||||||
|
tag={Link}
|
||||||
|
to={`/server/${serverId}/domain/${domain.domain}${domain.isDefault ? `_${DEFAULT_DOMAIN}` : ''}/visits`}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={pieChartIcon} fixedWidth /> Visit stats
|
||||||
|
</DropdownItem>
|
||||||
|
)}
|
||||||
|
<DropdownItem disabled={!canBeEdited} onClick={!canBeEdited ? undefined : toggleModal}>
|
||||||
|
<FontAwesomeIcon fixedWidth icon={editIcon} /> Edit redirects
|
||||||
|
</DropdownItem>
|
||||||
|
|
||||||
|
<EditDomainRedirectsModal
|
||||||
|
domain={domain}
|
||||||
|
isOpen={isModalOpen}
|
||||||
|
toggle={toggleModal}
|
||||||
|
editDomainRedirects={editDomainRedirects}
|
||||||
|
/>
|
||||||
|
</RowDropdownBtn>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
import { FC, useEffect, useRef, useState } from 'react';
|
|
||||||
import { UncontrolledTooltip } from 'reactstrap';
|
|
||||||
import { ExternalLink } from 'react-external-link';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
||||||
import {
|
import {
|
||||||
faTimes as invalidIcon,
|
|
||||||
faCheck as checkIcon,
|
faCheck as checkIcon,
|
||||||
faCircleNotch as loadingStatusIcon,
|
faCircleNotch as loadingStatusIcon,
|
||||||
|
faTimes as invalidIcon,
|
||||||
} from '@fortawesome/free-solid-svg-icons';
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
import { MediaMatcher } from '../../utils/types';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { DomainStatus } from '../data';
|
import type { FC } from 'react';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { ExternalLink } from 'react-external-link';
|
||||||
|
import { UncontrolledTooltip } from 'reactstrap';
|
||||||
|
import { useElementRef } from '../../utils/helpers/hooks';
|
||||||
|
import type { MediaMatcher } from '../../utils/types';
|
||||||
|
import type { DomainStatus } from '../data';
|
||||||
|
|
||||||
interface DomainStatusIconProps {
|
interface DomainStatusIconProps {
|
||||||
status: DomainStatus;
|
status: DomainStatus;
|
||||||
@@ -16,9 +18,9 @@ interface DomainStatusIconProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const DomainStatusIcon: FC<DomainStatusIconProps> = ({ status, matchMedia = window.matchMedia }) => {
|
export const DomainStatusIcon: FC<DomainStatusIconProps> = ({ status, matchMedia = window.matchMedia }) => {
|
||||||
const ref = useRef<HTMLSpanElement>();
|
const ref = useElementRef<HTMLSpanElement>();
|
||||||
const matchesMobile = () => matchMedia('(max-width: 991px)').matches;
|
const matchesMobile = () => matchMedia('(max-width: 991px)').matches;
|
||||||
const [ isMobile, setIsMobile ] = useState<boolean>(matchesMobile());
|
const [isMobile, setIsMobile] = useState<boolean>(matchesMobile());
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const listener = () => setIsMobile(matchesMobile());
|
const listener = () => setIsMobile(matchesMobile());
|
||||||
@@ -34,17 +36,13 @@ export const DomainStatusIcon: FC<DomainStatusIconProps> = ({ status, matchMedia
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span
|
<span ref={ref}>
|
||||||
ref={(el: HTMLSpanElement) => {
|
|
||||||
ref.current = el;
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{status === 'valid'
|
{status === 'valid'
|
||||||
? <FontAwesomeIcon fixedWidth icon={checkIcon} className="text-muted" />
|
? <FontAwesomeIcon fixedWidth icon={checkIcon} className="text-muted" />
|
||||||
: <FontAwesomeIcon fixedWidth icon={invalidIcon} className="text-danger" />}
|
: <FontAwesomeIcon fixedWidth icon={invalidIcon} className="text-danger" />}
|
||||||
</span>
|
</span>
|
||||||
<UncontrolledTooltip
|
<UncontrolledTooltip
|
||||||
target={(() => ref.current) as any}
|
target={ref}
|
||||||
placement={isMobile ? 'top-start' : 'left'}
|
placement={isMobile ? 'top-start' : 'left'}
|
||||||
autohide={status === 'valid'}
|
autohide={status === 'valid'}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
import { FC, useState } from 'react';
|
import type { FC } from 'react';
|
||||||
|
import { useState } from 'react';
|
||||||
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
|
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
|
||||||
import { ShlinkDomain, ShlinkDomainRedirects } from '../../api/types';
|
import type { ShlinkDomain } from '../../api/types';
|
||||||
import { InputFormGroup, InputFormGroupProps } from '../../utils/forms/InputFormGroup';
|
import type { InputFormGroupProps } from '../../utils/forms/InputFormGroup';
|
||||||
import { handleEventPreventingDefault, nonEmptyValueOrNull } from '../../utils/utils';
|
import { InputFormGroup } from '../../utils/forms/InputFormGroup';
|
||||||
import { InfoTooltip } from '../../utils/InfoTooltip';
|
import { InfoTooltip } from '../../utils/InfoTooltip';
|
||||||
|
import { handleEventPreventingDefault, nonEmptyValueOrNull } from '../../utils/utils';
|
||||||
|
import type { EditDomainRedirects } from '../reducers/domainRedirects';
|
||||||
|
|
||||||
interface EditDomainRedirectsModalProps {
|
interface EditDomainRedirectsModalProps {
|
||||||
domain: ShlinkDomain;
|
domain: ShlinkDomain;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
toggle: () => void;
|
toggle: () => void;
|
||||||
editDomainRedirects: (domain: string, redirects: Partial<ShlinkDomainRedirects>) => Promise<void>;
|
editDomainRedirects: (redirects: EditDomainRedirects) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FormGroup: FC<InputFormGroupProps & { isLast?: boolean }> = ({ isLast, ...rest }) => (
|
const FormGroup: FC<InputFormGroupProps & { isLast?: boolean }> = ({ isLast, ...rest }) => (
|
||||||
@@ -25,20 +28,23 @@ const FormGroup: FC<InputFormGroupProps & { isLast?: boolean }> = ({ isLast, ...
|
|||||||
export const EditDomainRedirectsModal: FC<EditDomainRedirectsModalProps> = (
|
export const EditDomainRedirectsModal: FC<EditDomainRedirectsModalProps> = (
|
||||||
{ isOpen, toggle, domain, editDomainRedirects },
|
{ isOpen, toggle, domain, editDomainRedirects },
|
||||||
) => {
|
) => {
|
||||||
const [ baseUrlRedirect, setBaseUrlRedirect ] = useState(domain.redirects?.baseUrlRedirect ?? '');
|
const [baseUrlRedirect, setBaseUrlRedirect] = useState(domain.redirects?.baseUrlRedirect ?? '');
|
||||||
const [ regular404Redirect, setRegular404Redirect ] = useState(domain.redirects?.regular404Redirect ?? '');
|
const [regular404Redirect, setRegular404Redirect] = useState(domain.redirects?.regular404Redirect ?? '');
|
||||||
const [ invalidShortUrlRedirect, setInvalidShortUrlRedirect ] = useState(
|
const [invalidShortUrlRedirect, setInvalidShortUrlRedirect] = useState(
|
||||||
domain.redirects?.invalidShortUrlRedirect ?? '',
|
domain.redirects?.invalidShortUrlRedirect ?? '',
|
||||||
);
|
);
|
||||||
const handleSubmit = handleEventPreventingDefault(async () => editDomainRedirects(domain.domain, {
|
const handleSubmit = handleEventPreventingDefault(async () => editDomainRedirects({
|
||||||
baseUrlRedirect: nonEmptyValueOrNull(baseUrlRedirect),
|
domain: domain.domain,
|
||||||
regular404Redirect: nonEmptyValueOrNull(regular404Redirect),
|
redirects: {
|
||||||
invalidShortUrlRedirect: nonEmptyValueOrNull(invalidShortUrlRedirect),
|
baseUrlRedirect: nonEmptyValueOrNull(baseUrlRedirect),
|
||||||
|
regular404Redirect: nonEmptyValueOrNull(regular404Redirect),
|
||||||
|
invalidShortUrlRedirect: nonEmptyValueOrNull(invalidShortUrlRedirect),
|
||||||
|
},
|
||||||
}).then(toggle));
|
}).then(toggle));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={isOpen} toggle={toggle} centered>
|
<Modal isOpen={isOpen} toggle={toggle} centered>
|
||||||
<form onSubmit={handleSubmit}>
|
<form name="domainRedirectsModal" onSubmit={handleSubmit}>
|
||||||
<ModalHeader toggle={toggle}>Edit redirects for <b>{domain.domain}</b></ModalHeader>
|
<ModalHeader toggle={toggle}>Edit redirects for <b>{domain.domain}</b></ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<FormGroup value={baseUrlRedirect} onChange={setBaseUrlRedirect}>
|
<FormGroup value={baseUrlRedirect} onChange={setBaseUrlRedirect}>
|
||||||
|
|||||||
@@ -1,33 +1,22 @@
|
|||||||
import { Action, Dispatch } from 'redux';
|
import type { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder';
|
||||||
import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder';
|
import type { ShlinkDomainRedirects } from '../../api/types';
|
||||||
import { ShlinkDomainRedirects } from '../../api/types';
|
import { createAsyncThunk } from '../../utils/helpers/redux';
|
||||||
import { GetState } from '../../container/types';
|
|
||||||
import { ApiErrorAction } from '../../api/types/actions';
|
|
||||||
import { parseApiError } from '../../api/utils';
|
|
||||||
|
|
||||||
/* eslint-disable padding-line-between-statements */
|
const EDIT_DOMAIN_REDIRECTS = 'shlink/domainRedirects/EDIT_DOMAIN_REDIRECTS';
|
||||||
export const EDIT_DOMAIN_REDIRECTS_START = 'shlink/domainRedirects/EDIT_DOMAIN_REDIRECTS_START';
|
|
||||||
export const EDIT_DOMAIN_REDIRECTS_ERROR = 'shlink/domainRedirects/EDIT_DOMAIN_REDIRECTS_ERROR';
|
|
||||||
export const EDIT_DOMAIN_REDIRECTS = 'shlink/domainRedirects/EDIT_DOMAIN_REDIRECTS';
|
|
||||||
/* eslint-enable padding-line-between-statements */
|
|
||||||
|
|
||||||
export interface EditDomainRedirectsAction extends Action<string> {
|
export interface EditDomainRedirects {
|
||||||
domain: string;
|
domain: string;
|
||||||
redirects: ShlinkDomainRedirects;
|
redirects: ShlinkDomainRedirects;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const editDomainRedirects = (buildShlinkApiClient: ShlinkApiClientBuilder) => (
|
export const editDomainRedirects = (
|
||||||
domain: string,
|
buildShlinkApiClient: ShlinkApiClientBuilder,
|
||||||
domainRedirects: Partial<ShlinkDomainRedirects>,
|
) => createAsyncThunk(
|
||||||
) => async (dispatch: Dispatch, getState: GetState) => {
|
EDIT_DOMAIN_REDIRECTS,
|
||||||
dispatch({ type: EDIT_DOMAIN_REDIRECTS_START });
|
async ({ domain, redirects: providedRedirects }: EditDomainRedirects, { getState }): Promise<EditDomainRedirects> => {
|
||||||
const { editDomainRedirects } = buildShlinkApiClient(getState);
|
const { editDomainRedirects: shlinkEditDomainRedirects } = buildShlinkApiClient(getState);
|
||||||
|
const redirects = await shlinkEditDomainRedirects({ domain, ...providedRedirects });
|
||||||
|
|
||||||
try {
|
return { domain, redirects };
|
||||||
const redirects = await editDomainRedirects({ domain, ...domainRedirects });
|
},
|
||||||
|
);
|
||||||
dispatch<EditDomainRedirectsAction>({ type: EDIT_DOMAIN_REDIRECTS, domain, redirects });
|
|
||||||
} catch (e: any) {
|
|
||||||
dispatch<ApiErrorAction>({ type: EDIT_DOMAIN_REDIRECTS_ERROR, errorData: parseApiError(e) });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,22 +1,16 @@
|
|||||||
import { Action, Dispatch } from 'redux';
|
import type { AsyncThunk, SliceCaseReducers } from '@reduxjs/toolkit';
|
||||||
import { ProblemDetailsError, ShlinkDomainRedirects } from '../../api/types';
|
import { createAction, createSlice } from '@reduxjs/toolkit';
|
||||||
import { buildReducer } from '../../utils/helpers/redux';
|
import type { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder';
|
||||||
import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder';
|
import type { ShlinkDomainRedirects } from '../../api/types';
|
||||||
import { GetState } from '../../container/types';
|
import type { ProblemDetailsError } from '../../api/types/errors';
|
||||||
import { parseApiError } from '../../api/utils';
|
import { parseApiError } from '../../api/utils';
|
||||||
import { ApiErrorAction } from '../../api/types/actions';
|
|
||||||
import { Domain, DomainStatus } from '../data';
|
|
||||||
import { hasServerData } from '../../servers/data';
|
import { hasServerData } from '../../servers/data';
|
||||||
|
import { createAsyncThunk } from '../../utils/helpers/redux';
|
||||||
import { replaceAuthorityFromUri } from '../../utils/helpers/uri';
|
import { replaceAuthorityFromUri } from '../../utils/helpers/uri';
|
||||||
import { EDIT_DOMAIN_REDIRECTS, EditDomainRedirectsAction } from './domainRedirects';
|
import type { Domain, DomainStatus } from '../data';
|
||||||
|
import type { EditDomainRedirects } from './domainRedirects';
|
||||||
|
|
||||||
/* eslint-disable padding-line-between-statements */
|
const REDUCER_PREFIX = 'shlink/domainsList';
|
||||||
export const LIST_DOMAINS_START = 'shlink/domainsList/LIST_DOMAINS_START';
|
|
||||||
export const LIST_DOMAINS_ERROR = 'shlink/domainsList/LIST_DOMAINS_ERROR';
|
|
||||||
export const LIST_DOMAINS = 'shlink/domainsList/LIST_DOMAINS';
|
|
||||||
export const FILTER_DOMAINS = 'shlink/domainsList/FILTER_DOMAINS';
|
|
||||||
export const VALIDATE_DOMAIN = 'shlink/domainsList/VALIDATE_DOMAIN';
|
|
||||||
/* eslint-enable padding-line-between-statements */
|
|
||||||
|
|
||||||
export interface DomainsList {
|
export interface DomainsList {
|
||||||
domains: Domain[];
|
domains: Domain[];
|
||||||
@@ -27,16 +21,12 @@ export interface DomainsList {
|
|||||||
errorData?: ProblemDetailsError;
|
errorData?: ProblemDetailsError;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListDomainsAction extends Action<string> {
|
interface ListDomains {
|
||||||
domains: Domain[];
|
domains: Domain[];
|
||||||
defaultRedirects?: ShlinkDomainRedirects;
|
defaultRedirects?: ShlinkDomainRedirects;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FilterDomainsAction extends Action<string> {
|
interface ValidateDomain {
|
||||||
searchTerm: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ValidateDomain extends Action<string> {
|
|
||||||
domain: string;
|
domain: string;
|
||||||
status: DomainStatus;
|
status: DomainStatus;
|
||||||
}
|
}
|
||||||
@@ -48,83 +38,89 @@ const initialState: DomainsList = {
|
|||||||
error: false,
|
error: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DomainsCombinedAction = ListDomainsAction
|
export const replaceRedirectsOnDomain = ({ domain, redirects }: EditDomainRedirects) =>
|
||||||
& ApiErrorAction
|
(d: Domain): Domain => (d.domain !== domain ? d : { ...d, redirects });
|
||||||
& FilterDomainsAction
|
|
||||||
& EditDomainRedirectsAction
|
|
||||||
& ValidateDomain;
|
|
||||||
|
|
||||||
export const replaceRedirectsOnDomain = (domain: string, redirects: ShlinkDomainRedirects) =>
|
|
||||||
(d: Domain): Domain => d.domain !== domain ? d : { ...d, redirects };
|
|
||||||
|
|
||||||
export const replaceStatusOnDomain = (domain: string, status: DomainStatus) =>
|
export const replaceStatusOnDomain = (domain: string, status: DomainStatus) =>
|
||||||
(d: Domain): Domain => d.domain !== domain ? d : { ...d, status };
|
(d: Domain): Domain => (d.domain !== domain ? d : { ...d, status });
|
||||||
|
|
||||||
export default buildReducer<DomainsList, DomainsCombinedAction>({
|
export const domainsListReducerCreator = (
|
||||||
[LIST_DOMAINS_START]: () => ({ ...initialState, loading: true }),
|
buildShlinkApiClient: ShlinkApiClientBuilder,
|
||||||
[LIST_DOMAINS_ERROR]: ({ errorData }) => ({ ...initialState, error: true, errorData }),
|
editDomainRedirects: AsyncThunk<EditDomainRedirects, any, any>,
|
||||||
[LIST_DOMAINS]: (_, { domains, defaultRedirects }) =>
|
|
||||||
({ ...initialState, domains, filteredDomains: domains, defaultRedirects }),
|
|
||||||
[FILTER_DOMAINS]: (state, { searchTerm }) => ({
|
|
||||||
...state,
|
|
||||||
filteredDomains: state.domains.filter(({ domain }) => domain.toLowerCase().match(searchTerm)),
|
|
||||||
}),
|
|
||||||
[EDIT_DOMAIN_REDIRECTS]: (state, { domain, redirects }) => ({
|
|
||||||
...state,
|
|
||||||
domains: state.domains.map(replaceRedirectsOnDomain(domain, redirects)),
|
|
||||||
filteredDomains: state.filteredDomains.map(replaceRedirectsOnDomain(domain, redirects)),
|
|
||||||
}),
|
|
||||||
[VALIDATE_DOMAIN]: (state, { domain, status }) => ({
|
|
||||||
...state,
|
|
||||||
domains: state.domains.map(replaceStatusOnDomain(domain, status)),
|
|
||||||
filteredDomains: state.filteredDomains.map(replaceStatusOnDomain(domain, status)),
|
|
||||||
}),
|
|
||||||
}, initialState);
|
|
||||||
|
|
||||||
export const listDomains = (buildShlinkApiClient: ShlinkApiClientBuilder) => () => async (
|
|
||||||
dispatch: Dispatch,
|
|
||||||
getState: GetState,
|
|
||||||
) => {
|
) => {
|
||||||
dispatch({ type: LIST_DOMAINS_START });
|
const listDomains = createAsyncThunk(`${REDUCER_PREFIX}/listDomains`, async (_: void, { getState }): Promise<ListDomains> => {
|
||||||
const { listDomains } = buildShlinkApiClient(getState);
|
const { listDomains: shlinkListDomains } = buildShlinkApiClient(getState);
|
||||||
|
const { data, defaultRedirects } = await shlinkListDomains();
|
||||||
|
|
||||||
try {
|
return {
|
||||||
const { domains, defaultRedirects } = await listDomains().then(({ data, defaultRedirects }) => ({
|
|
||||||
domains: data.map((domain): Domain => ({ ...domain, status: 'validating' })),
|
domains: data.map((domain): Domain => ({ ...domain, status: 'validating' })),
|
||||||
defaultRedirects,
|
defaultRedirects,
|
||||||
}));
|
};
|
||||||
|
});
|
||||||
|
|
||||||
dispatch<ListDomainsAction>({ type: LIST_DOMAINS, domains, defaultRedirects });
|
const checkDomainHealth = createAsyncThunk(
|
||||||
} catch (e: any) {
|
`${REDUCER_PREFIX}/checkDomainHealth`,
|
||||||
dispatch<ApiErrorAction>({ type: LIST_DOMAINS_ERROR, errorData: parseApiError(e) });
|
async (domain: string, { getState }): Promise<ValidateDomain> => {
|
||||||
}
|
const { selectedServer } = getState();
|
||||||
};
|
|
||||||
|
if (!hasServerData(selectedServer)) {
|
||||||
export const filterDomains = (searchTerm: string): FilterDomainsAction => ({ type: FILTER_DOMAINS, searchTerm });
|
return { domain, status: 'invalid' };
|
||||||
|
}
|
||||||
export const checkDomainHealth = (buildShlinkApiClient: ShlinkApiClientBuilder) => (domain: string) => async (
|
|
||||||
dispatch: Dispatch,
|
try {
|
||||||
getState: GetState,
|
const { url, ...rest } = selectedServer;
|
||||||
) => {
|
const { health } = buildShlinkApiClient({
|
||||||
const { selectedServer } = getState();
|
...rest,
|
||||||
|
url: replaceAuthorityFromUri(url, domain),
|
||||||
if (!hasServerData(selectedServer)) {
|
});
|
||||||
dispatch<ValidateDomain>({ type: VALIDATE_DOMAIN, domain, status: 'invalid' });
|
|
||||||
|
const { status } = await health();
|
||||||
return;
|
|
||||||
}
|
return { domain, status: status === 'pass' ? 'valid' : 'invalid' };
|
||||||
|
} catch (e) {
|
||||||
try {
|
return { domain, status: 'invalid' };
|
||||||
const { url, ...rest } = selectedServer;
|
}
|
||||||
const { health } = buildShlinkApiClient({
|
},
|
||||||
...rest,
|
);
|
||||||
url: replaceAuthorityFromUri(url, domain),
|
|
||||||
});
|
const filterDomains = createAction<string>(`${REDUCER_PREFIX}/filterDomains`);
|
||||||
|
|
||||||
const { status } = await health();
|
const { reducer } = createSlice<DomainsList, SliceCaseReducers<DomainsList>>({
|
||||||
|
name: REDUCER_PREFIX,
|
||||||
dispatch<ValidateDomain>({ type: VALIDATE_DOMAIN, domain, status: status === 'pass' ? 'valid' : 'invalid' });
|
initialState,
|
||||||
} catch (e) {
|
reducers: {},
|
||||||
dispatch<ValidateDomain>({ type: VALIDATE_DOMAIN, domain, status: 'invalid' });
|
extraReducers: (builder) => {
|
||||||
}
|
builder.addCase(listDomains.pending, () => ({ ...initialState, loading: true }));
|
||||||
|
builder.addCase(listDomains.rejected, (_, { error }) => (
|
||||||
|
{ ...initialState, error: true, errorData: parseApiError(error) }
|
||||||
|
));
|
||||||
|
builder.addCase(listDomains.fulfilled, (_, { payload }) => (
|
||||||
|
{ ...initialState, ...payload, filteredDomains: payload.domains }
|
||||||
|
));
|
||||||
|
|
||||||
|
builder.addCase(checkDomainHealth.fulfilled, ({ domains, filteredDomains, ...rest }, { payload }) => ({
|
||||||
|
...rest,
|
||||||
|
domains: domains.map(replaceStatusOnDomain(payload.domain, payload.status)),
|
||||||
|
filteredDomains: filteredDomains.map(replaceStatusOnDomain(payload.domain, payload.status)),
|
||||||
|
}));
|
||||||
|
|
||||||
|
builder.addCase(filterDomains, (state, { payload }) => ({
|
||||||
|
...state,
|
||||||
|
filteredDomains: state.domains.filter(({ domain }) => domain.toLowerCase().match(payload.toLowerCase())),
|
||||||
|
}));
|
||||||
|
|
||||||
|
builder.addCase(editDomainRedirects.fulfilled, (state, { payload }) => ({
|
||||||
|
...state,
|
||||||
|
domains: state.domains.map(replaceRedirectsOnDomain(payload)),
|
||||||
|
filteredDomains: state.filteredDomains.map(replaceRedirectsOnDomain(payload)),
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
reducer,
|
||||||
|
listDomains,
|
||||||
|
checkDomainHealth,
|
||||||
|
filterDomains,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,26 +1,34 @@
|
|||||||
import Bottle from 'bottlejs';
|
import type Bottle from 'bottlejs';
|
||||||
import { ConnectDecorator } from '../../container/types';
|
import { prop } from 'ramda';
|
||||||
import { checkDomainHealth, filterDomains, listDomains } from '../reducers/domainsList';
|
import type { ConnectDecorator } from '../../container/types';
|
||||||
import { DomainSelector } from '../DomainSelector';
|
import { DomainSelector } from '../DomainSelector';
|
||||||
import { ManageDomains } from '../ManageDomains';
|
import { ManageDomains } from '../ManageDomains';
|
||||||
import { editDomainRedirects } from '../reducers/domainRedirects';
|
import { editDomainRedirects } from '../reducers/domainRedirects';
|
||||||
|
import { domainsListReducerCreator } from '../reducers/domainsList';
|
||||||
|
|
||||||
const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
||||||
// Components
|
// Components
|
||||||
bottle.serviceFactory('DomainSelector', () => DomainSelector);
|
bottle.serviceFactory('DomainSelector', () => DomainSelector);
|
||||||
bottle.decorator('DomainSelector', connect([ 'domainsList' ], [ 'listDomains' ]));
|
bottle.decorator('DomainSelector', connect(['domainsList'], ['listDomains']));
|
||||||
|
|
||||||
bottle.serviceFactory('ManageDomains', () => ManageDomains);
|
bottle.serviceFactory('ManageDomains', () => ManageDomains);
|
||||||
bottle.decorator('ManageDomains', connect(
|
bottle.decorator('ManageDomains', connect(
|
||||||
[ 'domainsList', 'selectedServer' ],
|
['domainsList', 'selectedServer'],
|
||||||
[ 'listDomains', 'filterDomains', 'editDomainRedirects', 'checkDomainHealth' ],
|
['listDomains', 'filterDomains', 'editDomainRedirects', 'checkDomainHealth'],
|
||||||
));
|
));
|
||||||
|
|
||||||
// Actions
|
// Reducer
|
||||||
bottle.serviceFactory('listDomains', listDomains, 'buildShlinkApiClient');
|
bottle.serviceFactory(
|
||||||
bottle.serviceFactory('filterDomains', () => filterDomains);
|
'domainsListReducerCreator',
|
||||||
bottle.serviceFactory('editDomainRedirects', editDomainRedirects, 'buildShlinkApiClient');
|
domainsListReducerCreator,
|
||||||
bottle.serviceFactory('checkDomainHealth', checkDomainHealth, 'buildShlinkApiClient');
|
'buildShlinkApiClient',
|
||||||
};
|
'editDomainRedirects',
|
||||||
|
);
|
||||||
|
bottle.serviceFactory('domainsListReducer', prop('reducer'), 'domainsListReducerCreator');
|
||||||
|
|
||||||
export default provideServices;
|
// Actions
|
||||||
|
bottle.serviceFactory('listDomains', prop('listDomains'), 'domainsListReducerCreator');
|
||||||
|
bottle.serviceFactory('filterDomains', prop('filterDomains'), 'domainsListReducerCreator');
|
||||||
|
bottle.serviceFactory('editDomainRedirects', editDomainRedirects, 'buildShlinkApiClient');
|
||||||
|
bottle.serviceFactory('checkDomainHealth', prop('checkDomainHealth'), 'domainsListReducerCreator');
|
||||||
|
};
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
@import './utils/base';
|
@import './utils/base';
|
||||||
@import 'node_modules/bootstrap/scss/bootstrap.scss';
|
@import 'node_modules/bootstrap/scss/bootstrap.scss';
|
||||||
@import './common/react-tag-autocomplete.scss';
|
@import './common/react-tag-autocomplete.scss';
|
||||||
@import './theme/theme';
|
@import './utils/theme/theme';
|
||||||
|
@import './utils/mixins/text-ellipsis';
|
||||||
@import './utils/table/ResponsiveTable';
|
@import './utils/table/ResponsiveTable';
|
||||||
@import './utils/StickyCardPaginator';
|
@import './utils/StickyCardPaginator';
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
|
|
||||||
:root {
|
:root {
|
||||||
scroll-behavior: auto;
|
scroll-behavior: auto;
|
||||||
|
color-scheme: var(--color-scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
html,
|
html,
|
||||||
@@ -38,6 +40,10 @@ a:not(.nav-link):not(.navbar-brand):not(.page-link):not(.highlight-card):not(.bt
|
|||||||
background-color: $mainColor !important;
|
background-color: $mainColor !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bg-warning {
|
||||||
|
color: $lightTextColor;
|
||||||
|
}
|
||||||
|
|
||||||
.card-body,
|
.card-body,
|
||||||
.card-header,
|
.card-header,
|
||||||
.list-group-item {
|
.list-group-item {
|
||||||
@@ -49,7 +55,7 @@ a:not(.nav-link):not(.navbar-brand):not(.page-link):not(.highlight-card):not(.bt
|
|||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .075);
|
box-shadow: 0 .125rem .25rem rgb(0 0 0 / .075);
|
||||||
background-color: var(--primary-color);
|
background-color: var(--primary-color);
|
||||||
border-color: var(--border-color);
|
border-color: var(--border-color);
|
||||||
}
|
}
|
||||||
@@ -217,9 +223,7 @@ hr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.text-ellipsis {
|
.text-ellipsis {
|
||||||
text-overflow: ellipsis;
|
@include text-ellipsis();
|
||||||
overflow: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-bar {
|
.progress-bar {
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
import { render } from 'react-dom';
|
import 'chart.js/auto'; // TODO Import specific ones to reduce bundle size https://react-chartjs-2.js.org/docs/migration-to-v4/#tree-shaking
|
||||||
|
import { createRoot } from 'react-dom/client';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
import { homepage } from '../package.json';
|
import pack from '../package.json';
|
||||||
import { container } from './container';
|
import { container } from './container';
|
||||||
import { store } from './container/store';
|
import { setUpStore } from './container/store';
|
||||||
import { fixLeafletIcons } from './utils/helpers/leaflet';
|
|
||||||
import { register as registerServiceWorker } from './serviceWorkerRegistration';
|
import { register as registerServiceWorker } from './serviceWorkerRegistration';
|
||||||
import 'react-datepicker/dist/react-datepicker.css';
|
import { fixLeafletIcons } from './utils/helpers/leaflet';
|
||||||
import 'leaflet/dist/leaflet.css';
|
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
|
import 'leaflet/dist/leaflet.css';
|
||||||
|
import 'react-datepicker/dist/react-datepicker.css';
|
||||||
|
|
||||||
// This overwrites icons used for leaflet maps, fixing some issues caused by webpack while processing the CSS
|
// This overwrites icons used for leaflet maps, fixing some issues caused by webpack while processing the CSS
|
||||||
fixLeafletIcons();
|
fixLeafletIcons();
|
||||||
|
|
||||||
|
const store = setUpStore(container);
|
||||||
const { App, ScrollToTop, ErrorHandler, appUpdateAvailable } = container;
|
const { App, ScrollToTop, ErrorHandler, appUpdateAvailable } = container;
|
||||||
|
|
||||||
render(
|
createRoot(document.getElementById('root')!).render( // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<BrowserRouter basename={homepage}>
|
<BrowserRouter basename={pack.homepage}>
|
||||||
<ErrorHandler>
|
<ErrorHandler>
|
||||||
<ScrollToTop>
|
<ScrollToTop>
|
||||||
<App />
|
<App />
|
||||||
@@ -25,14 +27,11 @@ render(
|
|||||||
</ErrorHandler>
|
</ErrorHandler>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</Provider>,
|
</Provider>,
|
||||||
document.getElementById('root'),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// If you want your app to work offline and load faster, you can change
|
|
||||||
// unregister() to register() below. Note this comes with some pitfalls.
|
|
||||||
// Learn more about service workers: https://cra.link/PWA
|
// Learn more about service workers: https://cra.link/PWA
|
||||||
registerServiceWorker({
|
registerServiceWorker({
|
||||||
onUpdate() {
|
onUpdate() {
|
||||||
store.dispatch(appUpdateAvailable()); // eslint-disable-line @typescript-eslint/no-unsafe-call
|
store.dispatch(appUpdateAvailable());
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { FC, useEffect } from 'react';
|
|
||||||
import { pipe } from 'ramda';
|
import { pipe } from 'ramda';
|
||||||
|
import type { FC } from 'react';
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { CreateVisit } from '../../visits/types';
|
import type { CreateVisit } from '../../visits/types';
|
||||||
import { MercureInfo } from '../reducers/mercureInfo';
|
import type { MercureInfo } from '../reducers/mercureInfo';
|
||||||
import { bindToMercureTopic } from './index';
|
import { bindToMercureTopic } from './index';
|
||||||
|
|
||||||
export interface MercureBoundProps {
|
export interface MercureBoundProps {
|
||||||
@@ -23,7 +24,7 @@ export function boundToMercureHub<T = {}>(
|
|||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onMessage = (visit: CreateVisit) => interval ? pendingUpdates.add(visit) : createNewVisits([ visit ]);
|
const onMessage = (visit: CreateVisit) => (interval ? pendingUpdates.add(visit) : createNewVisits([visit]));
|
||||||
const topics = getTopicsForProps(props, params);
|
const topics = getTopicsForProps(props, params);
|
||||||
const closeEventSource = bindToMercureTopic(mercureInfo, topics, onMessage, loadMercureInfo);
|
const closeEventSource = bindToMercureTopic(mercureInfo, topics, onMessage, loadMercureInfo);
|
||||||
|
|
||||||
@@ -32,12 +33,12 @@ export function boundToMercureHub<T = {}>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
createNewVisits([ ...pendingUpdates ]);
|
createNewVisits([...pendingUpdates]);
|
||||||
pendingUpdates.clear();
|
pendingUpdates.clear();
|
||||||
}, interval * 1000 * 60);
|
}, interval * 1000 * 60);
|
||||||
|
|
||||||
return pipe(() => clearInterval(timer), () => closeEventSource?.());
|
return pipe(() => clearInterval(timer), () => closeEventSource?.());
|
||||||
}, [ mercureInfo ]);
|
}, [mercureInfo]);
|
||||||
|
|
||||||
return <WrappedComponent {...props} />;
|
return <WrappedComponent {...props} />;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { EventSourcePolyfill as EventSource } from 'event-source-polyfill';
|
import { EventSourcePolyfill as EventSource } from 'event-source-polyfill';
|
||||||
import { MercureInfo } from '../reducers/mercureInfo';
|
import type { MercureInfo } from '../reducers/mercureInfo';
|
||||||
|
|
||||||
export const bindToMercureTopic = <T>(mercureInfo: MercureInfo, topics: string[], onMessage: (message: T) => void, onTokenExpired: () => void) => { // eslint-disable-line max-len
|
export const bindToMercureTopic = <T>(mercureInfo: MercureInfo, topics: string[], onMessage: (message: T) => void, onTokenExpired: () => void) => { // eslint-disable-line max-len
|
||||||
const { mercureHubUrl, token, loading, error } = mercureInfo;
|
const { mercureHubUrl, token, loading, error } = mercureInfo;
|
||||||
|
|||||||
@@ -1,54 +1,44 @@
|
|||||||
import { Action, Dispatch } from 'redux';
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
import { ShlinkMercureInfo } from '../../api/types';
|
import type { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder';
|
||||||
import { GetState } from '../../container/types';
|
import type { ShlinkMercureInfo } from '../../api/types';
|
||||||
import { buildReducer } from '../../utils/helpers/redux';
|
import { createAsyncThunk } from '../../utils/helpers/redux';
|
||||||
import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder';
|
|
||||||
|
|
||||||
/* eslint-disable padding-line-between-statements */
|
const REDUCER_PREFIX = 'shlink/mercure';
|
||||||
export const GET_MERCURE_INFO_START = 'shlink/mercure/GET_MERCURE_INFO_START';
|
|
||||||
export const GET_MERCURE_INFO_ERROR = 'shlink/mercure/GET_MERCURE_INFO_ERROR';
|
|
||||||
export const GET_MERCURE_INFO = 'shlink/mercure/GET_MERCURE_INFO';
|
|
||||||
/* eslint-enable padding-line-between-statements */
|
|
||||||
|
|
||||||
export interface MercureInfo {
|
export interface MercureInfo extends Partial<ShlinkMercureInfo> {
|
||||||
token?: string;
|
|
||||||
mercureHubUrl?: string;
|
|
||||||
interval?: number;
|
interval?: number;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
error: boolean;
|
error: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GetMercureInfoAction = Action<string> & ShlinkMercureInfo & { interval?: number };
|
|
||||||
|
|
||||||
const initialState: MercureInfo = {
|
const initialState: MercureInfo = {
|
||||||
loading: true,
|
loading: true,
|
||||||
error: false,
|
error: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default buildReducer<MercureInfo, GetMercureInfoAction>({
|
export const mercureInfoReducerCreator = (buildShlinkApiClient: ShlinkApiClientBuilder) => {
|
||||||
[GET_MERCURE_INFO_START]: (state) => ({ ...state, loading: true, error: false }),
|
const loadMercureInfo = createAsyncThunk(
|
||||||
[GET_MERCURE_INFO_ERROR]: (state) => ({ ...state, loading: false, error: true }),
|
`${REDUCER_PREFIX}/loadMercureInfo`,
|
||||||
[GET_MERCURE_INFO]: (_, action) => ({ ...action, loading: false, error: false }),
|
(_: void, { getState }): Promise<ShlinkMercureInfo> => {
|
||||||
}, initialState);
|
const { settings } = getState();
|
||||||
|
if (!settings.realTimeUpdates.enabled) {
|
||||||
|
throw new Error('Real time updates not enabled');
|
||||||
|
}
|
||||||
|
|
||||||
export const loadMercureInfo = (buildShlinkApiClient: ShlinkApiClientBuilder) =>
|
return buildShlinkApiClient(getState).mercureInfo();
|
||||||
() => async (dispatch: Dispatch, getState: GetState) => {
|
},
|
||||||
dispatch({ type: GET_MERCURE_INFO_START });
|
);
|
||||||
|
|
||||||
const { settings } = getState();
|
const { reducer } = createSlice({
|
||||||
const { mercureInfo } = buildShlinkApiClient(getState);
|
name: REDUCER_PREFIX,
|
||||||
|
initialState,
|
||||||
|
reducers: {},
|
||||||
|
extraReducers: (builder) => {
|
||||||
|
builder.addCase(loadMercureInfo.pending, (state) => ({ ...state, loading: true, error: false }));
|
||||||
|
builder.addCase(loadMercureInfo.rejected, (state) => ({ ...state, loading: false, error: true }));
|
||||||
|
builder.addCase(loadMercureInfo.fulfilled, (_, { payload }) => ({ ...payload, loading: false, error: false }));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (!settings.realTimeUpdates.enabled) {
|
return { loadMercureInfo, reducer };
|
||||||
dispatch({ type: GET_MERCURE_INFO_ERROR });
|
};
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const info = await mercureInfo();
|
|
||||||
|
|
||||||
dispatch<GetMercureInfoAction>({ type: GET_MERCURE_INFO, interval: settings.realTimeUpdates.interval, ...info });
|
|
||||||
} catch (e) {
|
|
||||||
dispatch({ type: GET_MERCURE_INFO_ERROR });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import Bottle from 'bottlejs';
|
import type Bottle from 'bottlejs';
|
||||||
import { loadMercureInfo } from '../reducers/mercureInfo';
|
import { prop } from 'ramda';
|
||||||
|
import { mercureInfoReducerCreator } from '../reducers/mercureInfo';
|
||||||
|
|
||||||
|
export const provideServices = (bottle: Bottle) => {
|
||||||
|
// Reducer
|
||||||
|
bottle.serviceFactory('mercureInfoReducerCreator', mercureInfoReducerCreator, 'buildShlinkApiClient');
|
||||||
|
bottle.serviceFactory('mercureInfoReducer', prop('reducer'), 'mercureInfoReducerCreator');
|
||||||
|
|
||||||
const provideServices = (bottle: Bottle) => {
|
|
||||||
// Actions
|
// Actions
|
||||||
bottle.serviceFactory('loadMercureInfo', loadMercureInfo, 'buildShlinkApiClient');
|
bottle.serviceFactory('loadMercureInfo', prop('loadMercureInfo'), 'mercureInfoReducerCreator');
|
||||||
};
|
};
|
||||||
|
|
||||||
export default provideServices;
|
|
||||||
|
|||||||
@@ -1,45 +1,31 @@
|
|||||||
import { combineReducers } from 'redux';
|
import { combineReducers } from '@reduxjs/toolkit';
|
||||||
import serversReducer from '../servers/reducers/servers';
|
import type { IContainer } from 'bottlejs';
|
||||||
import selectedServerReducer from '../servers/reducers/selectedServer';
|
import { appUpdatesReducer } from '../app/reducers/appUpdates';
|
||||||
import shortUrlsListReducer from '../short-urls/reducers/shortUrlsList';
|
import { sidebarReducer } from '../common/reducers/sidebar';
|
||||||
import shortUrlCreationReducer from '../short-urls/reducers/shortUrlCreation';
|
import type { ShlinkState } from '../container/types';
|
||||||
import shortUrlDeletionReducer from '../short-urls/reducers/shortUrlDeletion';
|
import { serversReducer } from '../servers/reducers/servers';
|
||||||
import shortUrlEditionReducer from '../short-urls/reducers/shortUrlEdition';
|
import { settingsReducer } from '../settings/reducers/settings';
|
||||||
import shortUrlVisitsReducer from '../visits/reducers/shortUrlVisits';
|
|
||||||
import tagVisitsReducer from '../visits/reducers/tagVisits';
|
|
||||||
import orphanVisitsReducer from '../visits/reducers/orphanVisits';
|
|
||||||
import nonOrphanVisitsReducer from '../visits/reducers/nonOrphanVisits';
|
|
||||||
import shortUrlDetailReducer from '../short-urls/reducers/shortUrlDetail';
|
|
||||||
import tagsListReducer from '../tags/reducers/tagsList';
|
|
||||||
import tagDeleteReducer from '../tags/reducers/tagDelete';
|
|
||||||
import tagEditReducer from '../tags/reducers/tagEdit';
|
|
||||||
import mercureInfoReducer from '../mercure/reducers/mercureInfo';
|
|
||||||
import settingsReducer from '../settings/reducers/settings';
|
|
||||||
import domainsListReducer from '../domains/reducers/domainsList';
|
|
||||||
import visitsOverviewReducer from '../visits/reducers/visitsOverview';
|
|
||||||
import appUpdatesReducer from '../app/reducers/appUpdates';
|
|
||||||
import sidebarReducer from '../common/reducers/sidebar';
|
|
||||||
import { ShlinkState } from '../container/types';
|
|
||||||
|
|
||||||
export default combineReducers<ShlinkState>({
|
export const initReducers = (container: IContainer) => combineReducers<ShlinkState>({
|
||||||
servers: serversReducer,
|
servers: serversReducer,
|
||||||
selectedServer: selectedServerReducer,
|
selectedServer: container.selectedServerReducer,
|
||||||
shortUrlsList: shortUrlsListReducer,
|
shortUrlsList: container.shortUrlsListReducer,
|
||||||
shortUrlCreationResult: shortUrlCreationReducer,
|
shortUrlCreation: container.shortUrlCreationReducer,
|
||||||
shortUrlDeletion: shortUrlDeletionReducer,
|
shortUrlDeletion: container.shortUrlDeletionReducer,
|
||||||
shortUrlEdition: shortUrlEditionReducer,
|
shortUrlEdition: container.shortUrlEditionReducer,
|
||||||
shortUrlVisits: shortUrlVisitsReducer,
|
shortUrlDetail: container.shortUrlDetailReducer,
|
||||||
tagVisits: tagVisitsReducer,
|
shortUrlVisits: container.shortUrlVisitsReducer,
|
||||||
orphanVisits: orphanVisitsReducer,
|
tagVisits: container.tagVisitsReducer,
|
||||||
nonOrphanVisits: nonOrphanVisitsReducer,
|
domainVisits: container.domainVisitsReducer,
|
||||||
shortUrlDetail: shortUrlDetailReducer,
|
orphanVisits: container.orphanVisitsReducer,
|
||||||
tagsList: tagsListReducer,
|
nonOrphanVisits: container.nonOrphanVisitsReducer,
|
||||||
tagDelete: tagDeleteReducer,
|
tagsList: container.tagsListReducer,
|
||||||
tagEdit: tagEditReducer,
|
tagDelete: container.tagDeleteReducer,
|
||||||
mercureInfo: mercureInfoReducer,
|
tagEdit: container.tagEditReducer,
|
||||||
|
mercureInfo: container.mercureInfoReducer,
|
||||||
settings: settingsReducer,
|
settings: settingsReducer,
|
||||||
domainsList: domainsListReducer,
|
domainsList: container.domainsListReducer,
|
||||||
visitsOverview: visitsOverviewReducer,
|
visitsOverview: container.visitsOverviewReducer,
|
||||||
appUpdated: appUpdatesReducer,
|
appUpdated: appUpdatesReducer,
|
||||||
sidebar: sidebarReducer,
|
sidebar: sidebarReducer,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
import { FC, useEffect, useState } from 'react';
|
import type { FC } from 'react';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { useEffect, useState } from 'react';
|
||||||
import { Button } from 'reactstrap';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Result } from '../utils/Result';
|
import { Button } from 'reactstrap';
|
||||||
|
import { v4 as uuid } from 'uuid';
|
||||||
import { NoMenuLayout } from '../common/NoMenuLayout';
|
import { NoMenuLayout } from '../common/NoMenuLayout';
|
||||||
import { StateFlagTimeout, useGoBack, useToggle } from '../utils/helpers/hooks';
|
import type { TimeoutToggle } from '../utils/helpers/hooks';
|
||||||
import { ServerForm } from './helpers/ServerForm';
|
import { useGoBack, useToggle } from '../utils/helpers/hooks';
|
||||||
import { ImportServersBtnProps } from './helpers/ImportServersBtn';
|
import { Result } from '../utils/Result';
|
||||||
import { ServerData, ServersMap, ServerWithId } from './data';
|
import type { ServerData, ServersMap, ServerWithId } from './data';
|
||||||
import { DuplicatedServersModal } from './helpers/DuplicatedServersModal';
|
import { DuplicatedServersModal } from './helpers/DuplicatedServersModal';
|
||||||
|
import type { ImportServersBtnProps } from './helpers/ImportServersBtn';
|
||||||
|
import { ServerForm } from './helpers/ServerForm';
|
||||||
|
|
||||||
const SHOW_IMPORT_MSG_TIME = 4000;
|
const SHOW_IMPORT_MSG_TIME = 4000;
|
||||||
|
|
||||||
interface CreateServerProps {
|
interface CreateServerProps {
|
||||||
createServer: (server: ServerWithId) => void;
|
createServers: (servers: ServerWithId[]) => void;
|
||||||
servers: ServersMap;
|
servers: ServersMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,16 +28,16 @@ const ImportResult = ({ type }: { type: 'error' | 'success' }) => (
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const CreateServer = (ImportServersBtn: FC<ImportServersBtnProps>, useStateFlagTimeout: StateFlagTimeout) => (
|
export const CreateServer = (ImportServersBtn: FC<ImportServersBtnProps>, useTimeoutToggle: TimeoutToggle) => (
|
||||||
{ servers, createServer }: CreateServerProps,
|
{ servers, createServers }: CreateServerProps,
|
||||||
) => {
|
) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const goBack = useGoBack();
|
const goBack = useGoBack();
|
||||||
const hasServers = !!Object.keys(servers).length;
|
const hasServers = !!Object.keys(servers).length;
|
||||||
const [ serversImported, setServersImported ] = useStateFlagTimeout(false, SHOW_IMPORT_MSG_TIME);
|
const [serversImported, setServersImported] = useTimeoutToggle(false, SHOW_IMPORT_MSG_TIME);
|
||||||
const [ errorImporting, setErrorImporting ] = useStateFlagTimeout(false, SHOW_IMPORT_MSG_TIME);
|
const [errorImporting, setErrorImporting] = useTimeoutToggle(false, SHOW_IMPORT_MSG_TIME);
|
||||||
const [ isConfirmModalOpen, toggleConfirmModal ] = useToggle();
|
const [isConfirmModalOpen, toggleConfirmModal] = useToggle();
|
||||||
const [ serverData, setServerData ] = useState<ServerData | undefined>();
|
const [serverData, setServerData] = useState<ServerData | undefined>();
|
||||||
const save = () => {
|
const save = () => {
|
||||||
if (!serverData) {
|
if (!serverData) {
|
||||||
return;
|
return;
|
||||||
@@ -43,7 +45,7 @@ const CreateServer = (ImportServersBtn: FC<ImportServersBtnProps>, useStateFlagT
|
|||||||
|
|
||||||
const id = uuid();
|
const id = uuid();
|
||||||
|
|
||||||
createServer({ ...serverData, id });
|
createServers([{ ...serverData, id }]);
|
||||||
navigate(`/server/${id}`);
|
navigate(`/server/${id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,13 +55,14 @@ const CreateServer = (ImportServersBtn: FC<ImportServersBtnProps>, useStateFlagT
|
|||||||
);
|
);
|
||||||
|
|
||||||
serverExists ? toggleConfirmModal() : save();
|
serverExists ? toggleConfirmModal() : save();
|
||||||
}, [ serverData ]);
|
}, [serverData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NoMenuLayout>
|
<NoMenuLayout>
|
||||||
<ServerForm title={<h5 className="mb-0">Add new server</h5>} onSubmit={setServerData}>
|
<ServerForm title={<h5 className="mb-0">Add new server</h5>} onSubmit={setServerData}>
|
||||||
{!hasServers &&
|
{!hasServers && (
|
||||||
<ImportServersBtn tooltipPlacement="top" onImport={setServersImported} onImportError={setErrorImporting} />}
|
<ImportServersBtn tooltipPlacement="top" onImport={setServersImported} onImportError={setErrorImporting} />
|
||||||
|
)}
|
||||||
{hasServers && <Button outline onClick={goBack}>Cancel</Button>}
|
{hasServers && <Button outline onClick={goBack}>Cancel</Button>}
|
||||||
<Button outline color="primary" className="ms-2">Create server</Button>
|
<Button outline color="primary" className="ms-2">Create server</Button>
|
||||||
</ServerForm>
|
</ServerForm>
|
||||||
@@ -69,12 +72,10 @@ const CreateServer = (ImportServersBtn: FC<ImportServersBtnProps>, useStateFlagT
|
|||||||
|
|
||||||
<DuplicatedServersModal
|
<DuplicatedServersModal
|
||||||
isOpen={isConfirmModalOpen}
|
isOpen={isConfirmModalOpen}
|
||||||
duplicatedServers={serverData ? [ serverData ] : []}
|
duplicatedServers={serverData ? [serverData] : []}
|
||||||
onDiscard={goBack}
|
onDiscard={goBack}
|
||||||
onSave={save}
|
onSave={save}
|
||||||
/>
|
/>
|
||||||
</NoMenuLayout>
|
</NoMenuLayout>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CreateServer;
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { FC } from 'react';
|
|
||||||
import { faMinusCircle as deleteIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faMinusCircle as deleteIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
import { useToggle } from '../utils/helpers/hooks';
|
import { useToggle } from '../utils/helpers/hooks';
|
||||||
import { DeleteServerModalProps } from './DeleteServerModal';
|
import type { ServerWithId } from './data';
|
||||||
import { ServerWithId } from './data';
|
import type { DeleteServerModalProps } from './DeleteServerModal';
|
||||||
|
|
||||||
export interface DeleteServerButtonProps {
|
export type DeleteServerButtonProps = PropsWithChildren<{
|
||||||
server: ServerWithId;
|
server: ServerWithId;
|
||||||
className?: string;
|
className?: string;
|
||||||
textClassName?: string;
|
textClassName?: string;
|
||||||
}
|
}>;
|
||||||
|
|
||||||
const DeleteServerButton = (DeleteServerModal: FC<DeleteServerModalProps>): FC<DeleteServerButtonProps> => (
|
export const DeleteServerButton = (DeleteServerModal: FC<DeleteServerModalProps>): FC<DeleteServerButtonProps> => (
|
||||||
{ server, className, children, textClassName },
|
{ server, className, children, textClassName },
|
||||||
) => {
|
) => {
|
||||||
const [ isModalOpen, , showModal, hideModal ] = useToggle();
|
const [isModalOpen, , showModal, hideModal] = useToggle();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -27,5 +27,3 @@ const DeleteServerButton = (DeleteServerModal: FC<DeleteServerModalProps>): FC<D
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DeleteServerButton;
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
|
import { useRef } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { ServerWithId } from './data';
|
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
|
||||||
|
import type { ServerWithId } from './data';
|
||||||
|
|
||||||
export interface DeleteServerModalProps {
|
export interface DeleteServerModalProps {
|
||||||
server: ServerWithId;
|
server: ServerWithId;
|
||||||
@@ -14,19 +15,27 @@ interface DeleteServerModalConnectProps extends DeleteServerModalProps {
|
|||||||
deleteServer: (server: ServerWithId) => void;
|
deleteServer: (server: ServerWithId) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DeleteServerModal: FC<DeleteServerModalConnectProps> = (
|
export const DeleteServerModal: FC<DeleteServerModalConnectProps> = (
|
||||||
{ server, toggle, isOpen, deleteServer, redirectHome = true },
|
{ server, toggle, isOpen, deleteServer, redirectHome = true },
|
||||||
) => {
|
) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const closeModal = () => {
|
const doDelete = useRef<boolean>(false);
|
||||||
deleteServer(server);
|
const toggleAndDelete = () => {
|
||||||
|
doDelete.current = true;
|
||||||
toggle();
|
toggle();
|
||||||
|
};
|
||||||
|
const onClosed = () => {
|
||||||
|
if (!doDelete.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteServer(server);
|
||||||
redirectHome && navigate('/');
|
redirectHome && navigate('/');
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={isOpen} toggle={toggle} centered>
|
<Modal isOpen={isOpen} toggle={toggle} centered onClosed={onClosed}>
|
||||||
<ModalHeader toggle={toggle}><span className="text-danger">Remove server</span></ModalHeader>
|
<ModalHeader toggle={toggle} className="text-danger">Remove server</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<p>Are you sure you want to remove <b>{server ? server.name : ''}</b>?</p>
|
<p>Are you sure you want to remove <b>{server ? server.name : ''}</b>?</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -37,11 +46,9 @@ const DeleteServerModal: FC<DeleteServerModalConnectProps> = (
|
|||||||
</p>
|
</p>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<button className="btn btn-link" onClick={toggle}>Cancel</button>
|
<Button color="link" onClick={toggle}>Cancel</Button>
|
||||||
<button className="btn btn-danger" onClick={() => closeModal()}>Delete</button>
|
<Button color="danger" onClick={toggleAndDelete}>Delete</Button>
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DeleteServerModal;
|
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
import { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { Button } from 'reactstrap';
|
import { Button } from 'reactstrap';
|
||||||
import { NoMenuLayout } from '../common/NoMenuLayout';
|
import { NoMenuLayout } from '../common/NoMenuLayout';
|
||||||
import { useGoBack } from '../utils/helpers/hooks';
|
import { useGoBack, useParsedQuery } from '../utils/helpers/hooks';
|
||||||
|
import type { ServerData } from './data';
|
||||||
|
import { isServerWithId } from './data';
|
||||||
import { ServerForm } from './helpers/ServerForm';
|
import { ServerForm } from './helpers/ServerForm';
|
||||||
import { withSelectedServer } from './helpers/withSelectedServer';
|
import { withSelectedServer } from './helpers/withSelectedServer';
|
||||||
import { isServerWithId, ServerData } from './data';
|
|
||||||
|
|
||||||
interface EditServerProps {
|
interface EditServerProps {
|
||||||
editServer: (serverId: string, serverData: ServerData) => void;
|
editServer: (serverId: string, serverData: ServerData) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const EditServer = (ServerError: FC) => withSelectedServer<EditServerProps>(({ editServer, selectedServer }) => {
|
export const EditServer = (ServerError: FC) => withSelectedServer<EditServerProps>((
|
||||||
|
{ editServer, selectedServer, selectServer },
|
||||||
|
) => {
|
||||||
const goBack = useGoBack();
|
const goBack = useGoBack();
|
||||||
|
const { reconnect } = useParsedQuery<{ reconnect?: 'true' }>();
|
||||||
|
|
||||||
if (!isServerWithId(selectedServer)) {
|
if (!isServerWithId(selectedServer)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -19,6 +23,7 @@ export const EditServer = (ServerError: FC) => withSelectedServer<EditServerProp
|
|||||||
|
|
||||||
const handleSubmit = (serverData: ServerData) => {
|
const handleSubmit = (serverData: ServerData) => {
|
||||||
editServer(selectedServer.id, serverData);
|
editServer(selectedServer.id, serverData);
|
||||||
|
reconnect === 'true' && selectServer(selectedServer.id);
|
||||||
goBack();
|
goBack();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
import { FC, useEffect, useState } from 'react';
|
|
||||||
import { Button, Row } from 'reactstrap';
|
|
||||||
import { faFileDownload as exportIcon, faPlus as plusIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faFileDownload as exportIcon, faPlus as plusIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import type { FC } from 'react';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import { Button, Row } from 'reactstrap';
|
||||||
import { NoMenuLayout } from '../common/NoMenuLayout';
|
import { NoMenuLayout } from '../common/NoMenuLayout';
|
||||||
import { SimpleCard } from '../utils/SimpleCard';
|
import type { TimeoutToggle } from '../utils/helpers/hooks';
|
||||||
import SearchField from '../utils/SearchField';
|
|
||||||
import { Result } from '../utils/Result';
|
import { Result } from '../utils/Result';
|
||||||
import { StateFlagTimeout } from '../utils/helpers/hooks';
|
import { SearchField } from '../utils/SearchField';
|
||||||
import { ImportServersBtnProps } from './helpers/ImportServersBtn';
|
import { SimpleCard } from '../utils/SimpleCard';
|
||||||
import { ServersMap } from './data';
|
import type { ServersMap } from './data';
|
||||||
import { ManageServersRowProps } from './ManageServersRow';
|
import type { ImportServersBtnProps } from './helpers/ImportServersBtn';
|
||||||
import ServersExporter from './services/ServersExporter';
|
import type { ManageServersRowProps } from './ManageServersRow';
|
||||||
|
import type { ServersExporter } from './services/ServersExporter';
|
||||||
|
|
||||||
interface ManageServersProps {
|
interface ManageServersProps {
|
||||||
servers: ServersMap;
|
servers: ServersMap;
|
||||||
@@ -22,20 +23,20 @@ const SHOW_IMPORT_MSG_TIME = 4000;
|
|||||||
export const ManageServers = (
|
export const ManageServers = (
|
||||||
serversExporter: ServersExporter,
|
serversExporter: ServersExporter,
|
||||||
ImportServersBtn: FC<ImportServersBtnProps>,
|
ImportServersBtn: FC<ImportServersBtnProps>,
|
||||||
useStateFlagTimeout: StateFlagTimeout,
|
useTimeoutToggle: TimeoutToggle,
|
||||||
ManageServersRow: FC<ManageServersRowProps>,
|
ManageServersRow: FC<ManageServersRowProps>,
|
||||||
): FC<ManageServersProps> => ({ servers }) => {
|
): FC<ManageServersProps> => ({ servers }) => {
|
||||||
const allServers = Object.values(servers);
|
const allServers = Object.values(servers);
|
||||||
const [ serversList, setServersList ] = useState(allServers);
|
const [serversList, setServersList] = useState(allServers);
|
||||||
const filterServers = (searchTerm: string) => setServersList(
|
const filterServers = (searchTerm: string) => setServersList(
|
||||||
allServers.filter(({ name, url }) => `${name} ${url}`.match(searchTerm)),
|
allServers.filter(({ name, url }) => `${name} ${url}`.toLowerCase().match(searchTerm.toLowerCase())),
|
||||||
);
|
);
|
||||||
const hasAutoConnect = serversList.some(({ autoConnect }) => !!autoConnect);
|
const hasAutoConnect = serversList.some(({ autoConnect }) => !!autoConnect);
|
||||||
const [ errorImporting, setErrorImporting ] = useStateFlagTimeout(false, SHOW_IMPORT_MSG_TIME);
|
const [errorImporting, setErrorImporting] = useTimeoutToggle(false, SHOW_IMPORT_MSG_TIME);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setServersList(Object.values(servers));
|
setServersList(Object.values(servers));
|
||||||
}, [ servers ]);
|
}, [servers]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NoMenuLayout>
|
<NoMenuLayout>
|
||||||
@@ -61,17 +62,17 @@ export const ManageServers = (
|
|||||||
<table className="table table-hover responsive-table mb-0">
|
<table className="table table-hover responsive-table mb-0">
|
||||||
<thead className="responsive-table__header">
|
<thead className="responsive-table__header">
|
||||||
<tr>
|
<tr>
|
||||||
{hasAutoConnect && <th style={{ width: '50px' }} />}
|
{hasAutoConnect && <th aria-label="Auto-connect" style={{ width: '50px' }} />}
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Base URL</th>
|
<th>Base URL</th>
|
||||||
<th />
|
<th aria-label="Options" />
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{!serversList.length && <tr className="text-center"><td colSpan={4}>No servers found.</td></tr>}
|
{!serversList.length && <tr className="text-center"><td colSpan={4}>No servers found.</td></tr>}
|
||||||
{serversList.map((server) =>
|
{serversList.map((server) => (
|
||||||
<ManageServersRow key={server.id} server={server} hasAutoConnect={hasAutoConnect} />)
|
<ManageServersRow key={server.id} server={server} hasAutoConnect={hasAutoConnect} />
|
||||||
}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</SimpleCard>
|
</SimpleCard>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { FC } from 'react';
|
|
||||||
import { UncontrolledTooltip } from 'reactstrap';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
||||||
import { faCheck as checkIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faCheck as checkIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { ServerWithId } from './data';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { ManageServersRowDropdownProps } from './ManageServersRowDropdown';
|
import type { FC } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { UncontrolledTooltip } from 'reactstrap';
|
||||||
|
import type { ServerWithId } from './data';
|
||||||
|
import type { ManageServersRowDropdownProps } from './ManageServersRowDropdown';
|
||||||
|
|
||||||
export interface ManageServersRowProps {
|
export interface ManageServersRowProps {
|
||||||
server: ServerWithId;
|
server: ServerWithId;
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import { FC } from 'react';
|
import { faCircle as toggleOnIcon } from '@fortawesome/free-regular-svg-icons';
|
||||||
import { DropdownItem } from 'reactstrap';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
||||||
import {
|
import {
|
||||||
faBan as toggleOffIcon,
|
faBan as toggleOffIcon,
|
||||||
faEdit as editIcon,
|
faEdit as editIcon,
|
||||||
faMinusCircle as deleteIcon,
|
faMinusCircle as deleteIcon,
|
||||||
faPlug as connectIcon,
|
faPlug as connectIcon,
|
||||||
} from '@fortawesome/free-solid-svg-icons';
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
import { faCircle as toggleOnIcon } from '@fortawesome/free-regular-svg-icons';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { DropdownBtnMenu } from '../utils/DropdownBtnMenu';
|
import type { FC } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { DropdownItem } from 'reactstrap';
|
||||||
import { useToggle } from '../utils/helpers/hooks';
|
import { useToggle } from '../utils/helpers/hooks';
|
||||||
import { DeleteServerModalProps } from './DeleteServerModal';
|
import { RowDropdownBtn } from '../utils/RowDropdownBtn';
|
||||||
import { ServerWithId } from './data';
|
import type { ServerWithId } from './data';
|
||||||
|
import type { DeleteServerModalProps } from './DeleteServerModal';
|
||||||
|
|
||||||
export interface ManageServersRowDropdownProps {
|
export interface ManageServersRowDropdownProps {
|
||||||
server: ServerWithId;
|
server: ServerWithId;
|
||||||
@@ -25,21 +25,20 @@ interface ManageServersRowDropdownConnectProps extends ManageServersRowDropdownP
|
|||||||
export const ManageServersRowDropdown = (
|
export const ManageServersRowDropdown = (
|
||||||
DeleteServerModal: FC<DeleteServerModalProps>,
|
DeleteServerModal: FC<DeleteServerModalProps>,
|
||||||
): FC<ManageServersRowDropdownConnectProps> => ({ server, setAutoConnect }) => {
|
): FC<ManageServersRowDropdownConnectProps> => ({ server, setAutoConnect }) => {
|
||||||
const [ isMenuOpen, toggleMenu ] = useToggle();
|
const [isModalOpen,, showModal, hideModal] = useToggle();
|
||||||
const [ isModalOpen,, showModal, hideModal ] = useToggle();
|
|
||||||
const serverUrl = `/server/${server.id}`;
|
const serverUrl = `/server/${server.id}`;
|
||||||
const { autoConnect: isAutoConnect } = server;
|
const { autoConnect: isAutoConnect } = server;
|
||||||
const autoConnectIcon = isAutoConnect ? toggleOffIcon : toggleOnIcon;
|
const autoConnectIcon = isAutoConnect ? toggleOffIcon : toggleOnIcon;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownBtnMenu isOpen={isMenuOpen} toggle={toggleMenu}>
|
<RowDropdownBtn minWidth={170}>
|
||||||
<DropdownItem tag={Link} to={serverUrl}>
|
<DropdownItem tag={Link} to={serverUrl}>
|
||||||
<FontAwesomeIcon icon={connectIcon} fixedWidth /> Connect
|
<FontAwesomeIcon icon={connectIcon} fixedWidth /> Connect
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem tag={Link} to={`${serverUrl}/edit`}>
|
<DropdownItem tag={Link} to={`${serverUrl}/edit`}>
|
||||||
<FontAwesomeIcon icon={editIcon} fixedWidth /> Edit server
|
<FontAwesomeIcon icon={editIcon} fixedWidth /> Edit server
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem onClick={() => setAutoConnect(server, !server.autoConnect)}>
|
<DropdownItem onClick={() => setAutoConnect(server, !isAutoConnect)}>
|
||||||
<FontAwesomeIcon icon={autoConnectIcon} fixedWidth /> {isAutoConnect ? 'Do not a' : 'A'}uto-connect
|
<FontAwesomeIcon icon={autoConnectIcon} fixedWidth /> {isAutoConnect ? 'Do not a' : 'A'}uto-connect
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem divider />
|
<DropdownItem divider />
|
||||||
@@ -48,6 +47,6 @@ export const ManageServersRowDropdown = (
|
|||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
|
|
||||||
<DeleteServerModal redirectHome={false} server={server} isOpen={isModalOpen} toggle={hideModal} />
|
<DeleteServerModal redirectHome={false} server={server} isOpen={isModalOpen} toggle={hideModal} />
|
||||||
</DropdownBtnMenu>
|
</RowDropdownBtn>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
import { FC, useEffect } from 'react';
|
import type { FC } from 'react';
|
||||||
import { Card, CardBody, CardHeader, Row } from 'reactstrap';
|
import { useEffect } from 'react';
|
||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
import { ITEMS_IN_OVERVIEW_PAGE, ShortUrlsList as ShortUrlsListState } from '../short-urls/reducers/shortUrlsList';
|
import { Card, CardBody, CardHeader, Row } from 'reactstrap';
|
||||||
import { prettify } from '../utils/helpers/numbers';
|
import type { ShlinkShortUrlsListParams } from '../api/types';
|
||||||
import { TagsList } from '../tags/reducers/tagsList';
|
|
||||||
import { ShortUrlsTableProps } from '../short-urls/ShortUrlsTable';
|
|
||||||
import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub';
|
import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub';
|
||||||
import { CreateShortUrlProps } from '../short-urls/CreateShortUrl';
|
|
||||||
import { VisitsOverview } from '../visits/reducers/visitsOverview';
|
|
||||||
import { Versions } from '../utils/helpers/version';
|
|
||||||
import { Topics } from '../mercure/helpers/Topics';
|
import { Topics } from '../mercure/helpers/Topics';
|
||||||
import { ShlinkShortUrlsListParams } from '../api/types';
|
import type { Settings } from '../settings/reducers/settings';
|
||||||
import { supportsNonOrphanVisits, supportsOrphanVisits } from '../utils/helpers/features';
|
import type { CreateShortUrlProps } from '../short-urls/CreateShortUrl';
|
||||||
import { getServerId, SelectedServer } from './data';
|
import type { ShortUrlsList as ShortUrlsListState } from '../short-urls/reducers/shortUrlsList';
|
||||||
|
import { ITEMS_IN_OVERVIEW_PAGE } from '../short-urls/reducers/shortUrlsList';
|
||||||
|
import type { ShortUrlsTableType } from '../short-urls/ShortUrlsTable';
|
||||||
|
import type { TagsList } from '../tags/reducers/tagsList';
|
||||||
|
import { useFeature } from '../utils/helpers/features';
|
||||||
|
import { prettify } from '../utils/helpers/numbers';
|
||||||
|
import type { VisitsOverview } from '../visits/reducers/visitsOverview';
|
||||||
|
import type { SelectedServer } from './data';
|
||||||
|
import { getServerId } from './data';
|
||||||
import { HighlightCard } from './helpers/HighlightCard';
|
import { HighlightCard } from './helpers/HighlightCard';
|
||||||
|
import { VisitsHighlightCard } from './helpers/VisitsHighlightCard';
|
||||||
|
|
||||||
interface OverviewConnectProps {
|
interface OverviewConnectProps {
|
||||||
shortUrlsList: ShortUrlsListState;
|
shortUrlsList: ShortUrlsListState;
|
||||||
@@ -23,12 +27,12 @@ interface OverviewConnectProps {
|
|||||||
selectedServer: SelectedServer;
|
selectedServer: SelectedServer;
|
||||||
visitsOverview: VisitsOverview;
|
visitsOverview: VisitsOverview;
|
||||||
loadVisitsOverview: Function;
|
loadVisitsOverview: Function;
|
||||||
|
settings: Settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Overview = (
|
export const Overview = (
|
||||||
ShortUrlsTable: FC<ShortUrlsTableProps>,
|
ShortUrlsTable: ShortUrlsTableType,
|
||||||
CreateShortUrl: FC<CreateShortUrlProps>,
|
CreateShortUrl: FC<CreateShortUrlProps>,
|
||||||
ForServerVersion: FC<Versions>,
|
|
||||||
) => boundToMercureHub(({
|
) => boundToMercureHub(({
|
||||||
shortUrlsList,
|
shortUrlsList,
|
||||||
listShortUrls,
|
listShortUrls,
|
||||||
@@ -37,13 +41,13 @@ export const Overview = (
|
|||||||
selectedServer,
|
selectedServer,
|
||||||
loadVisitsOverview,
|
loadVisitsOverview,
|
||||||
visitsOverview,
|
visitsOverview,
|
||||||
|
settings: { visits },
|
||||||
}: OverviewConnectProps) => {
|
}: OverviewConnectProps) => {
|
||||||
const { loading, shortUrls } = shortUrlsList;
|
const { loading, shortUrls } = shortUrlsList;
|
||||||
const { loading: loadingTags } = tagsList;
|
const { loading: loadingTags } = tagsList;
|
||||||
const { loading: loadingVisits, visitsCount, orphanVisitsCount } = visitsOverview;
|
const { loading: loadingVisits, nonOrphanVisits, orphanVisits } = visitsOverview;
|
||||||
const serverId = getServerId(selectedServer);
|
const serverId = getServerId(selectedServer);
|
||||||
const linkToOrphanVisits = supportsOrphanVisits(selectedServer);
|
const linkToNonOrphanVisits = useFeature('nonOrphanVisits', selectedServer);
|
||||||
const linkToNonOrphanVisits = supportsNonOrphanVisits(selectedServer);
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -56,19 +60,22 @@ export const Overview = (
|
|||||||
<>
|
<>
|
||||||
<Row>
|
<Row>
|
||||||
<div className="col-lg-6 col-xl-3 mb-3">
|
<div className="col-lg-6 col-xl-3 mb-3">
|
||||||
<HighlightCard title="Visits" link={linkToNonOrphanVisits && `/server/${serverId}/non-orphan-visits`}>
|
<VisitsHighlightCard
|
||||||
{loadingVisits ? 'Loading...' : prettify(visitsCount)}
|
title="Visits"
|
||||||
</HighlightCard>
|
link={linkToNonOrphanVisits ? `/server/${serverId}/non-orphan-visits` : undefined}
|
||||||
|
excludeBots={visits?.excludeBots ?? false}
|
||||||
|
loading={loadingVisits}
|
||||||
|
visitsSummary={nonOrphanVisits}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-lg-6 col-xl-3 mb-3">
|
<div className="col-lg-6 col-xl-3 mb-3">
|
||||||
<HighlightCard title="Orphan visits" link={linkToOrphanVisits && `/server/${serverId}/orphan-visits`}>
|
<VisitsHighlightCard
|
||||||
<ForServerVersion minVersion="2.6.0">
|
title="Orphan visits"
|
||||||
{loadingVisits ? 'Loading...' : prettify(orphanVisitsCount ?? 0)}
|
link={`/server/${serverId}/orphan-visits`}
|
||||||
</ForServerVersion>
|
excludeBots={visits?.excludeBots ?? false}
|
||||||
<ForServerVersion maxVersion="2.5.*">
|
loading={loadingVisits}
|
||||||
<small className="text-muted"><i>Shlink 2.6 is needed</i></small>
|
visitsSummary={orphanVisits}
|
||||||
</ForServerVersion>
|
/>
|
||||||
</HighlightCard>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="col-lg-6 col-xl-3 mb-3">
|
<div className="col-lg-6 col-xl-3 mb-3">
|
||||||
<HighlightCard title="Short URLs" link={`/server/${serverId}/list-short-urls/1`}>
|
<HighlightCard title="Short URLs" link={`/server/${serverId}/list-short-urls/1`}>
|
||||||
@@ -109,4 +116,4 @@ export const Overview = (
|
|||||||
</Card>
|
</Card>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}, () => [ Topics.visits, Topics.orphanVisits ]);
|
}, () => [Topics.visits, Topics.orphanVisits]);
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
import { isEmpty, values } from 'ramda';
|
|
||||||
import { DropdownItem, DropdownMenu, DropdownToggle, UncontrolledDropdown } from 'reactstrap';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import { faPlus as plusIcon, faServer as serverIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faPlus as plusIcon, faServer as serverIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { getServerId, SelectedServer, ServersMap } from './data';
|
import { isEmpty, values } from 'ramda';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { DropdownItem, DropdownMenu, DropdownToggle, UncontrolledDropdown } from 'reactstrap';
|
||||||
|
import type { SelectedServer, ServersMap } from './data';
|
||||||
|
import { getServerId } from './data';
|
||||||
|
|
||||||
export interface ServersDropdownProps {
|
export interface ServersDropdownProps {
|
||||||
servers: ServersMap;
|
servers: ServersMap;
|
||||||
selectedServer: SelectedServer;
|
selectedServer: SelectedServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ServersDropdown = ({ servers, selectedServer }: ServersDropdownProps) => {
|
export const ServersDropdown = ({ servers, selectedServer }: ServersDropdownProps) => {
|
||||||
const serversList = values(servers);
|
const serversList = values(servers);
|
||||||
|
|
||||||
const renderServers = () => {
|
const renderServers = () => {
|
||||||
@@ -46,5 +47,3 @@ const ServersDropdown = ({ servers, selectedServer }: ServersDropdownProps) => {
|
|||||||
</UncontrolledDropdown>
|
</UncontrolledDropdown>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ServersDropdown;
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
.servers-list__list-group:not(.servers-list__list-group--embedded) {
|
.servers-list__list-group:not(.servers-list__list-group--embedded) {
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .075);
|
box-shadow: 0 .125rem .25rem rgb(0 0 0 / .075);
|
||||||
}
|
}
|
||||||
|
|
||||||
.servers-list__server-item.servers-list__server-item {
|
.servers-list__server-item.servers-list__server-item {
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { FC } from 'react';
|
|
||||||
import { ListGroup, ListGroupItem } from 'reactstrap';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import classNames from 'classnames';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
||||||
import { faChevronRight as chevronIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faChevronRight as chevronIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { ServerWithId } from './data';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { ListGroup, ListGroupItem } from 'reactstrap';
|
||||||
|
import type { ServerWithId } from './data';
|
||||||
import './ServersListGroup.scss';
|
import './ServersListGroup.scss';
|
||||||
|
|
||||||
interface ServersListGroupProps {
|
type ServersListGroupProps = PropsWithChildren<{
|
||||||
servers: ServerWithId[];
|
servers: ServerWithId[];
|
||||||
embedded?: boolean;
|
embedded?: boolean;
|
||||||
}
|
}>;
|
||||||
|
|
||||||
const ServerListItem = ({ id, name }: { id: string; name: string }) => (
|
const ServerListItem = ({ id, name }: { id: string; name: string }) => (
|
||||||
<ListGroupItem tag={Link} to={`/server/${id}`} className="servers-list__server-item">
|
<ListGroupItem tag={Link} to={`/server/${id}`} className="servers-list__server-item">
|
||||||
@@ -19,7 +19,7 @@ const ServerListItem = ({ id, name }: { id: string; name: string }) => (
|
|||||||
</ListGroupItem>
|
</ListGroupItem>
|
||||||
);
|
);
|
||||||
|
|
||||||
const ServersListGroup: FC<ServersListGroupProps> = ({ servers, children, embedded = false }) => (
|
export const ServersListGroup: FC<ServersListGroupProps> = ({ servers, children, embedded = false }) => (
|
||||||
<>
|
<>
|
||||||
{children && <h5 className="mb-md-3">{children}</h5>}
|
{children && <h5 className="mb-md-3">{children}</h5>}
|
||||||
{servers.length > 0 && (
|
{servers.length > 0 && (
|
||||||
@@ -31,5 +31,3 @@ const ServersListGroup: FC<ServersListGroupProps> = ({ servers, children, embedd
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default ServersListGroup;
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { omit } from 'ramda';
|
import { omit } from 'ramda';
|
||||||
import { SemVer } from '../../utils/helpers/version';
|
import type { SemVer } from '../../utils/helpers/version';
|
||||||
|
|
||||||
export interface ServerData {
|
export interface ServerData {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -35,15 +35,15 @@ export const hasServerData = (server: SelectedServer | ServerData): server is Se
|
|||||||
!!(server as ServerData)?.url && !!(server as ServerData)?.apiKey;
|
!!(server as ServerData)?.url && !!(server as ServerData)?.apiKey;
|
||||||
|
|
||||||
export const isServerWithId = (server: SelectedServer | ServerWithId): server is ServerWithId =>
|
export const isServerWithId = (server: SelectedServer | ServerWithId): server is ServerWithId =>
|
||||||
!!server?.hasOwnProperty('id');
|
!!(server as ServerWithId)?.id;
|
||||||
|
|
||||||
export const isReachableServer = (server: SelectedServer): server is ReachableServer =>
|
export const isReachableServer = (server: SelectedServer): server is ReachableServer =>
|
||||||
!!server?.hasOwnProperty('version');
|
!!(server as ReachableServer)?.version;
|
||||||
|
|
||||||
export const isNotFoundServer = (server: SelectedServer): server is NotFoundServer =>
|
export const isNotFoundServer = (server: SelectedServer): server is NotFoundServer =>
|
||||||
!!server?.hasOwnProperty('serverNotFound');
|
!!(server as NotFoundServer)?.serverNotFound;
|
||||||
|
|
||||||
export const getServerId = (server: SelectedServer) => isServerWithId(server) ? server.id : '';
|
export const getServerId = (server: SelectedServer) => (isServerWithId(server) ? server.id : '');
|
||||||
|
|
||||||
export const serverWithIdToServerData = (server: ServerWithId): ServerData =>
|
export const serverWithIdToServerData = (server: ServerWithId): ServerData =>
|
||||||
omit<ServerWithId, 'id' | 'autoConnect'>([ 'id', 'autoConnect' ], server);
|
omit<ServerWithId, 'id' | 'autoConnect'>(['id', 'autoConnect'], server);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { FC, Fragment } from 'react';
|
import type { FC } from 'react';
|
||||||
|
import { Fragment } from 'react';
|
||||||
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
|
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
|
||||||
import { ServerData } from '../data';
|
import type { ServerData } from '../data';
|
||||||
|
|
||||||
interface DuplicatedServersModalProps {
|
interface DuplicatedServersModalProps {
|
||||||
duplicatedServers: ServerData[];
|
duplicatedServers: ServerData[];
|
||||||
@@ -20,12 +21,12 @@ export const DuplicatedServersModal: FC<DuplicatedServersModalProps> = (
|
|||||||
<ModalBody>
|
<ModalBody>
|
||||||
<p>{hasMultipleServers ? 'The next servers already exist:' : 'There is already a server with:'}</p>
|
<p>{hasMultipleServers ? 'The next servers already exist:' : 'There is already a server with:'}</p>
|
||||||
<ul>
|
<ul>
|
||||||
{duplicatedServers.map(({ url, apiKey }, index) => !hasMultipleServers ? (
|
{duplicatedServers.map(({ url, apiKey }, index) => (!hasMultipleServers ? (
|
||||||
<Fragment key={index}>
|
<Fragment key={index}>
|
||||||
<li>URL: <b>{url}</b></li>
|
<li>URL: <b>{url}</b></li>
|
||||||
<li>API key: <b>{apiKey}</b></li>
|
<li>API key: <b>{apiKey}</b></li>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : <li key={index}><b>{url}</b> - <b>{apiKey}</b></li>)}
|
) : <li key={index}><b>{url}</b> - <b>{apiKey}</b></li>))}
|
||||||
</ul>
|
</ul>
|
||||||
<span>
|
<span>
|
||||||
{hasMultipleServers ? 'Do you want to ignore duplicated servers' : 'Do you want to save this server anyway'}?
|
{hasMultipleServers ? 'Do you want to ignore duplicated servers' : 'Do you want to save this server anyway'}?
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import { FC } from 'react';
|
|
||||||
import { versionMatch, Versions } from '../../utils/helpers/version';
|
|
||||||
import { isReachableServer, SelectedServer } from '../data';
|
|
||||||
|
|
||||||
interface ForServerVersionProps extends Versions {
|
|
||||||
selectedServer: SelectedServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ForServerVersion: FC<ForServerVersionProps> = ({ minVersion, maxVersion, selectedServer, children }) => {
|
|
||||||
if (!isReachableServer(selectedServer)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { version } = selectedServer;
|
|
||||||
const matchesVersion = versionMatch(version, { maxVersion, minVersion });
|
|
||||||
|
|
||||||
if (!matchesVersion) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <>{children}</>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ForServerVersion;
|
|
||||||
@@ -1,21 +1,30 @@
|
|||||||
import { FC } from 'react';
|
|
||||||
import { Card, CardText, CardTitle } from 'reactstrap';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import { faArrowAltCircleRight as linkIcon } from '@fortawesome/free-regular-svg-icons';
|
import { faArrowAltCircleRight as linkIcon } from '@fortawesome/free-regular-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import type { FC, PropsWithChildren, ReactNode } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { Card, CardText, CardTitle, UncontrolledTooltip } from 'reactstrap';
|
||||||
|
import { useElementRef } from '../../utils/helpers/hooks';
|
||||||
import './HighlightCard.scss';
|
import './HighlightCard.scss';
|
||||||
|
|
||||||
export interface HighlightCardProps {
|
export type HighlightCardProps = PropsWithChildren<{
|
||||||
title: string;
|
title: string;
|
||||||
link?: string | false;
|
link?: string;
|
||||||
}
|
tooltip?: ReactNode;
|
||||||
|
}>;
|
||||||
|
|
||||||
const buildExtraProps = (link?: string | false) => !link ? {} : { tag: Link, to: link };
|
const buildExtraProps = (link?: string) => (!link ? {} : { tag: Link, to: link });
|
||||||
|
|
||||||
export const HighlightCard: FC<HighlightCardProps> = ({ children, title, link }) => (
|
export const HighlightCard: FC<HighlightCardProps> = ({ children, title, link, tooltip }) => {
|
||||||
<Card className="highlight-card" body {...buildExtraProps(link)}>
|
const ref = useElementRef<HTMLElement>();
|
||||||
{link && <FontAwesomeIcon size="3x" className="highlight-card__link-icon" icon={linkIcon} />}
|
|
||||||
<CardTitle tag="h5" className="highlight-card__title">{title}</CardTitle>
|
return (
|
||||||
<CardText tag="h2">{children}</CardText>
|
<>
|
||||||
</Card>
|
<Card innerRef={ref} className="highlight-card" body {...buildExtraProps(link)}>
|
||||||
);
|
{link && <FontAwesomeIcon size="3x" className="highlight-card__link-icon" icon={linkIcon} />}
|
||||||
|
<CardTitle tag="h5" className="highlight-card__title">{title}</CardTitle>
|
||||||
|
<CardText tag="h2">{children}</CardText>
|
||||||
|
</Card>
|
||||||
|
{tooltip && <UncontrolledTooltip target={ref} placement="bottom">{tooltip}</UncontrolledTooltip>}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user