Compare commits
736 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d67615542f | ||
|
|
5b01020d20 | ||
|
|
01b025591d | ||
|
|
d9cd258b3f | ||
|
|
b7f15b570e | ||
|
|
39c380ad21 | ||
|
|
700be52e98 | ||
|
|
395f630d28 | ||
|
|
fb69e79129 | ||
|
|
ea7343b34c | ||
|
|
d27052b71c | ||
|
|
bf37a8bfb0 | ||
|
|
389c988ef5 | ||
|
|
7e878ece93 | ||
|
|
10ca9bd457 | ||
|
|
3c057c770d | ||
|
|
d4fc56aa55 | ||
|
|
4f2f3e3aea | ||
|
|
2ca84e798b | ||
|
|
6a84137aff | ||
|
|
abafbe0b21 | ||
|
|
52298d38a1 | ||
|
|
f973dc6116 | ||
|
|
1a022d4d06 | ||
|
|
a6d0262440 | ||
|
|
161fa63e12 | ||
|
|
fc8e4aa5a9 | ||
|
|
a653a9a1c6 | ||
|
|
6aa4e6c34e | ||
|
|
b420c7b302 | ||
|
|
1c5c0f4809 | ||
|
|
c99e3be2b1 | ||
|
|
24be94dfae | ||
|
|
bdbedc8539 | ||
|
|
d23449580c | ||
|
|
3ee0957a21 | ||
|
|
1077e220a8 | ||
|
|
41794ee38c | ||
|
|
4e22dba6a3 | ||
|
|
1341cfb31f | ||
|
|
4b9ac8441f | ||
|
|
d11358af59 | ||
|
|
514162964d | ||
|
|
1f11b380b6 | ||
|
|
4fcb2ebb25 | ||
|
|
5f3914efd5 | ||
|
|
aef736ecf7 | ||
|
|
bd1380f06c | ||
|
|
fa00b5434f | ||
|
|
7ea2ccc791 | ||
|
|
ed79f3c230 | ||
|
|
fb2efd8953 | ||
|
|
9080dde565 | ||
|
|
119d909b6f | ||
|
|
d10bea50bc | ||
|
|
dad3990c23 | ||
|
|
b6f1db57ee | ||
|
|
4b655761c6 | ||
|
|
373f0dbbbb | ||
|
|
f301513f5b | ||
|
|
73a885534a | ||
|
|
e7b18ed092 | ||
|
|
fced67d981 | ||
|
|
af23fa878c | ||
|
|
728b608247 | ||
|
|
491ebd378d | ||
|
|
88092fc1df | ||
|
|
fb25745426 | ||
|
|
c379709850 | ||
|
|
79d8e3dfaf | ||
|
|
8492d47274 | ||
|
|
4abaa5b7fb | ||
|
|
b5f77de194 | ||
|
|
e0e0b24a6b | ||
|
|
74e3b8fe0b | ||
|
|
d5669201f7 | ||
|
|
6094994cfa | ||
|
|
9e8498b16a | ||
|
|
a7f2d3224b | ||
|
|
ae7aea0e2c | ||
|
|
145765e3fa | ||
|
|
11bbef3aca | ||
|
|
9c1052c10b | ||
|
|
7890d0084a | ||
|
|
b295240d28 | ||
|
|
e9951e95a9 | ||
|
|
ffc8249c22 | ||
|
|
622fcd9db6 | ||
|
|
99d6eb5f7c | ||
|
|
8b4388edc7 | ||
|
|
f176ef305f | ||
|
|
a0953304f1 | ||
|
|
9d31c33cb8 | ||
|
|
1c748128ce | ||
|
|
440a25f8e3 | ||
|
|
9ce3e48493 | ||
|
|
288f68fa59 | ||
|
|
0b63e24338 | ||
|
|
5468d2fe36 | ||
|
|
2fa5af70be | ||
|
|
8cbd18b4ab | ||
|
|
728519de5e | ||
|
|
5f0bfdf298 | ||
|
|
a50a75046b | ||
|
|
8bf7c12ad6 | ||
|
|
79e70ea324 | ||
|
|
fdfe6a0470 | ||
|
|
3d65ed654c | ||
|
|
deab26c244 | ||
|
|
a7456d599b | ||
|
|
5fc213789c | ||
|
|
a6c1820be2 | ||
|
|
d6b462f112 | ||
|
|
18b4802e60 | ||
|
|
3ddd1e380f | ||
|
|
a7278e3728 | ||
|
|
48c8d23e7b | ||
|
|
6f53f44bf8 | ||
|
|
06ea04e382 | ||
|
|
7c6f434e9c | ||
|
|
d9843e6bbd | ||
|
|
9655bb8ccc | ||
|
|
17f7ce395d | ||
|
|
2dab89f774 | ||
|
|
f8967558d8 | ||
|
|
0843893f42 | ||
|
|
feb9476be7 | ||
|
|
27f7ffa13d | ||
|
|
9108c1b9c7 | ||
|
|
13b289654f | ||
|
|
5914effb1c | ||
|
|
b22d2e8621 | ||
|
|
5a4743d4f5 | ||
|
|
b70652f11d | ||
|
|
17166246d6 | ||
|
|
79b3f34187 | ||
|
|
02df7a2819 | ||
|
|
761886e17a | ||
|
|
b75d5b3bd1 | ||
|
|
00730d47bb | ||
|
|
43e47fe5f0 | ||
|
|
a0bcf6205c | ||
|
|
e26d66b521 | ||
|
|
fd601b7767 | ||
|
|
573a248114 | ||
|
|
c1f15ac635 | ||
|
|
87c5e28472 | ||
|
|
27c63f590c | ||
|
|
fb0ace7eb2 | ||
|
|
7e0786177f | ||
|
|
0bf54a4afe | ||
|
|
aef1b366db | ||
|
|
81df706914 | ||
|
|
f6cf0a7d91 | ||
|
|
c4e9a50760 | ||
|
|
c720b977e4 | ||
|
|
7de250da16 | ||
|
|
06a6da0e34 | ||
|
|
25ee80ebf6 | ||
|
|
0101ed0e0f | ||
|
|
7f9d01668d | ||
|
|
2d94753892 | ||
|
|
1a70d90462 | ||
|
|
f262187c1b | ||
|
|
7bec7d8bad | ||
|
|
1fe70aaad9 | ||
|
|
02d93043b6 | ||
|
|
ba577b8b38 | ||
|
|
3f8fc9c9b1 | ||
|
|
e499c5f815 | ||
|
|
15ed804b01 | ||
|
|
cd1cd9a2ba | ||
|
|
2cfb286084 | ||
|
|
e7f9fb86d2 | ||
|
|
72f3f6018a | ||
|
|
f7b0629567 | ||
|
|
91c1330796 | ||
|
|
a3d477dd7c | ||
|
|
1cfb2f934d | ||
|
|
56ed13ad3a | ||
|
|
2e11ebb888 | ||
|
|
8c67612a51 | ||
|
|
c8bf455bb0 | ||
|
|
53b31a3824 | ||
|
|
69d9318160 | ||
|
|
30d1022046 | ||
|
|
f1aa0675b1 | ||
|
|
22c6b53934 | ||
|
|
bc29e367ef | ||
|
|
19261c0a95 | ||
|
|
6572b8e763 | ||
|
|
f66b61818c | ||
|
|
6dd44e66fd | ||
|
|
d87358daa6 | ||
|
|
8c7b431f3f | ||
|
|
78e523dda1 | ||
|
|
9a4c306ee7 | ||
|
|
5134f9f29c | ||
|
|
624d913b49 | ||
|
|
8f41404b7d | ||
|
|
323cff974e | ||
|
|
04114ee860 | ||
|
|
afd9fa7295 | ||
|
|
75cf5bf4d9 | ||
|
|
d97c0a7110 | ||
|
|
d2c50e3cf6 | ||
|
|
1b09e11467 | ||
|
|
7c8a0bbf58 | ||
|
|
cc547b558f | ||
|
|
137bda7be1 | ||
|
|
5fcd9dadc7 | ||
|
|
11cd6a992e | ||
|
|
52cfd5de47 | ||
|
|
d7d7ce8253 | ||
|
|
9555df48d7 | ||
|
|
d14ea80b1e | ||
|
|
39dc1d1fe2 | ||
|
|
692ed051dd | ||
|
|
0060dc4b1c | ||
|
|
52ed6a8851 | ||
|
|
b8405b07cc | ||
|
|
f2d2056158 | ||
|
|
3ee8094dbb | ||
|
|
42661a7203 | ||
|
|
07466e6c7f | ||
|
|
7f236810ff | ||
|
|
a24dfd5b3d | ||
|
|
710df321f8 | ||
|
|
a72bec4ce2 | ||
|
|
0c63329673 | ||
|
|
fbe3cda5b4 | ||
|
|
85ebbcbb38 | ||
|
|
0ba3b9b5b8 | ||
|
|
f5babdcffd | ||
|
|
3b6f9f87e8 | ||
|
|
322f470bd3 | ||
|
|
38a4d841d8 | ||
|
|
847318e7de | ||
|
|
2ea1d9af25 | ||
|
|
21c9336c1c | ||
|
|
a0765c8046 | ||
|
|
a7d06abff3 | ||
|
|
13d46a4110 | ||
|
|
6da6b33cd9 | ||
|
|
24f73421d4 | ||
|
|
4a4b95de29 | ||
|
|
ecd92b911b | ||
|
|
1b8333240f | ||
|
|
ae54eec8d7 | ||
|
|
152e65f405 | ||
|
|
8007e76bb2 | ||
|
|
9b9e64b669 | ||
|
|
98acac37c4 | ||
|
|
8f261587d4 | ||
|
|
089aa826f8 | ||
|
|
1b5a5efb01 | ||
|
|
4d313da534 | ||
|
|
d31b3364f6 | ||
|
|
f03c338a33 | ||
|
|
7a27f7b601 | ||
|
|
655ded5d5e | ||
|
|
6d3189f587 | ||
|
|
217d076e12 | ||
|
|
d762ae1e39 | ||
|
|
df3ee490a9 | ||
|
|
bf3caf64bc | ||
|
|
aa818430b6 | ||
|
|
4d7ed8ac00 | ||
|
|
fb66465b9a | ||
|
|
14de67dbb0 | ||
|
|
510f215d78 | ||
|
|
f64272adf0 | ||
|
|
019835e190 | ||
|
|
307eee32f7 | ||
|
|
3904be09f4 | ||
|
|
ce52db96cb | ||
|
|
1018680572 | ||
|
|
fcdb72079d | ||
|
|
f71b399ab9 | ||
|
|
2a606c614d | ||
|
|
c850d2623c | ||
|
|
c263d7a74b | ||
|
|
c4515b8f74 | ||
|
|
8cdf1c0f1d | ||
|
|
8b17ffb3db | ||
|
|
7705b012fe | ||
|
|
c3bffe9993 | ||
|
|
4e3d8bc666 | ||
|
|
70f556ab7d | ||
|
|
23b0a92539 | ||
|
|
7d5b5c8ba1 | ||
|
|
07b64a4dc0 | ||
|
|
29081877fb | ||
|
|
b996a2db04 | ||
|
|
66ec08d278 | ||
|
|
4ba8e42352 | ||
|
|
c4f2b6855b | ||
|
|
a2e29f0379 | ||
|
|
904f529c19 | ||
|
|
8a06f98f45 | ||
|
|
99fcb6db04 | ||
|
|
6928992f8b | ||
|
|
32ab234adf | ||
|
|
9364655114 | ||
|
|
fb9de5cd64 | ||
|
|
1fe2e599a5 | ||
|
|
024a08ee76 | ||
|
|
0eb284ed9c | ||
|
|
878686f469 | ||
|
|
db1dd7c07e | ||
|
|
8ac5bd97b4 | ||
|
|
6f5c657264 | ||
|
|
91f1df45b0 | ||
|
|
3ad884b661 | ||
|
|
7db65635c3 | ||
|
|
9e03e8b837 | ||
|
|
9f8a3edcb3 | ||
|
|
d049da3b20 | ||
|
|
694748cda6 | ||
|
|
ef88644e6e | ||
|
|
98b5640c2c | ||
|
|
e921bf5276 | ||
|
|
8d1c39255f | ||
|
|
9dfbec9b1a | ||
|
|
7a0f2f6300 | ||
|
|
5d5c9e9c22 | ||
|
|
d9f5663ead | ||
|
|
20c35af7e0 | ||
|
|
b879db6447 | ||
|
|
153d59bf27 | ||
|
|
9e889465fb | ||
|
|
31984791ab | ||
|
|
892a7698eb | ||
|
|
7f4ff8adbb | ||
|
|
493d3d5dee | ||
|
|
febd100f96 | ||
|
|
21a9c39f12 | ||
|
|
5078129ac1 | ||
|
|
9b6bacc0c2 | ||
|
|
93b22227ef | ||
|
|
402b10ca98 | ||
|
|
23541606ca | ||
|
|
ea420936fa | ||
|
|
979f002f0c | ||
|
|
54fe38a92b | ||
|
|
1e2618d3b8 | ||
|
|
6b0fc80f1e | ||
|
|
d6d0539fa7 | ||
|
|
81742cbbaf | ||
|
|
300cd50310 | ||
|
|
d227a5db78 | ||
|
|
4f2dd9d240 | ||
|
|
9f750f7f6b | ||
|
|
e5a1563f39 | ||
|
|
bc3634e181 | ||
|
|
3343fba861 | ||
|
|
eff4712f69 | ||
|
|
2788264265 | ||
|
|
6fe52143a8 | ||
|
|
058b38528f | ||
|
|
d1619b3723 | ||
|
|
0bdf5f206e | ||
|
|
34aca8ff3f | ||
|
|
b4db7fdf11 | ||
|
|
d10d7fd96d | ||
|
|
9c0c2fc3f9 | ||
|
|
913b3c5fc1 | ||
|
|
6dd3fd275a | ||
|
|
2b05016586 | ||
|
|
52cc943185 | ||
|
|
edd6f7e807 | ||
|
|
d13e6fb0cc | ||
|
|
2208e9b562 | ||
|
|
dadcdb22f5 | ||
|
|
4246b85b43 | ||
|
|
4d259e50f3 | ||
|
|
e5fff0bc08 | ||
|
|
7a3aab2482 | ||
|
|
455ac9a275 | ||
|
|
b70cebb3f2 | ||
|
|
e3b24eea78 | ||
|
|
a96a48ed19 | ||
|
|
6114763e39 | ||
|
|
575f86cc34 | ||
|
|
93cf8b1258 | ||
|
|
76b7523d4a | ||
|
|
c2c1037c01 | ||
|
|
d3feee301e | ||
|
|
531a61a57b | ||
|
|
af252846f7 | ||
|
|
a94fa74a12 | ||
|
|
3e24c3b61b | ||
|
|
581e809fd2 | ||
|
|
e2ceb52c75 | ||
|
|
f975a71230 | ||
|
|
03df998b86 | ||
|
|
b758781407 | ||
|
|
8dec3a5277 | ||
|
|
191d6af4bd | ||
|
|
543b0a5a80 | ||
|
|
b86a644dcd | ||
|
|
e7a3ec3ee2 | ||
|
|
1f23be963a | ||
|
|
726050e777 | ||
|
|
06af621e7c | ||
|
|
30e67151fe | ||
|
|
0ba34cc8eb | ||
|
|
7a5ae2f19e | ||
|
|
de27e453c3 | ||
|
|
b913a14105 | ||
|
|
2bf0bc8334 | ||
|
|
b5529d3a8c | ||
|
|
b5a091861d | ||
|
|
931f980e16 | ||
|
|
5f091eada1 | ||
|
|
bd1a16a8f8 | ||
|
|
6f8669cec7 | ||
|
|
7d52ae3e7d | ||
|
|
3e194246ab | ||
|
|
cce28116a8 | ||
|
|
90125d51f2 | ||
|
|
dc670b8693 | ||
|
|
3f8a33e77c | ||
|
|
3763a1541a | ||
|
|
4bd61d1f80 | ||
|
|
713c6fc7d9 | ||
|
|
b5efcda25e | ||
|
|
12d7e76731 | ||
|
|
249c948d11 | ||
|
|
b8d0b1bd2a | ||
|
|
77b5c93652 | ||
|
|
137be6962c | ||
|
|
357406d2a4 | ||
|
|
4ba98ede77 | ||
|
|
89f250bfb7 | ||
|
|
425c70bfd8 | ||
|
|
74ffd63828 | ||
|
|
f8a2f81ce4 | ||
|
|
e8f05783a9 | ||
|
|
ae0f2282de | ||
|
|
cc0091f753 | ||
|
|
1e84db4a47 | ||
|
|
8f59da1ce7 | ||
|
|
e46751844c | ||
|
|
d131ac5d03 | ||
|
|
878c82e8f0 | ||
|
|
69fed72a81 | ||
|
|
bda6388100 | ||
|
|
1d6a9ec563 | ||
|
|
56517b9840 | ||
|
|
03a0945a29 | ||
|
|
023a0ca824 | ||
|
|
f6a0910c40 | ||
|
|
869708469d | ||
|
|
f51c8e7643 | ||
|
|
256d886930 | ||
|
|
e74a4b5320 | ||
|
|
751ffdab61 | ||
|
|
fec1fc3c76 | ||
|
|
35d27ffb04 | ||
|
|
3ba6b58b9e | ||
|
|
8ce81771b2 | ||
|
|
17c1ff1c4c | ||
|
|
9a2f83b2b5 | ||
|
|
dfd9a3efb8 | ||
|
|
5e630368e6 | ||
|
|
5327160774 | ||
|
|
b092c86658 | ||
|
|
2988b24fac | ||
|
|
b49b0ebf16 | ||
|
|
45f972e351 | ||
|
|
a824349ad2 | ||
|
|
2fd933fc32 | ||
|
|
b48cf19acf | ||
|
|
669a11186b | ||
|
|
355cdd2550 | ||
|
|
34a08e461f | ||
|
|
557cd4f7e2 | ||
|
|
b0189c6457 | ||
|
|
8da630e149 | ||
|
|
d65eafd37f | ||
|
|
4895cbb9dc | ||
|
|
1467c8e416 | ||
|
|
e12cd68010 | ||
|
|
e997d11c2c | ||
|
|
4947e0490a | ||
|
|
c68a7ee22a | ||
|
|
c4d99606cb | ||
|
|
5e3e70454d | ||
|
|
860808a654 | ||
|
|
476c98d4f3 | ||
|
|
35a3224f70 | ||
|
|
0c001a6d81 | ||
|
|
7a9ab1c803 | ||
|
|
eb6ba5f15d | ||
|
|
52cde329d7 | ||
|
|
aae2cd6866 | ||
|
|
becdf04acf | ||
|
|
e3c853361d | ||
|
|
385fc839b5 | ||
|
|
5d72d36c20 | ||
|
|
1fcd2fffd0 | ||
|
|
7cdc84b45d | ||
|
|
3f317d2559 | ||
|
|
788df59ae1 | ||
|
|
d57188addf | ||
|
|
778f7cedbb | ||
|
|
f71218998f | ||
|
|
d1d6a6b373 | ||
|
|
41de28c15f | ||
|
|
c1bbeeb6ac | ||
|
|
9f3d7df5cd | ||
|
|
a7d6637a81 | ||
|
|
14fa2e32ea | ||
|
|
c08f0dad8b | ||
|
|
43853ef14f | ||
|
|
b831c6c3bd | ||
|
|
1f51d60ed2 | ||
|
|
600a3e2045 | ||
|
|
5458657c8b | ||
|
|
603ee9d6bf | ||
|
|
3405f524df | ||
|
|
1fbbef41a7 | ||
|
|
eef04075a5 | ||
|
|
7880bb4abe | ||
|
|
ac0c6aa729 | ||
|
|
691e6c1afb | ||
|
|
09559c78af | ||
|
|
3d6ea5cf7c | ||
|
|
0a7a606541 | ||
|
|
61cc6c8d26 | ||
|
|
5e0db07ef3 | ||
|
|
d188d67c5a | ||
|
|
bd034c11b6 | ||
|
|
0ec867b185 | ||
|
|
c29b077e93 | ||
|
|
d8a42b4c3a | ||
|
|
7879476739 | ||
|
|
fd40e2b7bc | ||
|
|
aefe5e0848 | ||
|
|
fd7bfd845e | ||
|
|
01ca369388 | ||
|
|
15ef29ecea | ||
|
|
b19162ce91 | ||
|
|
7c31b210bd | ||
|
|
a63c214d8d | ||
|
|
c9ada8f41d | ||
|
|
06fac716d1 | ||
|
|
c462bc30e1 | ||
|
|
ad00e54df8 | ||
|
|
ca4543b227 | ||
|
|
ddca307001 | ||
|
|
dd651eb324 | ||
|
|
6ea7347ae1 | ||
|
|
b4810aa4cd | ||
|
|
8a99076a21 | ||
|
|
432bbcb4ac | ||
|
|
0f006a737f | ||
|
|
73d9a535bc | ||
|
|
da5eddaa6a | ||
|
|
d2362d4ddd | ||
|
|
18e41b3064 | ||
|
|
148dff996c | ||
|
|
20d12c4d7c | ||
|
|
f25389a638 | ||
|
|
a10e9646e6 | ||
|
|
8a697bb7d2 | ||
|
|
834eca8461 | ||
|
|
b5347b1801 | ||
|
|
939d9d4463 | ||
|
|
56aee7e96e | ||
|
|
49ab0d425d | ||
|
|
9227b00d1a | ||
|
|
a736bb3b21 | ||
|
|
ecbc0f64d6 | ||
|
|
a522a74199 | ||
|
|
bee4094b84 | ||
|
|
e3e909a023 | ||
|
|
d91d341bbf | ||
|
|
a3d85a7454 | ||
|
|
a5a5b0c3a4 | ||
|
|
50e7204a4f | ||
|
|
0c60b8710e | ||
|
|
bb92930116 | ||
|
|
c1483d4c99 | ||
|
|
aeedd45bb6 | ||
|
|
861cb6efc6 | ||
|
|
a8f4b47803 | ||
|
|
437d769527 | ||
|
|
8dfed49dcf | ||
|
|
794a0a1b14 | ||
|
|
86bd650213 | ||
|
|
c4cb462a5e | ||
|
|
3aecc4fd5b | ||
|
|
7c550af923 | ||
|
|
6588a0eede | ||
|
|
7b219158e1 | ||
|
|
1c7ab0e1ea | ||
|
|
148aa30915 | ||
|
|
781d9a0355 | ||
|
|
6a5c6817d0 | ||
|
|
3d3a292284 | ||
|
|
5bf9547e55 | ||
|
|
45078bb632 | ||
|
|
87060410b5 | ||
|
|
0bc898c999 | ||
|
|
94e188c6c0 | ||
|
|
8a74b3d736 | ||
|
|
897d93b9ab | ||
|
|
f7b0f692d9 | ||
|
|
80c0b84785 | ||
|
|
dc685084d1 | ||
|
|
763c767286 | ||
|
|
01302cf25e | ||
|
|
6dee9260c1 | ||
|
|
8f1847e38b | ||
|
|
176e0b4961 | ||
|
|
de9be5fcf4 | ||
|
|
b46db36a1f | ||
|
|
8dd9287eaf | ||
|
|
ab784515c0 | ||
|
|
337c8c1ee2 | ||
|
|
b46e637a64 | ||
|
|
b2d8cdb43f | ||
|
|
23ae01d34d | ||
|
|
306c496489 | ||
|
|
13e57eb2ae | ||
|
|
c4ecdc9175 | ||
|
|
2e99ee43ce | ||
|
|
4c7c457839 | ||
|
|
9b84df6774 | ||
|
|
9d010f8996 | ||
|
|
21b7ca1a0a | ||
|
|
26578ed55d | ||
|
|
1b6369264b | ||
|
|
7c0033397b | ||
|
|
49a75a08aa | ||
|
|
4dad18e45f | ||
|
|
0016333972 | ||
|
|
b65291bb01 | ||
|
|
dac8a08fd2 | ||
|
|
c18808503c | ||
|
|
06563feffc | ||
|
|
468a529f94 | ||
|
|
0c568a327f | ||
|
|
2e9db77b00 | ||
|
|
c85917e378 | ||
|
|
d2d9810afd | ||
|
|
db13d43f99 | ||
|
|
1acc64c074 | ||
|
|
32c4cd40d3 | ||
|
|
abf02ddbac | ||
|
|
552cfcf805 | ||
|
|
4198ad73de | ||
|
|
b6a49e3b11 | ||
|
|
e716624a3f | ||
|
|
6a8825ecb7 | ||
|
|
e171866226 | ||
|
|
c98616234f | ||
|
|
4fa9f8967b | ||
|
|
5ea42b6c15 | ||
|
|
d0bc6610b1 | ||
|
|
995769de27 | ||
|
|
aeb4f8ed9a | ||
|
|
44e1bef29b | ||
|
|
b472b44c5b | ||
|
|
227b762740 | ||
|
|
c0765eeb92 | ||
|
|
da1b727788 | ||
|
|
2875a857a5 | ||
|
|
81952acb84 | ||
|
|
33fd901552 | ||
|
|
394ae44401 | ||
|
|
5e3aaca8d8 | ||
|
|
1647ee023a | ||
|
|
a95451d12c | ||
|
|
c6c1caa420 | ||
|
|
14b2f3a9f6 | ||
|
|
022fe6af3a | ||
|
|
ed827c279a | ||
|
|
aede99b709 | ||
|
|
281fa9ebdd | ||
|
|
b7c2a423c8 | ||
|
|
a39e841af2 | ||
|
|
00384abe9c | ||
|
|
4b1b107f44 | ||
|
|
4175bd3a5e | ||
|
|
15aeb5c922 | ||
|
|
168f8d85ce | ||
|
|
5fc42d3850 | ||
|
|
64d7d16ea2 | ||
|
|
fa9de43123 | ||
|
|
87618181ab | ||
|
|
03cf9dbe79 | ||
|
|
4afc621d10 | ||
|
|
4f1d7fbd5f | ||
|
|
c5b7116992 | ||
|
|
b08610196c | ||
|
|
3ad070ea18 | ||
|
|
94bc49a0b3 | ||
|
|
9269593c46 | ||
|
|
baa19b5c4c | ||
|
|
4fc48d3259 | ||
|
|
03c0f4649f | ||
|
|
0280fc0f59 | ||
|
|
d0b48c90a6 | ||
|
|
e90ec0b27c | ||
|
|
fc66171a09 | ||
|
|
769f7f45ee | ||
|
|
ca89e8e4f9 | ||
|
|
d7dda228b6 | ||
|
|
28136a656f | ||
|
|
4502ca5543 | ||
|
|
b4decf9124 | ||
|
|
c5d12a49f4 | ||
|
|
dcab31b30c | ||
|
|
c917d643d2 | ||
|
|
8c2ca8656b | ||
|
|
9a22d51996 | ||
|
|
d95352f467 | ||
|
|
8dbfffc383 | ||
|
|
1606ce357e | ||
|
|
096d27f107 | ||
|
|
8cc03a973f | ||
|
|
f4c4f408e2 | ||
|
|
a65c7171c1 | ||
|
|
d14c4fa606 | ||
|
|
7e4c915b0b | ||
|
|
a5a15963b8 | ||
|
|
88515fc571 | ||
|
|
b20e8ae528 | ||
|
|
dcbbe9a9a6 | ||
|
|
61cabaa356 | ||
|
|
30f0df5a10 | ||
|
|
37562c06ec | ||
|
|
478fc2c274 |
24
.github/DISCUSSION_TEMPLATE/q-a.yml
vendored
@ -1,24 +0,0 @@
|
|||||||
title: 'Q&A'
|
|
||||||
body:
|
|
||||||
- type: input
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
attributes:
|
|
||||||
label: shlink-web-client version
|
|
||||||
placeholder: x.y.z
|
|
||||||
- type: dropdown
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
attributes:
|
|
||||||
label: How do you use shlink-web-client
|
|
||||||
options:
|
|
||||||
- https://app.shlink.io
|
|
||||||
- Docker image
|
|
||||||
- Self-hosted
|
|
||||||
- Other (explain in summary)
|
|
||||||
- type: textarea
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
attributes:
|
|
||||||
label: Summary
|
|
||||||
value: '<!-- Describe your issue, question or request here. -->'
|
|
||||||
7
.github/ISSUE_TEMPLATE.md
vendored
@ -1,7 +0,0 @@
|
|||||||
<!--
|
|
||||||
Before opening an issue, just take into account that this is a completely free of charge and open source project.
|
|
||||||
I'm always happy to help and provide support, but some understanding will be expected.
|
|
||||||
I do this in my own free time, so expect some delays when implementing new features and fixing bugs, and don't take it personal if an issue gets eventually closed.
|
|
||||||
You may also be asked to provide tests or ways to reproduce reported bugs.
|
|
||||||
Try to be polite, and understand it is impossible for an OSS project to cover all use cases.
|
|
||||||
-->
|
|
||||||
2
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -2,4 +2,4 @@ blank_issues_enabled: true
|
|||||||
contact_links:
|
contact_links:
|
||||||
- name: Question - Support
|
- name: Question - Support
|
||||||
about: Do you need help setting up or using shlink-web-client?
|
about: Do you need help setting up or using shlink-web-client?
|
||||||
url: https://github.com/shlinkio/shlink-web-client/discussions/new?category=q-a
|
url: https://github.com/orgs/shlinkio/discussions/new?category=help-wanted
|
||||||
|
|||||||
15
.github/dependabot.yml
vendored
@ -21,9 +21,12 @@ updates:
|
|||||||
shlink:
|
shlink:
|
||||||
patterns:
|
patterns:
|
||||||
- '@shlinkio/*'
|
- '@shlinkio/*'
|
||||||
types:
|
react:
|
||||||
patterns:
|
patterns:
|
||||||
- '@types/*'
|
- 'react'
|
||||||
|
- 'react-dom'
|
||||||
|
- '@types/react'
|
||||||
|
- '@types/react-dom'
|
||||||
testing:
|
testing:
|
||||||
patterns:
|
patterns:
|
||||||
- '@testing-library/*'
|
- '@testing-library/*'
|
||||||
@ -38,10 +41,10 @@ updates:
|
|||||||
workbox:
|
workbox:
|
||||||
patterns:
|
patterns:
|
||||||
- 'workbox*'
|
- 'workbox*'
|
||||||
ignore:
|
tailwindcss:
|
||||||
# Bootstrap can introduce visual breaking changes on styles
|
patterns:
|
||||||
# Ignore it, since the plan is to remove it anyway
|
- 'tailwindcss'
|
||||||
- dependency-name: 'bootstrap'
|
- '@tailwindcss/*'
|
||||||
- package-ecosystem: docker
|
- package-ecosystem: docker
|
||||||
directory: '/'
|
directory: '/'
|
||||||
schedule:
|
schedule:
|
||||||
|
|||||||
1
.github/workflows/ci.yml
vendored
@ -13,3 +13,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 22.x
|
node-version: 22.x
|
||||||
publish-coverage: true
|
publish-coverage: true
|
||||||
|
install-playwright: true
|
||||||
|
|||||||
4
.github/workflows/deploy-preview.yml
vendored
@ -5,7 +5,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@ -16,7 +16,7 @@ jobs:
|
|||||||
- name: Use node.js
|
- name: Use node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 22.x
|
node-version: 22.10
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
npm ci && \
|
npm ci && \
|
||||||
|
|||||||
4
.github/workflows/publish-release.yml
vendored
@ -7,14 +7,14 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Use node.js
|
- name: Use node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 22.x
|
node-version: 22.10
|
||||||
- name: Generate release assets
|
- name: Generate release assets
|
||||||
run: npm ci && VERSION=${GITHUB_REF#refs/tags/v} npm run build:dist
|
run: npm ci && VERSION=${GITHUB_REF#refs/tags/v} npm run build:dist
|
||||||
- name: Publish release with assets
|
- name: Publish release with assets
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"@shlinkio/stylelint-config-css-coding-standard"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
143
CHANGELOG.md
@ -4,6 +4,147 @@ 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).
|
||||||
|
|
||||||
|
## [4.6.2] - 2025-11-15
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [shlink-web-component#878](https://github.com/shlinkio/shlink-web-component/issues/878) Fix real-time updates interval setting being ignored.
|
||||||
|
|
||||||
|
|
||||||
|
## [4.6.1] - 2025-11-15
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* [#802](https://github.com/shlinkio/shlink-web-client/issues/802) Improve dependency injection in components.
|
||||||
|
* Stop injecting redux state and actions.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* Fix small UI issues.
|
||||||
|
|
||||||
|
|
||||||
|
## [4.6.0] - 2025-11-12
|
||||||
|
### Added
|
||||||
|
* [shlink-web-component#839](https://github.com/shlinkio/shlink-web-component/issues/839) Allow filtering short URLs by excluded tags when using Shlink >=4.6.0
|
||||||
|
* [shlink-web-component#838](https://github.com/shlinkio/shlink-web-component/issues/838) Allow filtering tag, orphan and non-orphan visits by domain, when using Shlink >=4.6.0
|
||||||
|
* [shlink-web-component#784](https://github.com/shlinkio/shlink-web-component/issues/784) Add optional `long-url` query parameter to short URL creation to prefill the long URL programmatically.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* Drop support for Shlink older than 4.0.0
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
|
||||||
|
## [4.5.1] - 2025-08-13
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [#1637](https://github.com/shlinkio/shlink-web-client/issues/1637) Fix brand color used in PWA
|
||||||
|
* [#1636](https://github.com/shlinkio/shlink-web-client/issues/1636) Make sure sidebar toggle is rendered only in sections where the sidebar exists.
|
||||||
|
|
||||||
|
|
||||||
|
## [4.5.0] - 2025-08-08
|
||||||
|
### Added
|
||||||
|
* [shlink-web-component#755](https://github.com/shlinkio/shlink-web-component/issues/755) Add support for `any-value-query-param` and `valueless-query-param` redirect conditions when using Shlink >=4.5.0.
|
||||||
|
* [shlink-web-component#756](https://github.com/shlinkio/shlink-web-component/issues/756) Add support for desktop device types on device redirect conditions, when using Shlink >=4.5.0.
|
||||||
|
* [shlink-web-component#713](https://github.com/shlinkio/shlink-web-component/issues/713) Expose a new `ShlinkSidebarToggleButton` component that can be used to customize the location of the sidebar toggle, rather than making it assume there's a header bar and position it there.
|
||||||
|
* [shlink-web-component#657](https://github.com/shlinkio/shlink-web-component/issues/657) Allow visits table columns to be customized via settings, and add a new optional "Region" column.
|
||||||
|
|
||||||
|
As a side effect, the "Show user agent" toggle has been removed from the list, as this can now be globally configured in the settings.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* Update to FontAwesome 7
|
||||||
|
* Update to Recharts 3
|
||||||
|
* Update to `@shlinkio/shlink-web-component` 0.16.1
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* [shlink-web-component#698](https://github.com/shlinkio/shlink-web-component/issues/698) Fix line chart selection triggering after clicking a dot in the chart. It now works only when dragging while the mouse is clicked.
|
||||||
|
|
||||||
|
|
||||||
|
## [4.4.1] - 2025-06-23
|
||||||
|
### Added
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* [shlink-web-component#661](https://github.com/shlinkio/shlink-web-component/issues/661) and [#1571](https://github.com/shlinkio/shlink-web-client/issues/1571) Fully replace bootstrap with tailwind.
|
||||||
|
* Add the new light theme brand color.
|
||||||
|
* Update to `@shlinkio/shlink-frontend-kit` 1.0.0 and `@shlinkio/shlink-web-component` 0.15
|
||||||
|
* Replace reactstrap nav bar with `NavBar` component from `@shlinkio/shlink-frontend-kit`
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
|
||||||
|
## [4.4.0] - 2025-04-20
|
||||||
|
### Added
|
||||||
|
* [#1510](https://github.com/shlinkio/shlink-web-client/issues/1510) Existing HTTP credentials (cookies, TLS certs, authentication headers) can now be forwarded to the API server if appropriate [CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Access-Control-Allow-Credentials) are set
|
||||||
|
* [shlink-web-component#637](https://github.com/shlinkio/shlink-web-component/pull/637) QR codes are now generated client-side, without hitting Shlink.
|
||||||
|
* [shlink-web-component#641](https://github.com/shlinkio/shlink-web-component/issues/641) It is now possible to provide any logo to be used with QR codes.
|
||||||
|
* [shlink-web-component#640](https://github.com/shlinkio/shlink-web-component/issues/640) Allow default QR code settings to be handled via app settings.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* Update to `react-router` 7.0
|
||||||
|
* Update to `@shlinkio/shlink-frontend-kit` 0.8.x
|
||||||
|
* Update to `@shlinkio/shlink-web-component` 0.13.x
|
||||||
|
* Update to `@shlinkio/shlink-js-sdk` 2.0.0
|
||||||
|
* Add `eslint-plugin-react-compiler`
|
||||||
|
* Run unit tests in a headless browser using vitest browser mode and playwright.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* *Nothing*
|
||||||
|
|
||||||
|
|
||||||
## [4.3.0] - 2024-11-30
|
## [4.3.0] - 2024-11-30
|
||||||
### Added
|
### Added
|
||||||
* [#1360](https://github.com/shlinkio/shlink-web-client/issues/1360) Added ability for server IDs to be generated based on the server name and URL, instead of generating a random UUID.
|
* [#1360](https://github.com/shlinkio/shlink-web-client/issues/1360) Added ability for server IDs to be generated based on the server name and URL, instead of generating a random UUID.
|
||||||
@ -298,7 +439,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
* [#774](https://github.com/shlinkio/shlink-web-client/issues/774) Dropped support for Shlink older than 2.8.0.
|
* [#774](https://github.com/shlinkio/shlink-web-client/issues/774) Dropped support for Shlink older than 2.8.0.
|
||||||
|
|
||||||
### Fixed
|
### 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.
|
* [#715](https://github.com/shlinkio/shlink-web-client/issues/715) Fixed connection still failing on misconfigured servers, after editing their params to set proper values.
|
||||||
|
|
||||||
|
|
||||||
## [3.8.2] - 2022-12-17
|
## [3.8.2] - 2022-12-17
|
||||||
|
|||||||
@ -45,11 +45,8 @@ shlink-web-client
|
|||||||
|
|
||||||
> Note: The `indocker` shell script is a helper used to run commands inside the docker container.
|
> Note: The `indocker` shell script is a helper used to run commands inside the docker container.
|
||||||
|
|
||||||
* `./indocker node --run lint`: Checks coding styles are fulfilled, both in JS/TS files and in stylesheets.
|
* `./indocker node --run lint`: Checks coding styles are fulfilled in JS/TS files.
|
||||||
* `./indocker node --run lint:js`: Checks coding styles are fulfilled in JS/TS files.
|
* `./indocker node --run lint:fix`: Fixes coding styles in JS/TS files.
|
||||||
* `./indocker node --run lint:css`: Checks coding styles are fulfilled in stylesheets.
|
|
||||||
* `./indocker node --run lint:js:fix`: Fixes coding styles in JS/TS files.
|
|
||||||
* `./indocker node --run lint:css:fix`: Fixes coding styles in stylesheets.
|
|
||||||
* `./indocker node --run test`: Runs unit tests with Jest.
|
* `./indocker node --run test`: Runs unit tests with Jest.
|
||||||
|
|
||||||
## Building the project
|
## Building the project
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
FROM node:23.3-alpine AS node
|
FROM node:25.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 && node --run build
|
RUN cd /shlink-web-client && npm ci && node --run build
|
||||||
|
|
||||||
FROM nginxinc/nginx-unprivileged:1.27-alpine
|
FROM nginxinc/nginx-unprivileged:1.29-alpine
|
||||||
ARG UID=101
|
ARG UID=101
|
||||||
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
|
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
|
||||||
|
|
||||||
|
|||||||
@ -1,24 +1,9 @@
|
|||||||
import '@testing-library/jest-dom/vitest';
|
import '@testing-library/jest-dom/vitest';
|
||||||
import { cleanup } from '@testing-library/react';
|
import { cleanup } from '@testing-library/react';
|
||||||
import axe from 'axe-core';
|
|
||||||
import { afterEach } from 'vitest';
|
import { afterEach } from 'vitest';
|
||||||
|
|
||||||
axe.configure({
|
|
||||||
checks: [
|
|
||||||
{
|
|
||||||
// Disable color contrast checking, as it doesn't work in jsdom
|
|
||||||
id: 'color-contrast',
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
// Clear all mocks and cleanup DOM after every test
|
// Clear all mocks and cleanup DOM after every test
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
cleanup();
|
cleanup();
|
||||||
});
|
});
|
||||||
|
|
||||||
HTMLCanvasElement.prototype.getContext = (() => {}) as any;
|
|
||||||
(global as any).scrollTo = () => {};
|
|
||||||
(global as any).matchMedia = () => ({ matches: false });
|
|
||||||
|
|||||||
15
dev.Dockerfile
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
FROM mcr.microsoft.com/playwright:v1.57.0-noble
|
||||||
|
|
||||||
|
ENV NODE_VERSION 22.14
|
||||||
|
ENV TINI_VERSION v0.19.0
|
||||||
|
|
||||||
|
# Install Node.js
|
||||||
|
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash && \
|
||||||
|
\. "$HOME/.nvm/nvm.sh" && \
|
||||||
|
nvm install ${NODE_VERSION}
|
||||||
|
|
||||||
|
# Install tini
|
||||||
|
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini
|
||||||
|
RUN chmod +x /sbin/tini
|
||||||
|
# Set tini as the entry point, as node does not properly handle signals
|
||||||
|
ENTRYPOINT ["/sbin/tini", "--"]
|
||||||
@ -2,8 +2,11 @@ services:
|
|||||||
shlink_web_client_node:
|
shlink_web_client_node:
|
||||||
container_name: shlink_web_client_node
|
container_name: shlink_web_client_node
|
||||||
user: 1000:1000 # With this, files created via `indocker` script will belong to the host user
|
user: 1000:1000 # With this, files created via `indocker` script will belong to the host user
|
||||||
image: node:22.10-alpine
|
build:
|
||||||
command: /bin/sh -c "cd /home/shlink/www && npm install && npm run start"
|
context: .
|
||||||
|
dockerfile: ./dev.Dockerfile
|
||||||
|
working_dir: /home/shlink/www
|
||||||
|
command: /bin/sh -c "npm install && npm run start"
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/home/shlink/www
|
- ./:/home/shlink/www
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||||
<meta name="theme-color" content="#4696e5">
|
<meta name="theme-color" content="#2078CF" media="(prefers-color-scheme: light)">
|
||||||
|
<meta name="theme-color" content="#0B2D4E" media="(prefers-color-scheme: dark)">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
manifest.json provides metadata used when your web app is added to the
|
manifest.json provides metadata used when your web app is added to the
|
||||||
@ -84,7 +85,7 @@
|
|||||||
<noscript>
|
<noscript>
|
||||||
You need to enable JavaScript to run this app.
|
You need to enable JavaScript to run this app.
|
||||||
</noscript>
|
</noscript>
|
||||||
<div id="root"></div>
|
<div id="root" class="h-full"></div>
|
||||||
<script type="module" src="/src/index.tsx"></script>
|
<script type="module" src="/src/index.tsx"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
|
import { BRAND_COLOR_LM } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { ManifestOptions } from 'vite-plugin-pwa';
|
import type { ManifestOptions } from 'vite-plugin-pwa';
|
||||||
|
|
||||||
export const manifest: Partial<ManifestOptions> = {
|
export const manifest: Partial<ManifestOptions> = {
|
||||||
short_name: 'Shlink',
|
short_name: 'Shlink',
|
||||||
name: 'Shlink',
|
name: 'Shlink Web Client',
|
||||||
start_url: '/',
|
start_url: '/',
|
||||||
display: 'standalone',
|
display: 'standalone',
|
||||||
theme_color: '#4696e5',
|
theme_color: BRAND_COLOR_LM, // Toolbar color
|
||||||
background_color: '#4696e5',
|
background_color: BRAND_COLOR_LM, // Splash screen background color
|
||||||
icons: [
|
icons: [
|
||||||
{
|
{
|
||||||
src: './icons/icon-16x16.png',
|
src: './icons/icon-16x16.png',
|
||||||
|
|||||||
16492
package-lock.json
generated
105
package.json
@ -7,12 +7,8 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "node --run lint:css && node --run lint:js",
|
"lint": "eslint src test config/test *.config.{js,ts}",
|
||||||
"lint:css": "stylelint src/*.scss src/**/*.scss",
|
"lint:fix": "node --run lint -- --fix",
|
||||||
"lint:js": "eslint src test config/test",
|
|
||||||
"lint:fix": "node --run lint:css:fix && node --run lint:js:fix",
|
|
||||||
"lint:css:fix": "node --run lint:css -- --fix",
|
|
||||||
"lint:js:fix": "node --run lint:js -- --fix",
|
|
||||||
"types": "tsc",
|
"types": "tsc",
|
||||||
"start": "vite serve --host=0.0.0.0",
|
"start": "vite serve --host=0.0.0.0",
|
||||||
"preview": "vite preview --host=0.0.0.0",
|
"preview": "vite preview --host=0.0.0.0",
|
||||||
@ -24,67 +20,68 @@
|
|||||||
"test:verbose": "node --run test -- --verbose"
|
"test:verbose": "node --run test -- --verbose"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^6.7.1",
|
"@fortawesome/fontawesome-free": "^7.1.0",
|
||||||
"@fortawesome/fontawesome-svg-core": "^6.7.1",
|
"@fortawesome/fontawesome-svg-core": "^7.1.0",
|
||||||
"@fortawesome/free-brands-svg-icons": "^6.7.1",
|
"@fortawesome/free-brands-svg-icons": "^7.1.0",
|
||||||
"@fortawesome/free-regular-svg-icons": "^6.7.1",
|
"@fortawesome/free-regular-svg-icons": "^7.1.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^6.7.1",
|
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
||||||
"@fortawesome/react-fontawesome": "^0.2.2",
|
"@fortawesome/react-fontawesome": "^3.1.1",
|
||||||
"@json2csv/plainjs": "^7.0.6",
|
"@json2csv/plainjs": "^7.0.6",
|
||||||
"@reduxjs/toolkit": "^2.4.0",
|
"@reduxjs/toolkit": "^2.11.1",
|
||||||
"@shlinkio/data-manipulation": "^1.0.3",
|
"@shlinkio/data-manipulation": "^1.0.4",
|
||||||
"@shlinkio/shlink-frontend-kit": "^0.6.0",
|
"@shlinkio/shlink-frontend-kit": "^1.4.0",
|
||||||
"@shlinkio/shlink-js-sdk": "^1.3.0",
|
"@shlinkio/shlink-js-sdk": "^3.0.1",
|
||||||
"@shlinkio/shlink-web-component": "^0.11.0",
|
"@shlinkio/shlink-web-component": "^0.17.1",
|
||||||
"bootstrap": "5.2.3",
|
"@vitest/browser-playwright": "^4.0.15",
|
||||||
"bottlejs": "^2.0.1",
|
"bottlejs": "^2.0.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"compare-versions": "^6.1.1",
|
"compare-versions": "^6.1.1",
|
||||||
"csvtojson": "^2.0.10",
|
"csvtojson": "^2.0.14",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"react": "^18.3.1",
|
"react": "^19.2.3",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^19.2.3",
|
||||||
"react-external-link": "^2.3.1",
|
"react-external-link": "^2.6.1",
|
||||||
"react-redux": "^9.1.2",
|
"react-redux": "^9.2.0",
|
||||||
"react-router-dom": "^6.28.0",
|
"react-router": "^7.10.1",
|
||||||
"reactstrap": "^9.2.3",
|
|
||||||
"redux-localstorage-simple": "^2.5.1",
|
"redux-localstorage-simple": "^2.5.1",
|
||||||
"workbox-core": "^7.3.0",
|
"workbox-core": "^7.4.0",
|
||||||
"workbox-expiration": "^7.3.0",
|
"workbox-expiration": "^7.4.0",
|
||||||
"workbox-precaching": "^7.3.0",
|
"workbox-precaching": "^7.4.0",
|
||||||
"workbox-routing": "^7.3.0",
|
"workbox-routing": "^7.4.0",
|
||||||
"workbox-strategies": "^7.3.0"
|
"workbox-strategies": "^7.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@shlinkio/eslint-config-js-coding-standard": "~3.2.1",
|
"@shlinkio/eslint-config-js-coding-standard": "~3.7.0",
|
||||||
"@shlinkio/stylelint-config-css-coding-standard": "~1.1.1",
|
"@stylistic/eslint-plugin": "^5.6.1",
|
||||||
"@stylistic/eslint-plugin": "^2.11.0",
|
"@tailwindcss/vite": "^4.1.18",
|
||||||
"@testing-library/jest-dom": "^6.6.3",
|
"@testing-library/jest-dom": "^6.9.1",
|
||||||
"@testing-library/react": "^16.0.1",
|
"@testing-library/react": "^16.3.0",
|
||||||
"@testing-library/user-event": "^14.5.2",
|
"@testing-library/user-event": "^14.6.1",
|
||||||
"@total-typescript/shoehorn": "^0.1.2",
|
"@total-typescript/shoehorn": "^0.1.2",
|
||||||
"@types/react": "^18.3.12",
|
"@types/node": "^25.0.1",
|
||||||
"@types/react-dom": "^18.3.1",
|
"@types/react": "^19.2.7",
|
||||||
"@types/uuid": "^10.0.0",
|
"@types/react-dom": "^19.2.3",
|
||||||
"@vitejs/plugin-react": "^4.3.4",
|
"@vitejs/plugin-react": "^5.1.2",
|
||||||
"@vitest/coverage-v8": "^2.1.6",
|
"@vitest/browser": "^4.0.3",
|
||||||
|
"@vitest/coverage-v8": "^4.0.15",
|
||||||
"adm-zip": "^0.5.16",
|
"adm-zip": "^0.5.16",
|
||||||
"axe-core": "^4.10.2",
|
"axe-core": "^4.11.0",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.6.2",
|
||||||
"eslint": "^9.16.0",
|
"eslint": "^9.39.2",
|
||||||
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.10.2",
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
"eslint-plugin-react": "^7.37.2",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"eslint-plugin-react-hooks": "^5.0.0",
|
"eslint-plugin-react-compiler": "^19.0.0-beta-714736e-20250131",
|
||||||
|
"eslint-plugin-react-hooks": "^7.0.1",
|
||||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||||
"history": "^5.3.0",
|
"history": "^5.3.0",
|
||||||
"jsdom": "^25.0.1",
|
"playwright": "^1.57.0",
|
||||||
"sass": "^1.81.0",
|
"tailwindcss": "^4.1.3",
|
||||||
"stylelint": "^15.11.0",
|
"typescript": "^5.9.3",
|
||||||
"typescript": "^5.7.2",
|
"typescript-eslint": "^8.49.0",
|
||||||
"typescript-eslint": "^8.16.0",
|
"vite": "^7.2.7",
|
||||||
"vite": "^6.0.1",
|
"vite-plugin-pwa": "^1.2.0",
|
||||||
"vite-plugin-pwa": "^0.21.1",
|
"vitest": "^4.0.3"
|
||||||
"vitest": "^2.0.2"
|
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
">0.2%",
|
">0.2%",
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 642 B After Width: | Height: | Size: 662 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 4.4 KiB |
@ -1 +1,8 @@
|
|||||||
<svg width="512pt" height="512pt" viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg"><g fill="#4595e3"><path d=" M 23.71 85.08 C 17.22 49.81 49.44 14.86 85.08 18.12 C 118.83 19.21 145.72 53.33 139.45 86.37 C 155.64 102.30 171.32 118.83 187.87 134.36 C 198.32 111.73 208.84 89.12 219.57 66.62 C 226.05 53.84 243.47 48.74 255.73 56.27 C 263.76 62.10 270.34 69.69 277.25 76.75 C 286.28 86.61 285.72 102.89 276.31 112.31 C 223.38 165.37 170.38 218.37 117.35 271.34 C 107.72 280.99 91.01 281.25 81.11 271.86 C 74.39 264.94 66.82 258.69 61.24 250.77 C 53.72 238.52 58.85 221.07 71.64 214.62 C 94.11 203.87 116.72 193.38 139.33 182.91 C 123.81 166.36 107.30 150.68 91.37 134.49 C 60.20 140.28 27.37 116.78 23.71 85.08 Z" /><path d=" M 205.21 201.23 C 225.32 181.36 260.88 181.11 281.14 200.86 C 299.25 218.75 317.37 236.65 335.10 254.93 C 356.73 278.01 352.01 318.70 326.03 336.56 C 320.07 330.47 313.73 324.65 308.12 318.28 C 323.86 309.39 328.76 286.18 316.63 272.39 C 301.73 256.95 286.30 242.03 271.24 226.75 C 264.49 219.65 256.80 212.00 246.37 211.52 C 224.65 208.64 205.52 233.36 214.49 253.58 C 221.09 266.81 234.22 275.12 243.62 286.24 C 240.43 295.96 238.09 306.13 238.29 316.46 C 225.55 304.29 213.16 291.73 200.89 279.09 C 180.97 257.57 183.10 220.45 205.21 201.23 Z" /><path d=" M 273.90 352.07 C 252.28 328.99 256.98 288.31 282.96 270.46 C 288.93 276.54 295.26 282.36 300.88 288.72 C 285.14 297.62 280.23 320.82 292.38 334.61 C 307.27 350.05 322.70 364.96 337.75 380.25 C 344.51 387.35 352.20 395.00 362.64 395.48 C 384.35 398.37 403.49 373.64 394.51 353.42 C 387.92 340.18 374.78 331.88 365.38 320.76 C 368.56 311.04 370.91 300.86 370.71 290.54 C 383.45 302.70 395.84 315.27 408.11 327.91 C 428.03 349.43 425.90 386.55 403.78 405.77 C 383.68 425.64 348.13 425.89 327.86 406.14 C 309.75 388.25 291.60 370.37 273.90 352.07 Z" /><path d=" M 422.11 403.83 C 431.96 394.07 441.60 384.06 451.66 374.51 C 460.90 383.74 471.89 392.70 474.89 406.11 C 480.16 429.97 484.08 454.13 488.76 478.12 C 490.00 483.41 484.47 488.29 479.35 486.63 C 454.66 481.52 429.55 478.12 405.14 471.84 C 393.17 467.97 385.20 457.75 376.55 449.27 C 386.39 439.49 396.13 429.60 406.06 419.91 C 416.37 433.45 435.74 414.00 422.11 403.83 Z" /></g></svg>
|
<svg width="512pt" height="512pt" viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g fill="#2078CF">
|
||||||
|
<path d=" M 23.71 85.08 C 17.22 49.81 49.44 14.86 85.08 18.12 C 118.83 19.21 145.72 53.33 139.45 86.37 C 155.64 102.30 171.32 118.83 187.87 134.36 C 198.32 111.73 208.84 89.12 219.57 66.62 C 226.05 53.84 243.47 48.74 255.73 56.27 C 263.76 62.10 270.34 69.69 277.25 76.75 C 286.28 86.61 285.72 102.89 276.31 112.31 C 223.38 165.37 170.38 218.37 117.35 271.34 C 107.72 280.99 91.01 281.25 81.11 271.86 C 74.39 264.94 66.82 258.69 61.24 250.77 C 53.72 238.52 58.85 221.07 71.64 214.62 C 94.11 203.87 116.72 193.38 139.33 182.91 C 123.81 166.36 107.30 150.68 91.37 134.49 C 60.20 140.28 27.37 116.78 23.71 85.08 Z"/>
|
||||||
|
<path d=" M 205.21 201.23 C 225.32 181.36 260.88 181.11 281.14 200.86 C 299.25 218.75 317.37 236.65 335.10 254.93 C 356.73 278.01 352.01 318.70 326.03 336.56 C 320.07 330.47 313.73 324.65 308.12 318.28 C 323.86 309.39 328.76 286.18 316.63 272.39 C 301.73 256.95 286.30 242.03 271.24 226.75 C 264.49 219.65 256.80 212.00 246.37 211.52 C 224.65 208.64 205.52 233.36 214.49 253.58 C 221.09 266.81 234.22 275.12 243.62 286.24 C 240.43 295.96 238.09 306.13 238.29 316.46 C 225.55 304.29 213.16 291.73 200.89 279.09 C 180.97 257.57 183.10 220.45 205.21 201.23 Z"/>
|
||||||
|
<path d=" M 273.90 352.07 C 252.28 328.99 256.98 288.31 282.96 270.46 C 288.93 276.54 295.26 282.36 300.88 288.72 C 285.14 297.62 280.23 320.82 292.38 334.61 C 307.27 350.05 322.70 364.96 337.75 380.25 C 344.51 387.35 352.20 395.00 362.64 395.48 C 384.35 398.37 403.49 373.64 394.51 353.42 C 387.92 340.18 374.78 331.88 365.38 320.76 C 368.56 311.04 370.91 300.86 370.71 290.54 C 383.45 302.70 395.84 315.27 408.11 327.91 C 428.03 349.43 425.90 386.55 403.78 405.77 C 383.68 425.64 348.13 425.89 327.86 406.14 C 309.75 388.25 291.60 370.37 273.90 352.07 Z"/>
|
||||||
|
<path d=" M 422.11 403.83 C 431.96 394.07 441.60 384.06 451.66 374.51 C 460.90 383.74 471.89 392.70 474.89 406.11 C 480.16 429.97 484.08 454.13 488.76 478.12 C 490.00 483.41 484.47 488.29 479.35 486.63 C 454.66 481.52 429.55 478.12 405.14 471.84 C 393.17 467.97 385.20 457.75 376.55 449.27 C 386.39 439.49 396.13 429.60 406.06 419.91 C 416.37 433.45 435.74 414.00 422.11 403.83 Z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 319 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 420 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 437 B After Width: | Height: | Size: 509 B |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 466 B After Width: | Height: | Size: 570 B |
|
Before Width: | Height: | Size: 551 B After Width: | Height: | Size: 642 B |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 638 B After Width: | Height: | Size: 799 B |
|
Before Width: | Height: | Size: 684 B After Width: | Height: | Size: 834 B |
|
Before Width: | Height: | Size: 750 B After Width: | Height: | Size: 908 B |
|
Before Width: | Height: | Size: 783 B After Width: | Height: | Size: 973 B |
|
Before Width: | Height: | Size: 984 B After Width: | Height: | Size: 1.1 KiB |
@ -1,23 +1,20 @@
|
|||||||
// 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';
|
|
||||||
|
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import AdmZip from 'adm-zip';
|
import AdmZip from 'adm-zip';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
function zipDist(version) {
|
function zipDist(version) {
|
||||||
const versionFileName = `./dist/shlink-web-client_${version}_dist.zip`;
|
const fileBaseName = `shlink-web-client_${version}_dist`;
|
||||||
|
const versionFileName = `./dist/${fileBaseName}.zip`;
|
||||||
|
|
||||||
console.log(chalk.cyan(`Generating dist file for version ${chalk.bold(version)}...`));
|
console.log(chalk.cyan(`Generating dist file for version ${chalk.bold(version)}...`));
|
||||||
const zip = new AdmZip();
|
const zip = new AdmZip();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (fs.existsSync(versionFileName)) {
|
if (fs.existsSync(versionFileName)) {
|
||||||
fs.unlink(versionFileName);
|
fs.unlinkSync(versionFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
zip.addLocalFolder('./build', `shlink-web-client_${version}_dist`);
|
zip.addLocalFolder('./build', fileBaseName);
|
||||||
zip.writeZip(versionFileName);
|
zip.writeZip(versionFileName);
|
||||||
console.log(chalk.green('Dist file properly generated'));
|
console.log(chalk.green('Dist file properly generated'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -10,7 +10,8 @@ setup_single_shlink_server() {
|
|||||||
[ -n "$SHLINK_SERVER_URL" ] || return 0
|
[ -n "$SHLINK_SERVER_URL" ] || return 0
|
||||||
[ -n "$SHLINK_SERVER_API_KEY" ] || return 0
|
[ -n "$SHLINK_SERVER_API_KEY" ] || return 0
|
||||||
local name="${SHLINK_SERVER_NAME:-Shlink}"
|
local name="${SHLINK_SERVER_NAME:-Shlink}"
|
||||||
echo "[{\"name\":\"${name}\",\"url\":\"${SHLINK_SERVER_URL}\",\"apiKey\":\"${SHLINK_SERVER_API_KEY}\"}]" > /usr/share/nginx/html/servers.json
|
local forwardCredentials="${SHLINK_SERVER_FORWARD_CREDENTIALS:-false}"
|
||||||
|
echo "[{\"name\":\"${name}\",\"url\":\"${SHLINK_SERVER_URL}\",\"apiKey\":\"${SHLINK_SERVER_API_KEY}\",\"forwardCredentials\":${forwardCredentials}}]" > /usr/share/nginx/html/servers.json
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_single_shlink_server
|
setup_single_shlink_server
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
import type { HttpClient } from '@shlinkio/shlink-js-sdk';
|
import type { HttpClient } from '@shlinkio/shlink-js-sdk';
|
||||||
import { ShlinkApiClient } from '@shlinkio/shlink-js-sdk';
|
import { ShlinkApiClient } from '@shlinkio/shlink-js-sdk';
|
||||||
import type { GetState } from '../../container/types';
|
|
||||||
import type { ServerWithId } from '../../servers/data';
|
import type { ServerWithId } from '../../servers/data';
|
||||||
import { hasServerData } from '../../servers/data';
|
import { hasServerData } from '../../servers/data';
|
||||||
|
import type { GetState } from '../../store';
|
||||||
|
|
||||||
const apiClients: Record<string, ShlinkApiClient> = {};
|
const apiClients: Map<string, ShlinkApiClient> = new Map();
|
||||||
|
|
||||||
const isGetState = (getStateOrSelectedServer: GetState | ServerWithId): getStateOrSelectedServer is GetState =>
|
|
||||||
typeof getStateOrSelectedServer === 'function';
|
|
||||||
const getSelectedServerFromState = (getState: GetState): ServerWithId => {
|
const getSelectedServerFromState = (getState: GetState): ServerWithId => {
|
||||||
const { selectedServer } = getState();
|
const { selectedServer } = getState();
|
||||||
if (!hasServerData(selectedServer)) {
|
if (!hasServerData(selectedServer)) {
|
||||||
@ -18,13 +16,22 @@ const getSelectedServerFromState = (getState: GetState): ServerWithId => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const buildShlinkApiClient = (httpClient: HttpClient) => (getStateOrSelectedServer: GetState | ServerWithId) => {
|
export const buildShlinkApiClient = (httpClient: HttpClient) => (getStateOrSelectedServer: GetState | ServerWithId) => {
|
||||||
const { url: baseUrl, apiKey } = isGetState(getStateOrSelectedServer)
|
const { url: baseUrl, apiKey, forwardCredentials } = typeof getStateOrSelectedServer === 'function'
|
||||||
? getSelectedServerFromState(getStateOrSelectedServer)
|
? getSelectedServerFromState(getStateOrSelectedServer)
|
||||||
: getStateOrSelectedServer;
|
: getStateOrSelectedServer;
|
||||||
const serverKey = `${apiKey}_${baseUrl}`;
|
const serverKey = `${apiKey}_${baseUrl}_${forwardCredentials ? 'forward' : 'no-forward'}`;
|
||||||
|
const existingApiClient = apiClients.get(serverKey);
|
||||||
|
|
||||||
const apiClient = apiClients[serverKey] ?? new ShlinkApiClient(httpClient, { apiKey, baseUrl });
|
if (existingApiClient) {
|
||||||
apiClients[serverKey] = apiClient;
|
return existingApiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
const apiClient = new ShlinkApiClient(
|
||||||
|
httpClient,
|
||||||
|
{ apiKey, baseUrl },
|
||||||
|
{ requestCredentials: forwardCredentials ? 'include' : undefined },
|
||||||
|
);
|
||||||
|
apiClients.set(serverKey, apiClient);
|
||||||
|
|
||||||
return apiClient;
|
return apiClient;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
import type Bottle from 'bottlejs';
|
|
||||||
import { buildShlinkApiClient } from './ShlinkApiClientBuilder';
|
|
||||||
|
|
||||||
export const provideServices = (bottle: Bottle) => {
|
|
||||||
bottle.serviceFactory('buildShlinkApiClient', buildShlinkApiClient, 'HttpClient');
|
|
||||||
};
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
@import '../../node_modules/@shlinkio/shlink-frontend-kit/dist/base';
|
|
||||||
|
|
||||||
.app-container {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app {
|
|
||||||
padding-top: $headerHeight;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shlink-wrapper {
|
|
||||||
min-height: 100%;
|
|
||||||
padding-bottom: $footer-height + $footer-margin;
|
|
||||||
margin-bottom: -($footer-height + $footer-margin);
|
|
||||||
}
|
|
||||||
|
|
||||||
.shlink-footer {
|
|
||||||
height: $footer-height;
|
|
||||||
margin-top: $footer-margin;
|
|
||||||
padding: 0;
|
|
||||||
|
|
||||||
@media (min-width: $mdMin) {
|
|
||||||
padding: 0 15px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
125
src/app/App.tsx
@ -1,100 +1,71 @@
|
|||||||
import { changeThemeInMarkup, getSystemPreferredTheme } from '@shlinkio/shlink-frontend-kit';
|
import { changeThemeInMarkup, getSystemPreferredTheme } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { Settings } from '@shlinkio/shlink-web-component/settings';
|
|
||||||
import { clsx } from 'clsx';
|
import { clsx } from 'clsx';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { Route, Routes, useLocation } from 'react-router-dom';
|
import { Route, Routes, useLocation } from 'react-router';
|
||||||
import { AppUpdateBanner } from '../common/AppUpdateBanner';
|
import { AppUpdateBanner } from '../common/AppUpdateBanner';
|
||||||
|
import { Home } from '../common/Home';
|
||||||
|
import { MainHeader } from '../common/MainHeader';
|
||||||
import { NotFound } from '../common/NotFound';
|
import { NotFound } from '../common/NotFound';
|
||||||
import type { FCWithDeps } from '../container/utils';
|
import { ShlinkVersionsContainer } from '../common/ShlinkVersionsContainer';
|
||||||
import { componentFactory, useDependencies } from '../container/utils';
|
import { ShlinkWebComponentContainer } from '../common/ShlinkWebComponentContainer';
|
||||||
import type { ServersMap } from '../servers/data';
|
import { CreateServer } from '../servers/CreateServer';
|
||||||
|
import { EditServer } from '../servers/EditServer';
|
||||||
|
import { ManageServers } from '../servers/ManageServers';
|
||||||
|
import { useLoadRemoteServers } from '../servers/reducers/remoteServers';
|
||||||
|
import { useSettings } from '../settings/reducers/settings';
|
||||||
|
import { Settings } from '../settings/Settings';
|
||||||
import { forceUpdate } from '../utils/helpers/sw';
|
import { forceUpdate } from '../utils/helpers/sw';
|
||||||
import './App.scss';
|
import { useAppUpdated } from './reducers/appUpdates';
|
||||||
|
|
||||||
type AppProps = {
|
export const App: FC = () => {
|
||||||
fetchServers: () => void;
|
const { appUpdated, resetAppUpdate } = useAppUpdated();
|
||||||
servers: ServersMap;
|
|
||||||
settings: Settings;
|
|
||||||
resetAppUpdate: () => void;
|
|
||||||
appUpdated: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type AppDeps = {
|
useLoadRemoteServers();
|
||||||
MainHeader: FC;
|
|
||||||
Home: FC;
|
|
||||||
ShlinkWebComponentContainer: FC;
|
|
||||||
CreateServer: FC;
|
|
||||||
EditServer: FC;
|
|
||||||
Settings: FC;
|
|
||||||
ManageServers: FC;
|
|
||||||
ShlinkVersionsContainer: FC;
|
|
||||||
};
|
|
||||||
|
|
||||||
const App: FCWithDeps<AppProps, AppDeps> = (
|
|
||||||
{ fetchServers, servers, settings, appUpdated, resetAppUpdate },
|
|
||||||
) => {
|
|
||||||
const {
|
|
||||||
MainHeader,
|
|
||||||
Home,
|
|
||||||
ShlinkWebComponentContainer,
|
|
||||||
CreateServer,
|
|
||||||
EditServer,
|
|
||||||
Settings,
|
|
||||||
ManageServers,
|
|
||||||
ShlinkVersionsContainer,
|
|
||||||
} = useDependencies(App);
|
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const initialServers = useRef(servers);
|
|
||||||
const isHome = location.pathname === '/';
|
const isHome = location.pathname === '/';
|
||||||
|
|
||||||
useEffect(() => {
|
const { settings } = useSettings();
|
||||||
// Try to fetch the remote servers if the list is empty during first render.
|
|
||||||
// We use a ref because we don't care if the servers list becomes empty later.
|
|
||||||
if (Object.keys(initialServers.current).length === 0) {
|
|
||||||
fetchServers();
|
|
||||||
}
|
|
||||||
}, [fetchServers]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
changeThemeInMarkup(settings.ui?.theme ?? getSystemPreferredTheme());
|
changeThemeInMarkup(settings.ui?.theme ?? getSystemPreferredTheme());
|
||||||
}, [settings.ui?.theme]);
|
}, [settings.ui?.theme]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container-fluid app-container">
|
<div className="h-full">
|
||||||
<MainHeader />
|
<>
|
||||||
|
<MainHeader />
|
||||||
|
|
||||||
<div className="app">
|
<div className="h-full pt-(--header-height)">
|
||||||
<div className={clsx('shlink-wrapper', { 'd-flex align-items-center pt-3': isHome })}>
|
<div
|
||||||
<Routes>
|
data-testid="shlink-wrapper"
|
||||||
<Route index element={<Home />} />
|
className={clsx(
|
||||||
<Route path="/settings/*" element={<Settings />} />
|
'min-h-full pb-[calc(var(--footer-height)+var(--footer-margin))] -mb-[calc(var(--footer-height)+var(--footer-margin))]',
|
||||||
<Route path="/manage-servers" element={<ManageServers />} />
|
{ 'flex items-center pt-4': isHome },
|
||||||
<Route path="/server/create" element={<CreateServer />} />
|
)}
|
||||||
<Route path="/server/:serverId/edit" element={<EditServer />} />
|
>
|
||||||
<Route path="/server/:serverId/*" element={<ShlinkWebComponentContainer />} />
|
<Routes>
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route index element={<Home />} />
|
||||||
</Routes>
|
<Route path="/settings">
|
||||||
|
{['', '*'].map((path) => <Route key={path} path={path} element={<Settings />} />)}
|
||||||
|
</Route>
|
||||||
|
<Route path="/manage-servers" element={<ManageServers />} />
|
||||||
|
<Route path="/server/create" element={<CreateServer />} />
|
||||||
|
<Route path="/server/:serverId/edit" element={<EditServer />} />
|
||||||
|
<Route path="/server/:serverId">
|
||||||
|
{['', '*'].map((path) => <Route key={path} path={path} element={<ShlinkWebComponentContainer />} />)}
|
||||||
|
</Route>
|
||||||
|
<Route path="*" element={<NotFound />} />
|
||||||
|
</Routes>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="h-(--footer-height) mt-(--footer-margin) md:px-4">
|
||||||
|
<ShlinkVersionsContainer />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
|
||||||
<div className="shlink-footer">
|
<AppUpdateBanner isOpen={appUpdated} onClose={resetAppUpdate} forceUpdate={forceUpdate} />
|
||||||
<ShlinkVersionsContainer />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<AppUpdateBanner isOpen={appUpdated} toggle={resetAppUpdate} forceUpdate={forceUpdate} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AppFactory = componentFactory(App, [
|
|
||||||
'MainHeader',
|
|
||||||
'Home',
|
|
||||||
'ShlinkWebComponentContainer',
|
|
||||||
'CreateServer',
|
|
||||||
'EditServer',
|
|
||||||
'Settings',
|
|
||||||
'ManageServers',
|
|
||||||
'ShlinkVersionsContainer',
|
|
||||||
]);
|
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import { createSlice } from '@reduxjs/toolkit';
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
|
import { useCallback } from 'react';
|
||||||
|
import { useAppDispatch, useAppSelector } from '../../store';
|
||||||
|
|
||||||
const { actions, reducer } = createSlice({
|
const { actions, reducer } = createSlice({
|
||||||
name: 'shlink/appUpdates',
|
name: 'shlink/appUpdates',
|
||||||
@ -12,3 +14,12 @@ const { actions, reducer } = createSlice({
|
|||||||
export const { appUpdateAvailable, resetAppUpdate } = actions;
|
export const { appUpdateAvailable, resetAppUpdate } = actions;
|
||||||
|
|
||||||
export const appUpdatesReducer = reducer;
|
export const appUpdatesReducer = reducer;
|
||||||
|
|
||||||
|
export const useAppUpdated = () => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const appUpdateAvailable = useCallback(() => dispatch(actions.appUpdateAvailable()), [dispatch]);
|
||||||
|
const resetAppUpdate = useCallback(() => dispatch(actions.resetAppUpdate()), [dispatch]);
|
||||||
|
const appUpdated = useAppSelector((state) => state.appUpdated);
|
||||||
|
|
||||||
|
return { appUpdated, appUpdateAvailable, resetAppUpdate };
|
||||||
|
};
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
import type Bottle from 'bottlejs';
|
|
||||||
import type { ConnectDecorator } from '../../container/types';
|
|
||||||
import { AppFactory } from '../App';
|
|
||||||
import { appUpdateAvailable, resetAppUpdate } from '../reducers/appUpdates';
|
|
||||||
|
|
||||||
export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
|
||||||
// Components
|
|
||||||
bottle.factory('App', AppFactory);
|
|
||||||
bottle.decorator('App', connect(['servers', 'settings', 'appUpdated'], ['fetchServers', 'resetAppUpdate']));
|
|
||||||
|
|
||||||
// Actions
|
|
||||||
bottle.serviceFactory('appUpdateAvailable', () => appUpdateAvailable);
|
|
||||||
bottle.serviceFactory('resetAppUpdate', () => resetAppUpdate);
|
|
||||||
};
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
@import '../../node_modules/@shlinkio/shlink-frontend-kit/dist/base';
|
|
||||||
@import '../utils/mixins/horizontal-align';
|
|
||||||
|
|
||||||
.app-update-banner.app-update-banner {
|
|
||||||
@include horizontal-align();
|
|
||||||
|
|
||||||
position: fixed;
|
|
||||||
top: $headerHeight - 25px;
|
|
||||||
padding: 0 4rem 0 0;
|
|
||||||
z-index: 1040;
|
|
||||||
margin: 0;
|
|
||||||
color: var(--text-color);
|
|
||||||
text-align: center;
|
|
||||||
width: 700px;
|
|
||||||
max-width: calc(100% - 30px);
|
|
||||||
box-shadow: 0 0 1rem var(--brand-color);
|
|
||||||
}
|
|
||||||
@ -1,34 +1,46 @@
|
|||||||
import { faSyncAlt as reloadIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faSyncAlt as reloadIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { SimpleCard, useToggle } from '@shlinkio/shlink-frontend-kit';
|
import { Button, Card, CloseButton,useToggle } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { MouseEventHandler } from 'react';
|
import { clsx } from 'clsx';
|
||||||
import { forwardRef, useCallback } from 'react';
|
import type { FC } from 'react';
|
||||||
import { Alert, Button } from 'reactstrap';
|
import { useCallback } from 'react';
|
||||||
import './AppUpdateBanner.scss';
|
|
||||||
|
|
||||||
interface AppUpdateBannerProps {
|
interface AppUpdateBannerProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
toggle: MouseEventHandler<any>;
|
onClose: () => void;
|
||||||
forceUpdate: () => void;
|
forceUpdate: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AppUpdateBanner = forwardRef<HTMLElement, AppUpdateBannerProps>(({ isOpen, toggle, forceUpdate }, ref) => {
|
export const AppUpdateBanner: FC<AppUpdateBannerProps> = ({ isOpen, onClose, forceUpdate }) => {
|
||||||
const [isUpdating,, setUpdating] = useToggle();
|
const { flag: isUpdating, setToTrue: setUpdating } = useToggle();
|
||||||
const update = useCallback(() => {
|
const update = useCallback(() => {
|
||||||
setUpdating();
|
setUpdating();
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
}, [forceUpdate, setUpdating]);
|
}, [forceUpdate, setUpdating]);
|
||||||
|
|
||||||
|
if (!isOpen) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Alert className="app-update-banner" isOpen={isOpen} toggle={toggle} tag={SimpleCard} color="secondary" innerRef={ref}>
|
<Card
|
||||||
<h4 className="mb-4">This app has just been updated!</h4>
|
role="alert"
|
||||||
<p className="mb-0">
|
className={clsx(
|
||||||
|
'w-[700px] max-w-[calc(100%-30px)]',
|
||||||
|
'fixed top-[35px] left-[50%] translate-x-[-50%] z-[1040]',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Card.Header className="flex items-center justify-between">
|
||||||
|
<h5>This app has just been updated!</h5>
|
||||||
|
<CloseButton onClick={onClose} />
|
||||||
|
</Card.Header>
|
||||||
|
<Card.Body className="flex gap-4 items-center justify-between max-md:flex-col">
|
||||||
Restart it to enjoy the new features.
|
Restart it to enjoy the new features.
|
||||||
<Button role="button" disabled={isUpdating} className="ms-2" color="secondary" size="sm" onClick={update}>
|
<Button disabled={isUpdating} variant="secondary" solid onClick={update}>
|
||||||
{!isUpdating && <>Restart now <FontAwesomeIcon icon={reloadIcon} className="ms-1" /></>}
|
{!isUpdating && <>Restart now <FontAwesomeIcon icon={reloadIcon} /></>}
|
||||||
{isUpdating && <>Restarting...</>}
|
{isUpdating && <>Restarting...</>}
|
||||||
</Button>
|
</Button>
|
||||||
</p>
|
</Card.Body>
|
||||||
</Alert>
|
</Card>
|
||||||
);
|
);
|
||||||
});
|
};
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { SimpleCard } from '@shlinkio/shlink-frontend-kit';
|
import { Button } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { PropsWithChildren, ReactNode } from 'react';
|
import type { PropsWithChildren, ReactNode } from 'react';
|
||||||
import { Component } from 'react';
|
import { Component } from 'react';
|
||||||
import { Button } from 'reactstrap';
|
import { ErrorLayout } from './ErrorLayout';
|
||||||
|
|
||||||
type ErrorHandlerProps = PropsWithChildren<{
|
type ErrorHandlerProps = PropsWithChildren<{
|
||||||
location?: typeof window.location;
|
location?: typeof window.location;
|
||||||
@ -33,14 +33,11 @@ export class ErrorHandler extends Component<ErrorHandlerProps, ErrorHandlerState
|
|||||||
|
|
||||||
if (hasError) {
|
if (hasError) {
|
||||||
return (
|
return (
|
||||||
<div className="home">
|
<ErrorLayout title="Oops! This is awkward :S">
|
||||||
<SimpleCard className="p-4">
|
<p>It seems that something went wrong. Try refreshing the page or just click this button.</p>
|
||||||
<h1>Oops! This is awkward :S</h1>
|
<br />
|
||||||
<p>It seems that something went wrong. Try refreshing the page or just click this button.</p>
|
<Button size="lg" onClick={() => location.reload()}>Take me back</Button>
|
||||||
<br />
|
</ErrorLayout>
|
||||||
<Button outline color="primary" onClick={() => location.reload()}>Take me back</Button>
|
|
||||||
</SimpleCard>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
src/common/ErrorLayout.tsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { SimpleCard } from '@shlinkio/shlink-frontend-kit';
|
||||||
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
|
|
||||||
|
export type ErrorLayoutProps = PropsWithChildren<{
|
||||||
|
title: string;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
export const ErrorLayout: FC<ErrorLayoutProps> = ({ children, title }) => (
|
||||||
|
<div className="pt-4">
|
||||||
|
<SimpleCard className="p-4 w-full lg:w-[65%] m-auto">
|
||||||
|
<h2>{title}</h2>
|
||||||
|
{children}
|
||||||
|
</SimpleCard>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
@ -1,15 +0,0 @@
|
|||||||
@import '../../node_modules/@shlinkio/shlink-frontend-kit/dist/base';
|
|
||||||
|
|
||||||
.home__title {
|
|
||||||
font-size: 1.75rem;
|
|
||||||
|
|
||||||
@media (min-width: $mdMin) {
|
|
||||||
font-size: 2.2rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.home__servers-container {
|
|
||||||
@media (min-width: $mdMin) {
|
|
||||||
border-left: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,21 +1,19 @@
|
|||||||
import { faExternalLinkAlt, faPlus } from '@fortawesome/free-solid-svg-icons';
|
import { faExternalLinkAlt, faPlus } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import { Button, Card } from '@shlinkio/shlink-frontend-kit';
|
||||||
import { clsx } from 'clsx';
|
import { clsx } from 'clsx';
|
||||||
|
import type { FC } from 'react';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { ExternalLink } from 'react-external-link';
|
import { ExternalLink } from 'react-external-link';
|
||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router';
|
||||||
import { Card } from 'reactstrap';
|
import { withoutSelectedServer } from '../servers/helpers/withoutSelectedServer';
|
||||||
import type { ServersMap } from '../servers/data';
|
import { useServers } from '../servers/reducers/servers';
|
||||||
import { ServersListGroup } from '../servers/ServersListGroup';
|
import { ServersListGroup } from '../servers/ServersListGroup';
|
||||||
import { ShlinkLogo } from './img/ShlinkLogo';
|
import { ShlinkLogo } from './img/ShlinkLogo';
|
||||||
import './Home.scss';
|
|
||||||
|
|
||||||
interface HomeProps {
|
export const Home: FC = withoutSelectedServer(() => {
|
||||||
servers: ServersMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Home = ({ servers }: HomeProps) => {
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { servers } = useServers();
|
||||||
const serversList = Object.values(servers);
|
const serversList = Object.values(servers);
|
||||||
const hasServers = serversList.length > 0;
|
const hasServers = serversList.length > 0;
|
||||||
|
|
||||||
@ -28,45 +26,45 @@ export const Home = ({ servers }: HomeProps) => {
|
|||||||
}, [serversList, navigate]);
|
}, [serversList, navigate]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-100">
|
<div className="px-3 w-full">
|
||||||
<Card className="mx-auto" style={{ maxWidth: '720px' }}>
|
<Card className="mx-auto max-w-[720px] overflow-hidden">
|
||||||
<div className="d-flex flex-column flex-md-row">
|
<div className="flex flex-col md:flex-row">
|
||||||
<div className="p-4 d-none d-md-flex align-items-center" style={{ width: '40%' }}>
|
<div className="p-6 hidden md:flex items-center w-[40%]">
|
||||||
<div className="w-100">
|
<div className="w-full">
|
||||||
<ShlinkLogo />
|
<ShlinkLogo />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="home__servers-container flex-grow-1">
|
<div className="md:border-l border-lm-border dark:border-dm-border flex-grow">
|
||||||
<h1
|
<h1
|
||||||
className={clsx('home__title p-4 text-center m-0', { 'border-bottom': !hasServers })}
|
className={clsx(
|
||||||
style={{ borderColor: 'var(--border-color) !important' }}
|
'p-4 text-center border-lm-border dark:border-dm-border',
|
||||||
|
{ 'border-b': !hasServers },
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
Welcome!
|
Welcome!
|
||||||
</h1>
|
</h1>
|
||||||
<ServersListGroup embedded servers={serversList}>
|
{hasServers ? <ServersListGroup servers={serversList} /> : (
|
||||||
{!hasServers && (
|
<div className="p-6 text-center flex flex-col gap-12 text-xl">
|
||||||
<div className="p-4 text-center d-flex flex-column gap-5">
|
<p>This application will help you manage your Shlink servers.</p>
|
||||||
<p className="mb-0">This application will help you manage your Shlink servers.</p>
|
<p>
|
||||||
<p className="mb-0">
|
<Button to="/server/create" size="lg" inline>
|
||||||
<Link to="/server/create" className="btn btn-outline-primary btn-lg me-2">
|
<FontAwesomeIcon icon={faPlus} widthAuto /> Add a server
|
||||||
<FontAwesomeIcon icon={faPlus}/> <span className="ms-1">Add a server</span>
|
</Button>
|
||||||
</Link>
|
</p>
|
||||||
</p>
|
<p>
|
||||||
<p className="mb-0">
|
<ExternalLink href="https://shlink.io/documentation">
|
||||||
<ExternalLink href="https://shlink.io/documentation">
|
<small>
|
||||||
<small>
|
<span className="mr-2">Learn more about Shlink</span>
|
||||||
<span className="me-2">Learn more about Shlink</span>
|
<FontAwesomeIcon icon={faExternalLinkAlt} />
|
||||||
<FontAwesomeIcon icon={faExternalLinkAlt}/>
|
</small>
|
||||||
</small>
|
</ExternalLink>
|
||||||
</ExternalLink>
|
</p>
|
||||||
</p>
|
</div>
|
||||||
</div>
|
)}
|
||||||
)}
|
|
||||||
</ServersListGroup>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
@import '../../node_modules/@shlinkio/shlink-frontend-kit/dist/base';
|
|
||||||
|
|
||||||
.main-header.main-header {
|
|
||||||
color: white;
|
|
||||||
background-color: var(--brand-color) !important;
|
|
||||||
|
|
||||||
.navbar-brand {
|
|
||||||
color: inherit !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.main-header__brand-logo {
|
|
||||||
width: 26px;
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.main-header__toggle-icon {
|
|
||||||
width: 20px;
|
|
||||||
transition: transform 300ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
.main-header__toggle-icon--opened {
|
|
||||||
transform: rotate(180deg);
|
|
||||||
}
|
|
||||||
@ -1,54 +1,33 @@
|
|||||||
import { faChevronDown as arrowIcon, faCogs as cogsIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faCogs as cogsIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { useToggle } from '@shlinkio/shlink-frontend-kit';
|
import { NavBar } from '@shlinkio/shlink-frontend-kit';
|
||||||
import { clsx } from 'clsx';
|
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { useEffect } from 'react';
|
import { Link, useLocation } from 'react-router';
|
||||||
import { Link, useLocation } from 'react-router-dom';
|
import { ServersDropdown } from '../servers/ServersDropdown';
|
||||||
import { Collapse, Nav, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
|
|
||||||
import type { FCWithDeps } from '../container/utils';
|
|
||||||
import { componentFactory, useDependencies } from '../container/utils';
|
|
||||||
import { ShlinkLogo } from './img/ShlinkLogo';
|
import { ShlinkLogo } from './img/ShlinkLogo';
|
||||||
import './MainHeader.scss';
|
|
||||||
|
|
||||||
type MainHeaderDeps = {
|
export const MainHeader: FC = () => {
|
||||||
ServersDropdown: FC;
|
const { pathname } = useLocation();
|
||||||
};
|
|
||||||
|
|
||||||
const MainHeader: FCWithDeps<unknown, MainHeaderDeps> = () => {
|
|
||||||
const { ServersDropdown } = useDependencies(MainHeader);
|
|
||||||
const [isNotCollapsed, toggleCollapse, , collapse] = useToggle();
|
|
||||||
const location = useLocation();
|
|
||||||
const { pathname } = location;
|
|
||||||
|
|
||||||
// In mobile devices, collapse the navbar when location changes
|
|
||||||
useEffect(collapse, [location, collapse]);
|
|
||||||
|
|
||||||
const settingsPath = '/settings';
|
const settingsPath = '/settings';
|
||||||
const toggleClass = clsx('main-header__toggle-icon', { 'main-header__toggle-icon--opened': isNotCollapsed });
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar color="primary" dark fixed="top" className="main-header" expand="md">
|
<NavBar
|
||||||
<NavbarBrand tag={Link} to="/">
|
className="[&]:fixed top-0 z-900"
|
||||||
<ShlinkLogo className="main-header__brand-logo" color="white" /> Shlink
|
brand={(
|
||||||
</NavbarBrand>
|
<Link to="/" className="[&]:text-white no-underline flex items-center gap-2">
|
||||||
|
<ShlinkLogo className="w-7" color="white" /> <small className="font-normal">Shlink</small>
|
||||||
<NavbarToggler onClick={toggleCollapse}>
|
</Link>
|
||||||
<FontAwesomeIcon icon={arrowIcon} className={toggleClass} />
|
)}
|
||||||
</NavbarToggler>
|
>
|
||||||
|
<NavBar.MenuItem
|
||||||
<Collapse navbar isOpen={isNotCollapsed}>
|
to={settingsPath}
|
||||||
<Nav navbar className="ms-auto">
|
active={pathname.startsWith(settingsPath)}
|
||||||
<NavItem>
|
className="flex items-center gap-1.5"
|
||||||
<NavLink tag={Link} to={settingsPath} active={pathname.startsWith(settingsPath)}>
|
>
|
||||||
<FontAwesomeIcon icon={cogsIcon} /> Settings
|
<FontAwesomeIcon icon={cogsIcon} /> Settings
|
||||||
</NavLink>
|
</NavBar.MenuItem>
|
||||||
</NavItem>
|
<ServersDropdown />
|
||||||
<ServersDropdown />
|
</NavBar>
|
||||||
</Nav>
|
|
||||||
</Collapse>
|
|
||||||
</Navbar>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MainHeaderFactory = componentFactory(MainHeader, ['ServersDropdown']);
|
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
@import '../../node_modules/@shlinkio/shlink-frontend-kit/dist/base';
|
|
||||||
|
|
||||||
.no-menu-wrapper {
|
|
||||||
padding: 15px 0 0;
|
|
||||||
|
|
||||||
@media (min-width: $mdMin) {
|
|
||||||
padding: 30px 20px 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +1,12 @@
|
|||||||
import { clsx } from 'clsx';
|
import { clsx } from 'clsx';
|
||||||
import type { FC, PropsWithChildren } from 'react';
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
import './NoMenuLayout.scss';
|
|
||||||
|
|
||||||
export type NoMenuLayoutProps = PropsWithChildren & {
|
export type NoMenuLayoutProps = PropsWithChildren & {
|
||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const NoMenuLayout: FC<NoMenuLayoutProps> = ({ children, className }) => (
|
export const NoMenuLayout: FC<NoMenuLayoutProps> = ({ children, className }) => (
|
||||||
<div className={clsx('no-menu-wrapper container-xl', className)}>{children}</div>
|
<div className={clsx('container mx-auto p-5 pt-8 max-md:p-3 max-md:py-4', className)}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,19 +1,16 @@
|
|||||||
import { SimpleCard } from '@shlinkio/shlink-frontend-kit';
|
import { Button } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC, PropsWithChildren } from 'react';
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { ErrorLayout } from './ErrorLayout';
|
||||||
|
|
||||||
type NotFoundProps = PropsWithChildren<{ to?: string }>;
|
type NotFoundProps = PropsWithChildren<{ to?: string }>;
|
||||||
|
|
||||||
export const NotFound: FC<NotFoundProps> = ({ to = '/', children = 'Home' }) => (
|
export const NotFound: FC<NotFoundProps> = ({ to = '/', children = 'Home' }) => (
|
||||||
<div className="home">
|
<ErrorLayout title="Oops! We could not find requested route.">
|
||||||
<SimpleCard className="p-4">
|
<p>
|
||||||
<h2>Oops! We could not find requested route.</h2>
|
Use your browser's back button to navigate to the page you have previously come from, or just press this
|
||||||
<p>
|
button.
|
||||||
Use your browser's back button to navigate to the page you have previously come from, or just press this
|
</p>
|
||||||
button.
|
<br />
|
||||||
</p>
|
<Button inline to={to} size="lg">{children}</Button>
|
||||||
<br />
|
</ErrorLayout>
|
||||||
<Link to={to} className="btn btn-outline-primary btn-lg">{children}</Link>
|
|
||||||
</SimpleCard>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import type { FC, PropsWithChildren } from 'react';
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router';
|
||||||
|
|
||||||
export const ScrollToTop: FC<PropsWithChildren> = ({ children }) => {
|
export const ScrollToTop: FC<PropsWithChildren> = ({ children }) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export interface ShlinkVersionsProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const VersionLink = ({ project, version }: { project: 'shlink' | 'shlink-web-client'; version: string }) => (
|
const VersionLink = ({ project, version }: { project: 'shlink' | 'shlink-web-client'; version: string }) => (
|
||||||
<ExternalLink href={`https://github.com/shlinkio/${project}/releases/${version}`} className="text-muted">
|
<ExternalLink href={`https://github.com/shlinkio/${project}/releases/${version}`} className="text-gray-500">
|
||||||
<b>{version}</b>
|
<b>{version}</b>
|
||||||
</ExternalLink>
|
</ExternalLink>
|
||||||
);
|
);
|
||||||
@ -21,7 +21,7 @@ export const ShlinkVersions = ({ selectedServer, clientVersion = SHLINK_WEB_CLIE
|
|||||||
const normalizedClientVersion = normalizeVersion(clientVersion);
|
const normalizedClientVersion = normalizeVersion(clientVersion);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<small className="text-muted">
|
<small className="text-gray-500">
|
||||||
{isReachableServer(selectedServer) && (
|
{isReachableServer(selectedServer) && (
|
||||||
<>Server: <VersionLink project="shlink" version={selectedServer.printableVersion} /> - </>
|
<>Server: <VersionLink project="shlink" version={selectedServer.printableVersion} /> - </>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
@import '../../node_modules/@shlinkio/shlink-frontend-kit/dist/base';
|
|
||||||
|
|
||||||
.shlink-versions-container--with-sidebar {
|
|
||||||
margin-left: 0;
|
|
||||||
|
|
||||||
@media (min-width: $mdMin) {
|
|
||||||
margin-left: $asideMenuWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,19 +1,15 @@
|
|||||||
import { clsx } from 'clsx';
|
import { clsx } from 'clsx';
|
||||||
import type { SelectedServer } from '../servers/data';
|
|
||||||
import { isReachableServer } from '../servers/data';
|
import { isReachableServer } from '../servers/data';
|
||||||
|
import { useSelectedServer } from '../servers/reducers/selectedServer';
|
||||||
import { ShlinkVersions } from './ShlinkVersions';
|
import { ShlinkVersions } from './ShlinkVersions';
|
||||||
import './ShlinkVersionsContainer.scss';
|
|
||||||
|
|
||||||
export type ShlinkVersionsContainerProps = {
|
export const ShlinkVersionsContainer = () => {
|
||||||
selectedServer: SelectedServer;
|
const { selectedServer } = useSelectedServer();
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={clsx('text-center', { 'md:ml-(--aside-menu-width)': isReachableServer(selectedServer) })}
|
||||||
|
>
|
||||||
|
<ShlinkVersions selectedServer={selectedServer} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ShlinkVersionsContainer = ({ selectedServer }: ShlinkVersionsContainerProps) => (
|
|
||||||
<div
|
|
||||||
className={clsx('text-center', {
|
|
||||||
'shlink-versions-container--with-sidebar': isReachableServer(selectedServer),
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<ShlinkVersions selectedServer={selectedServer} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|||||||
@ -1,40 +1,37 @@
|
|||||||
import type { ShlinkWebComponentType, TagColorsStorage } from '@shlinkio/shlink-web-component';
|
import type { TagColorsStorage } from '@shlinkio/shlink-web-component';
|
||||||
import type { Settings } from '@shlinkio/shlink-web-component/settings';
|
import {
|
||||||
|
ShlinkSidebarToggleButton,
|
||||||
|
ShlinkSidebarVisibilityProvider,
|
||||||
|
ShlinkWebComponent,
|
||||||
|
} from '@shlinkio/shlink-web-component';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import type { ShlinkApiClientBuilder } from '../api/services/ShlinkApiClientBuilder';
|
import type { ShlinkApiClientBuilder } from '../api/services/ShlinkApiClientBuilder';
|
||||||
import type { FCWithDeps } from '../container/utils';
|
import { withDependencies } from '../container/context';
|
||||||
import { componentFactory, useDependencies } from '../container/utils';
|
|
||||||
import { isReachableServer } from '../servers/data';
|
import { isReachableServer } from '../servers/data';
|
||||||
import type { WithSelectedServerProps } from '../servers/helpers/withSelectedServer';
|
import { ServerError } from '../servers/helpers/ServerError';
|
||||||
import { withSelectedServer } from '../servers/helpers/withSelectedServer';
|
import { withSelectedServer } from '../servers/helpers/withSelectedServer';
|
||||||
|
import { useSelectedServer } from '../servers/reducers/selectedServer';
|
||||||
|
import { useSettings } from '../settings/reducers/settings';
|
||||||
import { NotFound } from './NotFound';
|
import { NotFound } from './NotFound';
|
||||||
|
|
||||||
type ShlinkWebComponentContainerProps = WithSelectedServerProps & {
|
export type ShlinkWebComponentContainerProps = {
|
||||||
settings: Settings;
|
TagColorsStorage: TagColorsStorage;
|
||||||
|
buildShlinkApiClient: ShlinkApiClientBuilder;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ShlinkWebComponentContainerDeps = {
|
const ShlinkWebComponentContainerBase: FC<
|
||||||
buildShlinkApiClient: ShlinkApiClientBuilder,
|
ShlinkWebComponentContainerProps
|
||||||
TagColorsStorage: TagColorsStorage,
|
|
||||||
ShlinkWebComponent: ShlinkWebComponentType,
|
|
||||||
ServerError: FC,
|
|
||||||
};
|
|
||||||
|
|
||||||
const ShlinkWebComponentContainer: FCWithDeps<
|
|
||||||
ShlinkWebComponentContainerProps,
|
|
||||||
ShlinkWebComponentContainerDeps
|
|
||||||
// FIXME Using `memo` here to solve a flickering effect in charts.
|
// FIXME Using `memo` here to solve a flickering effect in charts.
|
||||||
// memo is probably not the right solution. The root cause is the withSelectedServer HOC, but I couldn't fix the
|
// memo is probably not the right solution. The root cause is the withSelectedServer HOC, but I couldn't fix the
|
||||||
// extra rendering there.
|
// extra rendering there.
|
||||||
// This should be revisited at some point.
|
// This should be revisited at some point.
|
||||||
> = withSelectedServer(memo(({ selectedServer, settings }) => {
|
> = withSelectedServer(memo(({
|
||||||
const {
|
buildShlinkApiClient,
|
||||||
buildShlinkApiClient,
|
TagColorsStorage: tagColorsStorage,
|
||||||
TagColorsStorage: tagColorsStorage,
|
}) => {
|
||||||
ShlinkWebComponent,
|
const { selectedServer } = useSelectedServer();
|
||||||
ServerError,
|
const { settings } = useSettings();
|
||||||
} = useDependencies(ShlinkWebComponentContainer);
|
|
||||||
|
|
||||||
if (!isReachableServer(selectedServer)) {
|
if (!isReachableServer(selectedServer)) {
|
||||||
return <ServerError />;
|
return <ServerError />;
|
||||||
@ -42,22 +39,24 @@ const ShlinkWebComponentContainer: FCWithDeps<
|
|||||||
|
|
||||||
const routesPrefix = `/server/${selectedServer.id}`;
|
const routesPrefix = `/server/${selectedServer.id}`;
|
||||||
return (
|
return (
|
||||||
<ShlinkWebComponent
|
<ShlinkSidebarVisibilityProvider>
|
||||||
serverVersion={selectedServer.version}
|
<ShlinkSidebarToggleButton className="fixed top-3.5 left-3 z-901" />
|
||||||
apiClient={buildShlinkApiClient(selectedServer)}
|
<ShlinkWebComponent
|
||||||
settings={settings}
|
serverVersion={selectedServer.version}
|
||||||
routesPrefix={routesPrefix}
|
apiClient={buildShlinkApiClient(selectedServer)}
|
||||||
tagColorsStorage={tagColorsStorage}
|
settings={settings}
|
||||||
createNotFound={(nonPrefixedHomePath) => (
|
routesPrefix={routesPrefix}
|
||||||
<NotFound to={`${routesPrefix}${nonPrefixedHomePath}`}>List short URLs</NotFound>
|
tagColorsStorage={tagColorsStorage}
|
||||||
)}
|
createNotFound={(nonPrefixedHomePath: string) => (
|
||||||
/>
|
<NotFound to={`${routesPrefix}${nonPrefixedHomePath}`}>List short URLs</NotFound>
|
||||||
|
)}
|
||||||
|
autoSidebarToggle={false}
|
||||||
|
/>
|
||||||
|
</ShlinkSidebarVisibilityProvider>
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const ShlinkWebComponentContainerFactory = componentFactory(ShlinkWebComponentContainer, [
|
export const ShlinkWebComponentContainer = withDependencies(ShlinkWebComponentContainerBase, [
|
||||||
'buildShlinkApiClient',
|
'buildShlinkApiClient',
|
||||||
'TagColorsStorage',
|
'TagColorsStorage',
|
||||||
'ShlinkWebComponent',
|
|
||||||
'ServerError',
|
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { MAIN_COLOR } from '@shlinkio/shlink-frontend-kit';
|
import { brandColor } from '@shlinkio/shlink-frontend-kit';
|
||||||
|
|
||||||
export interface ShlinkLogoProps {
|
export interface ShlinkLogoProps {
|
||||||
color?: string;
|
color?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ShlinkLogo = ({ color = MAIN_COLOR, className }: ShlinkLogoProps) => (
|
export const ShlinkLogo = ({ color = brandColor(), className }: ShlinkLogoProps) => (
|
||||||
<svg className={className} viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
<svg className={className} viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||||
<g fill={color}>
|
<g fill={color}>
|
||||||
<path
|
<path
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
import { FetchHttpClient } from '@shlinkio/shlink-js-sdk/browser';
|
|
||||||
import { ShlinkWebComponent } from '@shlinkio/shlink-web-component';
|
|
||||||
import type Bottle from 'bottlejs';
|
|
||||||
import type { ConnectDecorator } from '../../container/types';
|
|
||||||
import { withoutSelectedServer } from '../../servers/helpers/withoutSelectedServer';
|
|
||||||
import { ErrorHandler } from '../ErrorHandler';
|
|
||||||
import { Home } from '../Home';
|
|
||||||
import { MainHeaderFactory } from '../MainHeader';
|
|
||||||
import { ScrollToTop } from '../ScrollToTop';
|
|
||||||
import { ShlinkVersionsContainer } from '../ShlinkVersionsContainer';
|
|
||||||
import { ShlinkWebComponentContainerFactory } from '../ShlinkWebComponentContainer';
|
|
||||||
|
|
||||||
export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
|
||||||
// Services
|
|
||||||
bottle.constant('window', window);
|
|
||||||
bottle.constant('console', console);
|
|
||||||
bottle.constant('fetch', window.fetch.bind(window));
|
|
||||||
bottle.service('HttpClient', FetchHttpClient, 'fetch');
|
|
||||||
|
|
||||||
// Components
|
|
||||||
bottle.serviceFactory('ScrollToTop', () => ScrollToTop);
|
|
||||||
|
|
||||||
bottle.factory('MainHeader', MainHeaderFactory);
|
|
||||||
|
|
||||||
bottle.serviceFactory('Home', () => Home);
|
|
||||||
bottle.decorator('Home', withoutSelectedServer);
|
|
||||||
bottle.decorator('Home', connect(['servers'], ['resetSelectedServer']));
|
|
||||||
|
|
||||||
bottle.serviceFactory('ShlinkWebComponent', () => ShlinkWebComponent);
|
|
||||||
bottle.factory('ShlinkWebComponentContainer', ShlinkWebComponentContainerFactory);
|
|
||||||
bottle.decorator('ShlinkWebComponentContainer', connect(['selectedServer', 'settings'], ['selectServer']));
|
|
||||||
|
|
||||||
bottle.serviceFactory('ShlinkVersionsContainer', () => ShlinkVersionsContainer);
|
|
||||||
bottle.decorator('ShlinkVersionsContainer', connect(['selectedServer']));
|
|
||||||
|
|
||||||
bottle.serviceFactory('ErrorHandler', () => ErrorHandler);
|
|
||||||
};
|
|
||||||
63
src/container/context.tsx
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import type { IContainer } from 'bottlejs';
|
||||||
|
import { type ComponentType, createContext, useContext } from 'react';
|
||||||
|
|
||||||
|
const ContainerContext = createContext<IContainer | null>(null);
|
||||||
|
|
||||||
|
export const ContainerProvider = ContainerContext.Provider;
|
||||||
|
|
||||||
|
const useContainer = (wrapperName: string): IContainer => {
|
||||||
|
const container = useContext(ContainerContext);
|
||||||
|
if (!container) {
|
||||||
|
throw new Error(`You cannot use "${wrapperName}" outside of a ContainerProvider`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return container;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook used to extract dependencies from the container in other hooks.
|
||||||
|
*/
|
||||||
|
export const useDependencies = <T extends unknown[]>(...names: string[]): T => {
|
||||||
|
const container = useContainer('useDependencies');
|
||||||
|
|
||||||
|
return names.map((name) => {
|
||||||
|
const dependency = container[name];
|
||||||
|
if (!dependency) {
|
||||||
|
throw new Error(`Dependency with name "${name}" not found in container`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dependency;
|
||||||
|
}) as T;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Optionalize<P, K extends keyof P> = Omit<P, K> & Partial<Pick<P, K>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Higher Order Component used to inject services into components as props.
|
||||||
|
* All dependencies become optional props so that they can still be explicitly set in tests if desired.
|
||||||
|
*/
|
||||||
|
export function withDependencies<
|
||||||
|
Props extends Record<string, unknown>,
|
||||||
|
DependencyName extends string & keyof Props,
|
||||||
|
>(
|
||||||
|
Component: ComponentType<Props>,
|
||||||
|
dependencyNames: DependencyName[],
|
||||||
|
): ComponentType<Optionalize<Props, DependencyName>> {
|
||||||
|
function Wrapper(props: Omit<Props, DependencyName>) {
|
||||||
|
const container = useContext(ContainerContext);
|
||||||
|
|
||||||
|
// Inject services, unless they have been overridden by props passed from
|
||||||
|
// the parent component.
|
||||||
|
const dependencies: Partial<Record<DependencyName, unknown>> = {};
|
||||||
|
for (const dependency of dependencyNames) {
|
||||||
|
if (!(dependency in props)) {
|
||||||
|
dependencies[dependency] = container?.[dependency];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const propsWithServices = { ...dependencies, ...props } as Props;
|
||||||
|
return <Component {...propsWithServices} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Wrapper;
|
||||||
|
}
|
||||||
@ -1,42 +1,32 @@
|
|||||||
import type { IContainer } from 'bottlejs';
|
import { useTimeoutToggle } from '@shlinkio/shlink-frontend-kit';
|
||||||
|
import { FetchHttpClient } from '@shlinkio/shlink-js-sdk/fetch';
|
||||||
import Bottle from 'bottlejs';
|
import Bottle from 'bottlejs';
|
||||||
import { connect as reduxConnect } from 'react-redux';
|
import { buildShlinkApiClient } from '../api/services/ShlinkApiClientBuilder';
|
||||||
import { provideServices as provideApiServices } from '../api/services/provideServices';
|
import { ServersExporter } from '../servers/services/ServersExporter';
|
||||||
import { provideServices as provideAppServices } from '../app/services/provideServices';
|
import { ServersImporter } from '../servers/services/ServersImporter';
|
||||||
import { provideServices as provideCommonServices } from '../common/services/provideServices';
|
import { csvToJson, jsonToCsv } from '../utils/helpers/csvjson';
|
||||||
import { provideServices as provideServersServices } from '../servers/services/provideServices';
|
import { LocalStorage } from '../utils/services/LocalStorage';
|
||||||
import { provideServices as provideSettingsServices } from '../settings/services/provideServices';
|
import { TagColorsStorage } from '../utils/services/TagColorsStorage';
|
||||||
import { provideServices as provideUtilsServices } from '../utils/services/provideServices';
|
|
||||||
import type { ConnectDecorator } from './types';
|
|
||||||
|
|
||||||
type LazyActionMap = Record<string, (...args: unknown[]) => unknown>;
|
|
||||||
|
|
||||||
const bottle = new Bottle();
|
const bottle = new Bottle();
|
||||||
|
|
||||||
export const { container } = bottle;
|
export const { container } = bottle;
|
||||||
|
|
||||||
const lazyService = <T extends (...args: unknown[]) => unknown, K>(cont: IContainer, serviceName: string) =>
|
bottle.constant('window', window);
|
||||||
(...args: any[]) => (cont[serviceName] as T)(...args) as K;
|
bottle.constant('console', console);
|
||||||
|
bottle.constant('fetch', window.fetch.bind(window));
|
||||||
|
bottle.service('HttpClient', FetchHttpClient, 'fetch');
|
||||||
|
|
||||||
const mapActionService = (map: LazyActionMap, actionName: string): LazyActionMap => ({
|
bottle.constant('localStorage', window.localStorage);
|
||||||
...map,
|
bottle.service('Storage', LocalStorage, 'localStorage');
|
||||||
// Wrap actual action service in a function so that it is lazily created the first time it is called
|
bottle.service('TagColorsStorage', TagColorsStorage, 'Storage');
|
||||||
[actionName]: lazyService(container, actionName),
|
|
||||||
});
|
|
||||||
|
|
||||||
const pickProps = (propsToPick: string[]) => (obj: any) => Object.fromEntries(
|
bottle.constant('csvToJson', csvToJson);
|
||||||
propsToPick.map((key) => [key, obj[key]]),
|
bottle.constant('jsonToCsv', jsonToCsv);
|
||||||
);
|
|
||||||
|
|
||||||
const connect: ConnectDecorator = (propsFromState: string[] | null, actionServiceNames: string[] = []) =>
|
bottle.serviceFactory('useTimeoutToggle', () => useTimeoutToggle);
|
||||||
reduxConnect(
|
|
||||||
propsFromState ? pickProps(propsFromState) : null,
|
|
||||||
actionServiceNames.reduce(mapActionService, {}),
|
|
||||||
);
|
|
||||||
|
|
||||||
provideAppServices(bottle, connect);
|
bottle.serviceFactory('buildShlinkApiClient', buildShlinkApiClient, 'HttpClient');
|
||||||
provideCommonServices(bottle, connect);
|
|
||||||
provideApiServices(bottle);
|
bottle.service('ServersImporter', ServersImporter, 'csvToJson');
|
||||||
provideServersServices(bottle, connect);
|
bottle.service('ServersExporter', ServersExporter, 'Storage', 'window', 'jsonToCsv');
|
||||||
provideUtilsServices(bottle);
|
|
||||||
provideSettingsServices(bottle, connect);
|
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
import { configureStore } from '@reduxjs/toolkit';
|
|
||||||
import type { IContainer } from 'bottlejs';
|
|
||||||
import type { RLSOptions } from 'redux-localstorage-simple';
|
|
||||||
import { load, save } from 'redux-localstorage-simple';
|
|
||||||
import { initReducers } from '../reducers';
|
|
||||||
import { migrateDeprecatedSettings } from '../settings/helpers';
|
|
||||||
import type { ShlinkState } from './types';
|
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
|
||||||
const localStorageConfig: RLSOptions = {
|
|
||||||
states: ['settings', 'servers'],
|
|
||||||
namespace: 'shlink',
|
|
||||||
namespaceSeparator: '.',
|
|
||||||
debounce: 300,
|
|
||||||
};
|
|
||||||
const preloadedState = migrateDeprecatedSettings(load(localStorageConfig) as ShlinkState);
|
|
||||||
|
|
||||||
export const setUpStore = (container: IContainer) => configureStore({
|
|
||||||
devTools: !isProduction,
|
|
||||||
reducer: initReducers(container),
|
|
||||||
preloadedState,
|
|
||||||
middleware: (defaultMiddlewaresIncludingReduxThunk) =>
|
|
||||||
defaultMiddlewaresIncludingReduxThunk({ immutableCheck: false, serializableCheck: false }) // State is too big for these
|
|
||||||
.concat(save(localStorageConfig)),
|
|
||||||
});
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
import type { Settings } from '@shlinkio/shlink-web-component/settings';
|
|
||||||
import type { SelectedServer, ServersMap } from '../servers/data';
|
|
||||||
|
|
||||||
export interface ShlinkState {
|
|
||||||
servers: ServersMap;
|
|
||||||
selectedServer: SelectedServer;
|
|
||||||
settings: Settings;
|
|
||||||
appUpdated: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ConnectDecorator = (props: string[] | null, actions?: string[]) => any;
|
|
||||||
|
|
||||||
export type GetState = () => ShlinkState;
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
import type { IContainer } from 'bottlejs';
|
|
||||||
import type { FC } from 'react';
|
|
||||||
import { useRef } from 'react';
|
|
||||||
|
|
||||||
export type FCWithDeps<Props, Deps> = FC<Props> & Partial<Deps>;
|
|
||||||
|
|
||||||
export function useDependencies<Deps>(obj: Deps): Omit<Required<Deps>, keyof FC> {
|
|
||||||
const depsRef = useRef(obj as Omit<Required<Deps>, keyof FC>);
|
|
||||||
return depsRef.current;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function componentFactory<Deps, CompType = Omit<Partial<Deps>, keyof FC>>(
|
|
||||||
Component: CompType,
|
|
||||||
deps: ReadonlyArray<keyof CompType>,
|
|
||||||
) {
|
|
||||||
return (container: IContainer, console = globalThis.console) => {
|
|
||||||
deps.forEach((dep) => {
|
|
||||||
const resolvedDependency = container[dep as string];
|
|
||||||
if (!resolvedDependency && process.env.NODE_ENV !== 'production') {
|
|
||||||
console.error(`[Debug] Could not find "${dep as string}" dependency in container`);
|
|
||||||
}
|
|
||||||
|
|
||||||
Component[dep] = resolvedDependency;
|
|
||||||
});
|
|
||||||
|
|
||||||
return Component;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
@import '../node_modules/@shlinkio/shlink-frontend-kit/dist/base'; // Before bootstrap stylesheet. Includes SASS var overrides
|
|
||||||
@import '../node_modules/bootstrap/scss/bootstrap.scss';
|
|
||||||
@import '../node_modules/@shlinkio/shlink-frontend-kit/dist/index'; // After bootstrap. Includes CSS overwrites
|
|
||||||
@import '../node_modules/@shlinkio/shlink-web-component/dist/index';
|
|
||||||
@ -1,25 +1,31 @@
|
|||||||
import { createRoot } from 'react-dom/client';
|
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';
|
||||||
import pack from '../package.json';
|
import pack from '../package.json';
|
||||||
|
import { App } from './app/App';
|
||||||
|
import { appUpdateAvailable } from './app/reducers/appUpdates';
|
||||||
|
import { ErrorHandler } from './common/ErrorHandler';
|
||||||
|
import { ScrollToTop } from './common/ScrollToTop';
|
||||||
import { container } from './container';
|
import { container } from './container';
|
||||||
import { setUpStore } from './container/store';
|
import { ContainerProvider } from './container/context';
|
||||||
import { register as registerServiceWorker } from './serviceWorkerRegistration';
|
import { register as registerServiceWorker } from './serviceWorkerRegistration';
|
||||||
import './index.scss';
|
import { setUpStore } from './store';
|
||||||
|
import './tailwind.css';
|
||||||
|
|
||||||
const store = setUpStore(container);
|
const store = setUpStore();
|
||||||
const { App, ScrollToTop, ErrorHandler, appUpdateAvailable } = container;
|
|
||||||
|
|
||||||
createRoot(document.getElementById('root')!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
<Provider store={store}>
|
<ContainerProvider value={container}>
|
||||||
<BrowserRouter basename={pack.homepage}>
|
<Provider store={store}>
|
||||||
<ErrorHandler>
|
<BrowserRouter basename={pack.homepage}>
|
||||||
<ScrollToTop>
|
<ErrorHandler>
|
||||||
<App />
|
<ScrollToTop>
|
||||||
</ScrollToTop>
|
<App />
|
||||||
</ErrorHandler>
|
</ScrollToTop>
|
||||||
</BrowserRouter>
|
</ErrorHandler>
|
||||||
</Provider>,
|
</BrowserRouter>
|
||||||
|
</Provider>
|
||||||
|
</ContainerProvider>,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Learn more about service workers: https://cra.link/PWA
|
// Learn more about service workers: https://cra.link/PWA
|
||||||
|
|||||||
@ -1,48 +1,42 @@
|
|||||||
import type { TimeoutToggle } from '@shlinkio/shlink-frontend-kit';
|
import type { ResultProps, TimeoutToggle } from '@shlinkio/shlink-frontend-kit';
|
||||||
import { Result, useToggle } from '@shlinkio/shlink-frontend-kit';
|
import { Button, Result, useToggle } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router';
|
||||||
import { Button } from 'reactstrap';
|
|
||||||
import { NoMenuLayout } from '../common/NoMenuLayout';
|
import { NoMenuLayout } from '../common/NoMenuLayout';
|
||||||
import type { FCWithDeps } from '../container/utils';
|
import { withDependencies } from '../container/context';
|
||||||
import { componentFactory, useDependencies } from '../container/utils';
|
|
||||||
import { useGoBack } from '../utils/helpers/hooks';
|
import { useGoBack } from '../utils/helpers/hooks';
|
||||||
import type { ServerData, ServersMap, ServerWithId } from './data';
|
import type { ServerData } from './data';
|
||||||
import { ensureUniqueIds } from './helpers';
|
import { ensureUniqueIds } from './helpers';
|
||||||
import { DuplicatedServersModal } from './helpers/DuplicatedServersModal';
|
import { DuplicatedServersModal } from './helpers/DuplicatedServersModal';
|
||||||
import type { ImportServersBtnProps } from './helpers/ImportServersBtn';
|
import { ImportServersBtn } from './helpers/ImportServersBtn';
|
||||||
import { ServerForm } from './helpers/ServerForm';
|
import { ServerForm } from './helpers/ServerForm';
|
||||||
|
import { withoutSelectedServer } from './helpers/withoutSelectedServer';
|
||||||
|
import { useServers } from './reducers/servers';
|
||||||
|
|
||||||
const SHOW_IMPORT_MSG_TIME = 4000;
|
const SHOW_IMPORT_MSG_TIME = 4000;
|
||||||
|
|
||||||
type CreateServerProps = {
|
export type CreateServerProps = {
|
||||||
createServers: (servers: ServerWithId[]) => void;
|
|
||||||
servers: ServersMap;
|
|
||||||
};
|
|
||||||
|
|
||||||
type CreateServerDeps = {
|
|
||||||
ImportServersBtn: FC<ImportServersBtnProps>;
|
|
||||||
useTimeoutToggle: TimeoutToggle;
|
useTimeoutToggle: TimeoutToggle;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ImportResult = ({ type }: { type: 'error' | 'success' }) => (
|
const ImportResult = ({ variant }: Pick<ResultProps, 'variant'>) => (
|
||||||
<div className="mt-3">
|
<div className="mt-4">
|
||||||
<Result type={type}>
|
<Result variant={variant}>
|
||||||
{type === 'success' && 'Servers properly imported. You can now select one from the list :)'}
|
{variant === 'success' && 'Servers properly imported. You can now select one from the list :)'}
|
||||||
{type === 'error' && 'The servers could not be imported. Make sure the format is correct.'}
|
{variant === 'error' && 'The servers could not be imported. Make sure the format is correct.'}
|
||||||
</Result>
|
</Result>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const CreateServer: FCWithDeps<CreateServerProps, CreateServerDeps> = ({ servers, createServers }) => {
|
const CreateServerBase: FC<CreateServerProps> = withoutSelectedServer(({ useTimeoutToggle }) => {
|
||||||
const { ImportServersBtn, useTimeoutToggle } = useDependencies(CreateServer);
|
const { servers, createServers } = useServers();
|
||||||
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] = useTimeoutToggle(false, SHOW_IMPORT_MSG_TIME);
|
const [serversImported, setServersImported] = useTimeoutToggle({ delay: SHOW_IMPORT_MSG_TIME });
|
||||||
const [errorImporting, setErrorImporting] = useTimeoutToggle(false, SHOW_IMPORT_MSG_TIME);
|
const [errorImporting, setErrorImporting] = useTimeoutToggle({ delay: SHOW_IMPORT_MSG_TIME });
|
||||||
const [isConfirmModalOpen, toggleConfirmModal] = useToggle();
|
const { flag: isConfirmModalOpen, toggle: toggleConfirmModal } = useToggle();
|
||||||
const [serverData, setServerData] = useState<ServerData>();
|
const [serverData, setServerData] = useState<ServerData>();
|
||||||
const saveNewServer = useCallback((newServerData: ServerData) => {
|
const saveNewServer = useCallback((newServerData: ServerData) => {
|
||||||
const [newServerWithUniqueId] = ensureUniqueIds(servers, [newServerData]);
|
const [newServerWithUniqueId] = ensureUniqueIds(servers, [newServerData]);
|
||||||
@ -66,25 +60,25 @@ const CreateServer: FCWithDeps<CreateServerProps, CreateServerDeps> = ({ servers
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<NoMenuLayout>
|
<NoMenuLayout>
|
||||||
<ServerForm title={<h5 className="mb-0">Add new server</h5>} onSubmit={onSubmit}>
|
<ServerForm title="Add new server" onSubmit={onSubmit}>
|
||||||
{!hasServers && (
|
{!hasServers && (
|
||||||
<ImportServersBtn tooltipPlacement="top" onImport={setServersImported} onImportError={setErrorImporting} />
|
<ImportServersBtn tooltipPlacement="top" onImport={setServersImported} onError={setErrorImporting} />
|
||||||
)}
|
)}
|
||||||
{hasServers && <Button outline onClick={goBack}>Cancel</Button>}
|
{hasServers && <Button variant="secondary" onClick={goBack}>Cancel</Button>}
|
||||||
<Button outline color="primary" className="ms-2">Create server</Button>
|
<Button type="submit">Create server</Button>
|
||||||
</ServerForm>
|
</ServerForm>
|
||||||
|
|
||||||
{serversImported && <ImportResult type="success" />}
|
{serversImported && <ImportResult variant="success" />}
|
||||||
{errorImporting && <ImportResult type="error" />}
|
{errorImporting && <ImportResult variant="error" />}
|
||||||
|
|
||||||
<DuplicatedServersModal
|
<DuplicatedServersModal
|
||||||
isOpen={isConfirmModalOpen}
|
open={isConfirmModalOpen}
|
||||||
duplicatedServers={serverData ? [serverData] : []}
|
duplicatedServers={serverData ? [serverData] : []}
|
||||||
onDiscard={goBack}
|
onClose={goBack}
|
||||||
onSave={() => serverData && saveNewServer(serverData)}
|
onConfirm={() => serverData && saveNewServer(serverData)}
|
||||||
/>
|
/>
|
||||||
</NoMenuLayout>
|
</NoMenuLayout>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
export const CreateServerFactory = componentFactory(CreateServer, ['ImportServersBtn', 'useTimeoutToggle']);
|
export const CreateServer = withDependencies(CreateServerBase, ['useTimeoutToggle']);
|
||||||
|
|||||||
@ -1,39 +1,30 @@
|
|||||||
import { faMinusCircle as deleteIcon } from '@fortawesome/free-solid-svg-icons';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
||||||
import { useToggle } from '@shlinkio/shlink-frontend-kit';
|
import { useToggle } from '@shlinkio/shlink-frontend-kit';
|
||||||
import { clsx } from 'clsx';
|
|
||||||
import type { FC, PropsWithChildren } from 'react';
|
import type { FC, PropsWithChildren } from 'react';
|
||||||
import type { FCWithDeps } from '../container/utils';
|
import { useCallback } from 'react';
|
||||||
import { componentFactory, useDependencies } from '../container/utils';
|
import { useNavigate } from 'react-router';
|
||||||
import type { ServerWithId } from './data';
|
import type { ServerWithId } from './data';
|
||||||
import type { DeleteServerModalProps } from './DeleteServerModal';
|
import { DeleteServerModal } from './DeleteServerModal';
|
||||||
|
|
||||||
export type DeleteServerButtonProps = PropsWithChildren<{
|
export type DeleteServerButtonProps = PropsWithChildren<{
|
||||||
server: ServerWithId;
|
server: ServerWithId;
|
||||||
className?: string;
|
|
||||||
textClassName?: string;
|
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
type DeleteServerButtonDeps = {
|
export const DeleteServerButton: FC<DeleteServerButtonProps> = ({ server, children }) => {
|
||||||
DeleteServerModal: FC<DeleteServerModalProps>;
|
const { flag: isModalOpen, setToTrue: showModal, setToFalse: hideModal } = useToggle();
|
||||||
};
|
const navigate = useNavigate();
|
||||||
|
const onClose = useCallback((confirmed: boolean) => {
|
||||||
const DeleteServerButton: FCWithDeps<DeleteServerButtonProps, DeleteServerButtonDeps> = (
|
hideModal();
|
||||||
{ server, className, children, textClassName },
|
if (confirmed) {
|
||||||
) => {
|
navigate('/');
|
||||||
const { DeleteServerModal } = useDependencies(DeleteServerButton);
|
}
|
||||||
const [isModalOpen, , showModal, hideModal] = useToggle();
|
}, [hideModal, navigate]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<button type="button" className={clsx(className, 'p-0 bg-transparent border-0')} onClick={showModal}>
|
<button type="button" className="text-danger hover:underline" onClick={showModal}>
|
||||||
{!children && <FontAwesomeIcon fixedWidth icon={deleteIcon} />}
|
{children}
|
||||||
<span className={textClassName}>{children ?? 'Remove this server'}</span>
|
|
||||||
</button>
|
</button>
|
||||||
|
<DeleteServerModal server={server} open={isModalOpen} onClose={onClose} />
|
||||||
<DeleteServerModal server={server} isOpen={isModalOpen} toggle={hideModal} />
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DeleteServerButtonFactory = componentFactory(DeleteServerButton, ['DeleteServerModal']);
|
|
||||||
|
|||||||
@ -1,44 +1,35 @@
|
|||||||
|
import type { ExitAction } from '@shlinkio/shlink-frontend-kit';
|
||||||
|
import { CardModal } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { useRef } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
|
|
||||||
import type { ServerWithId } from './data';
|
import type { ServerWithId } from './data';
|
||||||
|
import { useServers } from './reducers/servers';
|
||||||
|
|
||||||
export interface DeleteServerModalProps {
|
export type DeleteServerModalProps = {
|
||||||
server: ServerWithId;
|
server: ServerWithId;
|
||||||
toggle: () => void;
|
onClose: (confirmed: boolean) => void;
|
||||||
isOpen: boolean;
|
open: boolean;
|
||||||
redirectHome?: boolean;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
interface DeleteServerModalConnectProps extends DeleteServerModalProps {
|
export const DeleteServerModal: FC<DeleteServerModalProps> = ({ server, onClose, open }) => {
|
||||||
deleteServer: (server: ServerWithId) => void;
|
const { deleteServer } = useServers();
|
||||||
}
|
const onClosed = useCallback((exitAction: ExitAction) => {
|
||||||
|
if (exitAction === 'confirm') {
|
||||||
export const DeleteServerModal: FC<DeleteServerModalConnectProps> = (
|
deleteServer(server);
|
||||||
{ server, toggle, isOpen, deleteServer, redirectHome = true },
|
|
||||||
) => {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const doDelete = useRef<boolean>(false);
|
|
||||||
const toggleAndDelete = () => {
|
|
||||||
doDelete.current = true;
|
|
||||||
toggle();
|
|
||||||
};
|
|
||||||
const onClosed = () => {
|
|
||||||
if (!doDelete.current) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}, [deleteServer, server]);
|
||||||
deleteServer(server);
|
|
||||||
if (redirectHome) {
|
|
||||||
navigate('/');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={isOpen} toggle={toggle} centered onClosed={onClosed}>
|
<CardModal
|
||||||
<ModalHeader toggle={toggle} className="text-danger">Remove server</ModalHeader>
|
open={open}
|
||||||
<ModalBody>
|
title="Remove server"
|
||||||
|
variant="danger"
|
||||||
|
onClose={() => onClose(false)}
|
||||||
|
onConfirm={() => onClose(true)}
|
||||||
|
onClosed={onClosed}
|
||||||
|
confirmText="Delete"
|
||||||
|
>
|
||||||
|
<div className="flex flex-col gap-y-4">
|
||||||
<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>
|
||||||
<i>
|
<i>
|
||||||
@ -46,11 +37,7 @@ export const DeleteServerModal: FC<DeleteServerModalConnectProps> = (
|
|||||||
You can create it again at any moment.
|
You can create it again at any moment.
|
||||||
</i>
|
</i>
|
||||||
</p>
|
</p>
|
||||||
</ModalBody>
|
</div>
|
||||||
<ModalFooter>
|
</CardModal>
|
||||||
<Button color="link" onClick={toggle}>Cancel</Button>
|
|
||||||
<Button color="danger" onClick={toggleAndDelete}>Delete</Button>
|
|
||||||
</ModalFooter>
|
|
||||||
</Modal>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,27 +1,17 @@
|
|||||||
import { useParsedQuery } from '@shlinkio/shlink-frontend-kit';
|
import { Button, useParsedQuery } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { Button } from 'reactstrap';
|
|
||||||
import { NoMenuLayout } from '../common/NoMenuLayout';
|
import { NoMenuLayout } from '../common/NoMenuLayout';
|
||||||
import type { FCWithDeps } from '../container/utils';
|
|
||||||
import { componentFactory } from '../container/utils';
|
|
||||||
import { useGoBack } from '../utils/helpers/hooks';
|
import { useGoBack } from '../utils/helpers/hooks';
|
||||||
import type { ServerData } from './data';
|
import type { ServerData } from './data';
|
||||||
import { isServerWithId } from './data';
|
import { isServerWithId } from './data';
|
||||||
import { ServerForm } from './helpers/ServerForm';
|
import { ServerForm } from './helpers/ServerForm';
|
||||||
import type { WithSelectedServerProps } from './helpers/withSelectedServer';
|
|
||||||
import { withSelectedServer } from './helpers/withSelectedServer';
|
import { withSelectedServer } from './helpers/withSelectedServer';
|
||||||
|
import { useSelectedServer } from './reducers/selectedServer';
|
||||||
|
import { useServers } from './reducers/servers';
|
||||||
|
|
||||||
type EditServerProps = WithSelectedServerProps & {
|
export const EditServer: FC = withSelectedServer(() => {
|
||||||
editServer: (serverId: string, serverData: ServerData) => void;
|
const { editServer } = useServers();
|
||||||
};
|
const { selectServer, selectedServer } = useSelectedServer();
|
||||||
|
|
||||||
type EditServerDeps = {
|
|
||||||
ServerError: FC;
|
|
||||||
};
|
|
||||||
|
|
||||||
const EditServer: FCWithDeps<EditServerProps, EditServerDeps> = withSelectedServer((
|
|
||||||
{ editServer, selectedServer, selectServer },
|
|
||||||
) => {
|
|
||||||
const goBack = useGoBack();
|
const goBack = useGoBack();
|
||||||
const { reconnect } = useParsedQuery<{ reconnect?: 'true' }>();
|
const { reconnect } = useParsedQuery<{ reconnect?: 'true' }>();
|
||||||
|
|
||||||
@ -40,15 +30,13 @@ const EditServer: FCWithDeps<EditServerProps, EditServerDeps> = withSelectedServ
|
|||||||
return (
|
return (
|
||||||
<NoMenuLayout>
|
<NoMenuLayout>
|
||||||
<ServerForm
|
<ServerForm
|
||||||
title={<h5 className="mb-0">Edit "{selectedServer.name}"</h5>}
|
title={<>Edit "{selectedServer.name}"</>}
|
||||||
initialValues={selectedServer}
|
initialValues={selectedServer}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
>
|
>
|
||||||
<Button outline className="me-2" onClick={goBack}>Cancel</Button>
|
<Button variant="secondary" onClick={goBack}>Cancel</Button>
|
||||||
<Button outline color="primary">Save</Button>
|
<Button type="submit">Save</Button>
|
||||||
</ServerForm>
|
</ServerForm>
|
||||||
</NoMenuLayout>
|
</NoMenuLayout>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export const EditServerFactory = componentFactory(EditServer, ['ServerError']);
|
|
||||||
|
|||||||
@ -1,39 +1,29 @@
|
|||||||
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 { TimeoutToggle } from '@shlinkio/shlink-frontend-kit';
|
import type { TimeoutToggle } from '@shlinkio/shlink-frontend-kit';
|
||||||
import { Result, SearchField, SimpleCard } from '@shlinkio/shlink-frontend-kit';
|
import { Button, Result, SearchInput, SimpleCard, Table } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import { Button } from 'reactstrap';
|
|
||||||
import { NoMenuLayout } from '../common/NoMenuLayout';
|
import { NoMenuLayout } from '../common/NoMenuLayout';
|
||||||
import type { FCWithDeps } from '../container/utils';
|
import { withDependencies } from '../container/context';
|
||||||
import { componentFactory, useDependencies } from '../container/utils';
|
import { ImportServersBtn } from './helpers/ImportServersBtn';
|
||||||
import type { ServersMap } from './data';
|
import { withoutSelectedServer } from './helpers/withoutSelectedServer';
|
||||||
import type { ImportServersBtnProps } from './helpers/ImportServersBtn';
|
import { ManageServersRow } from './ManageServersRow';
|
||||||
import type { ManageServersRowProps } from './ManageServersRow';
|
import { useServers } from './reducers/servers';
|
||||||
import type { ServersExporter } from './services/ServersExporter';
|
import type { ServersExporter } from './services/ServersExporter';
|
||||||
|
|
||||||
type ManageServersProps = {
|
export type ManageServersProps = {
|
||||||
servers: ServersMap;
|
|
||||||
};
|
|
||||||
|
|
||||||
type ManageServersDeps = {
|
|
||||||
ServersExporter: ServersExporter;
|
ServersExporter: ServersExporter;
|
||||||
ImportServersBtn: FC<ImportServersBtnProps>;
|
|
||||||
useTimeoutToggle: TimeoutToggle;
|
useTimeoutToggle: TimeoutToggle;
|
||||||
ManageServersRow: FC<ManageServersRowProps>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const SHOW_IMPORT_MSG_TIME = 4000;
|
const SHOW_IMPORT_MSG_TIME = 4000;
|
||||||
|
|
||||||
const ManageServers: FCWithDeps<ManageServersProps, ManageServersDeps> = ({ servers }) => {
|
const ManageServersBase: FC<ManageServersProps> = withoutSelectedServer(({
|
||||||
const {
|
ServersExporter: serversExporter,
|
||||||
ServersExporter: serversExporter,
|
useTimeoutToggle,
|
||||||
ImportServersBtn,
|
}) => {
|
||||||
useTimeoutToggle,
|
const { servers } = useServers();
|
||||||
ManageServersRow,
|
|
||||||
} = useDependencies(ManageServers);
|
|
||||||
const [searchTerm, setSearchTerm] = useState('');
|
const [searchTerm, setSearchTerm] = useState('');
|
||||||
const allServers = useMemo(() => Object.values(servers), [servers]);
|
const allServers = useMemo(() => Object.values(servers), [servers]);
|
||||||
const filteredServers = useMemo(
|
const filteredServers = useMemo(
|
||||||
@ -41,57 +31,54 @@ const ManageServers: FCWithDeps<ManageServersProps, ManageServersDeps> = ({ serv
|
|||||||
[allServers, searchTerm],
|
[allServers, searchTerm],
|
||||||
);
|
);
|
||||||
const hasAutoConnect = allServers.some(({ autoConnect }) => !!autoConnect);
|
const hasAutoConnect = allServers.some(({ autoConnect }) => !!autoConnect);
|
||||||
const [errorImporting, setErrorImporting] = useTimeoutToggle(false, SHOW_IMPORT_MSG_TIME);
|
|
||||||
|
const [errorImporting, setErrorImporting] = useTimeoutToggle({ delay: SHOW_IMPORT_MSG_TIME });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NoMenuLayout className="d-flex flex-column gap-3">
|
<NoMenuLayout className="flex flex-col gap-y-4">
|
||||||
<SearchField onChange={setSearchTerm} />
|
<SearchInput onChange={setSearchTerm} />
|
||||||
|
|
||||||
<div className="d-flex flex-column flex-md-row gap-2">
|
<div className="flex flex-col md:flex-row gap-2">
|
||||||
<div className="d-flex gap-2">
|
<div className="flex gap-2">
|
||||||
<ImportServersBtn className="flex-fill" onImportError={setErrorImporting}>Import servers</ImportServersBtn>
|
<ImportServersBtn className="flex-grow" onError={setErrorImporting}>Import servers</ImportServersBtn>
|
||||||
{filteredServers.length > 0 && (
|
{filteredServers.length > 0 && (
|
||||||
<Button outline className="flex-fill" onClick={async () => serversExporter.exportServers()}>
|
<Button variant="secondary" className="flex-grow" onClick={async () => serversExporter.exportServers()}>
|
||||||
<FontAwesomeIcon icon={exportIcon} fixedWidth /> Export servers
|
<FontAwesomeIcon icon={exportIcon} widthAuto /> Export servers
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Button outline color="primary" className="ms-md-auto" tag={Link} to="/server/create">
|
<Button className="md:ml-auto" to="/server/create">
|
||||||
<FontAwesomeIcon icon={plusIcon} fixedWidth /> Add a server
|
<FontAwesomeIcon icon={plusIcon} widthAuto /> Add a server
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<SimpleCard>
|
<SimpleCard className="card">
|
||||||
<table className="table table-hover responsive-table mb-0">
|
<Table header={(
|
||||||
<thead className="responsive-table__header">
|
<Table.Row>
|
||||||
<tr>
|
{hasAutoConnect && (
|
||||||
{hasAutoConnect && <th style={{ width: '50px' }}><span className="sr-only">Auto-connect</span></th>}
|
<Table.Cell className="w-[35px]"><span className="sr-only">Auto-connect</span></Table.Cell>
|
||||||
<th>Name</th>
|
)}
|
||||||
<th>Base URL</th>
|
<Table.Cell>Name</Table.Cell>
|
||||||
<th><span className="sr-only">Options</span></th>
|
<Table.Cell>Base URL</Table.Cell>
|
||||||
</tr>
|
<Table.Cell><span className="sr-only">Options</span></Table.Cell>
|
||||||
</thead>
|
</Table.Row>
|
||||||
<tbody>
|
)}>
|
||||||
{!filteredServers.length && <tr className="text-center"><td colSpan={4}>No servers found.</td></tr>}
|
{!filteredServers.length && (
|
||||||
{filteredServers.map((server) => (
|
<Table.Row className="text-center"><Table.Cell colSpan={4}>No servers found.</Table.Cell></Table.Row>
|
||||||
<ManageServersRow key={server.id} server={server} hasAutoConnect={hasAutoConnect} />
|
)}
|
||||||
))}
|
{filteredServers.map((server) => (
|
||||||
</tbody>
|
<ManageServersRow key={server.id} server={server} hasAutoConnect={hasAutoConnect} />
|
||||||
</table>
|
))}
|
||||||
|
</Table>
|
||||||
</SimpleCard>
|
</SimpleCard>
|
||||||
|
|
||||||
{errorImporting && (
|
{errorImporting && (
|
||||||
<div>
|
<div>
|
||||||
<Result type="error">The servers could not be imported. Make sure the format is correct.</Result>
|
<Result variant="error">The servers could not be imported. Make sure the format is correct.</Result>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</NoMenuLayout>
|
</NoMenuLayout>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
export const ManageServersFactory = componentFactory(ManageServers, [
|
export const ManageServers = withDependencies(ManageServersBase, ['ServersExporter', 'useTimeoutToggle']);
|
||||||
'ServersExporter',
|
|
||||||
'ImportServersBtn',
|
|
||||||
'useTimeoutToggle',
|
|
||||||
'ManageServersRow',
|
|
||||||
]);
|
|
||||||
|
|||||||
@ -1,48 +1,43 @@
|
|||||||
import { faCheck as checkIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faCheck as checkIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import { Table, Tooltip, useTooltip } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router';
|
||||||
import { UncontrolledTooltip } from 'reactstrap';
|
|
||||||
import type { FCWithDeps } from '../container/utils';
|
|
||||||
import { componentFactory, useDependencies } from '../container/utils';
|
|
||||||
import type { ServerWithId } from './data';
|
import type { ServerWithId } from './data';
|
||||||
import type { ManageServersRowDropdownProps } from './ManageServersRowDropdown';
|
import { ManageServersRowDropdown } from './ManageServersRowDropdown';
|
||||||
|
|
||||||
export type ManageServersRowProps = {
|
export type ManageServersRowProps = {
|
||||||
server: ServerWithId;
|
server: ServerWithId;
|
||||||
hasAutoConnect: boolean;
|
hasAutoConnect: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ManageServersRowDeps = {
|
export const ManageServersRow: FC<ManageServersRowProps> = ({ server, hasAutoConnect }) => {
|
||||||
ManageServersRowDropdown: FC<ManageServersRowDropdownProps>;
|
const { anchor, tooltip } = useTooltip();
|
||||||
};
|
|
||||||
|
|
||||||
const ManageServersRow: FCWithDeps<ManageServersRowProps, ManageServersRowDeps> = ({ server, hasAutoConnect }) => {
|
|
||||||
const { ManageServersRowDropdown } = useDependencies(ManageServersRow);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr className="responsive-table__row">
|
<Table.Row className="relative">
|
||||||
{hasAutoConnect && (
|
{hasAutoConnect && (
|
||||||
<td className="responsive-table__cell" data-th="Auto-connect">
|
<Table.Cell columnName="Auto-connect">
|
||||||
{server.autoConnect && (
|
{server.autoConnect && (
|
||||||
<>
|
<>
|
||||||
<FontAwesomeIcon icon={checkIcon} className="text-primary" id="autoConnectIcon" />
|
<FontAwesomeIcon
|
||||||
<UncontrolledTooltip target="autoConnectIcon" placement="right">
|
icon={checkIcon}
|
||||||
Auto-connect to this server
|
className="text-lm-brand dark:text-dm-brand"
|
||||||
</UncontrolledTooltip>
|
{...anchor}
|
||||||
|
data-testid="auto-connect"
|
||||||
|
/>
|
||||||
|
<Tooltip {...tooltip}>Auto-connect to this server</Tooltip>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</td>
|
</Table.Cell>
|
||||||
)}
|
)}
|
||||||
<th className="responsive-table__cell" data-th="Name">
|
<Table.Cell className="font-bold" columnName="Name">
|
||||||
<Link to={`/server/${server.id}`}>{server.name}</Link>
|
<Link to={`/server/${server.id}`}>{server.name}</Link>
|
||||||
</th>
|
</Table.Cell>
|
||||||
<td className="responsive-table__cell" data-th="Base URL">{server.url}</td>
|
<Table.Cell columnName="Base URL" className="max-lg:border-b-0">{server.url}</Table.Cell>
|
||||||
<td className="responsive-table__cell text-end">
|
<Table.Cell className="text-right max-lg:absolute right-0 -top-1 mx-lg:pt-0">
|
||||||
<ManageServersRowDropdown server={server} />
|
<ManageServersRowDropdown server={server} />
|
||||||
</td>
|
</Table.Cell>
|
||||||
</tr>
|
</Table.Row>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ManageServersRowFactory = componentFactory(ManageServersRow, ['ManageServersRowDropdown']);
|
|
||||||
|
|||||||
@ -6,55 +6,42 @@ import {
|
|||||||
faPlug as connectIcon,
|
faPlug as connectIcon,
|
||||||
} 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 { RowDropdownBtn, useToggle } from '@shlinkio/shlink-frontend-kit';
|
import { RowDropdown, useToggle } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import { DropdownItem } from 'reactstrap';
|
|
||||||
import type { FCWithDeps } from '../container/utils';
|
|
||||||
import { componentFactory, useDependencies } from '../container/utils';
|
|
||||||
import type { ServerWithId } from './data';
|
import type { ServerWithId } from './data';
|
||||||
import type { DeleteServerModalProps } from './DeleteServerModal';
|
import { DeleteServerModal } from './DeleteServerModal';
|
||||||
|
import { useServers } from './reducers/servers';
|
||||||
|
|
||||||
export type ManageServersRowDropdownProps = {
|
export type ManageServersRowDropdownProps = {
|
||||||
server: ServerWithId;
|
server: ServerWithId;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ManageServersRowDropdownConnectProps = ManageServersRowDropdownProps & {
|
export const ManageServersRowDropdown: FC<ManageServersRowDropdownProps> = ({ server }) => {
|
||||||
setAutoConnect: (server: ServerWithId, autoConnect: boolean) => void;
|
const { setAutoConnect } = useServers();
|
||||||
};
|
const { flag: isModalOpen, setToTrue: showModal, setToFalse: hideModal } = useToggle();
|
||||||
|
|
||||||
type ManageServersRowDropdownDeps = {
|
|
||||||
DeleteServerModal: FC<DeleteServerModalProps>
|
|
||||||
};
|
|
||||||
|
|
||||||
const ManageServersRowDropdown: FCWithDeps<ManageServersRowDropdownConnectProps, ManageServersRowDropdownDeps> = (
|
|
||||||
{ server, setAutoConnect },
|
|
||||||
) => {
|
|
||||||
const { DeleteServerModal } = useDependencies(ManageServersRowDropdown);
|
|
||||||
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 (
|
||||||
<RowDropdownBtn minWidth={isAutoConnect ? 210 : 170}>
|
<>
|
||||||
<DropdownItem tag={Link} to={serverUrl}>
|
<RowDropdown menuAlignment="right">
|
||||||
<FontAwesomeIcon icon={connectIcon} fixedWidth /> Connect
|
<RowDropdown.Item to={serverUrl} className="gap-1.5">
|
||||||
</DropdownItem>
|
<FontAwesomeIcon icon={connectIcon} /> Connect
|
||||||
<DropdownItem tag={Link} to={`${serverUrl}/edit`}>
|
</RowDropdown.Item>
|
||||||
<FontAwesomeIcon icon={editIcon} fixedWidth /> Edit server
|
<RowDropdown.Item to={`${serverUrl}/edit`} className="gap-1.5">
|
||||||
</DropdownItem>
|
<FontAwesomeIcon icon={editIcon} /> Edit server
|
||||||
<DropdownItem onClick={() => setAutoConnect(server, !isAutoConnect)}>
|
</RowDropdown.Item>
|
||||||
<FontAwesomeIcon icon={autoConnectIcon} fixedWidth /> {isAutoConnect ? 'Do not a' : 'A'}uto-connect
|
<RowDropdown.Item onClick={() => setAutoConnect(server, !isAutoConnect)} className="gap-1.5">
|
||||||
</DropdownItem>
|
<FontAwesomeIcon icon={autoConnectIcon} /> {isAutoConnect ? 'Do not a' : 'A'}uto-connect
|
||||||
<DropdownItem divider tag="hr" />
|
</RowDropdown.Item>
|
||||||
<DropdownItem className="dropdown-item--danger" onClick={showModal}>
|
<RowDropdown.Separator />
|
||||||
<FontAwesomeIcon icon={deleteIcon} fixedWidth /> Remove server
|
<RowDropdown.Item className="[&]:text-danger gap-1.5" onClick={showModal}>
|
||||||
</DropdownItem>
|
<FontAwesomeIcon icon={deleteIcon} /> Remove server
|
||||||
|
</RowDropdown.Item>
|
||||||
|
</RowDropdown>
|
||||||
|
|
||||||
<DeleteServerModal redirectHome={false} server={server} isOpen={isModalOpen} toggle={hideModal} />
|
<DeleteServerModal server={server} open={isModalOpen} onClose={hideModal} />
|
||||||
</RowDropdownBtn>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ManageServersRowDropdownFactory = componentFactory(ManageServersRowDropdown, ['DeleteServerModal']);
|
|
||||||
|
|||||||
@ -1,48 +1,39 @@
|
|||||||
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 { Link } from 'react-router-dom';
|
import { Dropdown, NavBar } from '@shlinkio/shlink-frontend-kit';
|
||||||
import { DropdownItem, DropdownMenu, DropdownToggle, UncontrolledDropdown } from 'reactstrap';
|
import type { FC } from 'react';
|
||||||
import type { SelectedServer, ServersMap } from './data';
|
|
||||||
import { getServerId } from './data';
|
import { getServerId } from './data';
|
||||||
|
import { useSelectedServer } from './reducers/selectedServer';
|
||||||
|
import { useServers } from './reducers/servers';
|
||||||
|
|
||||||
export interface ServersDropdownProps {
|
export const ServersDropdown: FC = () => {
|
||||||
servers: ServersMap;
|
const { servers } = useServers();
|
||||||
selectedServer: SelectedServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ServersDropdown = ({ servers, selectedServer }: ServersDropdownProps) => {
|
|
||||||
const serversList = Object.values(servers);
|
const serversList = Object.values(servers);
|
||||||
|
const { selectedServer } = useSelectedServer();
|
||||||
const renderServers = () => {
|
|
||||||
if (serversList.length === 0) {
|
|
||||||
return (
|
|
||||||
<DropdownItem tag={Link} to="/server/create">
|
|
||||||
<FontAwesomeIcon icon={plusIcon} /> <span className="ms-1">Add a server</span>
|
|
||||||
</DropdownItem>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{serversList.map(({ name, id }) => (
|
|
||||||
<DropdownItem key={id} tag={Link} to={`/server/${id}`} active={getServerId(selectedServer) === id}>
|
|
||||||
{name}
|
|
||||||
</DropdownItem>
|
|
||||||
))}
|
|
||||||
<DropdownItem divider tag="hr" />
|
|
||||||
<DropdownItem tag={Link} to="/manage-servers">
|
|
||||||
<FontAwesomeIcon icon={serverIcon} /> <span className="ms-1">Manage servers</span>
|
|
||||||
</DropdownItem>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UncontrolledDropdown nav inNavbar>
|
<NavBar.Dropdown buttonContent={(
|
||||||
<DropdownToggle nav caret>
|
<span className="flex items-center gap-1.5">
|
||||||
<FontAwesomeIcon icon={serverIcon} /> <span className="ms-1">Servers</span>
|
<FontAwesomeIcon icon={serverIcon} /> Servers
|
||||||
</DropdownToggle>
|
</span>
|
||||||
<DropdownMenu end style={{ right: 0 }}>{renderServers()}</DropdownMenu>
|
)}>
|
||||||
</UncontrolledDropdown>
|
{serversList.length === 0 ? (
|
||||||
|
<Dropdown.Item to="/server/create">
|
||||||
|
<FontAwesomeIcon icon={plusIcon} /> Add a server
|
||||||
|
</Dropdown.Item>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{serversList.map(({ name, id }) => (
|
||||||
|
<Dropdown.Item key={id} to={`/server/${id}`} selected={getServerId(selectedServer) === id}>
|
||||||
|
{name}
|
||||||
|
</Dropdown.Item>
|
||||||
|
))}
|
||||||
|
<Dropdown.Separator />
|
||||||
|
<Dropdown.Item to="/manage-servers">
|
||||||
|
<FontAwesomeIcon icon={serverIcon} /> Manage servers
|
||||||
|
</Dropdown.Item>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</NavBar.Dropdown>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,49 +0,0 @@
|
|||||||
@import '../../node_modules/@shlinkio/shlink-frontend-kit/dist/base';
|
|
||||||
@import '../utils/mixins/vertical-align';
|
|
||||||
@import '../utils/mixins/thin-scroll';
|
|
||||||
|
|
||||||
.servers-list__list-group.servers-list__list-group {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.servers-list__list-group:not(.servers-list__list-group--embedded) {
|
|
||||||
max-width: 400px;
|
|
||||||
box-shadow: 0 .125rem .25rem rgb(0 0 0 / .075);
|
|
||||||
}
|
|
||||||
|
|
||||||
.servers-list__server-item.servers-list__server-item {
|
|
||||||
text-align: left;
|
|
||||||
position: relative;
|
|
||||||
padding: .75rem 2.5rem .75rem 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.servers-list__server-item:not(:hover) {
|
|
||||||
color: $mainColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
.servers-list__server-item:hover {
|
|
||||||
background-color: var(--secondary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.servers-list__server-item-icon {
|
|
||||||
@include vertical-align();
|
|
||||||
|
|
||||||
right: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.servers-list__list-group--embedded.servers-list__list-group--embedded {
|
|
||||||
border-radius: 0;
|
|
||||||
border-top: 1px solid var(--border-color);
|
|
||||||
|
|
||||||
@media (min-width: $mdMin) {
|
|
||||||
max-height: 220px;
|
|
||||||
overflow-x: auto;
|
|
||||||
|
|
||||||
@include thin-scroll();
|
|
||||||
}
|
|
||||||
|
|
||||||
.servers-list__server-item {
|
|
||||||
border: none;
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,35 +1,41 @@
|
|||||||
import { faChevronRight as chevronIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faChevronRight as chevronIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { clsx } from 'clsx';
|
import { clsx } from 'clsx';
|
||||||
import type { FC, PropsWithChildren } from 'react';
|
import type { FC } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router';
|
||||||
import { ListGroup, ListGroupItem } from 'reactstrap';
|
|
||||||
import type { ServerWithId } from './data';
|
import type { ServerWithId } from './data';
|
||||||
import './ServersListGroup.scss';
|
|
||||||
|
|
||||||
type ServersListGroupProps = PropsWithChildren<{
|
type ServersListGroupProps = {
|
||||||
servers: ServerWithId[];
|
servers: ServerWithId[];
|
||||||
embedded?: boolean;
|
borderless?: 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">
|
<Link
|
||||||
{name}
|
to={`/server/${id}`}
|
||||||
<FontAwesomeIcon icon={chevronIcon} className="servers-list__server-item-icon" />
|
className={clsx(
|
||||||
</ListGroupItem>
|
'servers-list__server-item',
|
||||||
|
'flex items-center justify-between gap-x-2 px-4 py-3',
|
||||||
|
'rounded-none hover:bg-lm-secondary hover:dark:bg-dm-secondary',
|
||||||
|
'border-b last:border-0 border-lm-border dark:border-dm-border',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="truncate">{name}</span>
|
||||||
|
<FontAwesomeIcon icon={chevronIcon} />
|
||||||
|
</Link>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const ServersListGroup: FC<ServersListGroupProps> = ({ servers, children, embedded = false }) => (
|
export const ServersListGroup: FC<ServersListGroupProps> = ({ servers, borderless }) => (
|
||||||
<>
|
servers.length > 0 && (
|
||||||
{children && <div data-testid="title" className="mb-0 fs-5 fw-normal lh-sm">{children}</div>}
|
<div
|
||||||
{servers.length > 0 && (
|
data-testid="list"
|
||||||
<ListGroup
|
className={clsx(
|
||||||
data-testid="list"
|
'w-full border-lm-border dark:border-dm-border',
|
||||||
tag="div"
|
'md:max-h-56 md:overflow-y-auto -mb-1 scroll-thin',
|
||||||
className={clsx('servers-list__list-group', { 'servers-list__list-group--embedded': embedded })}
|
{ 'border-y': !borderless },
|
||||||
>
|
)}
|
||||||
{servers.map(({ id, name }) => <ServerListItem key={id} id={id} name={name} />)}
|
>
|
||||||
</ListGroup>
|
{servers.map(({ id, name }) => <ServerListItem key={id} id={id} name={name} />)}
|
||||||
)}
|
</div>
|
||||||
</>
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -4,6 +4,7 @@ export interface ServerData {
|
|||||||
name: string;
|
name: string;
|
||||||
url: string;
|
url: string;
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
|
forwardCredentials?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ServerWithId extends ServerData {
|
export interface ServerWithId extends ServerData {
|
||||||
@ -44,4 +45,31 @@ export const isNotFoundServer = (server: SelectedServer): server is NotFoundServ
|
|||||||
|
|
||||||
export const getServerId = (server: SelectedServer) => (isServerWithId(server) ? server.id : '');
|
export const getServerId = (server: SelectedServer) => (isServerWithId(server) ? server.id : '');
|
||||||
|
|
||||||
export const serverWithIdToServerData = ({ name, url, apiKey }: ServerWithId): ServerData => ({ name, url, apiKey });
|
/**
|
||||||
|
* Expose values that represent provided server, in a way that can be serialized in JSON or CSV strings.
|
||||||
|
*/
|
||||||
|
export const serializeServer = ({ name, url, apiKey, forwardCredentials }: ServerData): Record<string, string> => ({
|
||||||
|
name,
|
||||||
|
url,
|
||||||
|
apiKey,
|
||||||
|
forwardCredentials: forwardCredentials ? 'true' : 'false',
|
||||||
|
});
|
||||||
|
|
||||||
|
const validateServerData = (server: any): server is ServerData =>
|
||||||
|
typeof server.url === 'string' && typeof server.apiKey === 'string' && typeof server.name === 'string';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provided a record, it picks the right properties to build a ServerData object.
|
||||||
|
* @throws Error If any of the required ServerData properties is missing.
|
||||||
|
*/
|
||||||
|
export const deserializeServer = (potentialServer: Record<string, unknown>): ServerData => {
|
||||||
|
const { forwardCredentials, ...serverData } = potentialServer;
|
||||||
|
if (!validateServerData(serverData)) {
|
||||||
|
throw new Error('Server is missing required "url", "apiKey" and/or "name" properties');
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...serverData,
|
||||||
|
forwardCredentials: forwardCredentials === 'true',
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@ -1,41 +1,42 @@
|
|||||||
|
import { CardModal } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { Fragment } from 'react';
|
import { Fragment } from 'react';
|
||||||
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
|
|
||||||
import type { ServerData } from '../data';
|
import type { ServerData } from '../data';
|
||||||
|
|
||||||
interface DuplicatedServersModalProps {
|
export type DuplicatedServersModalProps = {
|
||||||
duplicatedServers: ServerData[];
|
duplicatedServers: ServerData[];
|
||||||
isOpen: boolean;
|
open: boolean;
|
||||||
onDiscard: () => void;
|
onClose: () => void;
|
||||||
onSave: () => void;
|
onConfirm: () => void;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const DuplicatedServersModal: FC<DuplicatedServersModalProps> = (
|
export const DuplicatedServersModal: FC<DuplicatedServersModalProps> = (
|
||||||
{ isOpen, duplicatedServers, onDiscard, onSave },
|
{ open, duplicatedServers, onClose, onConfirm },
|
||||||
) => {
|
) => {
|
||||||
const hasMultipleServers = duplicatedServers.length > 1;
|
const hasMultipleServers = duplicatedServers.length > 1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal centered isOpen={isOpen}>
|
<CardModal
|
||||||
<ModalHeader>Duplicated server{hasMultipleServers && 's'}</ModalHeader>
|
size="lg"
|
||||||
<ModalBody>
|
title={`Duplicated server${hasMultipleServers ? 's' : ''}`}
|
||||||
<p>{hasMultipleServers ? 'The next servers already exist:' : 'There is already a server with:'}</p>
|
open={open}
|
||||||
<ul>
|
onClose={onClose}
|
||||||
{duplicatedServers.map(({ url, apiKey }, index) => (!hasMultipleServers ? (
|
onConfirm={onConfirm}
|
||||||
<Fragment key={index}>
|
confirmText={`Save duplicate${hasMultipleServers ? 's' : ''}`}
|
||||||
<li>URL: <b>{url}</b></li>
|
cancelText={hasMultipleServers ? 'Ignore duplicates' : 'Discard'}
|
||||||
<li>API key: <b>{apiKey}</b></li>
|
>
|
||||||
</Fragment>
|
<p>{hasMultipleServers ? 'The next servers already exist:' : 'There is already a server with:'}</p>
|
||||||
) : <li key={index}><b>{url}</b> - <b>{apiKey}</b></li>))}
|
<ul className="list-disc my-4 pl-5">
|
||||||
</ul>
|
{duplicatedServers.map(({ url, apiKey }, index) => (!hasMultipleServers ? (
|
||||||
<span>
|
<Fragment key={index}>
|
||||||
{hasMultipleServers ? 'Do you want to ignore duplicated servers' : 'Do you want to save this server anyway'}?
|
<li>URL: <b>{url}</b></li>
|
||||||
</span>
|
<li>API key: <b>{apiKey}</b></li>
|
||||||
</ModalBody>
|
</Fragment>
|
||||||
<ModalFooter>
|
) : <li key={index}><b>{url}</b> - <b>{apiKey}</b></li>))}
|
||||||
<Button color="link" onClick={onDiscard}>{hasMultipleServers ? 'Ignore duplicates' : 'Discard'}</Button>
|
</ul>
|
||||||
<Button color="primary" onClick={onSave}>Save anyway</Button>
|
<span>
|
||||||
</ModalFooter>
|
{hasMultipleServers ? 'Do you want to save duplicated servers' : 'Do you want to save this server'}?
|
||||||
</Modal>
|
</span>
|
||||||
|
</CardModal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,113 +1,107 @@
|
|||||||
import { faFileUpload as importIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faFileUpload as importIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { useElementRef, useToggle } from '@shlinkio/shlink-frontend-kit';
|
import { Button, Tooltip, useToggle, useTooltip } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { ChangeEvent, PropsWithChildren } from 'react';
|
import type { ChangeEvent, FC, PropsWithChildren } from 'react';
|
||||||
import { useCallback, useRef, useState } from 'react';
|
import { useCallback, useRef, useState } from 'react';
|
||||||
import { Button, UncontrolledTooltip } from 'reactstrap';
|
import { withDependencies } from '../../container/context';
|
||||||
import type { FCWithDeps } from '../../container/utils';
|
import type { ServerData } from '../data';
|
||||||
import { componentFactory, useDependencies } from '../../container/utils';
|
import { useServers } from '../reducers/servers';
|
||||||
import type { ServerData, ServersMap, ServerWithId } from '../data';
|
|
||||||
import type { ServersImporter } from '../services/ServersImporter';
|
import type { ServersImporter } from '../services/ServersImporter';
|
||||||
import { DuplicatedServersModal } from './DuplicatedServersModal';
|
import { DuplicatedServersModal } from './DuplicatedServersModal';
|
||||||
import { dedupServers, ensureUniqueIds } from './index';
|
import { dedupServers, ensureUniqueIds } from './index';
|
||||||
|
|
||||||
export type ImportServersBtnProps = PropsWithChildren<{
|
export type ImportServersBtnProps = PropsWithChildren<{
|
||||||
onImport?: () => void;
|
onImport?: () => void;
|
||||||
onImportError?: (error: Error) => void;
|
onError?: (error: Error) => void;
|
||||||
tooltipPlacement?: 'top' | 'bottom';
|
tooltipPlacement?: 'top' | 'bottom';
|
||||||
className?: string;
|
className?: string;
|
||||||
|
|
||||||
|
// Injected
|
||||||
|
ServersImporter: ServersImporter
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
type ImportServersBtnConnectProps = ImportServersBtnProps & {
|
const ImportServersBtnBase: FC<ImportServersBtnProps> = ({
|
||||||
createServers: (servers: ServerWithId[]) => void;
|
|
||||||
servers: ServersMap;
|
|
||||||
};
|
|
||||||
|
|
||||||
type ImportServersBtnDeps = {
|
|
||||||
ServersImporter: ServersImporter
|
|
||||||
};
|
|
||||||
|
|
||||||
const ImportServersBtn: FCWithDeps<ImportServersBtnConnectProps, ImportServersBtnDeps> = ({
|
|
||||||
createServers,
|
|
||||||
servers,
|
|
||||||
children,
|
children,
|
||||||
onImport = () => {},
|
onImport,
|
||||||
onImportError = () => {},
|
onError = () => {},
|
||||||
tooltipPlacement = 'bottom',
|
tooltipPlacement = 'bottom',
|
||||||
className = '',
|
className = '',
|
||||||
|
ServersImporter: serversImporter,
|
||||||
}) => {
|
}) => {
|
||||||
const { ServersImporter: serversImporter } = useDependencies(ImportServersBtn);
|
const { createServers, servers } = useServers();
|
||||||
const ref = useElementRef<HTMLInputElement>();
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const { anchor, tooltip } = useTooltip({ placement: tooltipPlacement });
|
||||||
const [duplicatedServers, setDuplicatedServers] = useState<ServerData[]>([]);
|
const [duplicatedServers, setDuplicatedServers] = useState<ServerData[]>([]);
|
||||||
const [isModalOpen,, showModal, hideModal] = useToggle();
|
const { flag: isModalOpen, setToTrue: showModal, setToFalse: hideModal } = useToggle();
|
||||||
|
const newServersCreatedRef = useRef(false);
|
||||||
|
|
||||||
const importedServersRef = useRef<ServerWithId[]>([]);
|
|
||||||
const newServersRef = useRef<ServerWithId[]>([]);
|
|
||||||
|
|
||||||
const create = useCallback((serversData: ServerWithId[]) => {
|
|
||||||
createServers(serversData);
|
|
||||||
onImport();
|
|
||||||
}, [createServers, onImport]);
|
|
||||||
const onFile = useCallback(
|
const onFile = useCallback(
|
||||||
async ({ target }: ChangeEvent<HTMLInputElement>) =>
|
async ({ target }: ChangeEvent<HTMLInputElement>) =>
|
||||||
serversImporter.importServersFromFile(target.files?.[0])
|
serversImporter.importServersFromFile(target.files?.[0])
|
||||||
.then((importedServers) => {
|
.then((importedServers) => {
|
||||||
const { duplicatedServers, newServers } = dedupServers(servers, importedServers);
|
const { duplicatedServers, newServers } = dedupServers(servers, importedServers);
|
||||||
|
|
||||||
importedServersRef.current = ensureUniqueIds(servers, importedServers);
|
// Immediately create new servers
|
||||||
newServersRef.current = ensureUniqueIds(servers, newServers);
|
newServersCreatedRef.current = newServers.length > 0;
|
||||||
|
createServers(ensureUniqueIds(servers, newServers));
|
||||||
|
|
||||||
if (duplicatedServers.length === 0) {
|
// For duplicated servers, ask for confirmation
|
||||||
create(importedServersRef.current);
|
if (duplicatedServers.length > 0) {
|
||||||
} else {
|
|
||||||
setDuplicatedServers(duplicatedServers);
|
setDuplicatedServers(duplicatedServers);
|
||||||
showModal();
|
showModal();
|
||||||
|
} else {
|
||||||
|
onImport?.();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// Reset file input after processing file
|
// Reset file input after processing file
|
||||||
(target as { value: string | null }).value = null;
|
(target as { value: string | null }).value = null;
|
||||||
})
|
})
|
||||||
.catch(onImportError),
|
.catch(onError),
|
||||||
[create, onImportError, servers, serversImporter, showModal],
|
[createServers, onError, onImport, servers, serversImporter, showModal],
|
||||||
);
|
);
|
||||||
|
|
||||||
const createAllServers = useCallback(() => {
|
const createDuplicatedServers = useCallback(() => {
|
||||||
create(importedServersRef.current);
|
createServers(ensureUniqueIds(servers, duplicatedServers));
|
||||||
hideModal();
|
hideModal();
|
||||||
}, [create, hideModal]);
|
onImport?.();
|
||||||
const createNonDuplicatedServers = useCallback(() => {
|
}, [createServers, duplicatedServers, hideModal, onImport, servers]);
|
||||||
create(newServersRef.current);
|
const discardDuplicatedServers = useCallback(() => {
|
||||||
hideModal();
|
hideModal();
|
||||||
}, [create, hideModal]);
|
// If duplicated servers were discarded but some non-duplicated servers were created, call onImport
|
||||||
|
if (newServersCreatedRef.current) {
|
||||||
|
onImport?.();
|
||||||
|
}
|
||||||
|
}, [hideModal, onImport]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button outline id="importBtn" className={className} onClick={() => ref.current?.click()}>
|
<Button variant="secondary" className={className} onClick={() => fileInputRef.current?.click()} {...anchor}>
|
||||||
<FontAwesomeIcon icon={importIcon} fixedWidth /> {children ?? 'Import from file'}
|
<FontAwesomeIcon icon={importIcon} widthAuto /> {children ?? 'Import from file'}
|
||||||
</Button>
|
</Button>
|
||||||
<UncontrolledTooltip placement={tooltipPlacement} target="importBtn">
|
<Tooltip {...tooltip}>
|
||||||
You can create servers by importing a CSV file with <b>name</b>, <b>apiKey</b> and <b>url</b> columns.
|
You can create servers by importing a CSV file with <b>name</b>, <b>apiKey</b> and <b>url</b> columns.
|
||||||
</UncontrolledTooltip>
|
</Tooltip>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
accept=".csv"
|
accept=".csv"
|
||||||
className="d-none"
|
className="hidden"
|
||||||
aria-hidden
|
aria-hidden
|
||||||
ref={ref}
|
tabIndex={-1}
|
||||||
|
ref={fileInputRef}
|
||||||
onChange={onFile}
|
onChange={onFile}
|
||||||
data-testid="csv-file-input"
|
data-testid="csv-file-input"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DuplicatedServersModal
|
<DuplicatedServersModal
|
||||||
isOpen={isModalOpen}
|
open={isModalOpen}
|
||||||
duplicatedServers={duplicatedServers}
|
duplicatedServers={duplicatedServers}
|
||||||
onDiscard={createNonDuplicatedServers}
|
onClose={discardDuplicatedServers}
|
||||||
onSave={createAllServers}
|
onConfirm={createDuplicatedServers}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ImportServersBtnFactory = componentFactory(ImportServersBtn, ['ServersImporter']);
|
export const ImportServersBtn = withDependencies(ImportServersBtnBase, ['ServersImporter']);
|
||||||
|
|||||||
@ -1,17 +0,0 @@
|
|||||||
@import '../../../node_modules/@shlinkio/shlink-frontend-kit/dist/base';
|
|
||||||
|
|
||||||
.server-error__container {
|
|
||||||
text-align: center;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.server-error__delete-btn {
|
|
||||||
color: $dangerColor;
|
|
||||||
font-weight: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.server-error__delete-btn:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
@ -1,31 +1,21 @@
|
|||||||
import { Message } from '@shlinkio/shlink-frontend-kit';
|
import { Card, Message } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router';
|
||||||
import { NoMenuLayout } from '../../common/NoMenuLayout';
|
import { NoMenuLayout } from '../../common/NoMenuLayout';
|
||||||
import type { FCWithDeps } from '../../container/utils';
|
|
||||||
import { componentFactory, useDependencies } from '../../container/utils';
|
|
||||||
import type { SelectedServer, ServersMap } from '../data';
|
|
||||||
import { isServerWithId } from '../data';
|
import { isServerWithId } from '../data';
|
||||||
import type { DeleteServerButtonProps } from '../DeleteServerButton';
|
import { DeleteServerButton } from '../DeleteServerButton';
|
||||||
|
import { useSelectedServer } from '../reducers/selectedServer';
|
||||||
|
import { useServers } from '../reducers/servers';
|
||||||
import { ServersListGroup } from '../ServersListGroup';
|
import { ServersListGroup } from '../ServersListGroup';
|
||||||
import './ServerError.scss';
|
|
||||||
|
|
||||||
type ServerErrorProps = {
|
export const ServerError: FC = () => {
|
||||||
servers: ServersMap;
|
const { servers } = useServers();
|
||||||
selectedServer: SelectedServer;
|
const { selectedServer } = useSelectedServer();
|
||||||
};
|
|
||||||
|
|
||||||
type ServerErrorDeps = {
|
|
||||||
DeleteServerButton: FC<DeleteServerButtonProps>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ServerError: FCWithDeps<ServerErrorProps, ServerErrorDeps> = ({ servers, selectedServer }) => {
|
|
||||||
const { DeleteServerButton } = useDependencies(ServerError);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NoMenuLayout>
|
<NoMenuLayout>
|
||||||
<div className="server-error__container flex-column">
|
<div className="flex flex-col items-center gap-y-4 md:gap-y-8">
|
||||||
<Message className="w-100 mb-3 mb-md-5" type="error" fullWidth>
|
<Message className="w-full lg:w-[80%]" variant="error">
|
||||||
{!isServerWithId(selectedServer) && 'Could not find this Shlink server.'}
|
{!isServerWithId(selectedServer) && 'Could not find this Shlink server.'}
|
||||||
{isServerWithId(selectedServer) && (
|
{isServerWithId(selectedServer) && (
|
||||||
<>
|
<>
|
||||||
@ -35,25 +25,23 @@ const ServerError: FCWithDeps<ServerErrorProps, ServerErrorDeps> = ({ servers, s
|
|||||||
)}
|
)}
|
||||||
</Message>
|
</Message>
|
||||||
|
|
||||||
<ServersListGroup servers={Object.values(servers)}>
|
<p className="text-xl">
|
||||||
<p className="mb-md-3">
|
These are the Shlink servers currently configured. Choose one of
|
||||||
These are the Shlink servers currently configured. Choose one of
|
them or <Link to="/server/create">add a new one</Link>.
|
||||||
them or <Link to="/server/create">add a new one</Link>.
|
</p>
|
||||||
</p>
|
<Card className="w-full max-w-100 overflow-hidden">
|
||||||
</ServersListGroup>
|
<ServersListGroup borderless servers={Object.values(servers)} />
|
||||||
|
</Card>
|
||||||
|
|
||||||
{isServerWithId(selectedServer) && (
|
{isServerWithId(selectedServer) && (
|
||||||
<div className="container mt-3 mt-md-5">
|
<p className="text-xl">
|
||||||
<p className="fs-5 fw-normal lh-sm">
|
Alternatively, if you think you may have misconfigured this server, you
|
||||||
Alternatively, if you think you may have miss-configured this server, you
|
can <DeleteServerButton server={selectedServer}>remove
|
||||||
can <DeleteServerButton server={selectedServer} className="server-error__delete-btn">remove it</DeleteServerButton> or
|
it</DeleteServerButton> or
|
||||||
<Link to={`/server/${selectedServer.id}/edit?reconnect=true`}>edit it</Link>.
|
<Link to={`/server/${selectedServer.id}/edit?reconnect=true`}>edit it</Link>.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</NoMenuLayout>
|
</NoMenuLayout>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ServerErrorFactory = componentFactory(ServerError, ['DeleteServerButton']);
|
|
||||||
|
|||||||
@ -1,7 +1,15 @@
|
|||||||
import { InputFormGroup, SimpleCard } from '@shlinkio/shlink-frontend-kit';
|
import {
|
||||||
|
Checkbox,
|
||||||
|
Details,
|
||||||
|
Label,
|
||||||
|
LabelledInput,
|
||||||
|
LabelledRevealablePasswordInput,
|
||||||
|
SimpleCard,
|
||||||
|
useToggle,
|
||||||
|
} from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC, PropsWithChildren, ReactNode } from 'react';
|
import type { FC, PropsWithChildren, ReactNode } from 'react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { handleEventPreventingDefault } from '../../utils/utils';
|
import { usePreventDefault } from '../../utils/utils';
|
||||||
import type { ServerData } from '../data';
|
import type { ServerData } from '../data';
|
||||||
|
|
||||||
type ServerFormProps = PropsWithChildren<{
|
type ServerFormProps = PropsWithChildren<{
|
||||||
@ -14,17 +22,42 @@ export const ServerForm: FC<ServerFormProps> = ({ onSubmit, initialValues, child
|
|||||||
const [name, setName] = useState(initialValues?.name ?? '');
|
const [name, setName] = useState(initialValues?.name ?? '');
|
||||||
const [url, setUrl] = useState(initialValues?.url ?? '');
|
const [url, setUrl] = useState(initialValues?.url ?? '');
|
||||||
const [apiKey, setApiKey] = useState(initialValues?.apiKey ?? '');
|
const [apiKey, setApiKey] = useState(initialValues?.apiKey ?? '');
|
||||||
const handleSubmit = handleEventPreventingDefault(() => onSubmit({ name, url, apiKey }));
|
const { flag: forwardCredentials, toggle: toggleForwardCredentials } = useToggle(
|
||||||
|
initialValues?.forwardCredentials ?? false,
|
||||||
|
);
|
||||||
|
const handleSubmit = usePreventDefault(() => onSubmit({ name, url, apiKey, forwardCredentials }));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="server-form" name="serverForm" onSubmit={handleSubmit}>
|
<form name="serverForm" onSubmit={handleSubmit}>
|
||||||
<SimpleCard className="mb-3" title={title}>
|
<SimpleCard className="mb-4" bodyClassName="flex flex-col gap-y-3" title={title}>
|
||||||
<InputFormGroup value={name} onChange={setName}>Name</InputFormGroup>
|
<LabelledInput label="Name" value={name} onChange={(e) => setName(e.target.value)} required />
|
||||||
<InputFormGroup type="url" value={url} onChange={setUrl}>URL</InputFormGroup>
|
<LabelledInput label="URL" type="url" value={url} onChange={(e) => setUrl(e.target.value)} required />
|
||||||
<InputFormGroup value={apiKey} onChange={setApiKey}>API key</InputFormGroup>
|
<LabelledRevealablePasswordInput
|
||||||
|
label="API key"
|
||||||
|
value={apiKey}
|
||||||
|
onChange={(e) => setApiKey(e.target.value)}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<Details summary="Advanced options">
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
|
<Label className="flex items-center gap-x-1.5 cursor-pointer">
|
||||||
|
<Checkbox onChange={toggleForwardCredentials} checked={forwardCredentials} />
|
||||||
|
Forward credentials to this server on every request.
|
||||||
|
</Label>
|
||||||
|
<small className="pl-5.5 text-gray-600 dark:text-gray-400 mt-0.5">
|
||||||
|
{'"'}Credentials{'"'} here means cookies, TLS client certificates, or authentication headers containing a username
|
||||||
|
and password.
|
||||||
|
</small>
|
||||||
|
<small className="pl-5.5 text-gray-600 dark:text-gray-400">
|
||||||
|
<b>Important!</b> If you are not sure what this means, leave it unchecked. Enabling this option will
|
||||||
|
make all requests fail for Shlink older than v4.5.0, as it requires the server to set a more strict
|
||||||
|
value for <code className="whitespace-nowrap">Access-Control-Allow-Origin</code> than <code>*</code>.
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</Details>
|
||||||
</SimpleCard>
|
</SimpleCard>
|
||||||
|
|
||||||
<div className="text-end">{children}</div>
|
<div className="flex items-center justify-end gap-x-2">{children}</div>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,29 +1,16 @@
|
|||||||
import { Message } from '@shlinkio/shlink-frontend-kit';
|
import { Message } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router';
|
||||||
import { NoMenuLayout } from '../../common/NoMenuLayout';
|
import { NoMenuLayout } from '../../common/NoMenuLayout';
|
||||||
import type { FCWithDeps } from '../../container/utils';
|
|
||||||
import { useDependencies } from '../../container/utils';
|
|
||||||
import type { SelectedServer } from '../data';
|
|
||||||
import { isNotFoundServer } from '../data';
|
import { isNotFoundServer } from '../data';
|
||||||
|
import { useSelectedServer } from '../reducers/selectedServer';
|
||||||
|
import { ServerError } from './ServerError';
|
||||||
|
|
||||||
export type WithSelectedServerProps = {
|
export function withSelectedServer<T extends object>(WrappedComponent: FC<T>) {
|
||||||
selectServer: (serverId: string) => void;
|
const ComponentWrapper: FC<T> = (props) => {
|
||||||
selectedServer: SelectedServer;
|
|
||||||
};
|
|
||||||
|
|
||||||
type WithSelectedServerPropsDeps = {
|
|
||||||
ServerError: FC;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function withSelectedServer<T extends object>(
|
|
||||||
WrappedComponent: FCWithDeps<WithSelectedServerProps & T, WithSelectedServerPropsDeps>,
|
|
||||||
) {
|
|
||||||
const ComponentWrapper: FCWithDeps<WithSelectedServerProps & T, WithSelectedServerPropsDeps> = (props) => {
|
|
||||||
const { ServerError } = useDependencies(ComponentWrapper);
|
|
||||||
const params = useParams<{ serverId: string }>();
|
const params = useParams<{ serverId: string }>();
|
||||||
const { selectServer, selectedServer } = props;
|
const { selectServer, selectedServer } = useSelectedServer();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (params.serverId) {
|
if (params.serverId) {
|
||||||
|
|||||||
@ -1,13 +1,10 @@
|
|||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import { useSelectedServer } from '../reducers/selectedServer';
|
||||||
|
|
||||||
interface WithoutSelectedServerProps {
|
export function withoutSelectedServer<T extends object>(WrappedComponent: FC<T>) {
|
||||||
resetSelectedServer: () => unknown;
|
return (props: T) => {
|
||||||
}
|
const { resetSelectedServer } = useSelectedServer();
|
||||||
|
|
||||||
export function withoutSelectedServer<T extends object>(WrappedComponent: FC<WithoutSelectedServerProps & T>) {
|
|
||||||
return (props: WithoutSelectedServerProps & T) => {
|
|
||||||
const { resetSelectedServer } = props;
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
resetSelectedServer();
|
resetSelectedServer();
|
||||||
}, [resetSelectedServer]);
|
}, [resetSelectedServer]);
|
||||||
|
|||||||