Compare commits

...

740 Commits

Author SHA1 Message Date
Julien Fontanet
ba79673715 5.10.3 2017-06-30 19:32:53 +02:00
Julien Fontanet
e2a482a6ca 5.10.2 2017-06-30 19:15:43 +02:00
Julien Fontanet
8924444cc1 fix(react-novnc): use correct var (sic) 2017-06-30 19:14:35 +02:00
Julien Fontanet
8e83b0ffd2 5.10.1 2017-06-30 19:12:55 +02:00
Julien Fontanet
451384bcdc fix(react-novnc): default ports if missing 2017-06-30 19:12:17 +02:00
Julien Fontanet
b733164c50 5.10.0 2017-06-30 18:27:46 +02:00
badrAZ
72d9d8ba86 feat(backups): optional VDI→SR mapping (#2201)
Fixes #2070
2017-06-30 18:27:31 +02:00
Olivier Lambert
7c7646c65c feat(changelog): add the last changes for 5.10 release 2017-06-30 17:37:47 +02:00
Olivier Lambert
b1c087451e feat(console): remove the tip regarding console layout issues (#2251) 2017-06-30 17:30:53 +02:00
Nicolas Raynaud
f0f72f3bdd update noVNC to latest upstream version (#1780)
Fixes #404
2017-06-30 16:55:42 +02:00
badrAZ
0ab3267541 feat(self-service): improve IP pool UI (#2228)
Fixes #2203
2017-06-30 16:38:01 +02:00
badrAZ
995e76d323 feat(job/log): add more details on a backup (#2245)
Fixes #2239
2017-06-30 16:33:31 +02:00
Olivier Lambert
62a9f805c2 feat(changelog): add one enhancement 2017-06-30 13:43:37 +02:00
Olivier Lambert
84ea95a641 feat(changelog): initial changelog for 5.10 release 2017-06-30 10:08:44 +02:00
Olivier Lambert
316de42cd9 feat(host): forget host. Fixes #1934 (#2244)
feat(host): forget host. Fixes #1934
2017-06-29 12:27:47 +02:00
badrAZ
bc2256fc86 fix(vm/action-bar): always display migrate button (#2232)
Fixes #2212
2017-06-23 14:50:43 +02:00
Julien Fontanet
f0d85f4c4e fix(vm): remove unused imports 2017-06-20 19:19:29 +02:00
Julien Fontanet
1801f9cb06 feat(Home): display total disk size for each VM 2017-06-20 19:07:57 +02:00
Julien Fontanet
4be018ad15 feat(selectors/createSumBy): sum collection of items 2017-06-20 17:51:47 +02:00
Julien Fontanet
5dcf060975 chore(selectors/createPicker): avoid running collection wrapper when possible 2017-06-20 17:51:00 +02:00
Julien Fontanet
59f6b1f0c8 fix(StateButton): missing semicolons in CSS 2017-06-20 15:19:51 +02:00
Julien Fontanet
ae38a85b19 chore(package): update dependencies 2017-06-20 15:08:41 +02:00
badrAZ
324dbbcfc8 fix(modal/alert): resolve on close (#2224)
Fixes #2222
2017-06-20 15:08:33 +02:00
Julien Fontanet
9770b77df4 feat(sr/disks): improve filters 2017-06-20 10:41:50 +02:00
Julien Fontanet
0f91de389a fix(Health): check VBDs for orphaned VDI snapshots
VDI snapshots attached to a VM are not considered orphaned.
2017-06-19 16:41:55 +02:00
Julien Fontanet
7f5a623b37 feat(sr/general): display disks size 2017-06-08 11:59:44 +02:00
Julien Fontanet
c7cf73ff05 fix(sr/disks): difference between no VM and unknown VM 2017-06-08 11:59:08 +02:00
Julien Fontanet
4aab425cef 5.9.1 2017-06-08 10:23:34 +02:00
Julien Fontanet
0d9666639f fix(sr): unused imports 2017-06-06 17:08:12 +02:00
Julien Fontanet
6c26c09685 fix(sr/general): show VDI snaphots 2017-06-06 16:57:56 +02:00
Julien Fontanet
819f650b48 chore(sr/general): better retrieve VM associated to VDI 2017-06-06 16:57:56 +02:00
Julien Fontanet
353eba6365 fix(sr/disks): show the correct attached VM for snapshots 2017-06-06 16:57:55 +02:00
Julien Fontanet
063302b91d feat(renderXoUnknownItem): expose it 2017-06-06 16:57:55 +02:00
Julien Fontanet
562b51bc2f feat(SortedTable): can accept component instead of itemRenderer 2017-06-06 16:57:55 +02:00
Julien Fontanet
e33a6f9a05 chore(xo): use tap() from promise-toolbox 2017-06-05 15:50:16 +02:00
Danp2
b9db4e7704 fix(xo/deleteGroup): properly handle confirm rejection (#2197)
Resolve issue with canceling / exiting dialog
2017-06-05 15:48:31 +02:00
Julien Fontanet
3270d9c3a7 chore(plugins): coding style 2017-06-02 16:57:32 +02:00
Julien Fontanet
6d7399f96c fix(plugins): remove collpase button if not configurable 2017-06-02 16:57:32 +02:00
Julien Fontanet
886ef87bc5 fix(plugins): primary style on save button 2017-06-02 16:57:32 +02:00
Julien Fontanet
1e5dc9efe7 fix(json-schema-input/string): consider empty value as undefined (#2192) 2017-06-02 16:21:30 +02:00
Julien Fontanet
28ec66bf3b fix(backups): handle object values without id prop 2017-06-02 12:11:55 +02:00
Julien Fontanet
9199784a23 5.9.0 2017-05-31 18:14:51 +02:00
Pierre Donias
c7e447db6f feat(host): update patches when joining pool (#2187)
Fixes #878
2017-05-31 17:59:11 +02:00
Pierre Donias
f81615f8b6 feat(dashboard/health): VDIs attached to control domain (#2183)
Fixes #2126
2017-05-31 16:33:37 +02:00
badrAZ
12caceb02b feat: start a VM even when forbidden (#2161)
Fixes #2119
2017-05-31 16:05:57 +02:00
Julien Fontanet
30f71ab444 feat(selectors/createDoesHostNeedRestart): use host.rebootRequired (#2179) 2017-05-31 15:33:05 +02:00
Pierre Donias
fe04481ca3 feat(xo): subscribe to missing patches instead of explicitly checking (#2182) 2017-05-31 15:02:05 +02:00
Pierre Donias
7766e8edcd Better createDoesHostNeedRestart selector 2017-05-31 14:54:07 +02:00
Olivier Lambert
31d417c9d3 feat(changelog): added info for 5.9 release 2017-05-31 13:46:29 +02:00
Pierre Donias
5ed29197cf Use host.rebootRequired boolean 2017-05-30 16:26:32 +02:00
Pierre Donias
ff5f3e12d3 feat(selectors/createDoesHostNeedRestart): use host.patchesRequiringReboot
Fixes #2124
2017-05-30 16:26:32 +02:00
badrAZ
240180405c fix(job/logs): correctly extract vm id from returned value (#2167) 2017-05-30 15:51:37 +02:00
badrAZ
edca6495fc feat(self-service): add button "Select all" to the selects (#2181) 2017-05-30 12:39:20 +02:00
BCedric
8a9b753b01 feat(host/patches): advise to patch from pool (#2130)
Fixes #2057
2017-05-29 14:52:54 +02:00
Julien Fontanet
445fc696c9 fix(backup/new): clarify enabled setting (#2177) 2017-05-29 10:39:15 +02:00
Julien Fontanet
492e2362be chore(utils/firstDefined): fix comment, null is considered defined 2017-05-26 15:50:28 +02:00
badrAZ
1acee209be feat(backup/new): DR previous backups can be removed first (#2173)
Fixes #2157
2017-05-26 13:34:16 +02:00
Olivier Lambert
6785c48709 feat(tasks): display task description if it exists (#2172)
Fixes #2125
2017-05-25 12:45:33 +02:00
Olivier Lambert
808e674503 feat(menu): hide About entry if non-admin (on XOA) (#2170) 2017-05-24 17:36:13 +02:00
Julien Fontanet
6b2650282d 5.8.3 2017-05-23 18:53:10 +02:00
Julien Fontanet
475be2ee30 fix(vm/advanced): behave with missing container 2017-05-23 18:52:39 +02:00
Julien Fontanet
12e1da4ef2 5.8.2 2017-05-23 18:24:21 +02:00
Julien Fontanet
780d072bb7 fix(new/vm): check pool is defined (#2169)
Fixes #2168
2017-05-23 17:38:07 +02:00
Julien Fontanet
f7e5a5cf92 fix(Icon): prop-types → prop-types-decorator 2017-05-17 15:49:34 +02:00
Nicolas Raynaud
3574c8de5c fix(package): update react-select to 1.0.0-rc.4 (#2150)
Fixes #2142
2017-05-17 15:46:04 +02:00
Julien Fontanet
b09ab4d403 fix(Button): fix @propTypes() use 2017-05-17 15:30:36 +02:00
Olivier Lambert
1997f4af51 feat(host): add RAM usage for memory bar in tooltip. Fixes #2149 2017-05-16 21:33:40 +02:00
Danp2
347cd063a3 Fix scanFilesError (#2153) 2017-05-16 21:08:46 +02:00
Olivier Lambert
74a4519a33 fix(i18n): English typo 2017-05-16 15:20:52 +02:00
BCedric
20acf7cfb2 feat(vm/general): display when the VM was last running (#2147)
Fixes #1613
2017-05-16 15:16:44 +02:00
Julien Fontanet
99bc34b2da fix(form/toggle): remove debug trace 2017-05-15 16:48:50 +02:00
Julien Fontanet
f65b5e3ddd feat(settings/server): add click for info on error icon 2017-05-15 16:48:09 +02:00
Julien Fontanet
dc10492b84 fix(xo/connectServer): refresh subscription also in case of error 2017-05-15 16:48:08 +02:00
Julien Fontanet
6f7c10537b fix(vm/advanced): add missing key prop 2017-05-15 16:48:08 +02:00
Julien Fontanet
7f503cfc21 chore(form/toggle): simplify implementation 2017-05-15 16:48:08 +02:00
Julien Fontanet
9dbef0c20a chore(Icon): use propTypes decorator 2017-05-15 16:48:08 +02:00
Julien Fontanet
923166b4e3 feat(Icon): pass extraneous props down 2017-05-15 16:48:08 +02:00
Julien Fontanet
b420128e40 chore(settings/servers): remove useless styles 2017-05-15 16:48:08 +02:00
Julien Fontanet
7776a6ce23 5.8.1 2017-05-12 16:13:44 +02:00
Julien Fontanet
8db949734a feat(settings/servers): improve self-signed error 2017-05-12 16:07:49 +02:00
badrAZ
bb5bdfb9b2 feat(settings/servers): allow unauthorized certificates (#2148)
Fixes #2138
2017-05-12 12:01:08 +02:00
BCedric
9fac3ecd81 feat(backup/file-restore): explicit compatible backups (#2146) 2017-05-11 14:59:31 +02:00
BCedric
8a84cc2627 fix: display when host is disabled (#2121)
Fixes #2098
2017-05-09 17:16:38 +02:00
Julien Fontanet
61179ec67d feat(prop-types): can also be used to set context types 2017-05-09 14:33:15 +02:00
badrAZ
59fc5955ba fix(vm/advanced): affinity host selector (#2143)
Do not remove the current affinity host from the options.

Fixes #2141.
2017-05-09 10:57:31 +02:00
Julien Fontanet
e853ba6244 chore(BaseComponent): use explicit tests 2017-05-07 22:17:20 +02:00
badrAZ
fb40ae7264 feat(vm): ability to choose the cores per socket when creating or editing a VM (#2127)
Fixes #130
2017-05-04 16:12:17 +02:00
badrAZ
f629047be2 chore(vm/new-vm): use _linkState instead of _getOnChange (#2134) 2017-05-04 16:06:50 +02:00
Olivier Lambert
278d8adf1b fix(dashboard): compute correctly the total SR size and used space (#2132)
Fixes #2123
2017-05-03 17:12:58 +02:00
Olivier Lambert
87087d55aa feat(sr): also display unmanaged VDIs (#2131) 2017-05-03 17:07:03 +02:00
Julien Fontanet
46e95fe7eb feat(backup/new): min timeout is 1s 2017-04-28 22:30:32 +02:00
Julien Fontanet
090c9ea4d7 5.8.0 2017-04-28 16:35:45 +02:00
Olivier Lambert
647eb7299e feat(changelog): update changelog 2017-04-28 16:06:47 +02:00
Olivier Lambert
027652e80a feat(changelog): release 5.8 2017-04-28 11:35:40 +02:00
badrAZ
185d380c36 feat(vm/advanced): ability to switch between Cirrus/Standard VGA adapters (#531) (#2091)
Fixes #158
2017-04-27 17:07:54 +02:00
Olivier Lambert
9008b5c4e7 fix(dashboard): flip usage/total. Fixes #2115 2017-04-26 16:42:40 +02:00
Julien Fontanet
f5ad59803e fix(Wizard): take care of falsy children 2017-04-26 12:43:08 +02:00
Pierre Donias
81d1d7ba13 feat(XOSAN): ask user to restart toolstacks after pack installation (#2114) 2017-04-25 16:29:16 +02:00
Julien Fontanet
3328e71805 fix(backup/new): correctly edit schedule.enabled 2017-04-25 15:04:08 +02:00
Julien Fontanet
d7e3dbac26 fix(spelling): VDB → VBD 2017-04-25 14:32:46 +02:00
Olivier Lambert
905182bf2e feat(vm/disks): boot order only for HVMs and devices cannot be non-bootable (#2113)
Fixes #2015
2017-04-25 14:31:41 +02:00
Julien Fontanet
a0146290ee fix(package): downgrade resect to 2.5.4
Since reselect 3, selectors are pure which is incompatible with our use of inputs via closures:

```js
_getFoo = createSelector(
  () => this.props.bar,
  () => this.state.baz,
  (bar, baz) => /* ... */
)
```
2017-04-25 14:14:04 +02:00
Julien Fontanet
173aa22432 fix(intl/messages): correctly format numbers (#2112) 2017-04-25 12:29:56 +02:00
Julien Fontanet
9e5b871ebe chore(Wizard): use React.Children.map 2017-04-25 12:00:44 +02:00
Julien Fontanet
8824ce55ec chore(package): update some dependencies 2017-04-25 12:00:44 +02:00
Olivier Lambert
155edf5533 feat(dashboard): fix power test and remove users link for non-admins (#2111)
Fixes #2108
2017-04-25 12:00:34 +02:00
Olivier Lambert
6d06e1f89d feat(Menu): remove About if non admins (#2110)
Fixes #2109
2017-04-25 11:29:47 +02:00
Julien Fontanet
6d1e2c47d3 5.7.10 2017-04-24 17:53:00 +02:00
Julien Fontanet
8b9b0346cb chore(backup/new): do not send unnecessary job props 2017-04-24 17:51:13 +02:00
Julien Fontanet
0d11817e3f 5.7.9 2017-04-24 15:50:35 +02:00
Julien Fontanet
a8cb209717 chore(backup/new): clarify timeout meaning 2017-04-24 15:49:43 +02:00
Olivier Lambert
cf45ffddf1 feat(sr/disks): provide filters for snapshots (#2103)
Fixes #2102
2017-04-24 15:26:29 +02:00
Pierre Donias
2e0ea51c30 fix(dashboard): replace unused labelId by tooltip (#2100)
Fixes #2090
2017-04-21 17:41:51 +02:00
Julien Fontanet
0f7f8c7330 chore(Combobox): use uncontrollableInput 2017-04-20 12:08:16 +02:00
Julien Fontanet
808f72409f fix(home): replace history when setting initial filter 2017-04-19 17:19:14 +02:00
Julien Fontanet
f8e2d29372 chore(Button): own implementation instead of react-bootstrap (#2089) 2017-04-18 10:12:02 +02:00
Julien Fontanet
22dec27c65 chore(package): update standard to v10 (#2067) 2017-04-13 17:34:49 +02:00
Julien Fontanet
89b3806a7a fix(vm/action-bar): pending status for copy 2017-04-13 17:34:20 +02:00
Julien Fontanet
b6bedf9253 chore(ButtonGroup): own implementation instead of react-bootstrap 2017-04-13 14:43:32 +02:00
Julien Fontanet
0d4983043b feat(vm/tab-snapshots): add pending status on new snasphot 2017-04-13 14:16:07 +02:00
Julien Fontanet
f9ff3fe168 fix(vm/tab-disks): fix StateButton prop 2017-04-13 14:16:07 +02:00
Julien Fontanet
4a25c5323f feat(servers): add pending status 2017-04-13 14:16:07 +02:00
Julien Fontanet
9b4e2d3bb8 feat(vm/action-bar): add pending status 2017-04-13 14:16:07 +02:00
Julien Fontanet
3915efcf92 feat(ActionButton): add pending prop 2017-04-13 14:16:07 +02:00
Julien Fontanet
4591ff8522 chore(ActionButton): do not reassign redirectOnSuccess 2017-04-13 14:16:07 +02:00
Julien Fontanet
e3491797f3 chore(ActionButton): do not use React.PropTypes directly 2017-04-13 14:16:07 +02:00
Julien Fontanet
6eee167675 chore(ActionButton): props documentation 2017-04-13 14:16:07 +02:00
Julien Fontanet
16b965b28a chore(ActionButton): use relative import for Icon 2017-04-13 14:16:07 +02:00
Julien Fontanet
5125410efd chore(ActionButton): do not use react-bootstrap 2017-04-13 14:16:07 +02:00
karolsok
1a4da2a8de feat(intl): improve pl translation (#2088) 2017-04-13 09:50:29 +02:00
Julien Fontanet
991fbaec86 5.7.8 2017-04-12 17:32:37 +02:00
Pierre Donias
fb399278b3 fix(new-vm): add network predicate in VIF item (#2087)
Fixes #2086
2017-04-12 17:32:00 +02:00
Julien Fontanet
b868092365 fix(vms/new): only display Shared checkbox in resource set
Fixes #2061
2017-04-12 17:07:00 +02:00
Pierre Donias
80fdc6849f fix(XOSAN): use new pack format to check if XOSAN pack is installed (#2085) 2017-04-12 16:53:08 +02:00
karolsok
25ffcb952b fix(user/lang selector): fix Polski spelling (#2083) 2017-04-12 12:33:28 +02:00
Julien Fontanet
083ac1e2d6 5.7.7 2017-04-11 17:02:51 +02:00
Julien Fontanet
5a4b553a60 fix(form/Toggle): onChange now emits the raw value
Fixes #2080
2017-04-11 16:54:13 +02:00
Julien Fontanet
b1135ef566 fix(backup/new): do not send timeout=null on creation 2017-04-11 16:38:17 +02:00
Julien Fontanet
1928d1e00f chore(backup/new): remove now unnecessary code 2017-04-11 16:33:30 +02:00
Julien Fontanet
a369f7f387 fix(backup/new): wrap tags in array
Fixes #176
2017-04-11 16:12:08 +02:00
Olivier Lambert
33d9801dfe feat(i18n): add Polish language, fixes #2079 2017-04-11 08:51:44 +02:00
Julien Fontanet
8c7a031cca chore: coding style 2017-04-10 17:32:38 +02:00
Julien Fontanet
9484d87e76 chore(backup/new): clearer timeout label 2017-04-10 17:24:53 +02:00
Julien Fontanet
4b6822d6e5 fix(backup/new): default owner is current user 2017-04-10 17:23:10 +02:00
Julien Fontanet
7241a0529b fix(utils/addSubscription): only use setState() when mounted 2017-04-10 17:05:50 +02:00
Julien Fontanet
66083b4e50 fix(backup/new): timeout should be in seconds
Fixes #2076
2017-04-10 16:47:04 +02:00
karolsok
f631b3cc64 feat(intl): pl translation (#2068) 2017-04-10 16:07:01 +02:00
Julien Fontanet
bb58d9b4d6 5.7.6 2017-04-07 16:16:06 +02:00
Julien Fontanet
93ebff1055 fix(backup/new): default to non smart backup 2017-04-07 16:12:51 +02:00
Julien Fontanet
08aec1c09a fix(backup/new): job creation was broken 2017-04-07 16:10:56 +02:00
Julien Fontanet
8ca98a56fe 5.7.5 2017-04-07 15:52:13 +02:00
Julien Fontanet
705f53e3e5 fix(scheduling): timezone selection 2017-04-07 15:51:49 +02:00
Julien Fontanet
adaf069d20 5.7.4 2017-04-07 15:27:46 +02:00
Julien Fontanet
d7be7d8660 fix(select-objects): do not treat empty string as a value (2) 2017-04-07 15:25:41 +02:00
Julien Fontanet
faddee86b6 fix(select-objects): do not treat empty string as a value 2017-04-07 15:23:27 +02:00
Julien Fontanet
c4fcc65d16 fix(backup/new): coding style 2017-04-07 15:17:51 +02:00
Julien Fontanet
890631d33b fix(select-objects): correctly handle incorrect values with non-multi 2017-04-07 15:17:32 +02:00
Julien Fontanet
8e8145bb48 chore(backup/new): controlled inputs (#2072) 2017-04-07 15:02:53 +02:00
Julien Fontanet
d73d6719a5 5.7.3 2017-04-06 19:30:33 +02:00
Pierre Donias
3419bee198 feat(pack,patch): support 7.1 packs/patches format (#2069)
Fixes #2058
2017-04-06 19:05:51 +02:00
Julien Fontanet
4368fad393 fix(react-novnc): do not error if canvas is not mounted 2017-04-06 17:28:29 +02:00
badrAZ
ab93fdbf10 feat: Display a warning when the CD drive is not completely installed (#2066)
Fixes #2064
2017-04-06 15:22:42 +02:00
Julien Fontanet
8fd7697a45 fix(vm/disks): attach/create disk for non-PV VM 2017-04-06 12:15:22 +02:00
badrAZ
1121a60912 feat(host/network): use StateButton (#2063)
Fixes #2060
2017-04-06 09:58:41 +02:00
Julien Fontanet
e7b4bd2fe4 5.7.2 2017-04-05 15:07:39 +02:00
Julien Fontanet
fcd8bdd1b3 chore(backup/new): simplify smart-backup condition 2017-04-05 14:52:52 +02:00
badrAZ
e6f140f575 fix(select-objects): display missing objects (#2059)
Fixes #2052
2017-04-05 14:52:21 +02:00
Julien Fontanet
bfe4c45fcf fix(xo/configurePlugin): do not swallow error 2017-04-03 10:31:21 +02:00
Julien Fontanet
f95370124b 5.7.1 2017-03-31 18:05:29 +02:00
Julien Fontanet
2564343816 fix(xo-json-schema-input/vm): controlled mode 2017-03-31 18:03:35 +02:00
Julien Fontanet
03734eb761 fix(logs): do not fail on non-string params 2017-03-31 18:03:35 +02:00
Julien Fontanet
29d63a9fdd 5.7.0 2017-03-31 16:36:40 +02:00
Julien Fontanet
ca94b236a8 feat(settings/plugins): easier edition 2017-03-31 16:35:14 +02:00
Julien Fontanet
fa1ec30ba5 chore(json-schema-input): controlled inputs (#2001) 2017-03-31 16:21:54 +02:00
Olivier Lambert
2b1423aebe fix(changelog): it seems we are in 2017. 2017-03-31 14:55:56 +02:00
Pierre Donias
373332141f fix(pool/packs): starter plan required to install packs (#2055) 2017-03-31 11:01:17 +02:00
Olivier Lambert
ecf2cf15b5 fix(changelog): typo in 5.7 release 2017-03-31 10:32:50 +02:00
Olivier Lambert
4ee0831d93 feat(changelog): updates for 5.7 2017-03-31 10:31:11 +02:00
Pierre Donias
7df2a88c13 feat(xosan/pack): check XS version requirement (#2054) 2017-03-31 10:18:43 +02:00
Olivier Lambert
3d52556c67 feat(changelog): updates for 5.6 2017-03-31 10:11:38 +02:00
badrAZ
437b160a3f feat(servers): add label property (#2051)
Fixes #1965
2017-03-29 16:23:51 +02:00
Pierre Donias
5c87b82e0c feat(new-vm,vm): select an affinity host (#2039)
See #1983
2017-03-29 14:07:55 +02:00
badrAZ
7f2bc79d5f feat(ActionButton): improve error reporting (#2050)
Fixes #2048
2017-03-29 12:03:19 +02:00
Pierre Donias
837a61acf3 fix(home): not visible items should never be selected (#2042)
Fixes #2027
Fixes #2035
2017-03-29 10:53:31 +02:00
badrAZ
5971eed72a feat(jobs): configure job timeout (#2043)
Fixes #1956
2017-03-29 10:39:29 +02:00
Pierre Donias
1b8224030b fix(ipPools): prevent creating 2 IP pools with the same name (#2041)
Fixes #1731
2017-03-24 12:26:52 +01:00
Pierre Donias
ed3ec3fa8b fix(vm/disks): do not show bootable flags for non PV VMs (#2040)
Fixes #1996
2017-03-24 11:49:46 +01:00
Pierre Donias
aa98ca49e5 feat(locales): Hungarian (hu) (#2038)
Fixes #2019
2017-03-24 10:36:03 +01:00
badrAZ
44d35c2351 feat: more uses of StateButton (#2034) 2017-03-23 17:46:26 +01:00
badrAZ
df8eb7a000 feat({backup,job}/overview): clearer state (#2023)
Fixes #1958
2017-03-23 09:42:23 +01:00
Julien Fontanet
ac061c8750 chore(backup/new): improve description of report 2017-03-22 12:13:35 +01:00
Julien Fontanet
656d3e55ac feat(backup/new): report on failure by default 2017-03-22 12:09:13 +01:00
Julien Fontanet
50641287f8 fix(XoApp): wait for signin before show pages 2017-03-17 14:48:33 +01:00
Julien Fontanet
0bc072aa65 feat(Home): add a None filter 2017-03-17 14:26:21 +01:00
Julien Fontanet
9d7d665520 chore(Home#_getDefaultFilter): cleaner code 2017-03-17 14:26:21 +01:00
Julien Fontanet
819ea94e7b fix(xo): keep user in store up to date 2017-03-17 14:26:21 +01:00
badrAZ
40753568df fix(settings/remotes): no duplicate names (#2021)
Fixes #1879
2017-03-17 14:11:15 +01:00
badrAZ
8793aed561 feat(home): improve inter-types linkage (#2015)
Fixes #2012
2017-03-16 10:11:52 +01:00
Julien Fontanet
377a50bc09 fix: minor warnings 2017-03-15 17:02:03 +01:00
Julien Fontanet
fe5a43fbdf chore: update yarn.lock 2017-03-15 16:09:17 +01:00
badrAZ
7f44220220 feat(new VM): share a VM (#2013) 2017-03-15 14:38:28 +01:00
greenkeeper[bot]
0df1610ca9 chore(package): update gulp-csso to version 3.0.0 (#2009)
https://greenkeeper.io/
2017-03-14 14:51:53 +01:00
Julien Fontanet
24c8b9e02d chore(auto-controlled-component): remove base-component dep 2017-03-14 11:43:47 +01:00
Pierre Donias
01b311f2ba fix(new-vm): remove bootable option (#2008)
Fixes #2007
2017-03-14 11:27:49 +01:00
Pierre Donias
a2bb3182f4 feat(backup/logs): show job tag in table (#2005)
Fixes #1982
2017-03-14 10:54:39 +01:00
Pierre Donias
c86e15a310 feat(xo/utils/getDefaultNetworkForVif): match network with same VLAN (#1997)
Fixes #1990
2017-03-13 18:03:14 +01:00
Julien Fontanet
862e5a95e7 fix(package): update babel-plugin-lodash 2017-03-09 17:51:47 +01:00
Julien Fontanet
73e2c7e849 chore(package): use babel-plugin-dev 2017-03-09 17:50:08 +01:00
Julien Fontanet
0b0937e233 chore(base-component): remove shallow-equal dep 2017-03-09 15:22:52 +01:00
Julien Fontanet
6bf114859f chore(base-component): remove invoke dep 2017-03-09 15:20:14 +01:00
Julien Fontanet
db6d67eeb7 feat(JsonSchemaInput/EnumInput): handle enumNames 2017-03-08 18:08:59 +01:00
Julien Fontanet
a345d89aac fix(home): changing type reset paging
Fixes #1993
2017-03-06 15:47:42 +01:00
Pierre Donias
e8f8ebb112 feat(XOSAN): select suggestion, SVG graph (#1991) 2017-03-06 12:01:38 +01:00
Julien Fontanet
1dad5b5c3a 5.6.3 2017-03-02 19:07:29 +01:00
Pierre Donias
5cc5ee4e87 fix(XOSAN): XS v7.0 required to install XOSAN (#1981) 2017-03-02 17:38:55 +01:00
Julien Fontanet
e8d2b32a14 5.6.2 2017-03-01 17:09:19 +01:00
Julien Fontanet
f492909e42 fix(linting): ignored files go into /.gitignore 2017-03-01 15:19:39 +01:00
Pierre Donias
7ea17750a1 fix(pool/patches): disable patching for free plan (#1972) 2017-03-01 10:13:09 +01:00
Julien Fontanet
663e1f1a4b fix(menu): XOSAN only displayed to admins
Fixes #1968
2017-02-28 17:54:21 +01:00
Julien Fontanet
079310c67e fix(store/reducer/object): missing part of previous fix 2017-02-28 17:01:36 +01:00
Julien Fontanet
5cf7f1f886 fix(store/reducer/object): handle type change
Fixes #1967
2017-02-28 16:14:07 +01:00
Julien Fontanet
9f64af859e chore(package): update react-select to v1.0.0-rc.3 2017-02-28 10:44:04 +01:00
Julien Fontanet
007aa776cb chore(package): update index-modules to v0.3.0 2017-02-28 10:33:12 +01:00
Julien Fontanet
66bc092edd chore(package): update husky to v0.13.1 2017-02-28 10:30:44 +01:00
Julien Fontanet
140a88ee12 chore(package): update jest to v19.0.2 2017-02-28 10:29:44 +01:00
Julien Fontanet
f42758938d fix(package): migrate ghooks→husky config 2017-02-27 11:41:31 +01:00
Julien Fontanet
e19fd81536 chore: update yarn.lock 2017-02-27 11:40:28 +01:00
Julien Fontanet
73835ded96 chore(store/actions/createAction): minor optimizations 2017-02-27 11:37:56 +01:00
Julien Fontanet
1ec1a8bd94 chore(package): update superagent to version 3.5.0 (#1962)
Closes #1947

https://greenkeeper.io/
2017-02-27 11:34:57 +01:00
greenkeeper[bot]
f0b6d57ba8 chore(package): update modular-css to version 4.1.1 (#1952)
https://greenkeeper.io/
2017-02-27 11:33:12 +01:00
Julien Fontanet
f9a3ad14d1 5.6.1 2017-02-23 18:39:04 +01:00
Pierre Donias
1b86f533f7 feat(XOSAN) (#1955) 2017-02-23 18:34:20 +01:00
greenkeeper[bot]
46416fb026 chore(package): update notifyjs to version 3.0.0 (#1940)
https://greenkeeper.io/
2017-02-15 12:41:38 +01:00
Julien Fontanet
54ed37c95d chore: update yarn.lock 2017-02-14 15:21:44 +01:00
Julien Fontanet
fd79b47d9e fix(tasks): do not break on unknown host 2017-02-14 15:13:37 +01:00
greenkeeper[bot]
be8333824b chore(package): update browserify to version 14.1.0 (#1938)
https://greenkeeper.io/
2017-02-14 09:05:21 +01:00
Julien Fontanet
55daffc791 fix(pool): predicate for host to add is now dynamic (#1923) 2017-02-07 11:17:33 +01:00
Pierre Donias
375baf7fe5 feat(home): link to VM's resource set (#1920)
Fixes #1905
2017-02-01 17:01:40 +01:00
Pierre Donias
815e74c93c feat(vm): allow snapshot with ACLs (#1916)
Fixes #1865
2017-02-01 15:35:54 +01:00
Pierre Donias
547d6fbc93 feat(pool/advanced): install supplemental pack on all pool's hosts (#1910)
See #1896
2017-02-01 13:08:16 +01:00
greenkeeper[bot]
b45a4b9e6c chore(package): update chartist-plugin-legend to version 0.6.1 (#1915)
https://greenkeeper.io/
2017-02-01 09:21:28 +01:00
greenkeeper[bot]
3436d0256a chore(package): update modular-css to version 3.0.0 (#1914)
https://greenkeeper.io/
2017-01-31 08:35:26 +01:00
greenkeeper[bot]
2627cfd426 chore(package): update react-chartist to version 0.12.0 (#1912)
https://greenkeeper.io/
2017-01-30 10:53:38 +01:00
Olivier Lambert
34b18c00a1 fix(lang): button verbiage. Fixes #1911 2017-01-30 10:07:00 +01:00
Julien Fontanet
e13af7f5f0 5.6.0 2017-01-27 16:41:29 +01:00
Nicolas Raynaud
ca08613292 fix(VM import): behave if network is not an object (#1908) 2017-01-27 13:03:30 +01:00
Pierre Donias
4ab63591a0 feat(host/advanced): install a supplemental pack (#1895)
Fixes #1460
2017-01-25 16:08:45 +01:00
Pierre Donias
5b4f98b03b fix(scheduling): improve TimePicker UI (#1898)
Fixes #1893
2017-01-25 15:59:03 +01:00
Pierre Donias
f396d61633 feat(settings/logs): easy bug reporting from errors (#1907)
See #1602
2017-01-25 15:06:18 +01:00
Julien Fontanet
9f8c0c8cdf fix(scheduling): month range is 0-11 not 1-12 (#1894)
* fix(scheduling): month range is 0-11 not 1-12

* fix(scheduling): remove unused import
2017-01-19 17:46:37 +01:00
Julien Fontanet
198777ffab fix(xo): improve plugin errors 2017-01-19 16:42:38 +01:00
Pierre Donias
29c5ca1132 feat(host/advanced): display installed supplemental packs (#1890)
Fixes #1506
2017-01-16 18:03:57 +01:00
Pierre Donias
05d6f3d1ed feat(iso-device): show DVDs in ISO selector (#1889)
Fixes #1880
2017-01-16 17:06:56 +01:00
Olivier Lambert
536e82de3d feat(readme): add live chat link and icon 2017-01-16 14:54:57 +01:00
Pierre Donias
c59be7c315 fix(backup/new): smart backup pool filter (#1888)
Leaving the pool filter empty now means no filtering on pools, it should be clearer.

See #1885
2017-01-16 14:49:50 +01:00
Pierre Donias
b327bb5bd0 feat(backup/file-restore): restore multiple files (#1886)
Fixes #1877
2017-01-16 09:33:30 +01:00
Julien Fontanet
a3103587f5 chore(package): use husky instead of ghooks 2017-01-11 10:07:16 +01:00
Julien Fontanet
1bb11b574f chore: update yarn.lock 2017-01-11 10:05:18 +01:00
greenkeeper[bot]
405efe6a31 chore(package): update react-redux to version 5.0.0 (#1825)
https://greenkeeper.io/
2017-01-11 09:22:07 +01:00
Pierre Donias
73663c3703 fix(locales/fr): multiple fixes (#1876) 2017-01-10 17:42:41 +01:00
Julien Fontanet
421ee7125b chore: update yarn.lock 2017-01-09 10:12:31 +01:00
Julien Fontanet
1a6166b63c chore: update yarn.lock 2017-01-09 10:04:37 +01:00
Julien Fontanet
3828e75b7d fix(package): use bootstrap 4.0.0-alpha5 exactly
Bootstrap 4.0.0-alpha6 is not compatible, we'll migrate with beta1.

See #1871
2017-01-09 10:02:43 +01:00
greenkeeper[bot]
154da142c7 chore(package): update gulp-sourcemaps to version 2.2.3 (#1874)
https://greenkeeper.io/
2017-01-09 09:58:50 +01:00
Pierre Donias
312cd60dd1 feat(settings/servers): error handling (#1868)
Fixes #1833
2017-01-06 16:38:24 +01:00
greenkeeper[bot]
6bf522f72f chore(package): update promise-toolbox to version 0.8.0 (#1870)
https://greenkeeper.io/
2017-01-06 11:39:58 +01:00
Pierre Donias
a844f8d459 fix(backup/new): prevent negative depth values (#1869)
Fixes #1851
2017-01-06 11:12:56 +01:00
Julien Fontanet
8ee206174b fix(vm/advanced): PV args edition for all PV VMs
Currently only available if there are already PV args.
2017-01-05 16:51:56 +01:00
Olivier Lambert
1a08e24a5c feat(pool): harmonize links to hosts and storages (#1867)
Fixes #1864
2017-01-05 14:29:06 +01:00
greenkeeper[bot]
086cd0e038 chore(package): update modular-css to version 2.0.0 (#1862)
https://greenkeeper.io/
2017-01-04 09:43:32 +01:00
Julien Fontanet
42d123318c chore(pakcage): upgrade react/react-dom to v15.4.1 2017-01-03 15:28:53 +01:00
Julien Fontanet
89f160317c 5.5.3 2017-01-03 15:19:09 +01:00
Julien Fontanet
9ccd1a0362 chore: update yarn.lock 2017-01-03 15:18:27 +01:00
Pierre Donias
d116d014bc fix(host/network): PIF deletion (#1861)
Fixes #1853
2017-01-03 15:13:44 +01:00
Pierre Donias
7956cabcf4 feat(pool): combined stats tab (#1848)
Fixes #1324
2017-01-03 14:58:22 +01:00
Pierre Donias
36c61ad357 feat(vm/snapshots): icon to indicate if a snapshot is quiesce (#1860)
Fixes #1858
2017-01-03 10:54:58 +01:00
greenkeeper[bot]
25d60360d5 chore(package): update modular-css to version 1.0.0 (#1859)
https://greenkeeper.io/
2017-01-03 09:38:00 +01:00
Olivier Lambert
1e5579e3ad feat(icons): use microchip for the CPU icon 2017-01-02 17:14:05 +01:00
Julien Fontanet
77d43b2280 fix(settings/logs): correctly refresh users 2017-01-02 16:36:09 +01:00
Julien Fontanet
33e8929e8b fix(settings/groups): avoid error when adding a user 2017-01-02 16:36:02 +01:00
Julien Fontanet
b79fa9cb9f feat(backup/overview): sort by start if not end
Avoid unfinished (broken) jobs to stay at the top.
2017-01-02 16:34:36 +01:00
Olivier Lambert
a2812a85bd feat(vm): redirect to home after converting VM to template (#1857)
Fixes #1855
2017-01-02 14:12:33 +01:00
Olivier Lambert
e8ff46a8ba fix(health): add link from SR to hosts and not only for pools. Fixes #1850 (#1856) 2017-01-02 11:29:32 +01:00
Julien Fontanet
351c01d642 fix(intl/messages): typo
Fix #1849
2016-12-24 09:15:54 +01:00
Julien Fontanet
e333b1d083 chore(package): use new shorter paths for Jest serializer 2016-12-22 16:58:26 +01:00
Julien Fontanet
5ad49de642 5.5.2 2016-12-22 12:27:03 +01:00
Fabrice Marsaud
b45bb5c144 fix(xoa-updater): use the new source info (#1846) 2016-12-22 12:26:02 +01:00
Julien Fontanet
9402596f69 5.5.1 2016-12-22 11:18:32 +01:00
Fabrice Marsaud
096687ae2c fix(xoa-updates): also refresh on plan change (#1843) 2016-12-22 11:16:45 +01:00
Julien Fontanet
210b5de992 fix(backup/file-restore-modal): fetched timestamps are in seconds
Follow up to for #1840.
2016-12-20 17:10:55 +01:00
Julien Fontanet
f742fdbf1b fix(backup/file-restore): fetched timestamps are in seconds
Fixes #1840
2016-12-20 16:49:37 +01:00
Pierre Donias
e7026c522d fix(editable/XoSelect): update value before saving (#1835) 2016-12-20 13:54:22 +01:00
Julien Fontanet
c21fc4beda 5.5.0 2016-12-20 13:39:05 +01:00
Julien Fontanet
edf6fe782e chore: update yarn.lock 2016-12-20 13:36:39 +01:00
Pierre Donias
3cbb6c4a98 feat(backup): implement file restore (#1838)
Fixes #1590
2016-12-20 13:34:59 +01:00
Olivier Lambert
568a50acc5 feat(changelog): update changelog 2016-12-19 17:59:14 +01:00
Pierre Donias
fbcb756cef fix(backup/new): remove "Only metadata" option (#1837)
Fixes #1818
2016-12-19 17:53:04 +01:00
Pierre Donias
81eb4ba4f9 fix(form/Select): make text wrap when too long (#1836)
Fixes #1832
2016-12-19 17:15:03 +01:00
Olivier Lambert
0cc14d2ab8 fix(intl): fix the place holder for NFS path, removing the initial slash 2016-12-19 13:48:49 +01:00
greenkeeper[bot]
6aedadc982 chore(package): update jest to version 18.0.0 (#1831)
https://greenkeeper.io/
2016-12-15 12:34:05 +01:00
Olivier Lambert
a8d10dab3c feat(changelog): changelog for 5.5 release 2016-12-15 12:19:35 +01:00
Pierre Donias
1ff6ff1d7a fix(getDefaultNetworkForVif): allow PIFs with no IP (#1830)
Fixes #1788
2016-12-15 10:31:03 +01:00
Pierre Donias
8afe4a85dc fix(form/select-plain-object): make it controlled (#1829) 2016-12-14 17:18:31 +01:00
greenkeeper[bot]
c57fbdce63 chore(package): update index-modules to version 0.2.1 (#1822) 2016-12-12 16:49:29 +01:00
greenkeeper[bot]
bdc0278fd1 chore(package): update gulp-sass to version 3.0.0 (#1820)
https://greenkeeper.io/
2016-12-10 15:07:20 +01:00
Fabrice Marsaud
c3ac8d0587 fix(xoa-updater): propose refresh when xo-web is not up to date (#1815)
Fixes #1801.
2016-12-08 16:24:47 +01:00
Julien Fontanet
f3a5e1e97c feat: yarn integration (#1813) 2016-12-07 14:36:51 +01:00
Julien Fontanet
919aa5fc43 feat(tests): basic tests for grid components 2016-12-07 14:06:20 +01:00
Julien Fontanet
416c98ffd2 chore(tests): use jest instead of ava 2016-12-07 14:06:20 +01:00
Pierre Donias
8094447183 fix(self-service): make it controlled and multiple fixes (#1812)
Fixes:
- VIF IP edition was not possible if the current IP's IP-pool did not exist anymore
- VM creation: removing the pool/resource set in the selector was broken
- Prevent selecting a negative number as an IP pool quantity
- Prevent deleting a resource set that hasn't been created yet
- Remove console.log
2016-12-06 16:43:07 +01:00
Julien Fontanet
575375d3e0 5.4.1 2016-12-05 14:08:56 +01:00
Julien Fontanet
4296ae02dc fix(vm/network): fix IP addresses concatenation 2016-12-05 14:04:43 +01:00
Julien Fontanet
0e40af0515 feat(patch-react): name the patched render function 2016-12-05 14:03:39 +01:00
Julien Fontanet
5d3a0e7a41 fix(patch-react): assign arguments object directly 2016-12-05 10:43:09 +01:00
Julien Fontanet
8ae2aae37a fix(package): update xo-acl-resolver to v0.2.3
It ships a workaround for an issue when a VDI snapshot $snapshot_of is itself.
2016-12-02 16:18:31 +01:00
Pierre Donias
83b3cf406a fix(lang): auto-refresh XO app when changing language (#1809)
Fixes #1800
2016-12-02 13:09:35 +01:00
Julien Fontanet
1643ced4e0 feat: do not break if a component throws 2016-12-01 16:49:36 +01:00
Pierre Donias
b2a1840da7 fix(vm-import): SR selector disable condition (#1808)
Fixes #1804
2016-12-01 15:54:58 +01:00
Pierre Donias
b9f20d1e80 fix(select-objects): allow integer IDs (#1807)
Fixes #1805
2016-12-01 15:39:47 +01:00
Pierre Donias
0c77781be8 feat(backup/smart): tags/pools select all and negation (#1802)
Fixes #1503
2016-12-01 14:56:18 +01:00
Julien Fontanet
83245af1e2 feat: improve debugging in production (#1806)
* feat(build): enable sourcemaps in production

* feat(index): let browsers handle unhandled rejections

They do a much better job to display the error and its trace with sourcemaps.
2016-12-01 14:22:07 +01:00
Julien Fontanet
7db806a461 fix(xo/subcriptions): handle unsubscription during notification 2016-12-01 12:15:12 +01:00
Olivier Lambert
92b15fb1e2 feat(consoles): update tip about console issue to point to XS ticket 2016-11-29 11:00:30 +01:00
Pierre Donias
7b5182111c fix(dashboard/health): message parsing and link to object view (#1796)
Related to #1776
2016-11-29 09:53:19 +01:00
Nicolas Raynaud
82b1b81999 fix(dashboard/overview): graphs on Safari (#1771)
There seems to be a bug in Safari with flex layout, hard coding the height of the graph seems to do the trick.

Fixes #1755
2016-11-29 09:21:04 +01:00
Pierre Donias
f0a430f350 feat(acls): filter object selector (#1791)
Fixes #1515
2016-11-28 12:05:56 +01:00
Olivier Lambert
90f95b7270 feat(i18n): added selector for simplified Chinese 2016-11-28 10:53:41 +01:00
Olivier Lambert
15e6a93fac feat(i18n): added simplified Chinese translation 2016-11-28 10:45:33 +01:00
Julien Fontanet
01541a2577 feat(@autoControlledInput): make controlled inputs able to handle uncontrolled mode
See #1628.
2016-11-24 11:34:21 +01:00
Olivier Lambert
8c70bc0a17 feat(i18n): fix wrong translate key 2016-11-24 10:16:44 +01:00
Nicolas Raynaud
9d96074604 chore(package): update react-shortcuts to v1.3.1 (#1792)
Fix #1691
2016-11-24 09:58:56 +01:00
Julien Fontanet
114a4028f4 fix: coding style fixes 2016-11-24 09:57:02 +01:00
Julien Fontanet
b342a4ba17 5.4.0 2016-11-23 11:09:24 +01:00
Olivier Lambert
fcbf037619 feat(changelog): prepare for the 5.4 release 2016-11-22 18:23:23 +01:00
Pierre Donias
a8e4ab433d feat(backup/new): warning when using delta or continuous rep with XS<6.5 (#1782) 2016-11-22 17:10:26 +01:00
Pierre Donias
6613ba02ab feat(dashboard/health): better formating of alert messages (#1781)
Fixes #1776
2016-11-22 16:41:07 +01:00
Pierre Donias
2af7fde83f fix(dashboard/health): delete orphaned VDIs (#1778)
Fixes #1622
2016-11-21 15:49:23 +01:00
Pierre Donias
19a0d4bc98 feat(timezone-picker): make server timezone less central (#1774)
Fixes #1706
2016-11-21 15:48:01 +01:00
Pierre Donias
9ed49b1f27 fix(menu): non admin users should not see backups and SRs in menu (#1777)
Fixes #1773
2016-11-21 15:45:34 +01:00
Pierre Donias
d56df30a22 feat(host): link to VMs list (#1772)
Fixes #1432
2016-11-18 12:50:43 +01:00
Julien Fontanet
64908068d9 fix: remove Intl polyfill
Safari 10 fixes this issue.

Fixes #1629
2016-11-18 12:40:24 +01:00
Pierre Donias
fe69d59aeb feat(tags): link to home page with tag filter (#1770)
Fixes #1763
2016-11-18 11:31:12 +01:00
Julien Fontanet
b65e737f84 feat(complex-matcher): support matching boolean props
Fixes #1768
2016-11-17 15:28:52 +01:00
Pierre Donias
bd274fdc3c feat(home): can display SRs (#1767)
Fixes #1764
2016-11-17 15:03:46 +01:00
greenkeeper[bot]
ac19249c63 chore(package): update xo-common to version 0.1.0 (#1765)
https://greenkeeper.io/
2016-11-17 05:28:32 +01:00
badrAZ
2abff1fec8 fix(settings/plugins): fix test when no test schema (#1766) 2016-11-16 15:38:48 +01:00
badrAZ
f1a6cfae0d feat(settings/plugins): display plugin test failures (#1754) 2016-11-16 10:53:57 +01:00
greenkeeper[bot]
e43e90ed3c chore(package): update react-chartist to version 0.11.0 (#1761)
https://greenkeeper.io/
2016-11-15 12:58:44 +01:00
greenkeeper[bot]
0ee88fe0dc Update dependencies to enable Greenkeeper 🌴 (#1757)
https://greenkeeper.io/
2016-11-15 11:02:45 +01:00
Pierre Donias
07e7f2e14d fix(menu): jobs should not be available to non-admin users (#1760)
Fixes #1759
2016-11-15 09:46:37 +01:00
Julien Fontanet
366ab95a2f feat(backup,job): ability to set the job owner (#1758)
Fixes #1733
2016-11-14 17:43:02 +01:00
Pierre Donias
ca723068a1 Fix clearable condition. 2016-11-14 17:29:29 +01:00
Pierre Donias
e424a105b3 Minor fixes. 2016-11-14 17:23:05 +01:00
Pierre Donias
32d2f92413 Multiple fixes. 2016-11-14 16:48:33 +01:00
Pierre Donias
898e2ff010 feat(job,backup): handle unexisting job creator
See #1733
2016-11-14 15:32:52 +01:00
Pierre Donias
dfa5e76870 feat(sr/disks): also display VDI snapshots (#1750)
Fixes #1723
2016-11-09 16:38:52 +01:00
Julien Fontanet
c93dd12fae feat(settings/plugins): testing
See #1749
2016-11-09 16:34:29 +01:00
Julien Fontanet
dbb1b1e582 fix(settings/plugins): unloading 2016-11-09 16:19:07 +01:00
Julien Fontanet
76388ee160 feat(utils/Debug): correctly display undefined 2016-11-09 16:18:32 +01:00
Pierre Donias
5ec2eee69a fix(settings/plugins): no plugins message condition (#1746) 2016-11-09 10:08:18 +01:00
Pierre Donias
31875a36fe fix(backup/restore): do not display duplicate tags (#1745)
Fixes #1734
2016-11-08 17:43:01 +01:00
Olivier Lambert
c50598b78e fix(jobs): last slicing fixed for job IDs 2016-11-08 15:37:44 +01:00
Pierre Donias
2f0c81d9ad feat(settings/plugins): message when no plugins (#1744)
Fixes #1670
2016-11-08 15:30:36 +01:00
Olivier Lambert
c22f89c6bb fix(jobs): better slicing of job IDs 2016-11-08 15:29:46 +01:00
Pierre Donias
568a23cd35 feat(pool/networks): change columns layout. Fixes #1696 2016-11-08 15:20:13 +01:00
Pierre Donias
eb7c4c131d fix(xo): add xo-common package (#1742) 2016-11-07 18:18:07 +01:00
Pierre Donias
f0664cd2c7 feat(xo/restartHost-s): trigger error modal if host could not be restarted (#1740)
Fixes #1717
2016-11-07 17:10:02 +01:00
Julien Fontanet
570eb7bc89 chore(package): update jsonrpc-websocket-client to v0.1.1 2016-11-07 16:48:10 +01:00
Pierre Donias
1ee91b4925 feat(backup/overview): display jobs in a SortedTable (#1741)
Fixes #1726
2016-11-07 14:43:16 +01:00
Julien Fontanet
69fee37f00 5.3.2 2016-11-04 11:43:49 +01:00
Julien Fontanet
49be66ae69 fix(xo/deleteSchedule): resolveIds() → resolveId()
Fixes #1737
2016-11-04 10:53:52 +01:00
Julien Fontanet
a0efe6895c fix(jobs/schedules/<id>/edit): correctly pass id prop
Fixes #1736
2016-11-04 10:31:32 +01:00
Julien Fontanet
8ef07e917d fix(jobs/<id>/edit): correctly set the id prop
Fixes #1728
2016-11-04 10:00:55 +01:00
Olivier Lambert
d3995b7bab feat(job): slicing some job ids 2016-11-03 18:00:49 +01:00
Olivier Lambert
c353e71ce7 feat(jobs): slice ids to be more human readable (#1735) 2016-11-03 16:48:48 +01:00
Olivier Lambert
a3570a1c9f feat(pif): use carrier to detect physical link (#1732)
Fixes #1702
2016-11-02 16:59:43 +01:00
Pierre Donias
c593c98e6d fix(settings/acls): display only valid ACLs (#1730) 2016-11-02 14:32:22 +01:00
Olivier Lambert
a4b5b532f2 feat(health): add links to some objects (#1729)
Fixes #1700
2016-11-02 12:29:50 +01:00
Julien Fontanet
6357f23aeb fix(package): use bootstrap 4.0.0-alpha5 2016-10-31 11:26:33 +01:00
Olivier Lambert
01d9b3bd0e feat(home/pools): add links to VMs or hosts and add VM number (#1720)
Fixes #1226
2016-10-28 14:35:32 +02:00
Pierre Donias
6b428f7587 fix(IP pools): behave with missing VIFs (#1716) 2016-10-28 11:57:29 +02:00
Pierre Donias
f829aa76d7 fix(dashboard/stats): requires at least Enterprise plan (#1718) 2016-10-28 11:43:36 +02:00
Fabrice Marsaud
a72051e96f fix(xoa-updater): fix double connection (#1714)
* fix double connection
* fix minified class name display
2016-10-28 10:16:56 +02:00
Pierre Donias
797622ba66 fix(settings/config): export/import should be available to Starter plan (#1715) 2016-10-28 09:52:41 +02:00
Julien Fontanet
39342cd662 5.3.1 2016-10-27 18:24:31 +02:00
Olivier Lambert
051a3ac122 feat(changelog): modify changelog for 5.3.1 2016-10-27 18:21:25 +02:00
Julien Fontanet
f842a321ba fix(xo): properly sign out on auth failure (#1712)
Fixes #1711
2016-10-27 18:17:20 +02:00
Julien Fontanet
3cd2dd65d3 chore(xo/importConfig): no need to promisify 2016-10-27 17:52:13 +02:00
Pierre Donias
5ce7e0b108 feat(settings/config): import/export XO configuration (#1703)
See #786
2016-10-27 15:08:45 +02:00
Julien Fontanet
71c2058cc8 fix(package): do not test on Node 7 (#1705)
* fix(package): do not test on Node 7
* fix(package): directly depend on chartist 0.9
* fix(package): directly depend on react-overlays 0.6
2016-10-27 11:57:06 +02:00
Greenkeeper
f200d39d23 chore(package): update modular-css to version 0.28.0 (#1707)
https://greenkeeper.io/
2016-10-26 23:34:32 +02:00
Pierre Donias
7932845ac5 fix(xo/exportVm): window.location instead of window.open() (#1704) 2016-10-26 16:52:26 +02:00
Julien Fontanet
94bda6ac9e chore(intl): update all locales (#1698) 2016-10-25 14:48:53 +02:00
fufroma
7a65f80406 feat(intl/messages): more translations (#1684) 2016-10-25 14:12:11 +02:00
Pierre Donias
36ab58dad9 feat(backup/restore): VM-centered UI (#1697)
Fixes #1609
2016-10-25 12:59:01 +02:00
Julien Fontanet
e9be9e3761 chore(package): update react-router to version 3.0.0 2016-10-25 11:21:46 +02:00
Julien Fontanet
b54645c86c chore(package): update d3 to version 4.2.8 2016-10-25 11:21:11 +02:00
Greenkeeper
ab77d8430c chore(package): update promise-toolbox to version 0.7.0 (#1690)
https://greenkeeper.io/
2016-10-24 15:02:02 +02:00
Pierre Donias
c6f683b532 feat(host,pool): edit PIFs VLAN (#1685)
See #1092
2016-10-24 09:52:47 +02:00
Pierre Donias
a2604f5156 fix(xo-app): ensure there is always a page title (#1687) 2016-10-21 18:10:53 +02:00
Pierre Donias
5ae7f683d6 fix(new-vm): fix getting disks in self service (#1688) 2016-10-21 18:00:38 +02:00
fufroma
f953c89979 fix(new/sr): fix username handling (#1683)
Regression was introduced in e79096626a
2016-10-21 11:56:36 +02:00
Julien Fontanet
bb8aab02ea fix(form/Password): generator in controlled mode
Fixes #1678
2016-10-20 17:58:49 +02:00
Julien Fontanet
af0c03ff6a 5.3.0 2016-10-20 16:09:25 +02:00
Olivier Lambert
8859900537 feat(changelog): update for release 2016-10-20 16:07:25 +02:00
Julien Fontanet
130852ab85 fix(xo): pass the refresh function to tap() 2016-10-20 15:13:55 +02:00
fufroma
65fa8f96b4 feat(intl): minor improvements (#1668) 2016-10-20 14:54:06 +02:00
Pierre Donias
0a84e9e363 feat(host/network): configure IP mode (#1671)
Fixes #1651
2016-10-20 13:32:43 +02:00
Pierre Donias
163c69454b fix(modal): disable shortcuts when a modal is open (#1673)
Fixes #1589
2016-10-20 13:30:29 +02:00
Julien Fontanet
49d3fde0f3 fix(JsonSchemaInput/Array): fix items handling
#1663
2016-10-20 13:22:11 +02:00
Pierre Donias
bb67e2254e fix(package): use new syntax of Boostrap classes (#1667) 2016-10-19 16:05:59 +02:00
Pierre Donias
6d2abc4e74 feat(IP pools): can be used in resource sets (#1662)
Fixes #1565
2016-10-19 11:17:44 +02:00
Julien Fontanet
4875450053 fix(home): correctly set default filter when user is loaded
Fixes #1665
2016-10-18 11:57:55 +02:00
Julien Fontanet
19184ca8a0 chore(base-component): disable verbose logs 2016-10-18 11:18:00 +02:00
Julien Fontanet
654c3d324b chore(package): jade → pug 2016-10-18 11:17:35 +02:00
fufroma
c5b4811f16 feat(intl): various new translations (#1659)
Also: favicon.
2016-10-17 14:43:50 +02:00
Julien Fontanet
7a9dc4fd59 fix(package): minor style issues 2016-10-14 14:13:20 +02:00
fufroma
e79096626a feat(intl): more translatable messages (#1641) 2016-10-14 10:46:46 +02:00
fufroma
332d074d32 fix(intl/locales/fr): various fixes (#1638) 2016-10-13 14:14:42 +02:00
Pierre Donias
e511ecd76e fix(vm/copy): inital value of compress should be false (#1652)
Fixes #1645
2016-10-12 09:06:28 +02:00
Greenkeeper
bcfbd5eba9 chore(package): update promise-toolbox to version 0.6.0 (#1650)
https://greenkeeper.io/
2016-10-11 17:32:23 +02:00
Pierre Donias
9fa3db395b fix(self): SizeInput's empty value should be null (#1649) 2016-10-11 15:01:43 +02:00
Julien Fontanet
52a41ceb04 chore(package): update standard to version 8.4.0 2016-10-11 11:39:27 +02:00
Julien Fontanet
e65d67266d style: indent fixes 2016-10-11 10:21:57 +02:00
Julien Fontanet
0d1045821c chore(intl/locales/zh): update skeleton 2016-10-10 16:02:44 +02:00
Pierre Donias
45d526dda2 fix(select-objects): dynamic option height (#1644)
Fixes #1411
2016-10-10 15:47:46 +02:00
Julien Fontanet
e52f998e78 fix(tools/update-locales): remove incorrect import 2016-10-10 10:15:58 +02:00
Julien Fontanet
42ed3b9355 feat(tools/update-locales): create or update locales (#1632)
Replace the existing `tools/create-locale`.
2016-10-10 09:57:08 +02:00
Julien Fontanet
563b4cb1ec 5.2.5 2016-10-07 15:45:28 +02:00
Olivier Lambert
45bad231cf feat(changelog): add 5.2.4 and 5.2.5 release 2016-10-07 15:44:47 +02:00
Pierre Donias
d76bd2484b fix(console): disable shortcuts when console is focused (#1637)
Fixes #1614
2016-10-07 15:26:20 +02:00
Pierre Donias
445b60bb63 fix(vm/console): initial scale value should be 1 (#1639) 2016-10-07 14:06:16 +02:00
Julien Fontanet
3214e0e41e fix: style & minor issues 2016-10-06 18:28:23 +02:00
Julien Fontanet
c61230e145 fix(intl/locales/fr): remove incorrect entry 2016-10-06 16:13:54 +02:00
fufroma
fac6a29226 feat(intl): new translatable messages (#1627) 2016-10-06 16:05:47 +02:00
Olivier Lambert
7a8f414748 feat(home/host): sparklines in expanded zone (#1619)
Fixes #1634
2016-10-06 15:14:35 +02:00
Julien Fontanet
9f450d282e chore(package): use index-modules 2016-10-06 14:41:46 +02:00
Pierre Donias
31787067e3 feat(new-vm): set dynamic and static memory bounds (#1618)
Fixes #1603
2016-10-05 17:27:59 +02:00
fufroma
1a769b23e2 feat(i18n): update French translation (#1600) 2016-10-05 10:38:12 +02:00
Olivier Lambert
ae002abafc feat(home/pool): bar for pool RAM usage (#1626)
Fixes #1625
2016-10-05 10:26:47 +02:00
Julien Fontanet
31a25d9c16 5.2.4 2016-10-04 15:35:11 +02:00
Julien Fontanet
356295c361 fix(package): add missing make-error 2016-10-04 15:33:24 +02:00
Julien Fontanet
d10681b6d1 fix(package): add missing even-to-promise 2016-10-04 15:33:24 +02:00
Julien Fontanet
0602410aa8 fix(package): update xo-acl-resolver to 0.2.2
Fixes vatesfr/xo-web#1621
2016-10-04 15:33:23 +02:00
Olivier Lambert
1112768adc feat(home/host): add memory bar (#1617)
Fixes #1616
2016-10-03 18:06:36 +02:00
Julien Fontanet
86b599df89 5.2.3 2016-10-03 09:39:59 +02:00
Olivier Lambert
88f7661172 feat(changelog): add info for 5.2.3 release 2016-10-03 09:21:45 +02:00
Julien Fontanet
29c96c0119 chore(gitignore): pnpm compat 2016-10-03 09:15:18 +02:00
Julien Fontanet
d8c6e54c68 fix(user): add VM template label 2016-10-03 09:13:42 +02:00
Julien Fontanet
df053eb016 fix(user): do not crash on missing type label 2016-10-03 09:13:26 +02:00
Julien Fontanet
d1715f7711 chore(intl): homeTypeTemplate → homeTypeVmTemplate 2016-10-03 09:09:40 +02:00
Julien Fontanet
240282c72d chore(intl): remove unused message 2016-10-03 09:09:03 +02:00
Olivier Lambert
9e8dd6ea21 fix(README): broken link to doc 2016-10-02 23:23:19 +02:00
Julien Fontanet
32806a20c9 fix(sr): goes to homepage if object disappear
Fixes #1611
2016-10-02 23:02:14 +02:00
Pierre Donias
34dcfbbf49 fix(home/item): prevent item from being displayed on 2 rows (#1608)
Fixes #1580
2016-09-30 13:33:05 +02:00
Pierre Donias
91fec43866 feat(pool/network): create a bonded network (#1605)
See #876
2016-09-30 11:23:44 +02:00
Greenkeeper
aa2d196a79 chore(package): update vinyl to version 2.0.0 (#1607)
https://greenkeeper.io/
2016-09-29 23:06:53 +02:00
Pierre Donias
180ca458ad feat(vm/network): allow VIF edition (#1596)
See #1446
2016-09-28 14:29:15 +02:00
Greenkeeper
aa881c60e7 chore(package): update babel-eslint to version 7.0.0 (#1597)
https://greenkeeper.io/
2016-09-27 23:39:03 +02:00
Greenkeeper
5b6966042d standard@8.2.0 breaks build 🚨 (#1595)
https://greenkeeper.io/
2016-09-27 01:11:46 +02:00
Julien Fontanet
dc859da0cd chore(build): remove embedded dev server 2016-09-26 16:45:02 +02:00
Pierre Donias
151eb6cbd6 feat(updates,users,servers): disable credentials autocomplete (#1592)
Fixes #1304
2016-09-26 16:00:04 +02:00
Olivier Lambert
16db591bbf feat(vm): add red icon if VM doesn't have tools. Fixes #1575 2016-09-26 12:24:58 +02:00
Pierre Donias
05a55e5eb2 fix(xoa-upgrade): more suitable message for non-admin users (#1591)
Fixes #1564
2016-09-26 10:31:23 +02:00
Pierre Donias
dcd84b2b8f feat(shortcuts): help modal and new home shortcuts (#1588)
Fixes #1578
2016-09-23 18:43:10 +02:00
Greenkeeper
4a89119f0a Update react-virtualized to version 8.0.8 🚀 (#1587)
https://greenkeeper.io/
2016-09-23 17:11:55 +02:00
Julien Fontanet
bc1c30a7bf chore(package): add __self prop, better React warnings 2016-09-23 16:02:19 +02:00
Julien Fontanet
33cffbf28b fix(Copiable): do not pass tagName prop to wrapper 2016-09-23 15:50:40 +02:00
Julien Fontanet
a18b68116c chore(package): improve React stack traces in dev build 2016-09-23 15:45:03 +02:00
Pierre Donias
d5acf15bca feat(vm/network): indicate when an IP is already used (#1584)
Fixes #1566
2016-09-23 12:13:48 +02:00
Pierre Donias
84f970af68 fix(shortcuts): prevent Shortcuts from stopping events propagation (#1583)
`Editable`s were broken (could not use *enter* to save).
2016-09-23 11:35:56 +02:00
Julien Fontanet
969f636bb7 fix(host/storage): name sorting 2016-09-23 10:54:36 +02:00
Pierre Donias
6939aee20a feat(home): keyboard shortcuts (#1400)
Fixes #1279
2016-09-22 19:01:05 +02:00
Pierre Donias
ab2a02a555 fix(vm/tab-network): lock icon conditions (#1576)
Fixes #1573
2016-09-22 16:52:37 +02:00
Pierre Donias
70038e0764 fix(new-vm): lodash/sum instead of lodash/sumBy (#1577) 2016-09-22 16:19:34 +02:00
Olivier Lambert
e730ef5e11 feat(host/sr): Sr link and better storage tab. (#1572)
Fixes #1567
2016-09-22 16:04:45 +02:00
Olivier Lambert
835ad5aaf1 feat(vm/host/pools/sr): add tooltips. Fixes #1568 2016-09-22 11:02:05 +02:00
Pierre Donias
ac645c8617 fix(home): types dropdown button title (#1570) 2016-09-22 10:47:48 +02:00
Julien Fontanet
b801fdbab2 5.2.2 2016-09-21 18:01:03 +02:00
Pierre Donias
bf495953e2 feat(new-vm): show resource set limits (#1563)
Fixes #1541
2016-09-21 11:58:07 -04:00
Pierre Donias
45b165deec fix(home): VM bulk restart (#1562)
Fixes #1561
2016-09-21 14:48:16 +02:00
Olivier Lambert
09169578e8 feat(changelog): add issue #1562 2016-09-21 14:47:52 +02:00
Olivier Lambert
43b2366927 feat(changelog): update changelog for 5.2.2 2016-09-21 12:22:37 +02:00
Julien Fontanet
f015a69eec feat(host/patches): display if needs to be restarted (#1559)
Fixes #1352
2016-09-21 10:10:44 +02:00
Olivier Lambert
99568508dd fix(charts): change color order to avoid confusions. Fixes #1265 2016-09-20 18:41:44 +02:00
Olivier Lambert
e8515344dd feat(home): display a message if a filter is empty. (#1560)
feat(home): display a message if a filter is empty. Fixes #1517
2016-09-20 12:34:07 -04:00
Julien Fontanet
edc873a570 fix(pool/storage): fix sort by usage 2016-09-20 15:53:45 +02:00
Julien Fontanet
1a03e96ab2 fix(pool/storage): fix passing pool to SortedTable 2016-09-20 15:53:25 +02:00
Olivier Lambert
89e0bb4f0a feat(home/templates): template management (#1533)
Fixes #1091
2016-09-20 13:46:58 +02:00
Olivier Lambert
7d0fd60908 feat(pool/storage): display default SR and add button to set it (#1557)
Fixes #1554
2016-09-20 13:19:47 +02:00
Pierre Donias
6b20523df4 fix(vm/tab-network): check for undefined network (#1556)
Fixes #1518
2016-09-20 11:52:17 +02:00
Julien Fontanet
e9a612647e fix(home): do not overwrite current filter (#1555)
Fixes #1513
2016-09-20 05:38:33 -04:00
Julien Fontanet
28404ef149 feat(SortedTable): default column can be set by a simple prop 2016-09-20 09:43:57 +02:00
Olivier Lambert
a5f8230def feat(self): hide some buttons and tabs for self service VMs (#1550) 2016-09-19 15:17:45 +02:00
Pierre Donias
39171de5de fix(job/new): forbid "_" character in job names (#1548)
Fixes #1414
2016-09-19 11:58:46 +02:00
Pierre Donias
5aa5a0acbc fix(home): set items per page in createPager (#1549) 2016-09-19 11:39:56 +02:00
Olivier Lambert
a4518e630a fix(log): sort logs by end date 2016-09-19 11:04:15 +02:00
Julien Fontanet
94975f5ea6 feat(settings/logs): group action buttons
Fixes #1547
2016-09-19 10:59:19 +02:00
Julien Fontanet
7e98838d96 feat(ActionButton): can have a tooltip 2016-09-19 10:59:19 +02:00
Pierre Donias
e8c9c196ff feat(vm/snapshot): "Snapshot before" checkbox in revert modal (#1543)
Fixes #1445
2016-09-17 00:11:51 +02:00
Julien Fontanet
db314a238f fix(xo/subcriptions): mark as non-running on error 2016-09-16 17:13:56 +02:00
Julien Fontanet
2c85a6d4ab fix(self/admin): do not fail on empty limits
Fixes #1537
2016-09-16 17:13:56 +02:00
Pierre Donias
b683e14e80 feat(self): merge dashboard and administration (#1542)
Fixes #1429
2016-09-16 16:47:20 +02:00
Olivier Lambert
ba45095fa8 fix(editable): limit input size for long text to 50ex. Fixes #1528 2016-09-15 16:45:19 +02:00
Olivier Lambert
b8e5ffa9f7 feat(backup): improved view. Fixes #1534 2016-09-15 16:26:42 +02:00
Pierre Donias
b4bff9e032 feat(vm/disks): "Long click to migrate" tooltip on SR (#1529)
* feat(vm/disks): "Long click to migrate" tooltip on SR

Fixes #1512

* feat(vm/disks): migrate VDI button, force cursor on editable

* fix bulk VDI migration

* Return Promise.all

* Ternary operator
2016-09-15 16:08:50 +02:00
Olivier Lambert
0c461bc4e2 feat(backuplogs): shorten the start/end date format. Fixes #1535 2016-09-15 15:55:01 +02:00
Olivier Lambert
a33b2a5294 fix(home/menu): adapt message depending of user perm (#1532)
Fixes #1519
2016-09-15 13:56:33 +02:00
Olivier Lambert
298e1c4471 fix(host console): removing useless ISO selector for host. Fixes #1527 2016-09-15 13:07:33 +02:00
Julien Fontanet
1c70cdc10b fix(render-xo-item): remove unused import 2016-09-15 13:07:04 +02:00
Julien Fontanet
160e4bb530 fix(SelectVmTemplates): use correct placeholder
Fixes #1530
2016-09-15 12:00:32 +02:00
fufroma
e69ba8dd96 Fix typo on Changelog (#1526) 2016-09-15 04:44:42 -04:00
Julien Fontanet
e55f4c3eb2 feat(settings/logs): show complete error object 2016-09-14 17:42:32 +02:00
Pierre Donias
1a3272b980 feat(new-vm): auto poweron setting (#1514)
Fixes #1444
2016-09-14 15:25:54 +02:00
Julien Fontanet
7bed5e025a fix(home): fix empty default filter (#1504)
Fixes #1354
2016-09-14 14:38:24 +02:00
Pierre Donias
29d22c0598 feat(backup/new): confirm modal when local remote is selected (#1507)
Fixes #1441
2016-09-14 13:20:51 +02:00
Greenkeeper
a38c7c34ac chore(package): update react-key-handler to version 0.3.0 (#1505)
https://greenkeeper.io/
2016-09-14 01:42:16 +02:00
Julien Fontanet
8d690ce4ff 5.2.1 2016-09-13 16:54:42 +02:00
Olivier Lambert
2569568a03 feat(changelog): patch version 5.2.1 changelog 2016-09-13 16:52:47 +02:00
Olivier Lambert
2c6ff6b5b8 feat(stopHost modal): explain consequences if halting a pool master. Fixes #1458 2016-09-13 15:28:30 +02:00
Pierre Donias
1257f01027 feat(new-vm): create tags during VM creation (#1501)
See #1431
2016-09-13 14:17:04 +02:00
Pierre Donias
fad6830863 fix(settings/remotes): SMB domain is required (#1502)
Fixes #1499
2016-09-13 11:28:07 +02:00
Olivier Lambert
66262bb20b fix(vm console): re-fix issue #1485 2016-09-13 11:01:18 +02:00
Julien Fontanet
4abb0754c7 fix(remotes): edition of URL parts (#1500)
Fixes #1498
2016-09-13 10:20:48 +02:00
Pierre Donias
78c53bf3ad fix(xo): better message for snapshot deletion (#1497)
Fixes #1433
2016-09-13 09:42:18 +02:00
Pierre Donias
810d666d84 feat(home): tooltips on bulk action buttons (#1496)
Fixes #1456
2016-09-12 17:04:02 +02:00
Pierre Donias
67699f0bb6 feat(pool/network): SortedTable and collapsable PIFs table (#1494)
Fixes #1461
2016-09-12 16:44:43 +02:00
Pierre Donias
46274948c0 fix(settings/logs): properly handle unknown user (#1495) 2016-09-12 16:42:52 +02:00
Olivier Lambert
28e3a842ef feat(vm): new containers tab (#1492)
Fixes #1442
2016-09-12 13:50:14 +02:00
Pierre Donias
6d90f1d45d fix(user): prevent SSH key overflow (#1491)
Fixes #1475
2016-09-12 12:57:11 +02:00
Pierre Donias
09642c347d feat(new-vm): Advanced section (#1486)
Fixes #1444
2016-09-12 12:27:11 +02:00
Pierre Donias
2d0e06f785 fix(backup/new): better month and week days layout (#1490)
Fixes #1488
2016-09-12 11:58:24 +02:00
Pierre Donias
a5bc8497cf fix(vm/tab-network): set default network and MTU for VIF creation (#1487)
Fixes #1472
2016-09-12 11:26:32 +02:00
Julien Fontanet
4bcb65c518 5.2.0 2016-09-09 16:31:24 +02:00
Olivier Lambert
25361fa7eb feat(changelog): add IP management feature in changelog 2016-09-09 16:30:13 +02:00
Pierre Donias
889a265000 feat(settings/ips): new page to manage IP pools (#1418)
Fixes #1350, fixes #988 and fixes #240.
2016-09-09 16:19:26 +02:00
Olivier Lambert
3122f6dcd5 feat(changelog): update changelog for 5.2.0 2016-09-09 14:21:54 +02:00
Olivier Lambert
16aa2e8085 bug(vmConsole): re-display header if VM goes from running to halted state. Fixes #1485 2016-09-08 16:29:56 +02:00
Julien Fontanet
074d51a670 fix(xo/deleteVms): delete disks as well
Fixes #1484
2016-09-08 15:06:42 +02:00
Greenkeeper
2122a79132 chore(package): update chartist-plugin-legend to version 0.5.0 (#1482)
https://greenkeeper.io/
2016-09-08 11:01:50 +02:00
Ronan Abhamon
26dbc585ba feat(vm-import): supports ova import (#709) (#1361)
Fixes #709
2016-09-08 10:15:44 +02:00
Greenkeeper
4b3cfbd424 chore(package): update modular-css to version 0.27.1 (#1478)
https://greenkeeper.io/
2016-09-08 09:55:38 +02:00
Julien Fontanet
035191a2cc feat(xo/installAllPatchesOnPool): better pool-wide patching (#1476)
Fixes #1392
2016-09-07 17:55:02 +02:00
Olivier Lambert
06a40180a1 fix(vm): do not display VDI or VIF disconnect but when VM is not running. Fixes #1470 and fixes #1468 2016-09-05 16:59:21 +02:00
Julien Fontanet
aaf4c5dff7 chore(Vm): move isRunning into utils/isVmRunning 2016-09-05 16:40:13 +02:00
Olivier Lambert
0c83bc2b0e feat(logview): standardize and improve the settings/log view. Fixes #1467 2016-09-05 16:10:12 +02:00
Julien Fontanet
2d412fd8db fix(scheduling): month and day display
There were issues with some timezones.

Fixes #1404 & fixes #1438.
2016-09-01 11:47:50 -03:00
Julien Fontanet
443e2bec25 chore(NewVm#_getIsoPredicate): memoise selector 2016-09-01 10:57:13 -03:00
Olivier Lambert
d5e1323d82 feat(newVif): select management network by default when adding a vif. Fixes #1425 2016-09-01 15:34:49 +02:00
Julien Fontanet
7f0b77cc89 chore(package): update chartist-plugin-legend to version 0.4.0 (#1450)
https://greenkeeper.io/
2016-08-31 10:32:50 +02:00
greenkeeperio-bot
0169cff66c chore(package): update chartist-plugin-legend to version 0.4.0
https://greenkeeper.io/
2016-08-31 10:17:48 +02:00
Olivier Lambert
0fd1424a41 fix(newVm): check pool object for ISO selector when creating a VM from selfservice. Fixes #1448 2016-08-30 21:26:59 +02:00
Julien Fontanet
6280d56f32 chore(xo): use resolveId() (only) where it makes sense 2016-08-26 16:18:03 -04:00
Julien Fontanet
9f2a77872f fix(xo/deleteUser): dont attempt to display error when cancelled
Fixes vatesfr/xo-web#1439
2016-08-26 14:38:02 -04:00
Pierre Donias
b571c18e9a feat(host): indicate pool master in multiple places (#1423)
Fixes #1407
2016-08-25 12:33:55 -04:00
Greenkeeper
49863d6e4d Update standard to version 8.0.0 🚀 (#1435)
https://greenkeeper.io/
2016-08-24 13:00:00 -04:00
Julien Fontanet
48cc7bb647 5.1.9 2016-08-22 14:02:40 -04:00
Pierre Donias
442d42d8dc fix(settings/logs): show params in a modal (#1424) 2016-08-19 16:09:20 +02:00
Olivier Lambert
9501ebacfc feat(menu): add warning icon when disconnected 2016-08-19 13:52:31 +02:00
Pierre Donias
23f9fa46f8 fix(home/host-item): do not show pool name if not enough permissions (#1421) 2016-08-19 13:40:55 +02:00
Julien Fontanet
1bd0f37fd4 feat(Menu): display when disconnected
Fixes vatesfr/xo-web#1417
2016-08-19 12:27:48 +02:00
Pierre Donias
ed74ded923 feat(settings/logs): display parameters (#1420) 2016-08-19 10:06:45 +02:00
Olivier Lambert
b732410b74 feat(vm and home): add tooltip to OS icon. Fixes #1416 2016-08-18 14:12:46 +02:00
Olivier Lambert
a51f2b7fcf fix(newvm): check if ssh keys object exists 2016-08-18 13:59:08 +02:00
Olivier Lambert
fe12bbb60d fix(sr): container var check if not defined 2016-08-18 13:51:37 +02:00
Olivier Lambert
8882df7939 5.1.8 2016-08-17 11:07:30 +02:00
Olivier Lambert
185a554cd9 fix(newVm): fix wrong ISO SR predicate. Fixes #1415 2016-08-17 11:06:35 +02:00
Olivier Lambert
230e0dc2a5 5.1.7 2016-08-16 15:38:59 +02:00
Pierre Donias
f5b69fdfdc feat(vm/console): hide header and resize console (#1410)
Fix #1268
2016-08-16 14:49:44 +02:00
Greenkeeper
01dc0d8f1e chore(package): update modular-css to version 0.26.0 (#1385)
https://greenkeeper.io/
2016-08-16 12:45:29 +02:00
Greenkeeper
8035886a3c chore(package): update promise-toolbox to version 0.5.0 (#1409)
https://greenkeeper.io/
2016-08-16 12:22:45 +02:00
Olivier Lambert
0ab5f4b13f fix(host): wrong storage link. Fixes #1408 2016-08-16 11:16:56 +02:00
Pierre Donias
a1bc98def8 feat(host): redirect to home when host disappears (#1406) 2016-08-16 09:50:29 +02:00
Olivier Lambert
868cf6140b feat(settings): more tooltips for server connect/disconnect 2016-08-15 18:04:01 +02:00
Olivier Lambert
4b3473f480 feat(logstackmodal): use pre tag for stack trace 2016-08-15 17:52:04 +02:00
Olivier Lambert
7bc782cc62 feat(copiable): add tooltip on copiable component 2016-08-15 17:33:59 +02:00
Olivier Lambert
e625a53e4a fix(vm migration): allow target network without IPs. Fixes #1403 2016-08-15 15:20:59 +02:00
Olivier Lambert
b31185d96d fix(newVm): typo spotted by @Danp2 2016-08-15 14:07:12 +02:00
Olivier Lambert
09d75e972f feat(newVm): add missing tooltips. Fixes #1402 2016-08-15 11:44:36 +02:00
Olivier Lambert
f33568951b 5.1.6 2016-08-12 17:28:49 +02:00
Pierre Donias
8d8c442be5 feat(settings/logs): new view to display API logs (#1401)
Fix #1344
2016-08-12 17:27:50 +02:00
Olivier Lambert
f890b8ea7a feat(modal text): warns users about consequences of host eject 2016-08-11 21:13:32 +02:00
Pierre Donias
1b80b3929c feat(host): detach host from its pool (#1399)
Fixes #1395
2016-08-11 17:49:25 +02:00
Pierre Donias
4f946293f6 feat(pool): add host (#1398)
Fixes #1374
2016-08-11 17:05:41 +02:00
Olivier Lambert
36788cde2b feat(vm disk): add VBD connect for a running VM. Fixes #1397 2016-08-11 16:52:52 +02:00
Pierre Donias
1547c99e5a feat(new-vm): use saved SSH key in cloud config(#1394)
* feat(new-vm): use saved SSH key in cloud config. Fixes #1319
2016-08-11 13:32:54 +02:00
Olivier Lambert
5c9606dad8 feat(pool): improve pool view. Fixes #1393 2016-08-11 10:34:03 +02:00
Olivier Lambert
fdcb1dccf5 feat(pool): start to work on adding an existing host to a pool 2016-08-11 09:47:52 +02:00
Olivier Lambert
12812b8c23 5.1.5 2016-08-10 18:06:19 +02:00
Olivier Lambert
0098497255 fix(select): select color modified due to an update. Fixes #1391 2016-08-10 16:02:48 +02:00
Olivier Lambert
6562d2de7f feat(sr select): display space left on SR. Fixes #1358 2016-08-10 15:58:36 +02:00
Olivier Lambert
1f0e88cdb0 feat(backup): better tooltips. Fixes #1363 2016-08-10 14:17:27 +02:00
Olivier Lambert
197da91ef3 feat(vdi remove): add modal when removing a VDI. Fixes #1388 2016-08-10 13:39:13 +02:00
Olivier Lambert
cbd59789e2 fix(vm disks): _isFreeForWriting missing case. Fixes #1386 2016-08-10 13:13:17 +02:00
Olivier Lambert
190ecf3d74 fix(pool): pool name and description edition. Fixes #1390 2016-08-10 12:42:46 +02:00
Olivier Lambert
15b8f6bca2 feat(meter tooltips): add tooltips for meter object. Fixes #1387 2016-08-10 12:31:28 +02:00
Pierre Donias
5b406d731b fix(vm): select destination SR when at least one VDI is local (#1382)
* Fixes #1357 
* fix(vm): select destination SR when at least one VDI is local
* fix(vm): do not send map when not necessary
2016-08-09 17:03:08 +02:00
Olivier Lambert
4be9e67ac4 fix(metercss): remove useless and conflicting CSS styles 2016-08-09 10:31:03 +02:00
Olivier Lambert
d047421685 feat(updates): enhance update view. Also fixes #1341 2016-08-08 16:46:47 +02:00
Olivier Lambert
f6f415a421 fix(network): name instead of description 2016-08-08 14:55:15 +02:00
Pierre Donias
edfaaebac0 feat(dashboard/health): Storage table: BlockLink (SR) and Link (SR's pool)
Fixes #1381
2016-08-08 14:15:49 +02:00
Olivier Lambert
67df22a1bf feat(vmsnapshot): add snapshot export and copy. Fixes #1353 and #1336 2016-08-08 14:05:27 +02:00
Pierre Donias
7dc59a00f6 feat(pool): action button to create an SR (#1380)
Fixes #1372
2016-08-08 12:45:12 +02:00
Pierre Donias
6214fe4c2e feat(pool): action button to create a VM (#1379)
Fix #1373
2016-08-08 11:35:24 +02:00
Greenkeeper
21610c3e0a chore(package): update ava to version 0.16.0 (#1377)
https://greenkeeper.io/
2016-08-08 09:57:36 +02:00
Olivier Lambert
87550b0189 5.1.4 2016-08-07 19:35:37 +02:00
Ronan Abhamon
b7c42d0a08 fix(scheduling): range not working
Fixes #1376
2016-08-07 19:35:05 +02:00
Olivier Lambert
c15ad299ac fix(sparklines): smaller sparklines and removing useless dots 2016-08-05 14:39:07 +02:00
Olivier Lambert
48c56cd602 5.1.3 2016-08-05 12:42:01 +02:00
Ronan Abhamon
7957f621ef fix(backups-edit): display correctly old backup jobs
Fixes #1366
2016-08-05 12:12:20 +02:00
Olivier Lambert
38ddbfdc9c fix(dashboard): inverted value for SR total/used. Fixes #1370 2016-08-04 14:42:50 +02:00
Olivier Lambert
3d2aae81da 5.1.2 2016-08-03 17:22:49 +02:00
Olivier Lambert
2227b9d061 feat(new vm): hide URL install for HVM templates. Fixes #1362 2016-08-03 16:55:43 +02:00
Olivier Lambert
12aab5fa8c feat(snapshots): add tooltips and confirm modal for snapshot oprations. Fixes #1349 2016-08-03 16:34:31 +02:00
Olivier Lambert
7323e6e117 fix(tooltip): remove tooltip if button changes. Fixes #1360 2016-08-03 15:53:38 +02:00
Greenkeeper
6f36869609 chore(package): update gulp-uglify to version 2.0.0 (#1355)
https://greenkeeper.io/
2016-08-02 14:47:18 +02:00
Ronan Abhamon
4a12419162 feat(backups): supports smart backup (close #837) (#1335)
Fixes #837
2016-07-31 19:03:41 +02:00
ABHAMON Ronan
bf91938aa6 fix(form/Toggle): refresh when set is used (#1347)
Fixes #1339
2016-07-29 11:35:58 +02:00
ABHAMON Ronan
bd70bd2b45 fix(scheduling): fix month selection highlighting (#1345)
Fixes #1338
2016-07-29 10:31:42 +02:00
Greenkeeper
bb26c8e449 chore(package): update modular-css to version 0.25.0 (#1331)
https://greenkeeper.io/
2016-07-28 00:16:06 +02:00
Julien Fontanet
93c7a01e62 5.1.1 2016-07-27 15:31:00 +02:00
Julien Fontanet
9c2359e8ee fix(Tooltip): better PropTypes 2016-07-27 15:29:05 +02:00
Julien Fontanet
5b9000012e fix(Tooltip): behave if children is missing or a string 2016-07-27 15:17:02 +02:00
Julien Fontanet
bf00b4e8e3 fix(Tooltip): better PropTypes 2016-07-27 15:08:52 +02:00
ABHAMON Ronan
ee7787f4ae fix(heatmap): related to last Tooltip changes (#1327)
Fixes #1326
2016-07-27 10:10:55 +02:00
Olivier Lambert
0b88e743c9 feat(changelog): update changelog 2016-07-26 17:07:23 +02:00
Julien Fontanet
f07a947580 5.1.0 2016-07-26 16:54:35 +02:00
Julien Fontanet
0b8a9eedbc feat(tooltip): float → solid, do not follow cursor 2016-07-26 16:50:46 +02:00
ABHAMON Ronan
8d24e596ac fix(tooltip): use position.top instead of position.right (#1322) 2016-07-26 14:49:07 +02:00
ABHAMON Ronan
c2378a44cd fix(tooltip): do not inject an intermediary element (#1321)
Fixes #1150
2016-07-26 14:28:11 +02:00
ABHAMON Ronan
023f7fdef1 feat(home): custom filters & configure default filters (#1308)
Fixes #1235
2016-07-25 15:20:39 +02:00
ABHAMON Ronan
5d7a64bc28 fix(scheduling): timezone support (#1318) 2016-07-25 14:57:38 +02:00
ABHAMON Ronan
8661957a97 feat(timezone-picker): xo-server timezone in the select (#1316)
Fixes #1314
2016-07-25 13:21:37 +02:00
ABHAMON Ronan
7a15d265b7 fix(new/sr): fix IQNs, LUNs selection (#1317)
Fixes #1281
2016-07-25 13:04:05 +02:00
Olivier Lambert
2736881975 fix(new sr): cast port number. See issue #1281 2016-07-23 16:42:58 +02:00
Greenkeeper
44a85f4e0c chore(package): update globby to version 6.0.0 (#1313)
https://greenkeeper.io/
2016-07-23 16:41:41 +02:00
Julien Fontanet
52a6e42e7e fix(pool/storage): display read-only SRs 2016-07-23 16:26:41 +02:00
Julien Fontanet
3dbe058d4e feat(home): add link to VMs console 2016-07-23 15:58:12 +02:00
Pierre Donias
620139efc1 feat(settings/acls): (un)select all objects of a specific type (#1310)
Fixes #1296
2016-07-22 17:45:38 +02:00
Pierre Donias
71464ac2e3 feat(menu): add types as Home sub-menus (#1309)
Fixes #1306
2016-07-22 16:18:16 +02:00
Pierre Donias
4a65489d39 fix(xo): polyfill Intl for Safari (#1307)
Fixes #1120
2016-07-22 15:51:32 +02:00
Pierre Donias
65d7eac590 feat(user): SSH keys management (#1302)
Fix #1299
2016-07-21 12:21:27 +02:00
ABHAMON Ronan
02bbc01dc4 feat(scheduling): improve utilisability (#1300)
Fixes #1295
2016-07-21 10:25:57 +02:00
Pierre Donias
3066237c86 feat(self/admin): recompute resource sets limits (#1298)
Fixes #1287
2016-07-20 11:36:49 +02:00
Pierre Donias
53f3c0bef1 fix(new-vm): fix CPU weight and add CPU cap (#1297)
Fixes #1286
2016-07-20 10:41:50 +02:00
ABHAMON Ronan
823c91b457 feat(plugins): supports predefined configurations (#1294)
Fixes #1289
2016-07-20 09:46:30 +02:00
ABHAMON Ronan
3bd7e20411 feat(backups): jobs support timezones (#1290)
Fixes #1258
2016-07-20 09:45:35 +02:00
Pierre Donias
24d4610b04 feat(vm/tab-advanced): editable CPU weight and cap (#1293)
Fixes #1283
2016-07-20 09:44:24 +02:00
ABHAMON Ronan
b16097767a feat(json-schema-input): use only schema.defaults in combobox options (#1292)
Fix #1288
2016-07-19 15:06:33 +02:00
ABHAMON Ronan
2ff74ffd39 feat(line-chart): many fixes on graphs legends (#1291)
Fixes #1247
2016-07-19 13:39:53 +02:00
Julien Fontanet
f0bb464136 fix(intl/locales/zh): fix moment import 2016-07-19 10:51:56 +02:00
Julien Fontanet
4767830386 feat(i18n): skeleton for Chinese 2016-07-19 10:02:33 +02:00
Julien Fontanet
ce23d4f164 feat(editable): change cursor to make it easier to see 2016-07-19 09:40:29 +02:00
Pierre Donias
c1380d1256 feat(home): focus search input after changing type (#1285)
Fixes #1228
2016-07-18 17:51:47 +02:00
Pierre Donias
ed9a848858 feat(new-vm): create mutiple VMs with a name pattern (#1271)
Implements parts of #949: initial sequence number.
2016-07-18 14:42:18 +02:00
ABHAMON Ronan
5e4e15fc12 fix(self/overview): display correctly resources set (#1284)
Fixes #1282
2016-07-18 09:36:46 +02:00
Greenkeeper
0dea952a2a chore(package): update modular-css to version 0.23.2 (#1239)
https://greenkeeper.io/
2016-07-15 12:19:47 +02:00
Olivier Lambert
a1818dd525 5.0.9 2016-07-14 14:49:18 +02:00
Pierre Donias
659e336f66 fix(migrate-vms-modal): fix conditions for SR and Network selectors 2016-07-14 14:43:29 +02:00
Pierre Donias
058f7ecd9f feat(Usage): new component to display a usage progress bar
Fixes #1151
2016-07-13 12:50:29 +02:00
Olivier Lambert
831d9cb49f feat(i18n): Portuguese translation
* Translation PT-BR Reviewed and Updated
2016-07-13 11:57:06 +02:00
Olivier Lambert
a5d059b0b1 fix(vm): protect JS crash if arrays[0] is empty 2016-07-13 11:43:52 +02:00
Pierre Donias
4c3b959869 fix(home): add key prop to sort options 2016-07-13 09:59:59 +02:00
Pierre Donias
d81a169a39 fix(form/SizeInput): parseSize value cannot be undefined 2016-07-13 09:59:44 +02:00
Pierre Donias
0d47332526 feat(new-vm): self service with resource sets
Fixes #1155
2016-07-13 09:59:11 +02:00
Pierre Donias
539d136936 fix(page/title): check if the container exists before displaying its name in the title 2016-07-13 09:30:58 +02:00
Pierre Donias
4c28b5775d feat(page/title): page titles for each view
Fixed #1185
2016-07-11 17:33:00 +02:00
Pierre Donias
fe6f351f84 feat(new/sr): page header
Fixes #1129
2016-07-11 17:10:27 +02:00
Olivier Lambert
5dbeccf92f 5.0.8 2016-07-08 19:29:54 +02:00
Olivier Lambert
56bba1d84b fix(home): typo on host memoryTotal 2016-07-08 16:22:11 +02:00
ABHAMON Ronan
af05d362b4 fix(stats): avoid calculations on null stats objects
Fix #969
2016-07-08 13:53:25 +02:00
ABHAMON Ronan
268ccf9a36 feat(settings/plugins): presets are supported
Fix #1222
2016-07-08 12:50:45 +02:00
ABHAMON Ronan
e77d4fafaa feat(patches): fix all patches related issues
Fixes #1244, #1245 and #1246
2016-07-08 12:30:32 +02:00
Pierre Donias
b88b99e342 fix(new-vm): display fast clone option only if there are template disks
Fix #1172
2016-07-08 12:20:28 +02:00
Olivier Lambert
f862d0df5b fix(host,vm): use stacked value text in a tooltip for stats 2016-07-08 10:40:15 +02:00
Fabrice Marsaud
dac954155c feat(menu): better contrast and size for update icons 2016-07-07 17:23:12 +02:00
Fabrice Marsaud
cf9deceb15 fix(logs): displays job log message if available 2016-07-07 15:22:43 +02:00
Fabrice Marsaud
72aed98088 Filter errors and successes in job logs (#1242)
* Meta data for job log state

* Preset filters for sorted tables

* Work around a babel issue

Fixes #1232
2016-07-07 14:28:09 +02:00
Fabrice Marsaud
ec92eddde8 display log errors properly (#1248)
Fixes #1134
2016-07-07 14:25:14 +02:00
ABHAMON Ronan
e30b5ab6c3 fix(xo-app): use correct sortOrder on sortedTable instances (#1243) 2016-07-07 14:20:54 +02:00
Olivier Lambert
0a5d26b001 5.0.7 2016-07-07 12:14:37 +02:00
ABHAMON Ronan
7e4b881041 feat(srs/uuid): UI improvements (fix #1142) (#1230) 2016-07-07 11:23:37 +02:00
Fabrice Marsaud
27a6af414f fix(host): broken patch filter
Fixed #1236
2016-07-07 11:20:43 +02:00
Olivier Lambert
ba6204f811 feat(user): add Spanish in the language selector 2016-07-06 17:09:16 +02:00
Olivier Lambert
d17b1050ad feat(es): add i18n file for Spanish 2016-07-06 17:05:45 +02:00
Olivier Lambert
b70bc86f71 feat(plugins): compact plugin view. Fixes #1130 2016-07-06 15:14:13 +02:00
Olivier Lambert
42b08633e9 fix(host): correctly display XS version. Fixes #1225 2016-07-06 12:45:20 +02:00
ABHAMON Ronan
bc898e1afd fix(pools): use sorted table & links to srs/hosts (fix #1141) (#1219)
* fix(pools): use sorted table & links to srs/hosts (fix #1141)
2016-07-06 10:45:48 +02:00
Pierre Donias
48d5f34ae6 fix(new-vm): wrong conditions for creation disabling (#1224) 2016-07-06 10:07:07 +02:00
Olivier Lambert
67b8b15cd8 5.0.6 2016-07-05 19:14:36 +02:00
Pierre Donias
09d80afa69 fix(form/SizeInput): controlled & uncontrolled modes (#1220) 2016-07-05 19:06:28 +02:00
ABHAMON Ronan
c0d95304f6 fix(home): actions depend on the selected type (#1218)
Fix #1153
2016-07-05 18:14:37 +02:00
Olivier Lambert
5a0d67a9f6 feat(vm): allow halted VM migration (#1221)
Fixes #1216
2016-07-05 17:55:49 +02:00
Julien Fontanet
08305b4b93 feat(SortedTable): support rowLink prop 2016-07-05 17:04:55 +02:00
Olivier Lambert
04d5612946 chore(xo): more resolveId (#1217) 2016-07-05 14:41:10 +02:00
Olivier Lambert
3dcb6f1f61 fix(host patch): wrong version check for patching hosts 2016-07-05 13:26:59 +02:00
Olivier Lambert
4e7684e38b feat(actions): add confirms for critical actions (#1215)
Fixes #1211
2016-07-05 13:24:04 +02:00
Fabrice Marsaud
a692b7571f feat(logs): sortable (#1214) 2016-07-05 12:30:03 +02:00
ABHAMON Ronan
a098618efa feat(dashboard/overview): add links to related pages (#1212)
Fixes #1139
2016-07-05 11:10:58 +02:00
Pierre Donias
71381e75f1 fix(migration): intra-pool migration should not send maps (#1213) 2016-07-05 11:10:15 +02:00
Pierre Donias
05b345db4a feat(home): bulk VM copy (#1205)
Fixes #1154.
2016-07-05 10:33:30 +02:00
Julien Fontanet
f85f6eab9e 5.0.5 2016-07-04 19:04:36 +02:00
Julien Fontanet
b6dc8b507d fix(SortedTable): total number of items when collection is a map 2016-07-04 19:03:31 +02:00
ABHAMON Ronan
831308ee05 feat(pool/patches): can patches hosts (#1203)
Fixes #1149
2016-07-04 18:52:39 +02:00
Fabrice Marsaud
eb5bcb759f feat(home): can display pools (#1202)
Fixes #1140
2016-07-04 16:28:41 +02:00
ABHAMON Ronan
8286570811 feat(xo-line-charts): supports sum of stats series (#1197)
Fixes #1158
2016-07-04 16:27:26 +02:00
Pierre Donias
10b511f0ed fix(form/SizeInput): props.defaultValue instead of props.value (#1206) 2016-07-04 15:56:57 +02:00
Julien Fontanet
751e335bc0 5.0.4 2016-07-01 17:53:47 +02:00
Pierre Donias
cb107521f2 feat(migration): smart VIFs-networks mapping (#1195) 2016-07-01 17:10:57 +02:00
Olivier Lambert
e56af57b74 fix(card): minor style change 2016-07-01 17:09:10 +02:00
ABHAMON Ronan
a2a1cbab6e feat(sorted-table): display selected items number (#1200)
Fixes #1133
2016-07-01 17:07:57 +02:00
Pierre Donias
306a021a8d fix(new-vm): make radio buttons controlled (#1199)
Fixes #1198
2016-07-01 16:11:19 +02:00
Julien Fontanet
d8c414af2f fix(getEventValue): returns value prop for radios 2016-07-01 15:47:46 +02:00
Julien Fontanet
ec4c76b2e0 feat(selectors): filter() can be chained after pick() 2016-07-01 15:47:46 +02:00
ABHAMON Ronan
e23b8a6891 feat(dashboard/overview): display missing patches (#1191)
Fixes #1148
2016-07-01 15:28:07 +02:00
Olivier Lambert
34006bcbf6 fix(health): forget to check edition 2016-07-01 14:47:43 +02:00
ABHAMON Ronan
ed9aeabf6a chore(dashboard/health): use Card (#1194) 2016-07-01 11:20:32 +02:00
Fabrice Marsaud
799fc5089f feat(settings/remotes): add button to test a remote (#1192)
Fixes #1075.
2016-07-01 09:25:57 +02:00
Julien Fontanet
683d510aa6 5.0.3 2016-06-30 15:12:26 +02:00
Pierre Donias
ebd7e58f61 feat(home): bulk VM migration (#1187)
Fixes #1146
2016-06-30 15:04:21 +02:00
Fabrice Marsaud
9a498b54ac fix(menu): only display one icon for updates when collapsed (#1190)
Fixes #1188
2016-06-30 15:03:26 +02:00
ABHAMON Ronan
2687f45e6e fix(settings/plugins): set config value to undefined if value is null (#1189) 2016-06-30 14:31:43 +02:00
ABHAMON Ronan
f79a17fcec feat(json-schema-input): generate uiSchema JSON schema (#1182) 2016-06-30 13:52:20 +02:00
ABHAMON Ronan
8fd377d1e2 feat(dashboard/dataviz): parallel coordinates graph (#1174)
Fixes #1157
2016-06-30 11:36:29 +02:00
Olivier Lambert
fda06fbd29 feat(VM/network): VIFs management (#1186)
Fixes #1176
2016-06-30 11:28:25 +02:00
Fabrice Marsaud
cee4378e6d feat(xoa-updates): reload after upgrading (#1183)
Fixes #1131.
2016-06-30 11:26:03 +02:00
Fabrice Marsaud
ab6d342886 fix(VM/network): fix broken propTypes import (#1184) 2016-06-29 17:59:39 +02:00
Fabrice Marsaud
9954c08993 fix(xoa-updates): fix env test (#1181) 2016-06-29 12:16:25 +02:00
Julien Fontanet
3ae80aeab3 feat(link): expose Link and BlockLink components 2016-06-29 11:57:42 +02:00
Julien Fontanet
2a3534f659 chore(utils): do not re-export propTypes 2016-06-29 11:57:42 +02:00
Julien Fontanet
fc39de0d5a chore(sign-in): remove because unused 2016-06-29 11:57:41 +02:00
Julien Fontanet
64e4b79d41 chore(utils/createSimpleMatcher): remove because not used 2016-06-29 11:57:41 +02:00
Fabrice Marsaud
53887da3da feat(VM/network): VIF creation (#1173)
Fixes #1138.
2016-06-28 17:47:44 +02:00
ABHAMON Ronan
7c60d68f56 fix(xo-line-chart): set precision on LoadLineChart (#1175)
Fixes #1167
2016-06-28 17:17:46 +02:00
Julien Fontanet
2ac1b991b1 feat(BaseComponent#_linkedState): only allocate when necessary 2016-06-28 15:56:53 +02:00
Julien Fontanet
8257714cdb feat(get-event-value): works with checkbox/radio/select 2016-06-28 15:56:53 +02:00
Julien Fontanet
1b8bacbf5a chore(utils/autobind): remove in favor of ES7 class properties syntax 2016-06-28 15:56:52 +02:00
Julien Fontanet
1d5b84389d chore(utils): do not re-export invoke 2016-06-28 15:56:51 +02:00
Julien Fontanet
f7dcf52977 chore(utils/If): remove because does not work 2016-06-28 15:03:34 +02:00
Julien Fontanet
e26dd5147a feat(BaseComponent#linkState): creates a callback associated to a state entry 2016-06-28 14:56:51 +02:00
247 changed files with 45687 additions and 9334 deletions

10
.gitignore vendored
View File

@@ -1,9 +1,9 @@
/.nyc_output/
/bower_components/
/dist/
/node_modules/
/src/common/intl/locales/index.js
/src/common/themes/index.js
npm-debug.log
npm-debug.log.*
!node_modules/*
node_modules/*/
pnpm-debug.log
pnpm-debug.log.*

View File

@@ -1,11 +1,10 @@
language: node_js
node_js:
- 'stable'
#- '4' # Disabled for now because npm 2 cannot properly handled broken peer dependencies.
- '6'
#- '4' # npm 3's flat tree is needed because some packages do not
# declare their deps correctly (e.g. chartist-plugin-tooltip)
cache:
directories:
- node_modules
cache: yarn
# Use containers.
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/

View File

@@ -1,5 +1,491 @@
# ChangeLog
## **5.10.0** (2017-05-31)
### Enhancements
- Improve backup log display [\#2239](https://github.com/vatesfr/xo-web/issues/2239)
- Patch SR detection improvement [\#2215](https://github.com/vatesfr/xo-web/issues/2215)
- Less strict coalesce detection [\#2207](https://github.com/vatesfr/xo-web/issues/2207)
- IP pool UI improvement [\#2203](https://github.com/vatesfr/xo-web/issues/2203)
- Ability to clear "Auto power on" flag for DR-ed VM [\#2097](https://github.com/vatesfr/xo-web/issues/2097)
- [Delta backup restoration] Choose SR for each VDIs [\#2070](https://github.com/vatesfr/xo-web/issues/2070)
- Ability to forget an host (even if no longer present) [\#1934](https://github.com/vatesfr/xo-web/issues/1934)
### Bug fixes
- Cross pool migrate fail [\#2248](https://github.com/vatesfr/xo-web/issues/2248)
- ActionButtons with modals stay in pending state forever [\#2222](https://github.com/vatesfr/xo-web/issues/2222)
- Permission issue for a user on self service VMs [\#2212](https://github.com/vatesfr/xo-web/issues/2212)
- Self-Service resource loophole [\#2198](https://github.com/vatesfr/xo-web/issues/2198)
- Backup log no longer shows the name of destination VM [\#2195](https://github.com/vatesfr/xo-web/issues/2195)
- State not restored when exiting modal dialog [\#2194](https://github.com/vatesfr/xo-web/issues/2194)
- [Xapi#exportDeltaVm] Cannot read property 'managed' of undefined [\#2189](https://github.com/vatesfr/xo-web/issues/2189)
- VNC keyboard layout change [\#404](https://github.com/vatesfr/xo-web/issues/404)
## **5.9.0** (2017-05-31)
### Enhancements
- Allow DR to remove previous backup first [\#2157](https://github.com/vatesfr/xo-web/issues/2157)
- Feature request - add amount of RAM to memory bars [\#2149](https://github.com/vatesfr/xo-web/issues/2149)
- Make the acceptability of invalid certificates configurable [\#2138](https://github.com/vatesfr/xo-web/issues/2138)
- label of VM names in tasks link [\#2135](https://github.com/vatesfr/xo-web/issues/2135)
- Backup report timezone [\#2133](https://github.com/vatesfr/xo-web/issues/2133)
- xo-server-recover-account [\#2129](https://github.com/vatesfr/xo-web/issues/2129)
- Detect disks attached to control domain [\#2126](https://github.com/vatesfr/xo-web/issues/2126)
- Add task description in Tasks view [\#2125](https://github.com/vatesfr/xo-web/issues/2125)
- Host reboot warning after patching for 7.1 [\#2124](https://github.com/vatesfr/xo-web/issues/2124)
- Continuous Replication - possibility run VM without a clone [\#2119](https://github.com/vatesfr/xo-web/issues/2119)
- Unreachable host should be detected [\#2099](https://github.com/vatesfr/xo-web/issues/2099)
- Orange icon when host is is disabled [\#2098](https://github.com/vatesfr/xo-web/issues/2098)
- Enhanced backup report logs [\#2096](https://github.com/vatesfr/xo-web/issues/2096)
- Only show failures when configured to report on failures [\#2095](https://github.com/vatesfr/xo-web/issues/2095)
- "Add all" button in self service [\#2081](https://github.com/vatesfr/xo-web/issues/2081)
- Patch and pack mechanism changed on Ely [\#2058](https://github.com/vatesfr/xo-web/issues/2058)
- Tip or ask people to patch from pool view [\#2057](https://github.com/vatesfr/xo-web/issues/2057)
- File restore - Remind compatible backup [\#1930](https://github.com/vatesfr/xo-web/issues/1930)
- Reporting for halted vm time [\#1613](https://github.com/vatesfr/xo-web/issues/1613)
- Add standalone XS server to a pool and patch it to the pool level [\#878](https://github.com/vatesfr/xo-web/issues/878)
- Add Cores-per-sockets [\#130](https://github.com/vatesfr/xo-web/issues/130)
### Bug fixes
- VM creation is broken for non-admins [\#2168](https://github.com/vatesfr/xo-web/issues/2168)
- Can't create cloud config drive [\#2162](https://github.com/vatesfr/xo-web/issues/2162)
- Select is "moving" [\#2142](https://github.com/vatesfr/xo-web/issues/2142)
- Select issue for affinity host [\#2141](https://github.com/vatesfr/xo-web/issues/2141)
- Dashboard Storage Usage incorrect [\#2123](https://github.com/vatesfr/xo-web/issues/2123)
- Detect unmerged *base copy* and prevent too long chains [\#2047](https://github.com/vatesfr/xo-web/issues/2047)
## **5.8.0** (2017-04-28)
### Enhancements
- Limit About view info for non-admins [\#2109](https://github.com/vatesfr/xo-web/issues/2109)
- Enabling/disabling boot device on HVM VM [\#2105](https://github.com/vatesfr/xo-web/issues/2105)
- Filter: Hide snapshots in SR disk view [\#2102](https://github.com/vatesfr/xo-web/issues/2102)
- Smarter XOSAN install [\#2084](https://github.com/vatesfr/xo-web/issues/2084)
- PL translation [\#2079](https://github.com/vatesfr/xo-web/issues/2079)
- Remove the "share this VM" option if not in self service [\#2061](https://github.com/vatesfr/xo-web/issues/2061)
- "connected" status graphics are not the same on the host storage and networking tabs [\#2060](https://github.com/vatesfr/xo-web/issues/2060)
- Ability to view and edit `vga` and `videoram` fields in VM view [\#158](https://github.com/vatesfr/xo-web/issues/158)
- Performances [\#1](https://github.com/vatesfr/xen-api/issues/1)
### Bug fixes
- Dashboard display issues [\#2108](https://github.com/vatesfr/xo-web/issues/2108)
- Dashboard CPUs Usage [\#2105](https://github.com/vatesfr/xo-web/issues/2105)
- [Dashboard/Overview] Warning [\#2090](https://github.com/vatesfr/xo-web/issues/2090)
- VM creation displays all networks [\#2086](https://github.com/vatesfr/xo-web/issues/2086)
- Cannot change HA mode for a VM [\#2080](https://github.com/vatesfr/xo-web/issues/2080)
- [Smart backup] Tags selection does not work [\#2077](https://github.com/vatesfr/xo-web/issues/2077)
- [Backup jobs] Timeout should be in seconds, not milliseconds [\#2076](https://github.com/vatesfr/xo-web/issues/2076)
- Missing VM templates [\#2075](https://github.com/vatesfr/xo-web/issues/2075)
- [transport-email] From header not set [\#2074](https://github.com/vatesfr/xo-web/issues/2074)
- Missing objects should be displayed in backup edition [\#2052](https://github.com/vatesfr/xo-web/issues/2052)
## **5.7.0** (2017-03-31)
### Enhancements
- Improve ActionButton error reporting [\#2048](https://github.com/vatesfr/xo-web/issues/2048)
- Home view master checkbox UI issue [\#2027](https://github.com/vatesfr/xo-web/issues/2027)
- HU Translation [\#2019](https://github.com/vatesfr/xo-web/issues/2019)
- [Usage report] Add name for all objects [\#2017](https://github.com/vatesfr/xo-web/issues/2017)
- [Home] Improve inter-types linkage [\#2012](https://github.com/vatesfr/xo-web/issues/2012)
- Remove bootable checkboxes in VM creation [\#2007](https://github.com/vatesfr/xo-web/issues/2007)
- Do not display bootable toggles for disks of non-PV VMs [\#1996](https://github.com/vatesfr/xo-web/issues/1996)
- Try to match network VLAN for VM migration modal [\#1990](https://github.com/vatesfr/xo-web/issues/1990)
- [Usage reports] Add VM names in addition to UUIDs [\#1984](https://github.com/vatesfr/xo-web/issues/1984)
- Host affinity in "advanced" VM creation [\#1983](https://github.com/vatesfr/xo-web/issues/1983)
- Add job tag in backup logs [\#1982](https://github.com/vatesfr/xo-web/issues/1982)
- Possibility to add a label/description to servers [\#1965](https://github.com/vatesfr/xo-web/issues/1965)
- Possibility to create shared VM in a resource set [\#1964](https://github.com/vatesfr/xo-web/issues/1964)
- Clearer display of disabled (backup) jobs [\#1958](https://github.com/vatesfr/xo-web/issues/1958)
- Job should have a configurable timeout [\#1956](https://github.com/vatesfr/xo-web/issues/1956)
- Sort failed VMs in backup report [\#1950](https://github.com/vatesfr/xo-web/issues/1950)
- Support for UNIX socket path [\#1944](https://github.com/vatesfr/xo-web/issues/1944)
- Interface - Host Patching - Button Verbiage [\#1911](https://github.com/vatesfr/xo-web/issues/1911)
- Display if a VM is in Self Service (and which group) [\#1905](https://github.com/vatesfr/xo-web/issues/1905)
- Install supplemental pack on a whole pool [\#1896](https://github.com/vatesfr/xo-web/issues/1896)
- Allow VM snapshots with ACLs [\#1865](https://github.com/vatesfr/xo-web/issues/1886)
- Icon to indicate if a snapshot is quiesce [\#1858](https://github.com/vatesfr/xo-web/issues/1858)
- Pool Ips input too permissive [\#1731](https://github.com/vatesfr/xo-web/issues/1731)
- Select is going on top after each choice [\#1359](https://github.com/vatesfr/xo-web/issues/1359)
### Bug fixes
- Missing objects should be displayed in backup edition [\#2052](https://github.com/vatesfr/xo-web/issues/2052)
- Search bar content changes while typing [\#2035](https://github.com/vatesfr/xo-web/issues/2035)
- VM.$guest_metrics.PV_drivers_up_to_date is deprecated in XS 7.1 [\#2024](https://github.com/vatesfr/xo-web/issues/2024)
- Bootable flag selection checkbox for extra disk not fetched [\#1994](https://github.com/vatesfr/xo-web/issues/1994)
- Home view Changing type must reset paging [\#1993](https://github.com/vatesfr/xo-web/issues/1993)
- XOSAN menu item should only be displayed to admins [\#1968](https://github.com/vatesfr/xo-web/issues/1968)
- Object type change are not correctly handled in UI [\#1967](https://github.com/vatesfr/xo-web/issues/1967)
- VM creation is stuck when using ISO/DVD as install method [\#1966](https://github.com/vatesfr/xo-web/issues/1966)
- Install pack on whole pool fails [\#1957](https://github.com/vatesfr/xo-web/issues/1957)
- Consoles are broken in next-release [\#1954](https://github.com/vatesfr/xo-web/issues/1954)
- [VHD merge] Increase BAT when necessary [\#1939](https://github.com/vatesfr/xo-web/issues/1939)
- Issue on VM restore time [\#1936](https://github.com/vatesfr/xo-web/issues/1936)
- Two remotes should not be able to have the same name [\#1879](https://github.com/vatesfr/xo-web/issues/1879)
- Selfservice limits not honored after VM creation [\#1695](https://github.com/vatesfr/xo-web/issues/1695)
## **5.6.0** (2017-01-27)
Reporting, LVM File level restore.
### Enhancements
- Do not stop patches install if already applied [\#1904](https://github.com/vatesfr/xo-web/issues/1904)
- Improve scheduling UI [\#1893](https://github.com/vatesfr/xo-web/issues/1893)
- Smart backup and tag [\#1885](https://github.com/vatesfr/xo-web/issues/1885)
- Missing embeded API documention [\#1882](https://github.com/vatesfr/xo-web/issues/1882)
- Add local DVD in CD selector [\#1880](https://github.com/vatesfr/xo-web/issues/1880)
- File level restore for LVM [\#1878](https://github.com/vatesfr/xo-web/issues/1878)
- Restore multiple files from file level restore [\#1877](https://github.com/vatesfr/xo-web/issues/1877)
- Add a VM tab for host & pool views [\#1864](https://github.com/vatesfr/xo-web/issues/1864)
- Icon to indicate if a snapshot is quiesce [\#1858](https://github.com/vatesfr/xo-web/issues/1858)
- UI for disconnect hosts comp [\#1833](https://github.com/vatesfr/xo-web/issues/1833)
- Eject all xs-guest.iso in a pool [\#1798](https://github.com/vatesfr/xo-web/issues/1798)
- Display installed supplemental pack on host [\#1506](https://github.com/vatesfr/xo-web/issues/1506)
- Install supplemental pack on host comp [\#1460](https://github.com/vatesfr/xo-web/issues/1460)
- Pool-wide combined stats [\#1324](https://github.com/vatesfr/xo-web/issues/1324)
### Bug fixes
- IP-address not released when VM removed [\#1906](https://github.com/vatesfr/xo-web/issues/1906)
- Interface broken due to new Bootstrap Alpha [\#1871](https://github.com/vatesfr/xo-web/issues/1871)
- Self service recompute all limits broken [\#1866](https://github.com/vatesfr/xo-web/issues/1866)
- Patch not found error for XS 6.5 [\#1863](https://github.com/vatesfr/xo-web/issues/1863)
- Convert To Template issues [\#1855](https://github.com/vatesfr/xo-web/issues/1855)
- Removing PIF seems to fail [\#1853](https://github.com/vatesfr/xo-web/issues/1853)
- Depth should be >= 1 in backup creation [\#1851](https://github.com/vatesfr/xo-web/issues/1851)
- Wrong link in Dashboard > Health [\#1850](https://github.com/vatesfr/xo-web/issues/1850)
- Incorrect file dates shown in new File Restore feature [\#1840](https://github.com/vatesfr/xo-web/issues/1840)
- IP allocation problem [\#1747](https://github.com/vatesfr/xo-web/issues/1747)
- Selfservice limits not honored after VM creation [\#1695](https://github.com/vatesfr/xo-web/issues/1695)
## **5.5.0** (2016-12-20)
File level restore.
### Enhancements
- Better auto select network when migrate VM [\#1788](https://github.com/vatesfr/xo-web/issues/1788)
- Plugin for passive backup job reporting in Nagios [\#1664](https://github.com/vatesfr/xo-web/issues/1664)
- File level restore for delta backup [\#1590](https://github.com/vatesfr/xo-web/issues/1590)
- Better select filters for ACLs [\#1515](https://github.com/vatesfr/xo-web/issues/1515)
- All pools and "negative" filters [\#1503](https://github.com/vatesfr/xo-web/issues/1503)
- VM copy with disk selection [\#826](https://github.com/vatesfr/xo-web/issues/826)
- Disable metadata exports [\#1818](https://github.com/vatesfr/xo-web/issues/1818)
### Bug fixes
- Tool small selector [\#1832](https://github.com/vatesfr/xo-web/issues/1832)
- Replication does not work from a VM created by a CR or delta backup [\#1811](https://github.com/vatesfr/xo-web/issues/1811)
- Can't add a SSH key in VM creation [\#1805](https://github.com/vatesfr/xo-web/issues/1805)
- Issue when no default SR in a pool [\#1804](https://github.com/vatesfr/xo-web/issues/1804)
- XOA doesn't refresh after an update anymore [\#1801](https://github.com/vatesfr/xo-web/issues/1801)
- Shortcuts not inhibited on inputs on Safari [\#1691](https://github.com/vatesfr/xo-web/issues/1691)
## **5.4.0** (2016-11-23)
### Enhancements
- XML display in alerts [\#1776](https://github.com/vatesfr/xo-web/issues/1776)
- Remove some view for non admin users [\#1773](https://github.com/vatesfr/xo-web/issues/1773)
- Complex matcher should support matching boolean values [\#1768](https://github.com/vatesfr/xo-web/issues/1768)
- Home SR view [\#1764](https://github.com/vatesfr/xo-web/issues/1764)
- Filter on tag click [\#1763](https://github.com/vatesfr/xo-web/issues/1763)
- Testable plugins [\#1749](https://github.com/vatesfr/xo-web/issues/1749)
- Backup/Restore Design fix. [\#1734](https://github.com/vatesfr/xo-web/issues/1734)
- Display the owner of a \(backup\) job [\#1733](https://github.com/vatesfr/xo-web/issues/1733)
- Use paginated table for backup jobs [\#1726](https://github.com/vatesfr/xo-web/issues/1726)
- SR view / Disks: should display snapshot VDIs [\#1723](https://github.com/vatesfr/xo-web/issues/1723)
- Restored VM should have an identifiable name [\#1719](https://github.com/vatesfr/xo-web/issues/1719)
- If host reboot action returns NO\_HOSTS\_AVAILABLE, ask to force [\#1717](https://github.com/vatesfr/xo-web/issues/1717)
- Hide xo-server timezone in backups [\#1706](https://github.com/vatesfr/xo-web/issues/1706)
- Enable hyperlink for Hostname for Issues [\#1700](https://github.com/vatesfr/xo-web/issues/1700)
- Pool/network - Modify column [\#1696](https://github.com/vatesfr/xo-web/issues/1696)
- UI - Plugins - Display a message if no plugins [\#1670](https://github.com/vatesfr/xo-web/issues/1670)
- Display warning/error for delta backup on XS older than 6.5 [\#1647](https://github.com/vatesfr/xo-web/issues/1647)
- XO without internet access doesn't work [\#1629](https://github.com/vatesfr/xo-web/issues/1629)
- Improve backup restore view [\#1609](https://github.com/vatesfr/xo-web/issues/1609)
- UI Enhancement - Acronym for dummy [\#1604](https://github.com/vatesfr/xo-web/issues/1604)
- Slack XO plugin for backup report [\#1593](https://github.com/vatesfr/xo-web/issues/1593)
- Expose XAPI exceptions in the UI [\#1481](https://github.com/vatesfr/xo-web/issues/1481)
- Running VMs in the host overview, all VMs in the pool overview [\#1432](https://github.com/vatesfr/xo-web/issues/1432)
- Move location of NFS mount point [\#1405](https://github.com/vatesfr/xo-web/issues/1405)
- Home: Pool list - additionnal informations for pool [\#1226](https://github.com/vatesfr/xo-web/issues/1226)
- Modify VLAN of an existing network [\#1092](https://github.com/vatesfr/xo-web/issues/1092)
- Wrong instructions for CLI upgrade [\#787](https://github.com/vatesfr/xo-web/issues/787)
- Ability to export/import XO config [\#786](https://github.com/vatesfr/xo-web/issues/786)
- Test button for transport-email plugin [\#697](https://github.com/vatesfr/xo-web/issues/697)
- Merge `scheduler` API into `schedule` [\#664](https://github.com/vatesfr/xo-web/issues/664)
### Bug fixes
- Should jobs be accessible to non admins? [\#1759](https://github.com/vatesfr/xo-web/issues/1759)
- Schedules deletion is not working [\#1737](https://github.com/vatesfr/xo-web/issues/1737)
- Editing a job from the jobs overview page does not work [\#1736](https://github.com/vatesfr/xo-web/issues/1736)
- Editing a schedule from jobs overview does not work [\#1728](https://github.com/vatesfr/xo-web/issues/1728)
- ACLs not correctly imported [\#1722](https://github.com/vatesfr/xo-web/issues/1722)
- Some Bootstrap style broken [\#1721](https://github.com/vatesfr/xo-web/issues/1721)
- Not properly sign out on auth token expiration [\#1711](https://github.com/vatesfr/xo-web/issues/1711)
- Hosts/<UUID>/network status is incorrect [\#1702](https://github.com/vatesfr/xo-web/issues/1702)
- Patches application fails "Found : Moved Temporarily" [\#1701](https://github.com/vatesfr/xo-web/issues/1701)
- Password generation for user creation is not working [\#1678](https://github.com/vatesfr/xo-web/issues/1678)
- \#/dashboard/health Remove All Orphaned VDIs [\#1622](https://github.com/vatesfr/xo-web/issues/1622)
- Create a new SR - CIFS/SAMBA Broken [\#1615](https://github.com/vatesfr/xo-web/issues/1615)
- xo-cli --list-objects: truncated output ? 64k buffer limitation ? [\#1356](https://github.com/vatesfr/xo-web/issues/1356)
## **5.3.0** (2016-10-20)
### Enhancements
- Missing favicon [\#1660](https://github.com/vatesfr/xo-web/issues/1660)
- ipPools quota [\#1565](https://github.com/vatesfr/xo-web/issues/1565)
- Dashboard - orphaned VDI [\#1654](https://github.com/vatesfr/xo-web/issues/1654)
- Stats in home/host view when expanded [\#1634](https://github.com/vatesfr/xo-web/issues/1634)
- Bar for used and total RAM on home pool view [\#1625](https://github.com/vatesfr/xo-web/issues/1625)
- Can't translate some text [\#1624](https://github.com/vatesfr/xo-web/issues/1624)
- Dynamic RAM allocation at creation time [\#1603](https://github.com/vatesfr/xo-web/issues/1603)
- Display memory bar in home/host view [\#1616](https://github.com/vatesfr/xo-web/issues/1616)
- Improve keyboard navigation [\#1578](https://github.com/vatesfr/xo-web/issues/1578)
- Strongly suggest to install the guest tools [\#1575](https://github.com/vatesfr/xo-web/issues/1575)
- Missing tooltip [\#1568](https://github.com/vatesfr/xo-web/issues/1568)
- Emphasize already used ips in ipPools [\#1566](https://github.com/vatesfr/xo-web/issues/1566)
- Change "missing feature message" for non-admins [\#1564](https://github.com/vatesfr/xo-web/issues/1564)
- Allow VIF edition [\#1446](https://github.com/vatesfr/xo-web/issues/1446)
- Disable browser autocomplete on credentials on the Update page [\#1304](https://github.com/vatesfr/xo-web/issues/1304)
- keyboard shortcuts [\#1279](https://github.com/vatesfr/xo-web/issues/1279)
- Add network bond creation [\#876](https://github.com/vatesfr/xo-web/issues/876)
- `pool.setDefaultSr\(\)` should not require `pool` param [\#1558](https://github.com/vatesfr/xo-web/issues/1558)
- Select default SR [\#1554](https://github.com/vatesfr/xo-web/issues/1554)
- No error message when I exceed my resource set quota [\#1541](https://github.com/vatesfr/xo-web/issues/1541)
- Hide some buttons for self service VMs [\#1539](https://github.com/vatesfr/xo-web/issues/1539)
- Add Job ID to backup schedules [\#1534](https://github.com/vatesfr/xo-web/issues/1534)
- Correct name for VM selector with templates [\#1530](https://github.com/vatesfr/xo-web/issues/1530)
- Help text when no matches for a filter [\#1517](https://github.com/vatesfr/xo-web/issues/1517)
- Icon or tooltip to allow VDI migration in VM disk view [\#1512](https://github.com/vatesfr/xo-web/issues/1512)
- Create a snapshot before restoring one [\#1445](https://github.com/vatesfr/xo-web/issues/1445)
- Auto power on setting at creation time [\#1444](https://github.com/vatesfr/xo-web/issues/1444)
- local remotes should be avoided if possible [\#1441](https://github.com/vatesfr/xo-web/issues/1441)
- Self service edition unclear [\#1429](https://github.com/vatesfr/xo-web/issues/1429)
- Avoid "\_" char in job tag name [\#1414](https://github.com/vatesfr/xo-web/issues/1414)
- Display message if host reboot needed to apply patches [\#1352](https://github.com/vatesfr/xo-web/issues/1352)
- Color code on host PIF stats can be misleading [\#1265](https://github.com/vatesfr/xo-web/issues/1265)
- Sign in page is not rendered correctly [\#1161](https://github.com/vatesfr/xo-web/issues/1161)
- Template management [\#1091](https://github.com/vatesfr/xo-web/issues/1091)
- On pool view: collapse network list [\#1461](https://github.com/vatesfr/xo-web/issues/1461)
- Alert when trying to reboot/halt the pool master XS [\#1458](https://github.com/vatesfr/xo-web/issues/1458)
- Adding tooltip on Home page [\#1456](https://github.com/vatesfr/xo-web/issues/1456)
- Docker container management functionality missing from v5 [\#1442](https://github.com/vatesfr/xo-web/issues/1442)
- bad error message - delete snapshot [\#1433](https://github.com/vatesfr/xo-web/issues/1433)
- Create tag during VM creation [\#1431](https://github.com/vatesfr/xo-web/issues/1431)
### Bug fixes
- Display issues on plugin array edition [\#1663](https://github.com/vatesfr/xo-web/issues/1663)
- Import of delta backups fails [\#1656](https://github.com/vatesfr/xo-web/issues/1656)
- Host - Missing IP config for PIF [\#1651](https://github.com/vatesfr/xo-web/issues/1651)
- Remote copy is always activating compression [\#1645](https://github.com/vatesfr/xo-web/issues/1645)
- LB plugin UI problems [\#1630](https://github.com/vatesfr/xo-web/issues/1630)
- Keyboard shortcuts should not work when a modal is open [\#1589](https://github.com/vatesfr/xo-web/issues/1589)
- UI small bug in drop-down lists [\#1411](https://github.com/vatesfr/xo-web/issues/1411)
- md5 delta backup error [\#1672](https://github.com/vatesfr/xo-web/issues/1672)
- Can't edit VIF network [\#1640](https://github.com/vatesfr/xo-web/issues/1640)
- Do not expose shortcuts while console is focused [\#1614](https://github.com/vatesfr/xo-web/issues/1614)
- All users can see VM templates [\#1621](https://github.com/vatesfr/xo-web/issues/1621)
- Profile page is broken [\#1612](https://github.com/vatesfr/xo-web/issues/1612)
- SR delete should redirect to home [\#1611](https://github.com/vatesfr/xo-web/issues/1611)
- Delta VHD backup checksum is invalidated by chaining [\#1606](https://github.com/vatesfr/xo-web/issues/1606)
- VM with long description break on 2 lines [\#1580](https://github.com/vatesfr/xo-web/issues/1580)
- Network status on VM edition [\#1573](https://github.com/vatesfr/xo-web/issues/1573)
- VM template deletion fails [\#1571](https://github.com/vatesfr/xo-web/issues/1571)
- Template edition - "no such object" [\#1569](https://github.com/vatesfr/xo-web/issues/1569)
- missing links / element not displayed as links [\#1567](https://github.com/vatesfr/xo-web/issues/1567)
- Backup restore stalled on some SMB shares [\#1412](https://github.com/vatesfr/xo-web/issues/1412)
- Wrong bond display [\#1156](https://github.com/vatesfr/xo-web/issues/1156)
- Multiple reboot selection doesn't work [\#1562](https://github.com/vatesfr/xo-web/issues/1562)
- Server logs should be displayed in reverse chonological order [\#1547](https://github.com/vatesfr/xo-web/issues/1547)
- Cannot create resource sets without limits [\#1537](https://github.com/vatesfr/xo-web/issues/1537)
- UI - Weird display when editing long VM desc [\#1528](https://github.com/vatesfr/xo-web/issues/1528)
- Useless iso selector in host console [\#1527](https://github.com/vatesfr/xo-web/issues/1527)
- Pool and Host dummy welcome message [\#1519](https://github.com/vatesfr/xo-web/issues/1519)
- Bug on Network VM tab [\#1518](https://github.com/vatesfr/xo-web/issues/1518)
- Link to home with filter in query does not work [\#1513](https://github.com/vatesfr/xo-web/issues/1513)
- VHD merge fails with "RangeError: index out of range" on SMB remote [\#1511](https://github.com/vatesfr/xo-web/issues/1511)
- DR: previous VDIs are not removed [\#1510](https://github.com/vatesfr/xo-web/issues/1510)
- DR: previous copies not removed when same number as depth [\#1509](https://github.com/vatesfr/xo-web/issues/1509)
- Empty Saved Search doesn't load when set to default filter [\#1354](https://github.com/vatesfr/xo-web/issues/1354)
- Removing a user/group should delete its ACLs [\#899](https://github.com/vatesfr/xo-web/issues/899)
- OVA Import - XO stuck during import [\#1551](https://github.com/vatesfr/xo-web/issues/1551)
- SMB remote empty domain fails [\#1499](https://github.com/vatesfr/xo-web/issues/1499)
- Can't edit a remote password [\#1498](https://github.com/vatesfr/xo-web/issues/1498)
- Issue in VM create with CoreOS [\#1493](https://github.com/vatesfr/xo-web/issues/1493)
- Overlapping months in backup view [\#1488](https://github.com/vatesfr/xo-web/issues/1488)
- No line break for SSH key in user view [\#1475](https://github.com/vatesfr/xo-web/issues/1475)
- Create VIF UI issues [\#1472](https://github.com/vatesfr/xo-web/issues/1472)
## **5.2.0** (2016-09-09)
### Enhancements
- IP management [\#1350](https://github.com/vatesfr/xo-web/issues/1350), [\#988](https://github.com/vatesfr/xo-web/issues/988), [\#1427](https://github.com/vatesfr/xo-web/issues/1427) and [\#240](https://github.com/vatesfr/xo-web/issues/240)
- Update reverse proxy example [\#1474](https://github.com/vatesfr/xo-web/issues/1474)
- Improve log view [\#1467](https://github.com/vatesfr/xo-web/issues/1467)
- Backup Reports: e-mail subject [\#1463](https://github.com/vatesfr/xo-web/issues/1463)
- Backup Reports: report the error [\#1462](https://github.com/vatesfr/xo-web/issues/1462)
- Vif selector: select management network by default [\#1425](https://github.com/vatesfr/xo-web/issues/1425)
- Display when browser disconnected to server [\#1417](https://github.com/vatesfr/xo-web/issues/1417)
- Tooltip on OS icon in VM view [\#1416](https://github.com/vatesfr/xo-web/issues/1416)
- Display pool master [\#1407](https://github.com/vatesfr/xo-web/issues/1407)
- Missing tooltips in VM creation view [\#1402](https://github.com/vatesfr/xo-web/issues/1402)
- Handle VBD disconnect and connect [\#1397](https://github.com/vatesfr/xo-web/issues/1397)
- Eject host from a pool [\#1395](https://github.com/vatesfr/xo-web/issues/1395)
- Improve pool general view [\#1393](https://github.com/vatesfr/xo-web/issues/1393)
- Improve patching system [\#1392](https://github.com/vatesfr/xo-web/issues/1392)
- Pool name modification [\#1390](https://github.com/vatesfr/xo-web/issues/1390)
- Confirmation dialog before destroying VDIs [\#1388](https://github.com/vatesfr/xo-web/issues/1388)
- Tooltips for meter object [\#1387](https://github.com/vatesfr/xo-web/issues/1387)
- New Host assistant [\#1374](https://github.com/vatesfr/xo-web/issues/1374)
- New VM assistant [\#1373](https://github.com/vatesfr/xo-web/issues/1373)
- New SR assistant [\#1372](https://github.com/vatesfr/xo-web/issues/1372)
- Direct access to VDI listing from dashboard's SR usage breakdown [\#1371](https://github.com/vatesfr/xo-web/issues/1371)
- Can't set a network name at pool level [\#1368](https://github.com/vatesfr/xo-web/issues/1368)
- Change a few mouse over descriptions [\#1363](https://github.com/vatesfr/xo-web/issues/1363)
- Hide network install in VM create if template is HVM [\#1362](https://github.com/vatesfr/xo-web/issues/1362)
- SR space left during VM creation [\#1358](https://github.com/vatesfr/xo-web/issues/1358)
- Add destination SR on migration modal in VM view [\#1357](https://github.com/vatesfr/xo-web/issues/1357)
- Ability to create a new VM from a snapshot [\#1353](https://github.com/vatesfr/xo-web/issues/1353)
- Missing explanation/confirmation on Snapshot Page [\#1349](https://github.com/vatesfr/xo-web/issues/1349)
- Log view: expose API errors in the web UI [\#1344](https://github.com/vatesfr/xo-web/issues/1344)
- Registration on update page [\#1341](https://github.com/vatesfr/xo-web/issues/1341)
- Add export snapshot button [\#1336](https://github.com/vatesfr/xo-web/issues/1336)
- Use saved SSH keys in VM create CloudConfig [\#1319](https://github.com/vatesfr/xo-web/issues/1319)
- Collapse header in console view [\#1268](https://github.com/vatesfr/xo-web/issues/1268)
- Two max concurrent jobs in parallel [\#915](https://github.com/vatesfr/xo-web/issues/915)
- Handle OVA import via the web UI [\#709](https://github.com/vatesfr/xo-web/issues/709)
### Bug fixes
- Bug on VM console when header is hidden [\#1485](https://github.com/vatesfr/xo-web/issues/1485)
- Disks not removed when deleting multiple VMs [\#1484](https://github.com/vatesfr/xo-web/issues/1484)
- Do not display VDI disconnect button when a VM is not running [\#1470](https://github.com/vatesfr/xo-web/issues/1470)
- Do not display VIF disconnect button when a VM is not running [\#1468](https://github.com/vatesfr/xo-web/issues/1468)
- Error on migration if no default SR \(even when not used\) [\#1466](https://github.com/vatesfr/xo-web/issues/1466)
- DR issue while rotating old backup [\#1464](https://github.com/vatesfr/xo-web/issues/1464)
- Giving resource set to end-user ends with error [\#1448](https://github.com/vatesfr/xo-web/issues/1448)
- Error thrown when cancelling out of Delete User confirmation dialog [\#1439](https://github.com/vatesfr/xo-web/issues/1439)
- Wrong month label shown in Backup and Job scheduler [\#1438](https://github.com/vatesfr/xo-web/issues/1438)
- Bug on Self service creation/edition [\#1428](https://github.com/vatesfr/xo-web/issues/1428)
- ISO selection during VM create is not mounted after [\#1415](https://github.com/vatesfr/xo-web/issues/1415)
- Hosts general view: bad link for storage [\#1408](https://github.com/vatesfr/xo-web/issues/1408)
- Backup Schedule - "Month" and "Day of Week" display error [\#1404](https://github.com/vatesfr/xo-web/issues/1404)
- Migrate dialog doesn't present all available VIF's in new UI interface [\#1403](https://github.com/vatesfr/xo-web/issues/1403)
- NFS mount issues [\#1396](https://github.com/vatesfr/xo-web/issues/1396)
- Select component color [\#1391](https://github.com/vatesfr/xo-web/issues/1391)
- SR created with local path shouldn't be shared [\#1389](https://github.com/vatesfr/xo-web/issues/1389)
- Disks (VBD) are attached to VM in RO mode instead of RW even if RO is unchecked [\#1386](https://github.com/vatesfr/xo-web/issues/1386)
- Re-connection issues between server and XS hosts [\#1384](https://github.com/vatesfr/xo-web/issues/1384)
- Meter object style with Chrome 52 [\#1383](https://github.com/vatesfr/xo-web/issues/1383)
- Editing a rolling snapshot job seems to fail [\#1376](https://github.com/vatesfr/xo-web/issues/1376)
- Dashboard SR usage and total inverted [\#1370](https://github.com/vatesfr/xo-web/issues/1370)
- XenServer connection issue with host while using VGPUs [\#1369](https://github.com/vatesfr/xo-web/issues/1369)
- Job created with v4 are not correctly displayed in v5 [\#1366](https://github.com/vatesfr/xo-web/issues/1366)
- CPU accounting in resource set [\#1365](https://github.com/vatesfr/xo-web/issues/1365)
- Tooltip stay displayed when a button change state [\#1360](https://github.com/vatesfr/xo-web/issues/1360)
- Failure on host reboot [\#1351](https://github.com/vatesfr/xo-web/issues/1351)
- Editing Backup Jobs Without Compression, Slider Always Set To On [\#1339](https://github.com/vatesfr/xo-web/issues/1339)
- Month Selection on Backup Screen Wrong [\#1338](https://github.com/vatesfr/xo-web/issues/1338)
- Delta backup fail when removed VDIs [\#1333](https://github.com/vatesfr/xo-web/issues/1333)
## **5.1.0** (2016-07-26)
### Enhancements
- Improve backups timezone UI [\#1314](https://github.com/vatesfr/xo-web/issues/1314)
- HOME view submenus [\#1306](https://github.com/vatesfr/xo-web/issues/1306)
- Ability for a user to save SSH keys [\#1299](https://github.com/vatesfr/xo-web/issues/1299)
- \[ACLs\] Ability to select all hosts/VMs [\#1296](https://github.com/vatesfr/xo-web/issues/1296)
- Improve scheduling UI [\#1295](https://github.com/vatesfr/xo-web/issues/1295)
- Plugins: Predefined configurations [\#1289](https://github.com/vatesfr/xo-web/issues/1289)
- Button to recompute resource sets limits [\#1287](https://github.com/vatesfr/xo-web/issues/1287)
- Credit scheduler CAP and weight configuration [\#1283](https://github.com/vatesfr/xo-web/issues/1283)
- Migration form problem on the /v5/vms/\_\_UUID\_\_ page when doing xenmotion inside a pool [\#1254](https://github.com/vatesfr/xo-web/issues/1254)
- /v5/\#/pools/\_\_UUID\_\_: patch table improvement [\#1246](https://github.com/vatesfr/xo-web/issues/1246)
- /v5/\#/hosts/\_\_UUID\_\_: patch list improvements ? [\#1245](https://github.com/vatesfr/xo-web/issues/1245)
- F\*cking patches, how do they work? [\#1236](https://github.com/vatesfr/xo-web/issues/1236)
- Change Default Filter [\#1235](https://github.com/vatesfr/xo-web/issues/1235)
- Add a property on jobs to know their state [\#1232](https://github.com/vatesfr/xo-web/issues/1232)
- Spanish translation [\#1231](https://github.com/vatesfr/xo-web/issues/1231)
- Home: "Filter" input and keyboard focus [\#1228](https://github.com/vatesfr/xo-web/issues/1228)
- Display xenserver version [\#1225](https://github.com/vatesfr/xo-web/issues/1225)
- Plugin config: presets & defaults [\#1222](https://github.com/vatesfr/xo-web/issues/1222)
- Allow halted VM migration [\#1216](https://github.com/vatesfr/xo-web/issues/1216)
- Missing confirm dialog on critical button [\#1211](https://github.com/vatesfr/xo-web/issues/1211)
- Backup logs are not sortable [\#1196](https://github.com/vatesfr/xo-web/issues/1196)
- Page title with the name of current object [\#1185](https://github.com/vatesfr/xo-web/issues/1185)
- Existing VIF management [\#1176](https://github.com/vatesfr/xo-web/issues/1176)
- Do not display fast clone option is there isn't template disks [\#1172](https://github.com/vatesfr/xo-web/issues/1172)
- UI issue when adding a user [\#1159](https://github.com/vatesfr/xo-web/issues/1159)
- Combined values on stats [\#1158](https://github.com/vatesfr/xo-web/issues/1158)
- Parallel coordinates graph [\#1157](https://github.com/vatesfr/xo-web/issues/1157)
- VM creation on self-service as user [\#1155](https://github.com/vatesfr/xo-web/issues/1155)
- VM copy bulk action on home view [\#1154](https://github.com/vatesfr/xo-web/issues/1154)
- Better VDI map [\#1151](https://github.com/vatesfr/xo-web/issues/1151)
- Missing tooltips on buttons [\#1150](https://github.com/vatesfr/xo-web/issues/1150)
- Patching from pool view [\#1149](https://github.com/vatesfr/xo-web/issues/1149)
- Missing patches in dashboard [\#1148](https://github.com/vatesfr/xo-web/issues/1148)
- Improve tasks view [\#1147](https://github.com/vatesfr/xo-web/issues/1147)
- Home bulk VM migration [\#1146](https://github.com/vatesfr/xo-web/issues/1146)
- LDAP plugin clear password field [\#1145](https://github.com/vatesfr/xo-web/issues/1145)
- Cron default behavior [\#1144](https://github.com/vatesfr/xo-web/issues/1144)
- Modal for migrate on home [\#1143](https://github.com/vatesfr/xo-web/issues/1143)
- /v5/\#/srs/\_\_UUID\_\_: UI improvements [\#1142](https://github.com/vatesfr/xo-web/issues/1142)
- /v5/\#/pools/: some name should be links [\#1141](https://github.com/vatesfr/xo-web/issues/1141)
- create the page /v5/\#/pools/ [\#1140](https://github.com/vatesfr/xo-web/issues/1140)
- Dashboard: add links to different part of XOA [\#1139](https://github.com/vatesfr/xo-web/issues/1139)
- /v5/\#/dashboard/overview: add link on the "Top 5 SR Usage" graph [\#1135](https://github.com/vatesfr/xo-web/issues/1135)
- /v5/\#/backup/overview: display the error when there is one returned by xenserver on failed job. [\#1134](https://github.com/vatesfr/xo-web/issues/1134)
- /v5/: add an option to set the number of element displayed in tables [\#1133](https://github.com/vatesfr/xo-web/issues/1133)
- Updater refresh page after update [\#1131](https://github.com/vatesfr/xo-web/issues/1131)
- /v5/\#/settings/plugins [\#1130](https://github.com/vatesfr/xo-web/issues/1130)
- /v5/\#/new/sr: layout issue [\#1129](https://github.com/vatesfr/xo-web/issues/1129)
- v5 /v5/\#/vms/new: layout issue [\#1128](https://github.com/vatesfr/xo-web/issues/1128)
- v5 user page missing style [\#1127](https://github.com/vatesfr/xo-web/issues/1127)
- Remote helper/tester [\#1075](https://github.com/vatesfr/xo-web/issues/1075)
- Generate uiSchema from custom schema properties [\#951](https://github.com/vatesfr/xo-web/issues/951)
- Customizing VM names generation during batch creation [\#949](https://github.com/vatesfr/xo-web/issues/949)
### Bug fixes
- Plugins: Don't use `default` attributes in presets list [\#1288](https://github.com/vatesfr/xo-web/issues/1288)
- CPU weight must be an integer [\#1286](https://github.com/vatesfr/xo-web/issues/1286)
- Overview of self service is always empty [\#1282](https://github.com/vatesfr/xo-web/issues/1282)
- SR attach/creation issue [\#1281](https://github.com/vatesfr/xo-web/issues/1281)
- Self service resources not modified after a VM deletion [\#1276](https://github.com/vatesfr/xo-web/issues/1276)
- Scheduled jobs seems use GMT since 5.0 [\#1258](https://github.com/vatesfr/xo-web/issues/1258)
- Can't create a VM with disks on 2 different SRs [\#1257](https://github.com/vatesfr/xo-web/issues/1257)
- Graph display bug [\#1247](https://github.com/vatesfr/xo-web/issues/1247)
- /v5/#/hosts/__UUID__: Patch list not limited to the current pool [\#1244](https://github.com/vatesfr/xo-web/issues/1244)
- Replication issues [\#1233](https://github.com/vatesfr/xo-web/issues/1233)
- VM creation install method disabled fields [\#1198](https://github.com/vatesfr/xo-web/issues/1198)
- Update icon shouldn't be displayed when menu is collapsed [\#1188](https://github.com/vatesfr/xo-web/issues/1188)
- /v5/ : Load average graph axis issue [\#1167](https://github.com/vatesfr/xo-web/issues/1167)
- Some remote can't be opened [\#1164](https://github.com/vatesfr/xo-web/issues/1164)
- Bulk action for hosts in home and pool view [\#1153](https://github.com/vatesfr/xo-web/issues/1153)
- New Vif [\#1138](https://github.com/vatesfr/xo-web/issues/1138)
- Missing SRs [\#1123](https://github.com/vatesfr/xo-web/issues/1123)
- Continuous replication email alert does not obey per job setting [\#1121](https://github.com/vatesfr/xo-web/issues/1121)
- Safari XO5 issue [\#1120](https://github.com/vatesfr/xo-web/issues/1120)
- ACLs shoud be available in Enterprise Edition [\#1118](https://github.com/vatesfr/xo-web/issues/1118)
- SR edit name or description doesn't work [\#1116](https://github.com/vatesfr/xo-web/issues/1116)
- Bad RRD parsing for VIFs [\#969](https://github.com/vatesfr/xo-web/issues/969)
## **5.0.0** (2016-06-24)
### Enhancements

View File

@@ -1,4 +1,4 @@
# Xen Orchestra Web [![Build Status](https://travis-ci.org/vatesfr/xo-web.png?branch=master)](https://travis-ci.org/vatesfr/xo-web)
# Xen Orchestra Web [![Chat with us](https://storage.crisp.im/plugins/images/936925df-f37b-4ba8-bab0-70cd2edcb0be/badge.svg)](https://go.crisp.im/chat/embed/?website_id=-JzqzzwddSV7bKGtEyAQ) [![Build Status](https://travis-ci.org/vatesfr/xo-web.png?branch=master)](https://travis-ci.org/vatesfr/xo-web)
![](http://i.imgur.com/tRffA5y.png)
@@ -10,7 +10,7 @@ ___
## Installation
XOA or manual install procedure is [available here](https://github.com/vatesfr/xo/blob/master/doc/installation/README.md)
XOA or manual install procedure is [available here](https://xen-orchestra.com/docs/installation.html)
## Compilation

View File

@@ -11,17 +11,6 @@ var DIST_DIR = __dirname + '/dist' // eslint-disable-line no-path-concat
// http://www.random.org/integers/?num=1&min=1024&max=65535&col=1&base=10&format=plain&rnd=new
var LIVERELOAD_PORT = 26242
// Port to use for the embedded web server.
//
// Set to 0 to choose a random port at each run.
var SERVER_PORT = LIVERELOAD_PORT + 1
// Address the server should bind to.
//
// - `'localhost'` to make it accessible from this host only
// - `null` to make it accessible for the whole network
var SERVER_ADDR = 'localhost'
var PRODUCTION = process.env.NODE_ENV === 'production'
var DEVELOPMENT = !PRODUCTION
@@ -173,7 +162,7 @@ function browserify (path, opts) {
var bundler = require('browserify')(path, {
basedir: SRC_DIR,
debug: DEVELOPMENT, // TODO: enable also in production but need to make it work with gulp-uglify.
debug: true,
extensions: opts.extensions,
fullPaths: false,
paths: SRC_DIR + '/common',
@@ -249,8 +238,8 @@ function browserify (path, opts) {
gulp.task(function buildPages () {
return pipe(
src('index.jade', { sourcemaps: true }),
require('gulp-jade')(),
src('index.pug', { sourcemaps: true }),
require('gulp-pug')(),
DEVELOPMENT && require('gulp-embedlr')({
port: LIVERELOAD_PORT
}),
@@ -268,7 +257,8 @@ gulp.task(function buildScripts () {
}]
]
}),
PRODUCTION && require('gulp-uglify')(),
require('gulp-sourcemaps').init({ loadMaps: true }),
PRODUCTION && require('gulp-uglify/composer')(require('uglify-es'))(),
dest()
)
})
@@ -313,28 +303,3 @@ gulp.task('build', gulp.parallel(
gulp.task(function clean (done) {
require('rimraf')(DIST_DIR, done)
})
// -------------------------------------------------------------------
gulp.task(function server (done) {
require('connect')()
.use(require('serve-static')(DIST_DIR))
.listen(SERVER_PORT, SERVER_ADDR, function onListen () {
var address = this.address()
var port = address.port
address = address.address
// Correctly handle IPv6 addresses.
if (address.indexOf(':') !== -1) {
address = '[' + address + ']'
}
/* jshint devel: true*/
console.log('Listening on http://' + address + ':' + port)
})
.on('error', done)
.on('close', function onClose () {
done()
})
})

View File

@@ -1,7 +1,7 @@
{
"private": false,
"name": "xo-web",
"version": "5.0.2",
"version": "5.10.3",
"license": "AGPL-3.0",
"description": "Web interface client for Xen-Orchestra",
"keywords": [
@@ -31,100 +31,126 @@
"npm": ">=3"
},
"devDependencies": {
"@nraynaud/novnc": "^0.6.1-1",
"ansi_up": "^1.3.0",
"asap": "^2.0.4",
"ava": "^0.15.0",
"babel-eslint": "^6.0.0",
"babel-eslint": "^7.0.0",
"babel-plugin-dev": "^1.0.0",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-react-constant-elements": "^6.5.0",
"babel-plugin-transform-react-inline-elements": "^6.6.5",
"babel-plugin-transform-react-jsx-self": "^6.11.0",
"babel-plugin-transform-react-jsx-source": "^6.9.0",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.16.3",
"babel-runtime": "^6.6.1",
"babelify": "^7.2.0",
"benchmark": "^2.1.0",
"bootstrap": "github:twbs/bootstrap#v4-dev",
"browserify": "^13.0.0",
"bootstrap": "4.0.0-alpha.5",
"browserify": "^14.1.0",
"bundle-collapser": "^1.2.1",
"chartist-plugin-legend": "^0.3.1",
"chartist": "^0.10.1",
"chartist-plugin-legend": "^0.6.1",
"chartist-plugin-tooltip": "0.0.11",
"classnames": "^2.2.3",
"connect": "^3.4.1",
"cookies-js": "^1.2.2",
"d3": "^4.0.0-alpha.50",
"d3": "^4.2.8",
"dependency-check": "^2.5.1",
"font-awesome": "^4.5.0",
"enzyme": "^2.6.0",
"enzyme-to-json": "^1.4.4",
"event-to-promise": "^0.8.0",
"font-awesome": "^4.7.0",
"font-mfizz": "github:fizzed/font-mfizz",
"ghooks": "^1.1.1",
"globby": "^5.0.0",
"get-stream": "^2.3.0",
"globby": "^6.0.0",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-csso": "^2.0.0",
"gulp-autoprefixer": "^4.0.0",
"gulp-csso": "^3.0.0",
"gulp-embedlr": "^0.5.2",
"gulp-jade": "^1.1.0",
"gulp-plumber": "^1.1.0",
"gulp-pug": "^3.1.0",
"gulp-refresh": "^1.1.0",
"gulp-sass": "^2.2.0",
"gulp-uglify": "^1.5.3",
"gulp-sass": "^3.0.0",
"gulp-sourcemaps": "^2.2.3",
"gulp-uglify": "^3.0.0",
"gulp-watch": "^4.3.5",
"human-format": "^0.6.0",
"jsonrpc-websocket-client": "0.0.1-5",
"human-format": "^0.8.0",
"husky": "^0.13.1",
"index-modules": "^0.3.0",
"is-ip": "^1.0.0",
"jest": "^20.0.4",
"jsonrpc-websocket-client": "^0.1.1",
"kindof": "^2.0.0",
"later": "^1.2.0",
"lodash": "^4.6.1",
"loose-envify": "^1.1.0",
"make-error": "^1.2.1",
"marked": "^0.3.5",
"modular-css": "^0.22.1",
"modular-css": "^5.1.6",
"moment": "^2.13.0",
"notifyjs": "^2.0.1",
"novnc-node": "^0.5.3",
"promise-toolbox": "^0.4.0",
"moment-timezone": "^0.5.4",
"notifyjs": "^3.0.0",
"promise-toolbox": "^0.9.4",
"random-password": "^0.1.2",
"react": "^15.0.0",
"react": "^15.4.1",
"react-addons-shallow-compare": "^15.1.0",
"react-addons-test-utils": "^15.4.1",
"react-bootstrap-4": "^0.29.1",
"react-chartist": "^0.10.1",
"react-copy-to-clipboard": "^4.0.2",
"react-debounce-input": "^2.4.0",
"react-chartist": "^0.12.0",
"react-copy-to-clipboard": "^5.0.0",
"react-debounce-input": "^3.0.0",
"react-dnd": "^2.1.4",
"react-dnd-html5-backend": "^2.1.2",
"react-dom": "^15.0.0",
"react-document-title": "^2.0.2",
"react-dom": "^15.4.1",
"react-dropzone": "^3.5.0",
"react-intl": "^2.0.1",
"react-key-handler": "^0.2.0",
"react-key-handler": "^0.3.0",
"react-notify": "^2.0.1",
"react-redux": "^4.4.0",
"react-router": "^3.0.0-alpha.1",
"react-select": "^1.0.0-beta13",
"react-overlays": "^0.6.0",
"react-redux": "^5.0.0",
"react-router": "^3.0.0",
"react-select": "^1.0.0-rc.4",
"react-shortcuts": "^1.3.1",
"react-sparklines": "^1.5.0",
"react-virtualized": "^7.4.0",
"react-virtualized": "^8.0.8",
"readable-stream": "^2.0.6",
"redux": "^3.3.1",
"redux-devtools": "^3.1.1",
"redux-devtools-dock-monitor": "^1.1.0",
"redux-devtools-log-monitor": "^1.0.5",
"redux-thunk": "^2.0.1",
"reselect": "^2.2.1",
"serve-static": "^1.10.2",
"standard": "^7.0.0",
"superagent": "^2.0.0",
"vinyl": "^1.1.1",
"reselect": "^2.5.4",
"semver": "^5.3.0",
"standard": "^10.0.0",
"styled-components": "^2.1.0",
"superagent": "^3.5.0",
"tar-stream": "^1.5.2",
"uglify-es": "^3.0.18",
"uncontrollable-input": "^0.0.1",
"vinyl": "^2.0.0",
"watchify": "^3.7.0",
"xo-acl-resolver": "^0.2.1",
"xo-lib": "^0.8.0-1",
"xml2js": "^0.4.17",
"xo-acl-resolver": "^0.2.3",
"xo-common": "^0.1.1",
"xo-lib": "^0.8.0",
"xo-remote-parser": "^0.3"
},
"scripts": {
"benchmarks": "./tools/run-benchmarks.js 'src/**/*.bench.js'",
"build": "npm run build-indexes && NODE_ENV=production gulp build",
"build-indexes": "./tools/generate-index src/common/intl/locales",
"dev": "npm run build-indexes && gulp build server",
"dev-test": "ava --watch",
"build-indexes": "index-modules --auto src",
"commitmsg": "npm test",
"dev": "npm run build-indexes && NODE_ENV=development gulp build",
"dev-test": "jest --watch",
"lint": "standard",
"posttest": "npm run lint",
"prepublish": "npm run build",
"test": "ava"
"test": "jest"
},
"browserify": {
"transform": [
@@ -132,17 +158,14 @@
"loose-envify"
]
},
"ava": {
"babel": "inherit",
"files": [
"src/**/*.spec.js"
],
"require": [
"babel-register"
]
},
"babel": {
"env": {
"development": {
"plugins": [
"transform-react-jsx-self",
"transform-react-jsx-source"
]
},
"production": {
"plugins": [
"transform-react-constant-elements",
@@ -151,6 +174,8 @@
}
},
"plugins": [
"dev",
"lodash",
"transform-decorators-legacy",
"transform-runtime"
],
@@ -160,12 +185,15 @@
"stage-0"
]
},
"config": {
"ghooks": {
"commit-msg": "npm test"
}
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
},
"standard": {
"globals": [
"__DEV__"
],
"ignore": [
"dist"
],

View File

@@ -4,16 +4,16 @@
$ct-series-colors: (
$brand-success,
$brand-primary,
#60bd68,
#f17cb0,
#b2912f,
#b276b2,
#decf3f,
#f15854,
#4d4d4d,
#dda458,
#eacf7d,
#86797d,
#b276b2,
#f15854,
#b2912f,
#decf3f,
#dda458,
#60bd68,
#4d4d4d,
#eacf7d,
#b2c326,
#6188e2,
#a748ca
@@ -22,6 +22,18 @@ $ct-series-colors: (
@import "../node_modules/chartist/dist/scss/settings/_chartist-settings";
@import "../node_modules/chartist/dist/scss/chartist";
.ct-chart {
display: flex;
flex-direction: column-reverse;
}
// safari has a bug in flex computing that prevent charts from showing see #1755
// by fixing the height with a value found in Chrome it seems like it fixes the issue without breaking the layout
// elsewhere
.dashboardItem .ct-chart {
height: 150px;
}
// Line in charts with only 2px in width
.ct-line {
stroke-width: 2px;
@@ -55,7 +67,6 @@ $ct-series-colors: (
// Arrow!
&:before {
position: absolute;
bottom: -14px;
top: 100%;
left: 50%;
@@ -80,28 +91,27 @@ $ct-series-colors: (
// CHARTIST LEGEND =============================================================
.ct-legend {
position: absolute;
bottom: 0;
margin-bottom: -1em;
li {
position: relative;
padding-left: 1.4em;
padding-left: 0.5em;
list-style-type: none;
display: inline;
display: inline-block;
margin-right: 0.5em;
font-size: 0.8em;
}
li:before {
display: inline-block;
width: 1em;
height: 1em;
position: absolute;
left: 0;
content: '';
border: 3px solid transparent;
border-radius: 2px;
margin-top: 0.5em;
margin-right: 0.2em;
}
li.inactive:before {

View File

@@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Col 1`] = `
<div
className="col-xs-12"
/>
`;
exports[`Container 1`] = `
<div
className="container-fluid"
/>
`;
exports[`Row 1`] = `
<div
className=" row"
/>
`;

View File

@@ -1,26 +1,36 @@
// import _ from 'intl' TODO: fix tooltip
import ActionButton from 'action-button'
import map from 'lodash/map'
import React from 'react'
// import Tooltip from 'tooltip' TODO: fix tooltip
import {
ButtonGroup
} from 'react-bootstrap-4/lib'
import { map, noop } from 'lodash'
import _ from './intl'
import ActionButton from './action-button'
import ButtonGroup from './button-group'
const ActionBar = ({ actions, param }) => (
<ButtonGroup>
{map(actions, ({ handler, handlerParam = param, label, icon }, index) => (
/* <Tooltip key={index} content={_(label)}> TODO: fix tooltip */
<ActionButton
key={index}
btnStyle='secondary'
handler={handler}
handlerParam={handlerParam}
icon={icon}
size='large'
/>
/* </Tooltip> */
))}
{map(actions, (button, index) => {
if (!button) {
return
}
const {
handler,
handlerParam = param,
icon,
label,
pending,
redirectOnSuccess
} = button
return <ActionButton
key={index}
handler={handler || noop}
handlerParam={handlerParam}
icon={icon}
pending={pending}
redirectOnSuccess={redirectOnSuccess}
size='large'
tooltip={_(label)}
/>
})}
</ButtonGroup>
)
ActionBar.propTypes = {
@@ -28,7 +38,8 @@ ActionBar.propTypes = {
React.PropTypes.shape({
label: React.PropTypes.string.isRequired,
icon: React.PropTypes.string.isRequired,
handler: React.PropTypes.func
handler: React.PropTypes.func,
redirectOnSuccess: React.PropTypes.string
})
).isRequired,
display: React.PropTypes.oneOf(['icon', 'text', 'both'])

View File

@@ -1,58 +1,82 @@
import Icon from 'icon'
import isFunction from 'lodash/isFunction'
import React from 'react'
import { Button } from 'react-bootstrap-4/lib'
import Button from './button'
import Component from './base-component'
import Icon from './icon'
import logError from './log-error'
import { autobind, propTypes } from './utils'
import propTypes from './prop-types-decorator'
import Tooltip from './tooltip'
import { error as _error } from './notification'
@propTypes({
btnStyle: propTypes.string,
// React element to use as button content
children: propTypes.node,
// whether this button is disabled (default to false)
disabled: propTypes.bool,
// form identifier
//
// if provided, this button and its action are associated to this
// form for the submit event
form: propTypes.string,
// function to call when the action is triggered (via a clik on the
// button or submit on the form)
handler: propTypes.func.isRequired,
// optional value which will be passed as first param to the handler
handlerParam: propTypes.any,
// XO icon to use for this button
icon: propTypes.string.isRequired,
// whether the action of this action is already underway
pending: propTypes.bool,
// path to redirect to when the triggered action finish successfully
//
// if a function, it will be called with the result of the action to
// compute the path
redirectOnSuccess: propTypes.oneOfType([
propTypes.func,
propTypes.string
]),
size: propTypes.oneOf([
'large',
'small'
])
// React element to use tooltip for the component
tooltip: propTypes.node
})
export default class ActionButton extends Component {
static contextTypes = {
router: React.PropTypes.object
router: propTypes.object
}
@autobind
async _execute () {
if (this.state.working) {
if (this.props.pending || this.state.working) {
return
}
const {
children,
handler,
handlerParam
handlerParam,
tooltip
} = this.props
try {
this.setState({
error: null,
error: undefined,
working: true
})
const result = await handler(handlerParam)
let { redirectOnSuccess } = this.props
const { redirectOnSuccess } = this.props
if (redirectOnSuccess) {
if (isFunction(redirectOnSuccess)) {
redirectOnSuccess = redirectOnSuccess(result)
}
return this.context.router.push(redirectOnSuccess)
return this.context.router.push(
isFunction(redirectOnSuccess) ? redirectOnSuccess(result) : redirectOnSuccess
)
}
this.setState({
@@ -63,9 +87,15 @@ export default class ActionButton extends Component {
error,
working: false
})
logError(error)
// ignore when undefined because it usually means that the action has been canceled
if (error !== undefined) {
logError(error)
_error(children || tooltip || error.name, error.message || String(error))
}
}
}
_execute = ::this._execute
_eventListener = event => {
event.preventDefault()
@@ -91,29 +121,36 @@ export default class ActionButton extends Component {
render () {
const {
props: {
btnStyle,
children,
className,
disabled,
form,
icon,
size: bsSize,
style
pending,
tooltip,
...props
},
state: { error, working }
} = this
return <Button
bsStyle={error ? 'warning' : btnStyle}
form={form}
onClick={!form && this._execute}
disabled={working || disabled}
type={form ? 'submit' : 'button'}
{...{ bsSize, className, style }}
>
<Icon icon={working ? 'loading' : icon} fixedWidth />
if (error !== undefined) {
props.btnStyle = 'warning'
}
if (pending || working) {
props.disabled = true
}
delete props.handler
delete props.handlerParam
if (props.form === undefined) {
props.onClick = this._execute
}
delete props.redirectOnSuccess
const button = <Button {...props}>
<Icon icon={pending || working ? 'loading' : icon} fixedWidth />
{children && ' '}
{children}
</Button>
return tooltip
? <Tooltip content={tooltip}>{button}</Tooltip>
: button
}
}

View File

@@ -1,6 +1,7 @@
import ActionButton from 'action-button'
import React from 'react'
import { propTypes } from 'utils'
import ActionButton from './action-button'
import propTypes from './prop-types-decorator'
const ActionToggle = ({ className, value, ...props }) =>
<ActionButton

View File

@@ -1,34 +1,118 @@
import clone from 'lodash/clone'
import includes from 'lodash/includes'
import isArray from 'lodash/isArray'
import forEach from 'lodash/forEach'
import { Component } from 'react'
import map from 'lodash/map'
import { PureComponent } from 'react'
import invoke from './invoke'
import shallowEqual from './shallow-equal'
import getEventValue from './get-event-value'
export default class BaseComponent extends Component {
// Should components logs every renders?
//
// Usually set to process.env.NODE_ENV !== 'production'.
const VERBOSE = false
const cowSet = (object, path, value, depth) => {
if (depth >= path.length) {
return value
}
object = object != null ? clone(object) : {}
const prop = path[depth]
object[prop] = cowSet(object[prop], path, value, depth + 1)
return object
}
const get = (object, path, depth) => {
if (depth >= path.length) {
return object
}
const prop = path[depth++]
return isArray(object) && prop === '*'
? map(object, value => get(value, path, depth))
: get(object[prop], path, depth)
}
export default class BaseComponent extends PureComponent {
constructor (props, context) {
super(props, context)
// It really should have been done in React.Component!
this.state = {}
if (process.env.NODE_ENV !== 'production') {
this.render = invoke(this.render, render => () => {
this._linkedState = null
if (VERBOSE) {
this.render = (render => () => {
console.log('render', this.constructor.name)
return render.call(this)
})
})(this.render)
}
}
shouldComponentUpdate (newProps, newState) {
return !(
shallowEqual(this.props, newProps) &&
shallowEqual(this.state, newState)
)
// See https://preactjs.com/guide/linked-state
linkState (name, targetPath) {
const key = targetPath !== undefined
? `${name}##${targetPath}`
: name
let linkedState = this._linkedState
let cb
if (linkedState === null) {
linkedState = this._linkedState = {}
} else if ((cb = linkedState[key]) !== undefined) {
return cb
}
let getValue
if (targetPath !== undefined) {
const path = targetPath.split('.')
getValue = event => get(getEventValue(event), path, 0)
} else {
getValue = getEventValue
}
if (includes(name, '.')) {
const path = name.split('.')
return (linkedState[key] = event => {
this.setState(cowSet(this.state, path, getValue(event), 0))
})
}
return (linkedState[key] = event => {
this.setState({
[name]: getValue(event)
})
})
}
toggleState (name) {
let linkedState = this._linkedState
let cb
if (linkedState === null) {
linkedState = this._linkedState = {}
} else if ((cb = linkedState[name]) !== undefined) {
return cb
}
if (includes(name, '.')) {
const path = name.split('.')
return (linkedState[path] = event => {
this.setState(cowSet(this.state, path, !get(this.state, path, 0), 0))
})
}
return (linkedState[name] = () => {
this.setState({
[name]: !this.state[name]
})
})
}
}
if (process.env.NODE_ENV !== 'production') {
if (VERBOSE) {
const diff = (name, old, cur) => {
const keys = []

View File

@@ -0,0 +1,8 @@
import React from 'react'
const ButtonGroup = ({ children }) =>
<div className='btn-group' role='group'>
{children}
</div>
export { ButtonGroup as default }

56
src/common/button.js Normal file
View File

@@ -0,0 +1,56 @@
import classNames from 'classnames'
import React from 'react'
import propTypes from './prop-types-decorator'
const Button = ({
active,
block,
btnStyle = 'secondary',
children,
outline,
size,
...props
}) => {
props.className = classNames(
props.className,
'btn',
`btn${outline ? '-outline' : ''}-${btnStyle}`,
active !== undefined && 'active',
block && 'btn-block',
size === 'large' ? 'btn-lg' : size === 'small' ? 'btn-sm' : null
)
if (props.type === undefined && props.form === undefined) {
props.type = 'button'
}
return <button {...props}>{children}</button>
}
propTypes({
active: propTypes.bool,
block: propTypes.bool,
// Bootstrap button style
//
// See https://v4-alpha.getbootstrap.com/components/buttons/#examples
//
// The default value (secondary) is not listed here because it does
// not make sense to explicit it.
btnStyle: propTypes.oneOf([
'danger',
'info',
'link',
'primary',
'success',
'warning'
]),
outline: propTypes.bool,
size: propTypes.oneOf([
'large',
'small'
])
})(Button)
export { Button as default }

View File

@@ -1,5 +1,6 @@
import React from 'react'
import { propTypes } from 'utils'
import propTypes from './prop-types-decorator'
const CARD_STYLE = {
minHeight: '100%'
@@ -33,9 +34,9 @@ export const CardHeader = propTypes({
children,
className
}) => (
<h3 className={`card-header ${className || ''}`} style={CARD_HEADER_STYLE}>
<h4 className={`card-header ${className || ''}`} style={CARD_HEADER_STYLE}>
{children}
</h3>
</h4>
))
export const CardBlock = propTypes({

View File

@@ -1,14 +1,21 @@
import Component from 'base-component'
import Icon from 'icon'
import React from 'react'
import { propTypes } from 'utils'
import Button from './button'
import Component from './base-component'
import Icon from './icon'
import propTypes from './prop-types-decorator'
@propTypes({
children: propTypes.any.isRequired,
className: propTypes.string,
buttonText: propTypes.any.isRequired
buttonText: propTypes.any.isRequired,
defaultOpen: propTypes.bool
})
export default class Collapse extends Component {
state = {
isOpened: this.props.defaultOpen
}
_onClick = () => {
this.setState({
isOpened: !this.state.isOpened
@@ -21,9 +28,9 @@ export default class Collapse extends Component {
return (
<div className={props.className}>
<button className='btn btn-lg btn-primary btn-block' onClick={this._onClick}>
<Button block btnStyle='primary' size='large' onClick={this._onClick}>
{props.buttonText} <Icon icon={`chevron-${isOpened ? 'up' : 'down'}`} />
</button>
</Button>
{isOpened && props.children}
</div>
)

64
src/common/combobox.js Normal file
View File

@@ -0,0 +1,64 @@
import React from 'react'
import uncontrollableInput from 'uncontrollable-input'
import { isEmpty, map } from 'lodash'
import {
DropdownButton,
MenuItem
} from 'react-bootstrap-4/lib'
import Component from './base-component'
import propTypes from './prop-types-decorator'
@uncontrollableInput({
defaultValue: ''
})
@propTypes({
disabled: propTypes.bool,
options: propTypes.oneOfType([
propTypes.arrayOf(propTypes.string),
propTypes.objectOf(propTypes.string)
]),
onChange: propTypes.func.isRequired,
value: propTypes.string.isRequired
})
export default class Combobox extends Component {
_handleChange = event => {
this.props.onChange(event.target.value)
}
_setText (value) {
this.props.onChange(value)
}
render () {
const { options, ...props } = this.props
props.className = 'form-control'
props.onChange = this._handleChange
const Input = <input {...props} />
if (isEmpty(options)) {
return Input
}
return (
<div className='input-group'>
<div className='input-group-btn'>
<DropdownButton
bsStyle='secondary'
disabled={props.disabled}
id='selectInput'
title=''
>
{map(options, option =>
<MenuItem key={option} onClick={() => this._setText(option)}>
{option}
</MenuItem>
)}
</DropdownButton>
</div>
{Input}
</div>
)
}
}

View File

@@ -3,10 +3,11 @@ import {
createOr,
createNot,
createProperty,
createString
createString,
createTruthyProperty
} from './'
export const pattern = 'foo !"\\\\ \\"" name:|(wonderwoman batman)'
export const pattern = 'foo !"\\\\ \\"" name:|(wonderwoman batman) hasCape?'
export const ast = createAnd([
createString('foo'),
@@ -14,5 +15,6 @@ export const ast = createAnd([
createProperty('name', createOr([
createString('wonderwoman'),
createString('batman')
]))
])),
createTruthyProperty('hasCape')
])

View File

@@ -56,19 +56,22 @@ export const createProperty = (name, child) => ({ type: 'property', name, child
export const createString = value => ({ type: 'string', value })
export const createTruthyProperty = name => ({ type: 'truthyProperty', name })
// -------------------------------------------------------------------
// *and = terms
// terms = term+
// term = ws (groupedAnd | or | not | property | string) ws
// ws = ' '*
// groupedAnd = "(" and ")"
// *or = "|" ws "(" terms ")"
// *not = "!" term
// *property = string ws ":" term
// *string = quotedString | rawString
// quotedString = "\"" ( /[^"\]/ | "\\\\" | "\\\"" )+
// rawString = /[a-z0-9-_.]+/i
// *and = terms
// terms = term+
// term = ws (groupedAnd | or | not | property | truthyProperty | string) ws
// ws = ' '*
// groupedAnd = "(" and ")"
// *or = "|" ws "(" terms ")"
// *not = "!" term
// *property = string ws ":" term
// *truthyProperty = string ws "?"
// *string = quotedString | rawString
// quotedString = "\"" ( /[^"\]/ | "\\\\" | "\\\"" )+
// rawString = /[a-z0-9-_.]+/i
export const parse = invoke(() => {
let i
let n
@@ -108,6 +111,7 @@ export const parse = invoke(() => {
parseOr() ||
parseNot() ||
parseProperty() ||
parseTruthyProperty() ||
parseString()
)
if (child) {
@@ -203,6 +207,16 @@ export const parse = invoke(() => {
return value
}
}
const parseTruthyProperty = backtrace(() => {
let name
if (
(name = parseString()) &&
parseWs() &&
input[i++] === '?'
) {
return createTruthyProperty(name.value)
}
})
return input_ => {
if (!input_) {
@@ -280,10 +294,10 @@ export const getPropertyClausesStrings = function () {
export const removePropertyClause = function (name) {
let type
if (
!this ||
(type = this.type) === 'property' && this.name === name
) {
if (!this || (
(type = this.type) === 'property' &&
this.name === name
)) {
return
}
@@ -321,7 +335,7 @@ export const setPropertyClause = function (name, child) {
return _addAndClause(
this,
property,
node => node.type === 'property' && node.name === name,
node => node.type === 'property' && node.name === name
)
}
@@ -341,6 +355,7 @@ export const execute = invoke(() => {
property: ({ name, child }, value) => (
value != null && child::execute(value[name])
),
truthyProperty: ({ name }, value) => !!value[name],
string: invoke(() => {
const match = (pattern, value) => {
if (isString(value)) {
@@ -378,7 +393,8 @@ export const toString = invoke(() => {
property: ({ name, child }) => `${toString(createString(name))}:${toString(child)}`,
string: ({ value }) => isRawString(value)
? value
: `"${value.replace(/\\|"/g, match => `\\${match}`)}"`
: `"${value.replace(/\\|"/g, match => `\\${match}`)}"`,
truthyProperty: ({ name }) => `${toString(createString(name))}?`
}
const toString = node => visitors[node.type](node)

View File

@@ -1,4 +1,4 @@
import test from 'ava'
/* eslint-env jest */
import {
getPropertyClausesStrings,
@@ -11,43 +11,36 @@ import {
pattern
} from './index.fixtures'
test('getPropertyClausesStrings', t => {
let tmp = parse('foo bar:baz baz:|(foo bar)')::getPropertyClausesStrings()
t.deepEqual(
tmp,
{
bar: [ 'baz' ],
baz: [ 'foo', 'bar' ]
}
)
it('getPropertyClausesStrings', () => {
const tmp = parse('foo bar:baz baz:|(foo bar)')::getPropertyClausesStrings()
expect(tmp).toEqual({
bar: [ 'baz' ],
baz: [ 'foo', 'bar' ]
})
})
test('parse', t => {
t.deepEqual(parse(pattern), ast)
it('parse', () => {
expect(parse(pattern)).toEqual(ast)
})
test('setPropertyClause', t => {
t.is(
null::setPropertyClause('foo', 'bar')::toString(),
'foo:bar'
)
it('setPropertyClause', () => {
expect(
null::setPropertyClause('foo', 'bar')::toString()
).toBe('foo:bar')
t.is(
parse('baz')::setPropertyClause('foo', 'bar')::toString(),
'baz foo:bar'
)
expect(
parse('baz')::setPropertyClause('foo', 'bar')::toString()
).toBe('baz foo:bar')
t.is(
parse('plip foo:baz plop')::setPropertyClause('foo', 'bar')::toString(),
'plip plop foo:bar'
)
expect(
parse('plip foo:baz plop')::setPropertyClause('foo', 'bar')::toString()
).toBe('plip plop foo:bar')
t.is(
parse('foo:|(baz plop)')::setPropertyClause('foo', 'bar')::toString(),
'foo:bar'
)
expect(
parse('foo:|(baz plop)')::setPropertyClause('foo', 'bar')::toString()
).toBe('foo:bar')
})
test('toString', t => {
t.is(pattern, ast::toString())
it('toString', () => {
expect(pattern).toBe(ast::toString())
})

View File

@@ -2,26 +2,31 @@ import CopyToClipboard from 'react-copy-to-clipboard'
import classNames from 'classnames'
import React, { createElement } from 'react'
import _ from '../intl'
import Button from '../button'
import Icon from '../icon'
import { propTypes } from '../utils'
import propTypes from '../prop-types-decorator'
import Tooltip from '../tooltip'
import styles from './index.css'
const Copiable = propTypes({
data: propTypes.string,
tagName: propTypes.string
})(props => createElement(
props.tagName || 'span',
})(({ className, tagName = 'span', ...props }) => createElement(
tagName,
{
...props,
className: classNames(styles.container, props.className)
className: classNames(styles.container, className)
},
props.children,
' ',
<CopyToClipboard text={props.data || props.children}>
<button className={classNames('btn btn-sm btn-secondary', styles.button)}>
<Icon icon='clipboard' />
</button>
</CopyToClipboard>
<Tooltip content={_('copyToClipboard')}>
<CopyToClipboard text={props.data || props.children}>
<Button className={styles.button} size='small'>
<Icon icon='clipboard' />
</Button>
</CopyToClipboard>
</Tooltip>
))
export { Copiable as default }

9
src/common/d3-utils.js vendored Normal file
View File

@@ -0,0 +1,9 @@
import forEach from 'lodash/forEach'
export function setStyles (style) {
forEach(style, (value, key) => {
this.style(key, value)
})
return this
}

View File

@@ -1,7 +1,9 @@
import React, { Component, PropTypes } from 'react'
import { isPromise } from 'promise-toolbox'
const toString = value => JSON.stringify(value, null, 2)
const toString = value => value === undefined
? 'undefined'
: JSON.stringify(value, null, 2)
// This component does not handle changes in its `promise` property.
class DebugAsync extends Component {
@@ -35,8 +37,8 @@ class DebugAsync extends Component {
return <pre>
{'Promise { '}
{status === 'rejected' && '<rejected> '}
{toString(value)}
{status === 'rejected' && '<rejected> '}
{toString(value)}
{' }'}
</pre>
}

View File

@@ -0,0 +1,22 @@
@value dropzoneColor: #8f8686;
.dropzone {
border-radius: 4px;
border: 2px dashed dropzoneColor;
cursor: pointer;
display: flex;
height: 12em;
margin-bottom: 20px;
width: 100%;
}
.activeDropzone {
background: #f0f0f0;
border-style: solid;
}
.dropzoneText {
color: dropzoneColor;
font-size: 1.2em;
margin: auto;
}

View File

@@ -0,0 +1,20 @@
import Component from 'base-component'
import propTypes from 'prop-types-decorator'
import React from 'react'
import ReactDropzone from 'react-dropzone'
import styles from './index.css'
@propTypes({
onDrop: propTypes.func,
message: propTypes.node
})
export default class Dropzone extends Component {
render () {
const { onDrop, message } = this.props
return <ReactDropzone onDrop={onDrop} className={styles.dropzone} activeClassName={styles.activeDropzone}>
<div className={styles.dropzoneText}>{message}</div>
</ReactDropzone>
}
}

View File

@@ -0,0 +1,13 @@
.clickToEdit * {
cursor: context-menu !important;
}
.shortClick {
border-bottom: 1px dashed #ccc;
}
.select {
padding: 0px;
}
.size {
width: 10rem;
}

View File

@@ -1,3 +1,4 @@
import classNames from 'classnames'
import findKey from 'lodash/findKey'
import isFunction from 'lodash/isFunction'
import isString from 'lodash/isString'
@@ -5,29 +6,32 @@ import map from 'lodash/map'
import pick from 'lodash/pick'
import React from 'react'
import _ from './intl'
import Component from './base-component'
import logError from './log-error'
import Icon from './icon'
import Tooltip from './tooltip'
import { formatSize, propTypes } from './utils'
import { SizeInput } from './form'
import _ from '../intl'
import Component from '../base-component'
import getEventValue from '../get-event-value'
import Icon from '../icon'
import logError from '../log-error'
import propTypes from '../prop-types-decorator'
import Tooltip from '../tooltip'
import { formatSize } from '../utils'
import { SizeInput } from '../form'
import {
SelectHost,
SelectIp,
SelectNetwork,
SelectPool,
SelectRemote,
SelectResourceSetIp,
SelectSr,
SelectSubject,
SelectTag,
SelectVm,
SelectVmTemplate
} from './select-objects'
} from '../select-objects'
import styles from './index.css'
const LONG_CLICK = 400
const SELECT_STYLE = { padding: '0px' }
const SIZE_STYLE = { width: '10rem' }
const EDITABLE_STYLE = { borderBottom: '1px dashed #ccc' }
@propTypes({
alt: propTypes.node.isRequired
@@ -132,7 +136,8 @@ class Editable extends Component {
this._closeEdition()
} catch (error) {
this.setState({
error: isString(error) ? error : error.message,
// `error` may be undefined if the action has been cancelled
error: error !== undefined && (isString(error) ? error : error.message),
saving: false
})
logError(error)
@@ -156,7 +161,7 @@ class Editable extends Component {
const { useLongClick } = props
const success = <Icon icon='success' />
return <span style={useLongClick ? null : EDITABLE_STYLE}>
return <span className={classNames(styles.clickToEdit, !useLongClick && styles.shortClick)}>
<span
onClick={!useLongClick && this._openEdition}
onMouseDown={useLongClick && this.__startTimer}
@@ -256,7 +261,8 @@ export class Text extends Editable {
readOnly={saving}
ref='input'
style={{
width: `${value.length + 1}ex`
width: `${value.length + 1}ex`,
maxWidth: '50ex'
}}
type={this._isPassword ? 'password' : 'text'}
/>
@@ -270,80 +276,99 @@ export class Password extends Text {
}
@propTypes({
value: propTypes.number.isRequired
nullable: propTypes.bool,
value: propTypes.number
})
export class Number extends Component {
get value () {
return +this.refs.input.value
}
_onChange = value => this.props.onChange(+value)
_onChange = value => {
if (value === '') {
if (this.props.nullable) {
value = null
} else {
return
}
} else {
value = +value
}
this.props.onChange(value)
}
render () {
const { value } = this.props
return <Text
{...this.props}
onChange={this._onChange}
value={String(this.props.value)}
value={value === null ? '' : String(value)}
/>
}
}
@propTypes({
labelProp: propTypes.string.isRequired,
options: propTypes.oneOfType([
propTypes.array,
propTypes.object
]).isRequired
]).isRequired,
renderer: propTypes.func
})
export class Select extends Editable {
constructor (props) {
super()
this._defaultValue = findKey(props.options, option => option === props.value)
componentWillReceiveProps (props) {
if (
props.value !== this.props.value ||
props.options !== this.props.options
) {
this.setState({ valueKey: findKey(props.options, option => option === props.value) })
}
}
get value () {
return this.props.options[this._select.value]
return this.props.options[this.state.valueKey]
}
_onChange = event => {
this._save()
this.setState({ valueKey: getEventValue(event) }, this._save)
}
_optionToJsx = (option, index) => {
const { labelProp } = this.props
_optionToJsx = (option, key) => {
const { renderer } = this.props
return <option
key={index}
value={index}
key={key}
value={key}
>
{labelProp ? option[labelProp] : option}
{renderer ? renderer(option) : option}
</option>
}
_onEditionMount = ref => {
this._select = ref
// Seems to work in Google Chrome (not in Firefox)
ref && ref.dispatchEvent(new window.MouseEvent('mousedown'))
}
_renderDisplay () {
return this.props.children ||
<span>{this.props.value[this.props.labelProp]}</span>
const { children, renderer, value } = this.props
return children ||
<span>{renderer ? renderer(value) : value}</span>
}
_renderEdition () {
const { saving } = this.state
const { saving, valueKey } = this.state
const { options } = this.props
return <select
autoFocus
className='form-control'
defaultValue={this._defaultValue}
className={classNames('form-control', styles.select)}
onBlur={this._closeEdition}
onChange={this._onChange}
onKeyDown={this._onKeyDown}
readOnly={saving}
ref={this._onEditionMount}
style={SELECT_STYLE}
value={valueKey}
>
{map(options, this._optionToJsx)}
</select>
@@ -352,9 +377,11 @@ export class Select extends Editable {
const MAP_TYPE_SELECT = {
host: SelectHost,
ip: SelectIp,
network: SelectNetwork,
pool: SelectPool,
remote: SelectRemote,
resourceSetIp: SelectResourceSetIp,
SR: SelectSr,
subject: SelectSubject,
tag: SelectTag,
@@ -364,15 +391,14 @@ const MAP_TYPE_SELECT = {
@propTypes({
labelProp: propTypes.string.isRequired,
predicate: propTypes.func,
value: propTypes.oneOfType([
propTypes.string,
propTypes.object
]).isRequired
])
})
export class XoSelect extends Editable {
get value () {
return this.refs.select.value
return this.state.value
}
_renderDisplay () {
@@ -380,16 +406,14 @@ export class XoSelect extends Editable {
<span>{this.props.value[this.props.labelProp]}</span>
}
_onChange = object => {
object ? this._save() : this._closeEdition()
}
_onChange = object =>
this.setState({ value: object }, object && this._save)
_renderEdition () {
const {
placeholder,
predicate,
saving,
xoType
xoType,
...props
} = this.props
const Select = MAP_TYPE_SELECT[xoType]
@@ -403,12 +427,10 @@ export class XoSelect extends Editable {
// when this element is clicked.
return <a onBlur={this._closeEdition}>
<Select
{...props}
autoFocus
disabled={saving}
onChange={this._onChange}
placeholder={placeholder}
predicate={predicate}
ref='select'
/>
</a>
}
@@ -440,15 +462,18 @@ export class Size extends Editable {
const { value } = this.props
return <span
// SizeInput uses `input-group` which makes it behave as a block element (display: table).
// `form-inline` to use it as an inline element
className='form-inline'
onBlur={this._closeEditionIfUnfocused}
onFocus={this._focus}
onKeyDown={this._onKeyDown}
>
<SizeInput
autoFocus
className={styles.size}
ref='input'
readOnly={saving}
style={SIZE_STYLE}
defaultValue={value}
/>
</span>

View File

@@ -20,7 +20,7 @@ export { Ellipsis as default }
export const EllipsisContainer = ({ children }) => (
<div style={ellipsisContainerStyle}>
{React.Children.map(children, child =>
child.type === Ellipsis ? child : <span>{child}</span>
child == null || child.type === Ellipsis ? child : <span>{child}</span>
)}
</div>
)

View File

@@ -1,4 +1,4 @@
import test from 'ava'
/* eslint-env jest */
import filterReduce from './filter-reduce'
@@ -6,23 +6,20 @@ const add = (a, b) => a + b
const data = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
const isEven = x => !(x & 1)
test('filterReduce', t => {
it('filterReduce', () => {
// Returns all elements not matching the predicate and the result of
// a reduction over those who do.
t.deepEqual(
filterReduce(data, isEven, add),
expect(filterReduce(data, isEven, add)).toEqual(
[ 1, 3, 5, 7, 9, 20 ]
)
// The default reducer is the identity.
t.deepEqual(
filterReduce(data, isEven),
expect(filterReduce(data, isEven)).toEqual(
[ 1, 3, 5, 7, 9, 0 ]
)
// If an initial value is passed it is used.
t.deepEqual(
filterReduce(data, isEven, add, 22),
expect(filterReduce(data, isEven, add, 22)).toEqual(
[ 1, 3, 5, 7, 9, 42 ]
)
})

View File

@@ -1,6 +1,7 @@
import React from 'react'
import * as Grid from 'grid'
import { propTypes } from 'utils'
import * as Grid from './grid'
import propTypes from './prop-types-decorator'
export const LabelCol = propTypes({
children: propTypes.any.isRequired

View File

@@ -1,19 +1,25 @@
import BaseComponent from 'base-component'
import classNames from 'classnames'
import Icon from 'icon'
import map from 'lodash/map'
import randomPassword from 'random-password'
import React from 'react'
import round from 'lodash/round'
import SingleLineRow from 'single-line-row'
import { Container, Col } from 'grid'
import {
DropdownButton,
MenuItem
} from 'react-bootstrap-4/lib'
import Button from '../button'
import Component from '../base-component'
import getEventValue from '../get-event-value'
import propTypes from '../prop-types-decorator'
import {
autobind,
firstDefined,
formatSizeRaw,
parseSize,
propTypes
parseSize
} from '../utils'
export Select from './select'
@@ -33,16 +39,23 @@ export class Password extends Component {
this.refs.field.value = value
}
@autobind
_generate () {
this.refs.field.value = randomPassword(8)
_generate = () => {
const value = randomPassword(8)
const isControlled = this.props.value !== undefined
if (isControlled) {
this.props.onChange(value)
} else {
this.refs.field.value = value
}
// FIXME: in controlled mode, visibility should only be updated
// when the value prop is changed according to the emitted value.
this.setState({
visible: true
})
}
@autobind
_toggleVisibility () {
_toggleVisibility = () => {
this.setState({
visible: !this.state.visible
})
@@ -58,9 +71,9 @@ export class Password extends Component {
return <div className='input-group'>
{enableGenerator && <span className='input-group-btn'>
<button type='button' className='btn btn-secondary' onClick={this._generate}>
<Button onClick={this._generate}>
<Icon icon='password' />
</button>
</Button>
</span>}
<input
{...props}
@@ -69,9 +82,9 @@ export class Password extends Component {
type={visible ? 'text' : 'password'}
/>
<span className='input-group-btn'>
<button type='button' className='btn btn-secondary' onClick={this._toggleVisibility}>
<Button onClick={this._toggleVisibility}>
<Icon icon={visible ? 'shown' : 'hidden'} />
</button>
</Button>
</span>
</div>
}
@@ -80,72 +93,45 @@ export class Password extends Component {
// ===================================================================
@propTypes({
defaultValue: propTypes.number,
max: propTypes.number.isRequired,
min: propTypes.number.isRequired,
onChange: propTypes.func,
step: propTypes.number,
onChange: propTypes.func
value: propTypes.number
})
export class Range extends Component {
constructor (props) {
super()
this.state = {
value: props.defaultValue || props.min
componentDidMount () {
const { min, onChange, value } = this.props
if (!value) {
onChange && onChange(min)
}
}
get value () {
return this.state.value
}
set value (value) {
const { onChange } = this.props
this.state.value = +value
if (onChange) {
onChange(value)
}
}
@autobind
_handleChange (event) {
const { onChange } = this.props
const { value } = event.target
if (value === this.state.value) {
return
}
this.setState({
value
}, onChange && (() => onChange(value)))
}
_onChange = value =>
this.props.onChange(getEventValue(value))
render () {
const {
props
} = this
const step = props.step || 1
const { value } = this.state
const { max, min, step, value } = this.props
return (
<div className='form-group row'>
<label className='col-sm-2 control-label'>
{value}
</label>
<div className='col-sm-10'>
return <Container>
<SingleLineRow>
<Col size={2}>
<span className='pull-right'>{value}</span>
</Col>
<Col size={10}>
<input
className='form-control'
type='range'
min={props.min}
max={props.max}
max={max}
min={min}
onChange={this._onChange}
step={step}
type='range'
value={value}
onChange={this._handleChange}
/>
</div>
</div>
)
</Col>
</SingleLineRow>
</Container>
}
}
@@ -162,72 +148,156 @@ const DEFAULT_UNIT = 'GiB'
placeholder: propTypes.string,
readOnly: propTypes.bool,
required: propTypes.bool,
style: propTypes.object
style: propTypes.object,
value: propTypes.oneOfType([
propTypes.number,
propTypes.oneOf([ null ])
])
})
export class SizeInput extends Component {
export class SizeInput extends BaseComponent {
constructor (props) {
super(props)
const humanSize = props.defaultValue && formatSizeRaw(props.defaultValue)
this._defaultValue = humanSize && humanSize.value
this.state = { unit: humanSize ? humanSize.prefix + 'B' : props.defaultUnit || DEFAULT_UNIT }
this.state = this._createStateFromBytes(firstDefined(props.value, props.defaultValue, null))
}
componentWillReceiveProps (newProps) {
this.value = newProps.value
componentWillReceiveProps (props) {
const { value } = props
if (value !== undefined && value !== this.props.value) {
this.setState(this._createStateFromBytes(value))
}
}
_createStateFromBytes (bytes) {
if (bytes === this._bytes) {
return {
input: this._input,
unit: this._unit
}
}
if (bytes === null) {
return {
input: '',
unit: this.props.defaultUnit || DEFAULT_UNIT
}
}
const { prefix, value } = formatSizeRaw(bytes)
return {
input: String(round(value, 2)),
unit: `${prefix}B`
}
}
get value () {
const value = this.refs.value.value
return value ? parseSize(value + ' ' + this.state.unit) : undefined
const { input, unit } = this.state
if (!input) {
return null
}
return parseSize(`${+input} ${unit}`)
}
set value (newValue) {
const humanSize = newValue && formatSizeRaw(newValue)
this.refs.value.value = humanSize ? humanSize.value : ''
this.setState({ unit: humanSize ? humanSize.prefix + 'B' : DEFAULT_UNIT })
set value (value) {
if (
process.env.NODE_ENV !== 'production' &&
this.props.value !== undefined
) {
throw new Error('cannot set value of controlled SizeInput')
}
this.setState(this._createStateFromBytes(value))
}
_onChange = () =>
this.props.onChange && this.props.onChange(this.value)
_onChange (input, unit) {
const { onChange } = this.props
// Empty input equals null.
const bytes = input
? parseSize(`${+input} ${unit}`)
: null
const isControlled = this.props.value !== undefined
if (isControlled) {
// Store input and unit for this change to update correctly on new
// props.
this._bytes = bytes
this._input = input
this._unit = unit
} else {
this.setState({ input, unit })
// onChange is optional in uncontrolled mode.
if (!onChange) {
return
}
}
onChange(bytes)
}
_updateNumber = event => {
const input = event.target.value
if (!input) {
return this._onChange(input, this.state.unit)
}
const number = +input
// NaN: do not ack this change.
if (number !== number) { // eslint-disable-line no-self-compare
return
}
// Same numeric value: simply update the input.
const prevInput = this.state.input
if (prevInput && +prevInput === number) {
return this.setState({ input })
}
this._onChange(input, this.state.unit)
}
_updateUnit = unit => {
this.setState({ unit })
this._onChange()
const { input } = this.state
// 0 is always 0, no matter the unit.
if (+input) {
this._onChange(input, unit)
} else {
this.setState({ unit })
}
}
render () {
const {
autoFocus,
className,
placeholder,
readOnly,
placeholder,
required,
style
} = this.props
return <span
className={classNames(className, 'input-group')}
style={style}
>
return <span className={classNames('input-group', className)} style={style}>
<input
autoFocus={autoFocus}
className='form-control'
defaultValue={this._defaultValue}
min={0}
onChange={this._onChange}
disabled={readOnly}
onChange={this._updateNumber}
placeholder={placeholder}
readOnly={readOnly}
required={required}
ref='value'
type='number'
type='text'
value={this.state.input}
/>
<span className='input-group-btn'>
<DropdownButton
bsStyle='secondary'
disabled={readOnly}
id='size'
pullRight
disabled={readOnly}
title={this.state.unit}
>
{map(UNITS, unit =>

View File

@@ -1,12 +1,15 @@
import uncontrollableInput from 'uncontrollable-input'
import Component from 'base-component'
import find from 'lodash/find'
import map from 'lodash/map'
import React, { Component } from 'react'
import { Select } from 'form'
import { propTypes } from 'utils'
import React from 'react'
import propTypes from '../prop-types-decorator'
import Select from './select'
@propTypes({
autoFocus: propTypes.bool,
defaultValue: propTypes.any,
disabled: propTypes.bool,
optionRenderer: propTypes.func,
multi: propTypes.bool,
@@ -14,13 +17,26 @@ import { propTypes } from 'utils'
options: propTypes.array,
placeholder: propTypes.string,
predicate: propTypes.func,
required: propTypes.bool
required: propTypes.bool,
value: propTypes.any
})
@uncontrollableInput()
export default class SelectPlainObject extends Component {
constructor (props) {
super(props)
this.state = {
value: this._computeValue(props.defaultValue, props)
componentDidMount () {
const { options, value } = this.props
this.setState({
options: this._computeOptions(options),
value: this._computeValue(value, this.props)
})
}
componentWillReceiveProps (newProps) {
if (newProps !== this.props) {
this.setState({
options: this._computeOptions(newProps.options),
value: this._computeValue(newProps.value, newProps)
})
}
}
@@ -34,25 +50,10 @@ export default class SelectPlainObject extends Component {
}
return map(value, reduceValue)
}
return reduceValue(value)
}
componentWillMount () {
const { options } = this.props
this.setState({
options: this._computeOptions(options)
})
}
componentWillReceiveProps (newProps) {
const { options } = newProps
this.setState({
options: this._computeOptions(options)
})
}
_computeOptions (options) {
const { optionKey = 'id' } = this.props
const { optionRenderer = o => o.label || o[optionKey] || o } = this.props
@@ -62,10 +63,13 @@ export default class SelectPlainObject extends Component {
}))
}
get value () {
const { optionKey = 'id' } = this.props
const { value } = this.state
const { options } = this.props
_getObject (value) {
if (value == null) {
return undefined
}
const { optionKey = 'id', options } = this.props
const pickValue = value => {
value = value.value || value
return find(options, option => option[optionKey] === value || option === value)
@@ -78,18 +82,12 @@ export default class SelectPlainObject extends Component {
return pickValue(value)
}
set value (value) {
this.setState({
value: this._computeValue(value)
})
}
_handleChange = value => {
const { onChange } = this.props
this.setState({
value: this._computeValue(value)
}, onChange && (() => { onChange(this.value) }))
if (onChange) {
onChange(this._getObject(value))
}
}
_renderOption = option => option.label
@@ -109,7 +107,8 @@ export default class SelectPlainObject extends Component {
placeholder={props.placeholder}
required={props.required}
value={state.value}
valueRenderer={this._renderOption} />
valueRenderer={this._renderOption}
/>
)
}
}

View File

@@ -1,11 +1,15 @@
import map from 'lodash/map'
import React, { Component } from 'react'
import ReactSelect from 'react-select'
import { propTypes } from 'utils'
import sum from 'lodash/sum'
import {
AutoSizer,
VirtualScroll
CellMeasurer,
List
} from 'react-virtualized'
import propTypes from '../prop-types-decorator'
const SELECT_MENU_STYLE = {
overflow: 'hidden'
}
@@ -14,15 +18,19 @@ const SELECT_STYLE = {
minWidth: '10em'
}
const LIST_STYLE = {
whiteSpace: 'normal'
}
const MAX_OPTIONS = 5
// See: https://github.com/bvaughn/react-virtualized-select/blob/master/source/VirtualizedSelect/VirtualizedSelect.js
@propTypes({
maxHeight: propTypes.number,
optionHeight: propTypes.number
maxHeight: propTypes.number
})
export default class Select extends Component {
static defaultProps = {
maxHeight: 200,
optionHeight: 40,
optionRenderer: (option, labelKey) => option[labelKey]
}
@@ -31,34 +39,52 @@ export default class Select extends Component {
options,
...otherOptions
}) => {
const {
maxHeight,
optionHeight
} = this.props
const { maxHeight } = this.props
const focusedOptionIndex = options.indexOf(focusedOption)
const height = Math.min(maxHeight, options.length * optionHeight)
let height = options.length > MAX_OPTIONS && maxHeight
const wrappedRowRenderer = ({ index }) =>
const wrappedRowRenderer = ({ index, key, style }) =>
this._optionRenderer({
...otherOptions,
focusedOption,
focusedOptionIndex,
key,
option: options[index],
options
options,
style
})
return (
<AutoSizer disableHeight>
{({ width }) => (
<VirtualScroll
height={height}
rowCount={options.length}
rowHeight={optionHeight}
rowRenderer={wrappedRowRenderer}
scrollToIndex={focusedOptionIndex}
width={width}
/>
width ? (
<CellMeasurer
cellRenderer={({ rowIndex }) => wrappedRowRenderer({ index: rowIndex })}
columnCount={1}
rowCount={options.length}
// FIXME: 16 px: ugly workaround to take into account the scrollbar
// during the offscreen render to measure the row height
// See https://github.com/bvaughn/react-virtualized/issues/401
width={width - 16}
>
{({ getRowHeight }) => {
if (options.length <= MAX_OPTIONS) {
height = sum(map(options, (_, index) => getRowHeight({ index })))
}
return <List
height={height}
rowCount={options.length}
rowHeight={getRowHeight}
rowRenderer={wrappedRowRenderer}
scrollToIndex={focusedOptionIndex}
style={LIST_STYLE}
width={width}
/>
}}
</CellMeasurer>
) : null
)}
</AutoSizer>
)
@@ -67,8 +93,10 @@ export default class Select extends Component {
_optionRenderer = ({
focusedOption,
focusOption,
key,
labelKey,
option,
style,
selectValue
}) => {
let className = 'Select-option'
@@ -90,7 +118,8 @@ export default class Select extends Component {
className={className}
onClick={!disabled && (() => selectValue(option))}
onMouseOver={!disabled && (() => focusOption(option))}
style={{ height: props.optionHeight }}
style={style}
key={key}
>
{props.optionRenderer(option, labelKey)}
</div>
@@ -101,6 +130,7 @@ export default class Select extends Component {
return (
<ReactSelect
{...this.props}
backspaceToRemoveMessage=''
menuRenderer={this._renderMenu}
menuStyle={SELECT_MENU_STYLE}
style={SELECT_STYLE}

46
src/common/form/toggle.js Normal file
View File

@@ -0,0 +1,46 @@
import React from 'react'
import classNames from 'classnames'
import uncontrollableInput from 'uncontrollable-input'
import Component from '../base-component'
import Icon from '../icon'
import propTypes from '../prop-types-decorator'
@uncontrollableInput()
@propTypes({
className: propTypes.string,
onChange: propTypes.func,
icon: propTypes.string,
iconOn: propTypes.string,
iconOff: propTypes.string,
iconSize: propTypes.number,
value: propTypes.bool
})
export default class Toggle extends Component {
static defaultProps = {
iconOn: 'toggle-on',
iconOff: 'toggle-off',
iconSize: 2
}
_toggle = () => {
const { props } = this
props.onChange(!props.value)
}
render () {
const { props } = this
return (
<Icon
className={classNames(
props.disabled ? 'text-muted' : props.value ? 'text-success' : null,
props.className
)}
icon={props.icon || (props.value ? props.iconOn : props.iconOff)}
onClick={this._toggle}
size={props.iconSize}
/>
)
}
}

View File

@@ -1,3 +0,0 @@
.checkbox {
display: none;
}

View File

@@ -1,89 +0,0 @@
import React from 'react'
import classNames from 'classnames'
import Component from '../../base-component'
import Icon from '../../icon'
import propTypes from '../../prop-types'
import styles from './index.css'
@propTypes({
className: propTypes.string,
defaultValue: propTypes.bool,
onChange: propTypes.func,
icon: propTypes.string,
iconOn: propTypes.string,
iconOff: propTypes.string,
iconSize: propTypes.number,
value: propTypes.bool
})
export default class Toggle extends Component {
static defaultProps = {
iconOn: 'toggle-on',
iconOff: 'toggle-off',
iconSize: 2
}
get value () {
const { props } = this
const { value } = props
if (value != null) {
return value
}
const { input } = this.refs
if (input) {
return input.checked
}
return props.defaultValue || false
}
set value (value) {
if (
process.env.NODE_ENV !== 'production' &&
this.props.value != null
) {
throw new Error('cannot set value of controlled Toggle')
}
this.refs.input.checked = Boolean(value)
}
_onChange = event => {
if (this.props.value == null) {
this.forceUpdate()
}
const { onChange } = this.props
onChange && onChange(event.target.checked)
}
render () {
const { props, value } = this
return (
<label
className={classNames(
props.disabled ? 'text-muted' : value ? 'text-success' : null,
props.className
)}
>
<Icon
icon={props.icon || (value ? props.iconOn : props.iconOff)}
size={props.iconSize}
/>
<input
checked={props.value}
className={styles.checkbox}
defaultChecked={props.defaultValue}
disabled={props.disabled}
onChange={this._onChange}
ref='input'
type='checkbox'
/>
</label>
)
}
}

View File

@@ -0,0 +1,17 @@
// If the param is an event, returns the value of it's target,
// otherwise returns the param.
const getEventValue = event => {
let target
if (!event || !(target = event.target)) {
return event
}
return (
target.nodeName.toLowerCase() === 'input' &&
target.type.toLowerCase() === 'checkbox'
)
? target.checked
: target.value
}
export { getEventValue as default }

View File

@@ -1,6 +1,7 @@
import classNames from 'classnames'
import React from 'react'
import { propTypes } from 'utils'
import propTypes from './prop-types-decorator'
export const Col = propTypes({
className: propTypes.string,

13
src/common/grid.spec.js Normal file
View File

@@ -0,0 +1,13 @@
/* eslint-env jest */
import React from 'react'
import { forEach } from 'lodash'
import { shallow } from 'enzyme'
import * as grid from './grid'
forEach(grid, (Component, name) => {
it(name, () => {
expect(shallow(<Component />)).toMatchSnapshot()
})
})

View File

@@ -0,0 +1,33 @@
const common = {
homeFilterNone: ''
}
export const VM = {
...common,
homeFilterPendingVms: 'current_operations:"" ',
homeFilterNonRunningVms: '!power_state:running ',
homeFilterHvmGuests: 'virtualizationMode:hvm ',
homeFilterRunningVms: 'power_state:running ',
homeFilterTags: 'tags:'
}
export const host = {
...common,
homeFilterRunningHosts: 'power_state:running ',
homeFilterTags: 'tags:'
}
export const pool = {
...common,
homeFilterTags: 'tags:'
}
export const vmTemplate = {
...common,
homeFilterTags: 'tags:'
}
export const SR = {
...common,
homeFilterTags: 'tags:'
}

36
src/common/home-tags.js Normal file
View File

@@ -0,0 +1,36 @@
import React from 'react'
import Component from './base-component'
import propTypes from './prop-types-decorator'
import Tags from './tags'
import { createString, createProperty, toString } from './complex-matcher'
@propTypes({
labels: propTypes.arrayOf(React.PropTypes.string).isRequired,
onAdd: propTypes.func,
onChange: propTypes.func,
onDelete: propTypes.func,
type: propTypes.string
})
export default class HomeTags extends Component {
static contextTypes = {
router: React.PropTypes.object
}
_onClick = label => {
const s = encodeURIComponent(createProperty('tags', createString(label))::toString())
const t = encodeURIComponent(this.props.type)
this.context.router.push(`/home?t=${t}&s=${s}`)
}
render () {
return <Tags
labels={this.props.labels}
onAdd={this.props.onAdd}
onChange={this.props.onChange}
onClick={this._onClick}
onDelete={this.props.onDelete}
/>
}
}

View File

@@ -0,0 +1,220 @@
import isEmpty from 'lodash/isEmpty'
import keys from 'lodash/keys'
import map from 'lodash/map'
import React from 'react'
import { Portal } from 'react-overlays'
import _ from './intl'
import ActionButton from './action-button'
import Component from './base-component'
import forEach from 'lodash/forEach'
import Link from './link'
import propTypes from './prop-types-decorator'
import SortedTable from './sorted-table'
import TabButton from './tab-button'
import { connectStore } from './utils'
import {
createGetObjectsOfType,
createFilter,
createSelector
} from './selectors'
import {
installAllHostPatches,
installAllPatchesOnPool,
subscribeHostMissingPatches
} from './xo'
// ===================================================================
const MISSING_PATCHES_COLUMNS = [
{
name: _('srHost'),
itemRenderer: host => <Link to={`/hosts/${host.id}`}>{host.name_label}</Link>,
sortCriteria: host => host.name_label
},
{
name: _('hostDescription'),
itemRenderer: host => host.name_description,
sortCriteria: host => host.name_description
},
{
name: _('hostMissingPatches'),
itemRenderer: (host, { missingPatches }) => <Link to={`/hosts/${host.id}/patches`}>{missingPatches[host.id]}</Link>,
sortCriteria: (host, { missingPatches }) => missingPatches[host.id]
},
{
name: _('patchUpdateButton'),
itemRenderer: (host, { installAllHostPatches }) => (
<ActionButton
btnStyle='primary'
handler={installAllHostPatches}
handlerParam={host}
icon='host-patch-update'
/>
)
}
]
const POOLS_MISSING_PATCHES_COLUMNS = [{
name: _('srPool'),
itemRenderer: (host, { pools }) => {
const pool = pools[host.$pool]
return <Link to={`/pools/${pool.id}`}>{pool.name_label}</Link>
},
sortCriteria: (host, { pools }) => pools[host.$pool].name_label
}].concat(MISSING_PATCHES_COLUMNS)
// Small component to homogenize Button usage in HostsPatchesTable
const ActionButton_ = ({ children, labelId, ...props }) =>
<ActionButton
{...props}
tooltip={_(labelId)}
>
{children}
</ActionButton>
// ===================================================================
class HostsPatchesTable extends Component {
constructor (props) {
super(props)
this.state.missingPatches = {}
}
_getHosts = createFilter(
() => this.props.hosts,
createSelector(
() => this.state.missingPatches,
missingPatches => host => missingPatches[host.id]
)
)
_subscribeMissingPatches = (hosts = this.props.hosts) => {
const unsubs = map(hosts, host =>
subscribeHostMissingPatches(
host,
patches => this.setState({
missingPatches: {
...this.state.missingPatches,
[host.id]: patches.length
}
})
)
)
if (this.unsubscribeMissingPatches !== undefined) {
this.unsubscribeMissingPatches()
}
this.unsubscribeMissingPatches = () => forEach(unsubs, unsub => unsub())
}
_installAllMissingPatches = () => {
const pools = {}
forEach(this._getHosts(), host => {
pools[host.$pool] = true
})
return Promise.all(map(
keys(pools),
installAllPatchesOnPool
))
}
componentDidMount () {
// Force one Portal refresh.
// Because Portal cannot see the container reference at first rendering.
this.forceUpdate()
this._subscribeMissingPatches()
}
componentWillReceiveProps (nextProps) {
if (nextProps.hosts !== this.props.hosts) {
this._subscribeMissingPatches(nextProps.hosts)
}
}
componentWillUnmount () {
this.unsubscribeMissingPatches()
}
render () {
const {
buttonsGroupContainer,
container,
displayPools,
pools,
useTabButton
} = this.props
const hosts = this._getHosts()
const noPatches = isEmpty(hosts)
const Container = container || 'div'
const Button = useTabButton
? TabButton
: ActionButton_
return (
<div>
{!noPatches
? (
<SortedTable
collection={hosts}
columns={displayPools ? POOLS_MISSING_PATCHES_COLUMNS : MISSING_PATCHES_COLUMNS}
userData={{
installAllHostPatches,
missingPatches: this.state.missingPatches,
pools
}}
/>
) : <p>{_('patchNothing')}</p>
}
<Portal container={() => buttonsGroupContainer()}>
<Container>
<Button
btnStyle='primary'
disabled={noPatches}
handler={this._installAllMissingPatches}
icon='host-patch-update'
labelId='installPoolPatches'
/>
</Container>
</Portal>
</div>
)
}
}
// ===================================================================
@connectStore(() => {
const getPools = createGetObjectsOfType('pool')
return {
pools: getPools
}
})
class HostsPatchesTableByPool extends Component {
render () {
const { props } = this
return <HostsPatchesTable {...props} pools={props.pools} />
}
}
// ===================================================================
export default propTypes({
buttonsGroupContainer: propTypes.func.isRequired,
container: propTypes.any,
displayPools: propTypes.bool,
hosts: propTypes.oneOfType([
propTypes.arrayOf(propTypes.object),
propTypes.objectOf(propTypes.object)
]).isRequired,
useTabButton: propTypes.bool
})(props => props.displayPools
? <HostsPatchesTableByPool {...props} />
: <HostsPatchesTable {...props} />
)

View File

@@ -1,21 +1,25 @@
import classNames from 'classnames'
import isInteger from 'lodash/isInteger'
import React, { PropTypes } from 'react'
import React from 'react'
const Icon = ({ className, icon, size = 1, fixedWidth }) => (
<i className={classNames(
className,
icon ? `xo-icon-${icon}` : 'fa', // Without icon prop, is a placeholder.
isInteger(size) ? `fa-${size}x` : `fa-${size}`,
fixedWidth && 'fa-fw'
)} />
)
Icon.propTypes = {
fixedWidth: PropTypes.bool,
icon: PropTypes.string,
size: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
])
import propTypes from './prop-types-decorator'
const Icon = ({ icon, size = 1, fixedWidth, ...props }) => {
props.className = classNames(
props.className,
icon !== undefined ? `xo-icon-${icon}` : 'fa', // Without icon prop, is a placeholder.
isInteger(size) ? `fa-${size}x` : `fa-${size}`,
fixedWidth && 'fa-fw'
)
return <i {...props} />
}
propTypes(Icon)({
fixedWidth: propTypes.bool,
icon: propTypes.string,
size: propTypes.oneOfType([
propTypes.string,
propTypes.number
])
})
export default Icon

View File

@@ -62,11 +62,17 @@ export class IntlProvider extends Component {
render () {
const { lang, children } = this.props
// Adding a key prop is a work-around suggested by react-intl documentation
// to make sure changes to the locale trigger a re-render of the child components
// https://github.com/yahoo/react-intl/wiki/Components#dynamic-language-selection
//
// FIXME: remove the key prop when React context propagation is fixed (https://github.com/facebook/react/issues/2517)
return <IntlProvider_
key={lang}
locale={lang}
messages={locales[lang]}
>
{children}
{children}
</IntlProvider_>
}
}

View File

@@ -1 +0,0 @@
/index.js

View File

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

126
src/common/ip.js Normal file
View File

@@ -0,0 +1,126 @@
import forEachRight from 'lodash/forEachRight'
import forEach from 'lodash/forEach'
import isArray from 'lodash/isArray'
import isIp from 'is-ip'
import some from 'lodash/some'
export { isIp }
export const isIpV4 = isIp.v4
export const isIpV6 = isIp.v6
// Source: https://github.com/ezpaarse-project/ip-range-generator/blob/master/index.js
const ipv4 = /^(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(?:\.(?!$)|$)){4}$/
function ip2hex (ip) {
let parts = ip.split('.').map(str => parseInt(str, 10))
let n = 0
n += parts[3]
n += parts[2] * 256 // 2^8
n += parts[1] * 65536 // 2^16
n += parts[0] * 16777216 // 2^24
return n
}
function assertIpv4 (str, msg) {
if (!ipv4.test(str)) { throw new Error(msg) }
}
function * range (ip1, ip2) {
assertIpv4(ip1, 'argument "ip1" must be a valid IPv4 address')
assertIpv4(ip2, 'argument "ip2" must be a valid IPv4 address')
let hex = ip2hex(ip1)
let hex2 = ip2hex(ip2)
if (hex > hex2) {
let tmp = hex
hex = hex2
hex2 = tmp
}
for (let i = hex; i <= hex2; i++) {
yield `${(i >> 24) & 0xff}.${(i >> 16) & 0xff}.${(i >> 8) & 0xff}.${i & 0xff}`
}
}
// -----------------------------------------------------------------------------
export const getNextIpV4 = ip => {
const splitIp = ip.split('.')
if (splitIp.length !== 4 || some(splitIp, value => value < 0 || value > 255)) {
return
}
let index
forEachRight(splitIp, (value, i) => {
if (value < 255) {
index = i
return false
}
splitIp[i] = 1
})
if (index === 0 && +splitIp[0] === 255) {
return 0
}
splitIp[index]++
return splitIp.join('.')
}
export const formatIps = ips => {
if (!isArray(ips)) {
throw new Error('ips must be an array')
}
if (ips.length === 0) {
return []
}
const sortedIps = ips.sort((ip1, ip2) => {
const splitIp1 = ip1.split('.')
const splitIp2 = ip2.split('.')
if (splitIp1.length !== 4) {
return 1
}
if (splitIp2.length !== 4) {
return -1
}
return splitIp1[3] - splitIp2[3] +
(splitIp1[2] - splitIp2[2]) * 256 +
(splitIp1[1] - splitIp2[1]) * 256 * 256 +
(splitIp1[0] - splitIp2[0]) * 256 * 256 * 256
})
const range = { first: '', last: '' }
const formattedIps = []
let index = 0
forEach(sortedIps, ip => {
if (ip !== getNextIpV4(range.last)) {
if (range.first) {
formattedIps[index] = range.first === range.last ? range.first : { ...range }
index++
}
range.first = range.last = ip
} else {
range.last = ip
}
})
formattedIps[index] = range.first === range.last ? range.first : range
return formattedIps
}
export const parseIpPattern = pattern => {
const ips = []
forEach(pattern.split(';'), rawIpRange => {
const ipRange = rawIpRange.split('-')
if (ipRange.length < 2) {
ips.push(ipRange[0])
} else if (!isIpV4(ipRange[0]) || !isIpV4(ipRange[1])) {
ips.push(rawIpRange)
} else {
ips.push(...range(ipRange[0], ipRange[1]))
}
})
return ips
}

View File

@@ -1,7 +1,13 @@
import React from 'react'
import _ from 'intl'
import ActionButton from './action-button'
import Component from './base-component'
import Icon from 'icon'
import propTypes from './prop-types-decorator'
import Tooltip from 'tooltip'
import { alert } from 'modal'
import { connectStore } from './utils'
import { SelectVdi } from './select-objects'
import {
createGetObjectsOfType,
@@ -9,10 +15,6 @@ import {
createGetObject,
createSelector
} from './selectors'
import {
connectStore,
propTypes
} from './utils'
import {
ejectCd,
insertCd
@@ -46,7 +48,18 @@ import {
export default class IsoDevice extends Component {
_getPredicate = createSelector(
() => this.props.vm.$pool,
poolId => sr => sr.$pool === poolId && sr.SR_type === 'iso'
() => this.props.vm.$container,
(vmPool, vmContainer) => sr => {
const vmRunning = vmContainer !== vmPool
const sameHost = vmContainer === sr.$container
const samePool = vmPool === sr.$pool
return (
samePool &&
(vmRunning ? sr.shared || sameHost : true) &&
(sr.SR_type === 'iso' || (sr.SR_type === 'udev' && sr.size))
)
}
)
_handleInsert = iso => {
@@ -61,25 +74,38 @@ export default class IsoDevice extends Component {
_handleEject = () => ejectCd(this.props.vm)
_showWarning = () => alert(_('cdDriveNotInstalled'), _('cdDriveInstallation'))
render () {
const { mountedIso } = this.props
const {cdDrive, mountedIso} = this.props
return (
<div className='input-group'>
<SelectVdi
srPredicate={this._getPredicate()}
onChange={this._handleInsert}
ref='selectIso'
value={mountedIso}
/>
<span className='input-group-btn'>
<ActionButton
btnStyle='secondary'
disabled={!mountedIso}
handler={this._handleEject}
icon='vm-eject'
/>
</span>
{mountedIso && !cdDrive.device &&
<Tooltip content={_('cdDriveNotInstalled')}>
<a
className='text-warning btn btn-link'
onClick={this._showWarning}
>
<Icon
icon='alarm'
size='lg'
/>
</a>
</Tooltip>
}
</div>
)
}

View File

@@ -1,27 +0,0 @@
import { Component } from 'react'
import {
propTypes
} from 'utils'
// ===================================================================
@propTypes({
disabled: propTypes.bool,
label: propTypes.any.isRequired,
onChange: propTypes.func,
placeholder: propTypes.string,
required: propTypes.bool,
schema: propTypes.object.isRequired,
uiSchema: propTypes.object,
defaultValue: propTypes.any
})
export default class AbstractInput extends Component {
set value (value) {
this.refs.input.value = value === undefined ? '' : String(value)
}
get value () {
const { value } = this.refs.input
return !value ? undefined : value
}
}

View File

@@ -1,191 +1,123 @@
import _ from 'intl'
import React, { Component, cloneElement } from 'react'
import map from 'lodash/map'
import filter from 'lodash/filter'
import React from 'react'
import uncontrollableInput from 'uncontrollable-input'
import { filter, map } from 'lodash'
import {
autobind,
propsEqual,
propTypes
} from 'utils'
import _ from '../intl'
import Button from '../button'
import Component from '../base-component'
import propTypes from '../prop-types-decorator'
import { EMPTY_ARRAY } from '../utils'
import GenericInput from './generic-input'
import {
descriptionRender,
forceDisplayOptionalAttr
} from './helpers'
// ===================================================================
class ArrayItem extends Component {
get value () {
return this.refs.input.value
}
set value (value) {
this.refs.input.value = value
}
render () {
const { children } = this.props
return (
<li className='list-group-item clearfix'>
{cloneElement(children, {
ref: 'input'
})}
<button disabled={children.props.disabled} className='btn btn-danger pull-xs-right' type='button' onClick={this.props.onDelete}>
{_('remove')}
</button>
</li>
)
}
}
// ===================================================================
@propTypes({
depth: propTypes.number,
disabled: propTypes.bool,
label: propTypes.any.isRequired,
required: propTypes.bool,
schema: propTypes.object.isRequired,
uiSchema: propTypes.object,
defaultValue: propTypes.array
uiSchema: propTypes.object
})
export default class ArrayInput extends Component {
constructor (props) {
super(props)
this.state = {
use: props.required || forceDisplayOptionalAttr(props),
children: this._makeChildren(props)
}
this._nextChildKey = 0
@uncontrollableInput()
export default class ObjectInput extends Component {
state = {
use: this.props.required || forceDisplayOptionalAttr(this.props)
}
get value () {
if (this.state.use) {
return map(this.refs, 'value')
}
_onAddItem = () => {
const { props } = this
props.onChange((props.value || EMPTY_ARRAY).concat(undefined))
}
set value (value = []) {
this.setState({
children: this._makeChildren({ ...this.props, value })
})
_onChangeItem = (value, name) => {
const key = Number(name)
const { props } = this
const newValue = (props.value || EMPTY_ARRAY).slice()
newValue[key] = value
props.onChange(newValue)
}
@autobind
_handleOptionalChange (event) {
this.setState({
use: event.target.checked
})
}
@autobind
_handleAdd () {
const { children } = this.state
this.setState({
children: children.concat(this._makeChild(this.props))
})
}
_remove (key) {
this.setState({
children: filter(this.state.children, child => child.key !== key)
})
}
_makeChild (props) {
const key = String(this._nextChildKey++)
const {
schema: {
items
}
} = props
return (
<ArrayItem key={key} onDelete={() => { this._remove(key) }}>
<GenericInput
depth={props.depth}
disabled={props.disabled}
label={items.title || _('item')}
required
schema={items}
uiSchema={props.uiSchema.items}
defaultValue={props.defaultValue}
/>
</ArrayItem>
)
}
_makeChildren ({ defaultValue, ...props }) {
return map(defaultValue, defaultValue => {
return (
this._makeChild({
...props,
defaultValue
})
)
})
}
componentWillReceiveProps (props) {
if (
!propsEqual(
this.props,
props,
[ 'depth', 'disabled', 'label', 'required', 'schema', 'uiSchema' ]
)
) {
this.setState({
children: this._makeChildren(props)
})
}
_onRemoveItem = key => {
const { props } = this
props.onChange(filter(props.value, (_, i) => i !== key))
}
render () {
const {
props,
state
props: {
depth = 0,
disabled,
label,
required,
schema,
uiSchema,
value = EMPTY_ARRAY
},
state: { use }
} = this
const {
disabled,
schema
} = props
const { use } = state
const depth = props.depth || 0
const childDepth = depth + 2
const itemSchema = schema.items
const itemUiSchema = uiSchema && uiSchema.items
const itemLabel = itemSchema.title || _('item')
return (
<div style={{'paddingLeft': `${depth}em`}}>
<legend>{props.label}</legend>
<legend>{label}</legend>
{descriptionRender(schema.description)}
<hr />
{!props.required &&
<div className='checkbox'>
<label>
<input
checked={use}
disabled={disabled}
onChange={this._handleOptionalChange}
type='checkbox'
/> {_('fillOptionalInformations')}
</label>
</div>
}
{use &&
<div className={'card-block'}>
<ul style={{'paddingLeft': 0}} >
{map(this.state.children, (child, index) =>
cloneElement(child, { ref: index })
)}
</ul>
<button disabled={disabled} className='btn btn-primary pull-xs-right m-t-1 m-r-1' type='button' onClick={this._handleAdd}>
{_('add')}
</button>
</div>
}
{!required && <div className='checkbox'>
<label>
<input
checked={use}
disabled={disabled}
onChange={this.linkState('use')}
type='checkbox'
/> {_('fillOptionalInformations')}
</label>
</div>}
{use && <div className='card-block'>
<ul style={{'paddingLeft': 0}} >
{map(value, (value, key) =>
<li className='list-group-item clearfix' key={key}>
<GenericInput
depth={childDepth}
disabled={disabled}
label={itemLabel}
name={key}
onChange={this._onChangeItem}
required
schema={itemSchema}
uiSchema={itemUiSchema}
value={value}
/>
<Button
btnStyle='danger'
className='pull-right'
disabled={disabled}
name={key}
onClick={() => this._onRemoveItem(key)}
>
{_('remove')}
</Button>
</li>
)}
</ul>
<Button
btnStyle='primary'
className='pull-right mt-1 mr-1'
disabled={disabled}
onClick={this._onAddItem}
>
{_('add')}
</Button>
</div>}
</div>
)
}

View File

@@ -1,32 +1,30 @@
import React from 'react'
import { Toggle } from 'form'
import AbstractInput from './abstract-input'
import uncontrollableInput from 'uncontrollable-input'
import Component from '../base-component'
import { Toggle } from '../form'
import { PrimitiveInputWrapper } from './helpers'
// ===================================================================
export default class BooleanInput extends AbstractInput {
get value () {
return this.refs.input.value
}
set value (value) {
this.refs.input.value = value
}
@uncontrollableInput()
export default class BooleanInput extends Component {
render () {
const { props } = this
const {
disabled,
onChange,
value,
...props
} = this.props
return (
<PrimitiveInputWrapper {...props}>
<div className='checkbox form-control'>
<Toggle
defaultValue={props.defaultValue || props.schema.default}
disabled={props.disabled}
onChange={props.onChange}
ref='input'
disabled={disabled}
onChange={onChange}
value={value}
/>
</div>
</PrimitiveInputWrapper>

View File

@@ -1,33 +1,54 @@
import React from 'react'
import _ from 'intl'
import map from 'lodash/map'
import uncontrollableInput from 'uncontrollable-input'
import Component from 'base-component'
import React from 'react'
import { createSelector } from 'reselect'
import { findIndex, map } from 'lodash'
import AbstractInput from './abstract-input'
import { PrimitiveInputWrapper } from './helpers'
// ===================================================================
export default class EnumInput extends AbstractInput {
@uncontrollableInput()
export default class EnumInput extends Component {
_getSelectedIndex = createSelector(
() => this.props.schema.enum,
() => {
const {
schema,
value = schema.default
} = this.props
return value
},
(enumValues, value) => {
const index = findIndex(enumValues, current => current === value)
return index === -1 ? '' : index
}
)
_onChange = event => {
this.props.onChange(this.props.schema.enum[event.target.value])
}
render () {
const { props } = this
const {
onChange,
disabled,
schema: { enum: enumValues, enumNames = enumValues },
required
} = props
} = this.props
return (
<PrimitiveInputWrapper {...props}>
<PrimitiveInputWrapper {...this.props}>
<select
className='form-control'
defaultValue={props.defaultValue || ''}
disabled={props.disabled}
onChange={onChange && (event => onChange(event.target.value))}
ref='input'
disabled={disabled}
onChange={this._onChange}
required={required}
value={this._getSelectedIndex()}
>
{_('noSelectedValue', message => <option value=''>{message}</option>)}
{map(props.schema.enum, (value, index) =>
<option value={value} key={index}>{value}</option>
{map(enumNames, (name, index) =>
<option value={index} key={index}>{name}</option>
)}
</select>
</PrimitiveInputWrapper>

View File

@@ -1,10 +1,9 @@
import React, { Component } from 'react'
import includes from 'lodash/includes'
import {
EMPTY_OBJECT,
propTypes
} from 'utils'
import getEventValue from '../get-event-value'
import propTypes from '../prop-types-decorator'
import uncontrollableInput from 'uncontrollable-input'
import { EMPTY_OBJECT } from '../utils'
import ArrayInput from './array-input'
import BooleanInput from './boolean-input'
@@ -13,55 +12,18 @@ import IntegerInput from './integer-input'
import NumberInput from './number-input'
import ObjectInput from './object-input'
import StringInput from './string-input'
import XoHighLevelObjectInput from './xo-highlevel-object-input'
import XoHostInput from './xo-host-input'
import XoPoolInput from './xo-pool-input'
import XoRemoteInput from './xo-remote-input'
import XoRoleInput from './xo-role-input'
import XoSrInput from './xo-sr-input'
import XoSubjectInput from './xo-subject-input'
import XoVmInput from './xo-vm-input'
import { getType } from './helpers'
// ===================================================================
const getType = (schema, attr = 'type') => {
if (!schema) {
return
}
const type = schema[attr]
if (Array.isArray(type)) {
if (includes(type, 'integer')) {
return 'integer'
}
if (includes(type, 'number')) {
return 'number'
}
return 'string'
}
return type
}
const getXoType = schema => getType(schema, 'xo:type')
const InputByType = {
array: ArrayInput,
boolean: BooleanInput,
host: XoHostInput,
integer: IntegerInput,
number: NumberInput,
object: ObjectInput,
pool: XoPoolInput,
remote: XoRemoteInput,
sr: XoSrInput,
string: StringInput,
vm: XoVmInput,
xoobject: XoHighLevelObjectInput,
role: XoRoleInput,
subject: XoSubjectInput
string: StringInput
}
// ===================================================================
@@ -70,33 +32,31 @@ const InputByType = {
depth: propTypes.number,
disabled: propTypes.bool,
label: propTypes.any.isRequired,
onChange: propTypes.func,
required: propTypes.bool,
schema: propTypes.object.isRequired,
uiSchema: propTypes.object,
defaultValue: propTypes.any
uiSchema: propTypes.object
})
@uncontrollableInput()
export default class GenericInput extends Component {
get value () {
return this.refs.input.value
}
set value (value) {
this.refs.input.value = value
_onChange = event => {
const { name, onChange } = this.props
onChange && onChange(getEventValue(event), name)
}
render () {
const {
schema,
value = schema.default,
uiSchema = EMPTY_OBJECT,
...opts
} = this.props
const props = {
...opts,
onChange: this._onChange,
schema,
uiSchema,
ref: 'input'
value
}
// Enum, special case.
@@ -104,14 +64,13 @@ export default class GenericInput extends Component {
return <EnumInput {...props} />
}
// $type = Job Creation Schemas && Old XO plugins.
const type = getXoType(schema) || getType(schema, '$type') || getType(schema)
const type = getType(schema)
const Input = uiSchema.widget || InputByType[type.toLowerCase()]
if (!Input) {
throw new Error(`Unsupported type: ${type}.`)
}
return <Input {...props} />
return <Input {...props} {...uiSchema.config} />
}
}

View File

@@ -1,10 +1,43 @@
import React from 'react'
import includes from 'lodash/includes'
import isArray from 'lodash/isArray'
import marked from 'marked'
import { Col, Row } from 'grid'
// ===================================================================
export const getType = schema => {
if (!schema) {
return
}
const type = schema.type
if (isArray(type)) {
if (includes(type, 'integer')) {
return 'integer'
}
if (includes(type, 'number')) {
return 'number'
}
return 'string'
}
return type
}
export const getXoType = schema => {
const type = schema && (schema['xo:type'] || schema.$type)
if (type) {
return type.toLowerCase()
}
}
// ===================================================================
export const descriptionRender = description =>
<span className='text-muted' dangerouslySetInnerHTML={{__html: marked(description || '')}} />
@@ -29,19 +62,19 @@ export const PrimitiveInputWrapper = ({ label, required = false, schema, childre
// ===================================================================
export const forceDisplayOptionalAttr = ({ schema, defaultValue }) => {
if (!schema || !defaultValue) {
export const forceDisplayOptionalAttr = ({ schema, value }) => {
if (!schema || !value) {
return false
}
// Array
if (schema.items && Array.isArray(defaultValue)) {
if (schema.items && Array.isArray(value)) {
return true
}
// Object
for (const key in schema.properties) {
if (defaultValue[key]) {
if (value[key]) {
return true
}
}

View File

@@ -1,2 +1 @@
import GenericInput from './generic-input'
export default GenericInput
export default from './generic-input'

View File

@@ -1,37 +1,42 @@
import React from 'react'
import AbstractInput from './abstract-input'
import uncontrollableInput from 'uncontrollable-input'
import Combobox from '../combobox'
import Component from '../base-component'
import getEventValue from '../get-event-value'
import { PrimitiveInputWrapper } from './helpers'
// ===================================================================
export default class IntegerInput extends AbstractInput {
get value () {
const { value } = this.refs.input
return !value ? undefined : +value
}
set value (value) {
// Getter/Setter are always inherited together.
// `get value` is defined in the subclass, so `set value`
// must be defined too.
super.value = value
@uncontrollableInput()
export default class IntegerInput extends Component {
_onChange = event => {
const value = getEventValue(event)
this.props.onChange(value ? +value : undefined)
}
render () {
const { props } = this
const { onChange } = props
const { required, schema } = this.props
const {
disabled,
onChange, // eslint-disable-line no-unused-vars
placeholder = schema.default,
value,
...props
} = this.props
return (
<PrimitiveInputWrapper {...props}>
<input
className='form-control'
defaultValue={props.defaultValue || ''}
disabled={props.disabled}
onChange={onChange && (event => onChange(event.target.value))}
placeholder={props.placeholder}
ref='input'
required={props.required}
<Combobox
value={value === undefined ? '' : String(value)}
disabled={disabled}
max={schema.max}
min={schema.min}
onChange={this._onChange}
options={schema.defaults}
placeholder={placeholder}
required={required}
step={1}
type='number'
/>

View File

@@ -1,37 +1,42 @@
import React from 'react'
import AbstractInput from './abstract-input'
import uncontrollableInput from 'uncontrollable-input'
import Combobox from '../combobox'
import Component from '../base-component'
import getEventValue from '../get-event-value'
import { PrimitiveInputWrapper } from './helpers'
// ===================================================================
export default class NumberInput extends AbstractInput {
get value () {
const { value } = this.refs.input
return !value ? undefined : +value
}
set value (value) {
// Getter/Setter are always inherited together.
// `get value` is defined in the subclass, so `set value`
// must be defined too.
super.value = value
@uncontrollableInput()
export default class NumberInput extends Component {
_onChange = event => {
const value = getEventValue(event)
this.props.onChange(value ? +value : undefined)
}
render () {
const { props } = this
const { onChange } = props
const { required, schema } = this.props
const {
disabled,
onChange, // eslint-disable-line no-unused-vars
placeholder = schema.default,
value,
...props
} = this.props
return (
<PrimitiveInputWrapper {...props}>
<input
className='form-control'
defaultValue={props.defaultValue || ''}
disabled={props.disabled}
onChange={onChange && (event => onChange(event.target.value))}
placeholder={props.placeholder}
ref='input'
required={props.required}
<Combobox
value={value === undefined ? '' : String(value)}
disabled={disabled}
max={schema.max}
min={schema.min}
onChange={this._onChange}
options={schema.defaults}
placeholder={placeholder}
required={required}
step='any'
type='number'
/>

View File

@@ -1,166 +1,97 @@
import _ from 'intl'
import React, { Component, cloneElement } from 'react'
import forEach from 'lodash/forEach'
import includes from 'lodash/includes'
import map from 'lodash/map'
import React from 'react'
import uncontrollableInput from 'uncontrollable-input'
import { createSelector } from 'reselect'
import { keyBy, map } from 'lodash'
import {
autobind,
propsEqual,
propTypes
} from 'utils'
import _ from '../intl'
import Component from '../base-component'
import propTypes from '../prop-types-decorator'
import { EMPTY_OBJECT } from '../utils'
import GenericInput from './generic-input'
import {
descriptionRender,
forceDisplayOptionalAttr
} from './helpers'
// ===================================================================
class ObjectItem extends Component {
get value () {
return this.refs.input.value
}
set value (value) {
this.refs.input.value = value
}
render () {
const { props } = this
return (
<div className='p-b-1'>
{cloneElement(props.children, {
ref: 'input'
})}
</div>
)
}
}
// ===================================================================
@propTypes({
depth: propTypes.number,
disabled: propTypes.bool,
label: propTypes.any.isRequired,
required: propTypes.bool,
schema: propTypes.object.isRequired,
uiSchema: propTypes.object,
defaultValue: propTypes.object
uiSchema: propTypes.object
})
@uncontrollableInput()
export default class ObjectInput extends Component {
constructor (props) {
super(props)
this.state = {
use: Boolean(props.required) || forceDisplayOptionalAttr(props),
children: this._makeChildren(props)
}
state = {
use: this.props.required || forceDisplayOptionalAttr(this.props)
}
get value () {
if (!this.state.use) {
return
}
const obj = {}
forEach(this.refs, (instance, key) => {
obj[key] = instance.value
})
return obj
}
set value (value = {}) {
forEach(this.refs, (instance, id) => {
instance.value = value[id]
_onChildChange = (value, key) => {
this.props.onChange({
...this.props.value,
[key]: value
})
}
@autobind
_handleOptionalChange (event) {
const { checked } = event.target
this.setState({
use: checked
})
}
_makeChildren (props) {
const {
depth = 0,
schema,
uiSchema = {},
defaultValue = {}
} = props
const obj = {}
forEach(schema.properties, (childSchema, key) => {
obj[key] = (
<ObjectItem key={key}>
<GenericInput
depth={depth + 2}
disabled={props.disabled}
label={childSchema.title || key}
required={includes(schema.required, key)}
schema={childSchema}
uiSchema={uiSchema.properties}
defaultValue={defaultValue[key]}
/>
</ObjectItem>
)
})
return obj
}
componentWillReceiveProps (props) {
if (
!propsEqual(
this.props,
props,
[ 'depth', 'disabled', 'label', 'required', 'schema', 'uiSchema' ]
)
) {
this.setState({
children: this._makeChildren(props)
})
}
}
_getRequiredProps = createSelector(
() => this.props.schema.required,
required => required
? keyBy(required)
: EMPTY_OBJECT
)
render () {
const { props, state } = this
const { use } = state
const depth = props.depth || 0
const {
props: {
depth = 0,
disabled,
label,
required,
schema,
uiSchema,
value = EMPTY_OBJECT
},
state: { use }
} = this
const childDepth = depth + 2
const properties = (uiSchema != null && uiSchema.properties) || EMPTY_OBJECT
const requiredProps = this._getRequiredProps()
return (
<div style={{'paddingLeft': `${depth}em`}}>
<legend>{props.label}</legend>
{descriptionRender(props.schema.description)}
<legend>{label}</legend>
{descriptionRender(schema.description)}
<hr />
{!props.required &&
<div className='checkbox'>
<label>
<input
checked={use}
disabled={props.disabled}
onChange={this._handleOptionalChange}
type='checkbox'
/> {_('fillOptionalInformations')}
</label>
</div>
}
{use &&
<div className='card-block'>
{map(state.children, (child, index) =>
cloneElement(child, { ref: index })
)}
</div>
}
{!required && <div className='checkbox'>
<label>
<input
checked={use}
disabled={disabled}
onChange={this.linkState('use')}
type='checkbox'
/> {_('fillOptionalInformations')}
</label>
</div>}
{use && <div className='card-block'>
{map(schema.properties, (childSchema, key) =>
<div className='pb-1' key={key}>
<GenericInput
depth={childDepth}
disabled={disabled}
label={childSchema.title || key}
name={key}
onChange={this._onChildChange}
required={Boolean(requiredProps[key])}
schema={childSchema}
uiSchema={properties[key]}
value={value[key]}
/>
</div>
)}
</div>}
</div>
)
}

View File

@@ -1,26 +1,48 @@
import React from 'react'
import uncontrollableInput from 'uncontrollable-input'
import Combobox from '../combobox'
import Component from '../base-component'
import getEventValue from '../get-event-value'
import propTypes from '../prop-types-decorator'
import AbstractInput from './abstract-input'
import { PrimitiveInputWrapper } from './helpers'
// ===================================================================
export default class StringInput extends AbstractInput {
@propTypes({
password: propTypes.bool
})
@uncontrollableInput()
export default class StringInput extends Component {
// the value of this input is undefined not '' when empty to make
// it homogenous with when the user has never touched this input
_onChange = event => {
const value = getEventValue(event)
this.props.onChange(value !== '' ? value : undefined)
}
render () {
const { props } = this
const { onChange } = props
const { required, schema } = this.props
const {
disabled,
password,
placeholder = schema.default,
value,
...props
} = this.props
delete props.onChange
return (
<PrimitiveInputWrapper {...props}>
<input
className='form-control'
defaultValue={props.defaultValue || ''}
disabled={props.disabled}
onChange={onChange && (event => onChange(event.target.value))}
placeholder={props.placeholder}
ref='input'
required={props.required}
type={props.schema['xo:type'] === 'password' ? 'password' : 'text'}
<Combobox
value={value !== undefined ? value : ''}
disabled={disabled}
onChange={this._onChange}
options={schema.defaults}
placeholder={placeholder || schema.default}
required={required}
type={password && 'password'}
/>
</PrimitiveInputWrapper>
)

View File

@@ -1,20 +0,0 @@
import map from 'lodash/map'
import AbstractInput from './abstract-input'
// ===================================================================
export default class XoAbstractInput extends AbstractInput {
get value () {
const value = this.refs.input.value
if (this.props.schema.type === 'array') {
return map(value, object => object.id || object)
}
return value.id || value
}
set value (value) {
this.refs.input.value = value
}
}

59
src/common/link.js Normal file
View File

@@ -0,0 +1,59 @@
import Link from 'react-router/lib/Link'
import React from 'react'
import { routerShape } from 'react-router/lib/PropTypes'
import Component from './base-component'
import propTypes from './prop-types-decorator'
// ===================================================================
export { Link as default }
// -------------------------------------------------------------------
const _IGNORED_TAGNAMES = {
A: true,
BUTTON: true,
INPUT: true,
SELECT: true
}
@propTypes({
tagName: propTypes.string
})
export class BlockLink extends Component {
static contextTypes = {
router: routerShape
}
_style = { cursor: 'pointer' }
_onClickCapture = event => {
const { currentTarget } = event
let element = event.target
while (element !== currentTarget) {
if (_IGNORED_TAGNAMES[element.tagName]) {
return
}
element = element.parentNode
}
event.stopPropagation()
if (event.ctrlKey || event.button === 1) {
window.open(this.context.router.createHref(this.props.to))
} else {
this.context.router.push(this.props.to)
}
}
render () {
const { children, tagName = 'div' } = this.props
const Component = tagName
return (
<Component
style={this._style}
onClickCapture={this._onClickCapture}
>
{children}
</Component>
)
}
}

View File

@@ -1,10 +1,18 @@
import _ from 'intl'
import Icon from 'icon'
import isArray from 'lodash/isArray'
import isString from 'lodash/isString'
import map from 'lodash/map'
import React, { Component, cloneElement } from 'react'
import { Button, Modal as ReactModal } from 'react-bootstrap-4/lib'
import { propTypes } from './utils'
import { Modal as ReactModal } from 'react-bootstrap-4/lib'
import _ from './intl'
import Button from './button'
import Icon from './icon'
import propTypes from './prop-types-decorator'
import Tooltip from './tooltip'
import {
disable as disableShortcuts,
enable as enableShortcuts
} from './shortcuts'
let instance
@@ -14,31 +22,114 @@ const modal = (content, onClose) => {
} else if (instance.state.showModal) {
throw new Error('Other modal still open.')
}
instance.setState({ content, onClose, showModal: true })
instance.setState({ content, onClose, showModal: true }, disableShortcuts)
}
export const alert = (title, body) => {
return new Promise(resolve => {
@propTypes({
buttons: propTypes.arrayOf(propTypes.shape({
btnStyle: propTypes.string,
icon: propTypes.string,
label: propTypes.string.isRequired,
tooltip: propTypes.node,
value: propTypes.any
})).isRequired,
children: propTypes.node.isRequired,
icon: propTypes.string,
title: propTypes.node.isRequired
})
class GenericModal extends Component {
_getBodyValue = () => {
const { body } = this.refs
if (body !== undefined) {
return body.getWrappedInstance === undefined
? body.value
: body.getWrappedInstance().value
}
}
_resolve = (value = this._getBodyValue()) => {
this.props.resolve(value)
instance.close()
}
_reject = () => {
this.props.reject()
instance.close()
}
render () {
const { Body, Footer, Header, Title } = ReactModal
modal(
<div>
<Header closeButton>
<Title>{title}</Title>
</Header>
<Body>{body}</Body>
<Footer>
<Button bsStyle='primary' onClick={() => {
resolve()
instance.close()
}}>
{_('alertOk')}
const {
buttons,
icon,
title
} = this.props
const body = _addRef(this.props.children, 'body')
return <div>
<Header closeButton>
<Title>
{icon
? <span><Icon icon={icon} /> {title}</span>
: title
}
</Title>
</Header>
<Body>
{body}
</Body>
<Footer>
{map(buttons, ({
label,
tooltip,
value,
icon,
...props
}) => {
const button = <Button
onClick={() => this._resolve(value)}
key={value}
{...props}
>
{icon !== undefined && <Icon icon={icon} fixedWidth />}
{label}
</Button>
</Footer>
</div>,
return <span>
{tooltip !== undefined
? <Tooltip content={tooltip}>{button}</Tooltip>
: button
}
{' '}
</span>
})}
{this.props.reject !== undefined &&
<Button onClick={this._reject} >
{_('genericCancel')}
</Button>
}
</Footer>
</div>
}
}
const ALERT_BUTTONS = [ { label: _('alertOk'), value: 'ok' } ]
export const alert = (title, body) => (
new Promise(resolve => {
modal(
<GenericModal
buttons={ALERT_BUTTONS}
resolve={resolve}
title={title}
>
{body}
</GenericModal>,
resolve
)
})
}
)
const _addRef = (component, ref) => {
if (isString(component) || isArray(component)) {
@@ -51,75 +142,38 @@ const _addRef = (component, ref) => {
return component
}
@propTypes({
children: propTypes.node.isRequired,
title: propTypes.node.isRequired,
icon: propTypes.string
})
class Confirm extends Component {
_resolve = () => {
const { body } = this.refs
this.props.resolve(body && body.value || body.getWrappedInstance && body.getWrappedInstance().value)
instance.close()
}
_reject = () => {
this.props.reject()
instance.close()
}
_style = { marginRight: '0.5em' }
render () {
const { Body, Footer, Header, Title } = ReactModal
const { title, icon } = this.props
const body = _addRef(this.props.children, 'body')
return <div>
<Header closeButton>
<Title>
{icon
? <span><Icon icon={icon} /> {title}</span>
: title}
</Title>
</Header>
<Body>
{body}
</Body>
<Footer>
<Button
bsStyle='primary'
onClick={this._resolve}
style={this._style}
>
{_('confirmOk')}
</Button>
<Button
bsStyle='secondary'
onClick={this._reject}
>
{_('confirmCancel')}
</Button>
</Footer>
</div>
}
}
const CONFIRM_BUTTONS = [ { btnStyle: 'primary', label: _('confirmOk') } ]
export const confirm = ({
body,
title,
icon = 'alarm'
icon = 'alarm',
title
}) => (
chooseAction({
body,
buttons: CONFIRM_BUTTONS,
icon,
title
})
)
export const chooseAction = ({
body,
buttons,
icon,
title
}) => {
return new Promise((resolve, reject) => {
modal(
<Confirm
title={title}
resolve={resolve}
reject={reject}
<GenericModal
buttons={buttons}
icon={icon}
reject={reject}
resolve={resolve}
title={title}
>
{body}
</Confirm>,
</GenericModal>,
reject
)
})
@@ -129,18 +183,22 @@ export default class Modal extends Component {
constructor () {
super()
this.state = { showModal: false }
}
componentDidMount () {
if (instance) {
throw new Error('Modal is a singleton!')
}
instance = this
}
componentWillMount () {
this.setState({ showModal: false })
componentWillUnmount () {
instance = undefined
}
close () {
this.setState({ showModal: false })
this.setState({ showModal: false }, enableShortcuts)
}
_onHide = () => {

View File

@@ -1,7 +1,8 @@
import classNames from 'classnames'
import Link from 'react-router/lib/Link'
import React from 'react'
import Link from './link'
export const NavLink = ({ children, to }) => (
<li className='nav-item' role='tab'>
<Link className='nav-link' activeClassName='active' to={to}>

View File

@@ -8,15 +8,17 @@ export let info
export let success
export class Notification extends Component {
constructor () {
super()
componentDidMount () {
if (instance) {
throw new Error('Notification is a singleton!')
}
instance = this
}
componentWillUnmount () {
instance = undefined
}
// This special component never have to rerender!
shouldComponentUpdate () {
return false

View File

@@ -0,0 +1,33 @@
import assign from 'lodash/assign'
import { PropTypes } from 'react'
// Decorators to help declaring properties and context types on React
// components without using the tedious static properties syntax.
//
// ```js
// @propTypes({
// children: propTypes.node.isRequired
// }, {
// store: propTypes.object.isRequired
// })
// class MyComponent extends React.Component {}
// ```
const propTypes = (propTypes, contextTypes) => target => {
if (propTypes !== undefined) {
target.propTypes = {
...target.propTypes,
...propTypes
}
}
if (contextTypes !== undefined) {
target.contextTypes = {
...target.contextTypes,
...contextTypes
}
}
return target
}
assign(propTypes, PropTypes)
export { propTypes as default }

View File

@@ -1,22 +0,0 @@
import assign from 'lodash/assign'
import { PropTypes } from 'react'
// Decorators to help declaring on React components without using the
// tedious static properties syntax.
//
// ```js
// @propTypes({
// children: propTypes.node.isRequired
// })
// class MyComponent extends React.Component {}
// ```
const propTypes = types => target => {
target.propTypes = {
...target.propTypes,
...types
}
return target
}
assign(propTypes, PropTypes)
export { propTypes as default }

View File

@@ -1,12 +1,13 @@
import React, { Component } from 'react'
import RFB from '@nraynaud/novnc/lib/rfb'
import { createBackoff } from 'jsonrpc-websocket-client'
import { propTypes } from 'utils'
import { RFB } from 'novnc-node'
import {
format as formatUrl,
parse as parseUrl,
resolve as resolveUrl
} from 'url'
import { enable as enableShortcuts, disable as disableShortcuts } from 'shortcuts'
import propTypes from './prop-types-decorator'
const parseRelativeUrl = url => parseUrl(resolveUrl(String(window.location), url))
@@ -69,11 +70,17 @@ export default class NoVnc extends Component {
this._rfb = null
rfb.disconnect()
}
enableShortcuts()
}
_connect = () => {
this._clean()
const { canvas } = this.refs
if (!canvas) {
return
}
const url = parseRelativeUrl(this.props.url)
fixProtocol(url)
@@ -83,14 +90,24 @@ export default class NoVnc extends Component {
const rfb = this._rfb = new RFB({
encrypt: isSecure,
target: this.refs.canvas,
wsProtocols: [ 'chat' ],
onClipboard: onClipboardChange && ((_, text) => {
onClipboardChange(text)
}),
onUpdateState: this._onUpdateState
})
rfb.connect(formatUrl(url))
// remove leading slashes from the path
//
// a leading slassh will be added by noVNC
const clippedPath = url.path.replace(/^\/+/, '')
// a port is required
//
// if not available from the URL, use the default ones
const { port = isSecure ? 443 : 80 } = url
rfb.connect(url.hostname, port, null, clippedPath)
disableShortcuts()
}
componentDidMount () {
@@ -101,6 +118,14 @@ export default class NoVnc extends Component {
this._clean()
}
componentWillReceiveProps (props) {
const rfb = this._rfb
if (rfb && this.props.scale !== props.scale) {
rfb.get_display().set_scale(props.scale || 1)
rfb.get_mouse().set_scale(props.scale || 1)
}
}
_focus = () => {
const rfb = this._rfb
if (rfb) {
@@ -111,6 +136,8 @@ export default class NoVnc extends Component {
rfb.get_keyboard().grab()
rfb.get_mouse().grab()
disableShortcuts()
}
}
@@ -119,6 +146,8 @@ export default class NoVnc extends Component {
if (rfb) {
rfb.get_keyboard().ungrab()
rfb.get_mouse().ungrab()
enableShortcuts()
}
}

View File

@@ -1,12 +1,14 @@
import Icon from 'icon'
import React, { Component } from 'react'
import { createGetObject } from 'selectors'
import { isSrWritable } from 'xo'
import _ from 'intl'
import React from 'react'
import Icon from './icon'
import propTypes from './prop-types-decorator'
import { createGetObject } from './selectors'
import { isSrWritable } from './xo'
import {
connectStore,
formatSize,
propTypes
} from 'utils'
formatSize
} from './utils'
// ===================================================================
@@ -54,13 +56,12 @@ export const SrItem = propTypes({
let label = `${sr.name_label || sr.id}`
if (isSrWritable(sr)) {
label += ` (${formatSize(sr.size)})`
label += ` (${formatSize(sr.size - sr.physical_usage)} free)`
}
return (
<span>
<Icon icon='sr' /> {label}
{container && ` (${container.name_label || container.id})`}
</span>
)
}))
@@ -107,6 +108,27 @@ const xoItemToRender = {
<Icon icon='user' /> {user.email}
</span>
),
resourceSet: resourceSet => (
<span>
<Icon icon='resource-set' /> {resourceSet.name}
</span>
),
sshKey: key => (
<span>
<Icon icon='ssh-key' /> {key.label}
</span>
),
ipPool: ipPool => (
<span>
<Icon icon='ip' /> {ipPool.name}
</span>
),
ipAddress: ({label, used}) => {
if (used) {
return <strong className='text-warning'>{label}</strong>
}
return <span>{label}</span>
},
// XO objects.
pool: pool => (
@@ -132,11 +154,18 @@ const xoItemToRender = {
// VM.
VM: vm => <VmItem vm={vm} />,
'VM-snapshot': vm => <VmItem vm={vm} />,
'VM-controller': vm => (
<span>
<Icon icon='host' />
{' '}
<VmItem vm={vm} />
</span>
),
// PIF.
PIF: pif => (
<span>
<Icon icon='network' /> {pif.device}
<Icon icon='network' /> {pif.device} ({pif.deviceName})
</span>
),
@@ -153,7 +182,14 @@ const renderXoItem = (item, {
} = {}) => {
const { id, type, label } = item
if (!type && label) {
if (item.removed) {
return <span key={id} className='text-danger'> <Icon icon='alarm' /> {id}</span>
}
if (!type) {
if (process.env.NODE_ENV !== 'production' && !label) {
throw new Error(`an item must have at least either a type or a label`)
}
return (
<span key={id} className={className}>
{label}
@@ -186,7 +222,9 @@ const GenericXoItem = connectStore(() => {
})
})(({ xoItem, ...props }) => xoItem
? renderXoItem(xoItem, props)
: <span className='text-muted'>no such item</span>
: renderXoUnknownItem()
)
export const renderXoItemFromId = (id, props) => <GenericXoItem {...props} id={id} />
export const renderXoUnknownItem = () => <span className='text-muted'>{_('errorNoSuchItem')}</span>

View File

@@ -1,37 +1,53 @@
import Component from 'base-component'
import React from 'react'
import _ from 'intl'
import forEach from 'lodash/forEach'
import includes from 'lodash/includes'
import join from 'lodash/join'
import classNames from 'classnames'
import later from 'later'
import map from 'lodash/map'
import sortedIndex from 'lodash/sortedIndex'
import { Range } from 'form'
import { FormattedTime } from 'react-intl'
import React from 'react'
import { FormattedDate, FormattedTime } from 'react-intl'
import {
forEach,
includes,
isArray,
map,
sortedIndex
} from 'lodash'
import { Col, Row } from 'grid'
import {
Panel,
Tab,
Tabs
} from 'react-bootstrap-4/lib'
import {
propTypes
} from 'utils'
import _ from './intl'
import Button from './button'
import Component from './base-component'
import propTypes from './prop-types-decorator'
import TimezonePicker from './timezone-picker'
import Icon from './icon'
import Tooltip from './tooltip'
import { Card, CardHeader, CardBlock } from './card'
import { Col, Row } from './grid'
import { Range, Toggle } from './form'
// ===================================================================
const NAV_EVERY = 1
const NAV_EACH_SELECTED = 2
const NAV_EVERY_N = 3
// By default, later uses UTC but we use this line for future versions.
later.date.UTC()
// ===================================================================
const CLICKABLE = { cursor: 'pointer' }
const PREVIEW_SLIDER_STYLE = { width: '400px' }
// ===================================================================
const UNITS = [ 'minute', 'hour', 'monthDay', 'month', 'weekDay' ]
const MINUTES_RANGE = [2, 30]
const HOURS_RANGE = [2, 12]
const MONTH_DAYS_RANGE = [2, 15]
const MONTHS_RANGE = [2, 6]
const MIN_PREVIEWS = 5
const MAX_PREVIEWS = 20
const MONTHS = [
[ 0, 1, 2, 3, 4, 5 ],
[ 6, 7, 8, 9, 10, 11 ]
[ 0, 1, 2 ],
[ 3, 4, 5 ],
[ 6, 7, 8 ],
[ 9, 10, 11 ]
]
const DAYS = (() => {
@@ -50,7 +66,11 @@ const DAYS = (() => {
return days
})()
const WEEK_DAYS = [[ 0, 1, 2, 3, 4, 5, 6 ]]
const WEEK_DAYS = [
[ 0, 1, 2 ],
[ 3, 4, 5 ],
[ 6 ]
]
const HOURS = (() => {
const hours = []
@@ -80,47 +100,62 @@ const MINS = (() => {
return minutes
})()
const PICKTIME_TO_ID = {
minute: 0,
hour: 1,
monthDay: 2,
month: 3,
weekDay: 4
}
const TIME_FORMAT = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: 'numeric'
minute: 'numeric',
// The timezone is not significant for displaying the date previews
// as long as it is the same used to generate the next occurrences
// from the cron patterns.
// Therefore we can use UTC everywhere and say to the user that the
// previews are in the configured timezone.
timeZone: 'UTC'
}
// ===================================================================
// monthNum: [ 0 : 11 ]
const getMonthName = (monthNum) =>
<FormattedTime value={new Date(1970, monthNum)} month='long' />
<FormattedDate value={Date.UTC(1970, monthNum)} month='long' timeZone='UTC' />
// dayNum: [ 0 : 6 ]
const getDayName = (dayNum) =>
// January, 1970, 5th => Monday
<FormattedTime value={new Date(1970, 0, 4 + dayNum)} weekday='long' />
<FormattedDate value={Date.UTC(1970, 0, 4 + dayNum)} weekday='long' timeZone='UTC' />
// ===================================================================
@propTypes({
cron: propTypes.string.isRequired
cronPattern: propTypes.string.isRequired
})
export class SchedulePreview extends Component {
_handleChange = value => {
this.setState({
value
})
}
render () {
const { props } = this
const cronSched = later.parse.cron(props.cron)
const dates = later.schedule(cronSched).next(this.state.value || MIN_PREVIEWS)
const { cronPattern } = this.props
const { value } = this.state
const cronSched = later.parse.cron(cronPattern)
const dates = later.schedule(cronSched).next(value)
return (
<div>
<div className='form-inline p-b-1'>
<Range min={MIN_PREVIEWS} max={MAX_PREVIEWS} onChange={this._handleChange} />
<div className='alert alert-info' role='alert'>
{_('cronPattern')} <strong>{cronPattern}</strong>
</div>
<div className='mb-1' style={PREVIEW_SLIDER_STYLE}>
<Range min={MIN_PREVIEWS} max={MAX_PREVIEWS} onChange={this.linkState('value')} value={+value} />
</div>
<ul className='list-group'>
{map(dates, (date, id) => (
@@ -139,34 +174,21 @@ export class SchedulePreview extends Component {
@propTypes({
children: propTypes.any.isRequired,
onChange: propTypes.func
onChange: propTypes.func.isRequired,
tdId: propTypes.number.isRequired,
value: propTypes.bool.isRequired
})
class ToggleTd extends Component {
get value () {
return this.state.value
}
set value (value) {
const { onChange } = this.props
this.setState({
value
}, onChange && (() => onChange(value)))
}
_onClick = () => {
const { onChange } = this.props
const value = !this.state.value
this.setState({
value
}, onChange && (() => onChange(value)))
const { props } = this
props.onChange(props.tdId, !props.value)
}
render () {
const { props } = this
return (
<td style={{ cursor: 'pointer' }} className={this.state.value ? 'table-success' : ''} onClick={this._onClick}>
{this.props.children}
<td style={CLICKABLE} className={props.value ? 'table-success' : ''} onClick={this._onClick}>
{props.children}
</td>
)
}
@@ -175,319 +197,351 @@ class ToggleTd extends Component {
// ===================================================================
@propTypes({
data: propTypes.array.isRequired,
dataRender: propTypes.func,
onChange: propTypes.func
labelId: propTypes.string.isRequired,
options: propTypes.array.isRequired,
optionRenderer: propTypes.func,
onChange: propTypes.func.isRequired,
value: propTypes.array.isRequired
})
class TableSelect extends Component {
constructor () {
super()
this.state = {
value: []
}
}
get value () {
return this.state.value
}
set value (value) {
const { onChange } = this.props
forEach(this.refs, (ref, id) => {
// Don't call ref.input directly because onChange of each ToggleTd is called else!
ref.setState({
value: includes(value, +id)
})
})
this.setState({
value
}, onChange && (() => onChange(value)))
static defaultProps = {
optionRenderer: value => value
}
_reset = () => {
this.value = []
this.props.onChange([])
}
_handleChange = (id, value) => {
const { onChange } = this.props
const newValue = this.state.value.slice()
_handleChange = (tdId, tdValue) => {
const { props } = this
if (value) {
newValue.splice(sortedIndex(newValue, id), 0, id)
const newValue = props.value.slice()
const index = sortedIndex(newValue, tdId)
if (tdValue) {
// Add
if (newValue[index] !== tdId) {
newValue.splice(index, 0, tdId)
}
} else {
newValue.splice(sortedIndex(newValue, id), 1)
// Remove
if (newValue[index] === tdId) {
newValue.splice(index, 1)
}
}
this.setState({
value: newValue
}, onChange && (() => onChange(newValue)))
props.onChange(newValue)
}
render () {
const dataRender = this.props.dataRender || ((value) => value)
const {
props: {
data
}
} = this
const { length } = data[0]
labelId,
options,
optionRenderer,
value
} = this.props
return (
<div>
<table className='table table-bordered table-sm'>
<tbody>
{map(data, (line, i) => (
<tr key={i}>
{map(line, (value, j) => {
const id = length * i + j
return (
<ToggleTd
key={id}
ref={id}
children={dataRender(value)}
onChange={(value) => { this._handleChange(id, value) }}
/>
)
})}
</tr>
))}
</tbody>
</table>
<button className='btn btn-secondary pull-xs-right' onClick={this._reset}>
{_('selectTableReset')}
</button>
</div>
)
return <div>
<table className='table table-bordered table-sm'>
<tbody>
{map(options, (line, i) => (
<tr key={i}>
{map(line, tdOption => (
<ToggleTd
children={optionRenderer(tdOption)}
tdId={tdOption}
key={tdOption}
onChange={this._handleChange}
value={includes(value, tdOption)}
/>
))}
</tr>
))}
</tbody>
</table>
<Button
className='pull-right'
onClick={this._reset}
>
{_(`selectTableAll${labelId}`)} {value && !value.length && <Icon icon='success' />}
</Button>
</div>
}
}
// ===================================================================
// "2,7" => [2,7] "*/2" => 2 "*" => []
const cronToValue = (cron, range) => {
if (cron.indexOf('/') === 1) {
return +cron.split('/')[1]
}
if (cron === '*') {
return []
}
return map(cron.split(','), Number)
}
// [2,7] => "2,7" 2 => "*/2" [] => "*"
const valueToCron = value => {
if (!isArray(value)) {
return `*/${value}`
}
if (!value.length) {
return '*'
}
return value.join(',')
}
@propTypes({
dataRender: propTypes.func,
onChange: propTypes.func,
headerAddon: propTypes.node,
optionRenderer: propTypes.func,
onChange: propTypes.func.isRequired,
range: propTypes.array,
type: propTypes.string.isRequired
labelId: propTypes.string.isRequired,
value: propTypes.any.isRequired
})
class TimePicker extends Component {
constructor () {
super()
this.state = {
activeKey: NAV_EVERY
}
}
_update = cron => {
const { tableValue, rangeValue } = this.state
get value () {
const { activeKey } = this.state
const { refs } = this
const newValue = cronToValue(cron)
const periodic = !isArray(newValue)
if (activeKey === NAV_EVERY) {
return 'all'
}
if (activeKey === NAV_EACH_SELECTED) {
return refs.select.value
}
return refs.range.value
}
set value (value) {
const { refs } = this
const { onChange } = this.props
if (value === 'all') {
this.setState({
activeKey: NAV_EVERY
}, onChange && (() => onChange(value)))
} else if (Array.isArray(value)) {
this.setState({
activeKey: NAV_EACH_SELECTED
})
refs.select.value = value
} else {
this.setState({
activeKey: NAV_EVERY_N
})
refs.range.value = value
}
}
_updateOpen = () => {
this.setState({
open: !this.state.open
periodic,
tableValue: periodic ? tableValue : newValue,
rangeValue: periodic ? newValue : rangeValue
})
}
_selectTab = activeKey => {
const { onChange } = this.props
this.setState({
activeKey
}, onChange && (() => onChange(this.value)))
componentWillReceiveProps (props) {
if (props.value !== this.props.value) {
this._update(props.value)
}
}
componentDidMount () {
this._update(this.props.value)
}
_onChange = value => {
this.props.onChange(valueToCron(value))
}
_tableTab = () => this._onChange(this.state.tableValue || [])
_periodicTab = () => this._onChange(this.state.rangeValue || this.props.range[0])
render () {
const {
props,
state
} = this
headerAddon,
labelId,
options,
optionRenderer,
range
} = this.props
const {
onChange,
range,
type
} = props
periodic,
tableValue,
rangeValue
} = this.state
return (
<div className='card'>
<button className='card-header btn btn-lg btn-block' onClick={this._updateOpen}>
{_(`scheduling${type}`)}
</button>
<Panel collapsible expanded={state.open}>
<div className='card-block'>
<Tabs bsStyle='tabs' activeKey={state.activeKey} onSelect={this._selectTab}>
<Tab tabClassName='nav-item' eventKey={NAV_EVERY} title={_(`schedulingEvery${type}`)} />
<Tab tabClassName='nav-item' eventKey={NAV_EACH_SELECTED} title={_(`schedulingEachSelected${type}`)}>
<TableSelect ref='select' data={props.data} dataRender={props.dataRender} onChange={onChange} />
</Tab>
{range &&
<Tab tabClassName='nav-item' eventKey={NAV_EVERY_N} title={_(`schedulingEveryN${type}`)}>
<Range ref='range' min={range[0]} max={range[1]} onChange={onChange} />
</Tab>}
</Tabs>
</div>
</Panel>
</div>
return <Card>
<CardHeader>
{_(`scheduling${labelId}`)}
{headerAddon}
</CardHeader>
<CardBlock>
{range && <ul className='nav nav-tabs mb-1'>
<li className='nav-item'>
<a onClick={this._tableTab} className={classNames('nav-link', !periodic && 'active')} style={CLICKABLE}>
{_(`schedulingEachSelected${labelId}`)}
</a>
</li>
<li className='nav-item'>
<a onClick={this._periodicTab} className={classNames('nav-link', periodic && 'active')} style={CLICKABLE}>
{_(`schedulingEveryN${labelId}`)}
</a>
</li>
</ul>}
{periodic
? <Range ref='range' min={range[0]} max={range[1]} onChange={this._onChange} value={rangeValue} />
: <TableSelect
labelId={labelId}
onChange={this._onChange}
options={options}
optionRenderer={optionRenderer}
value={tableValue || []}
/>
}
</CardBlock>
</Card>
}
}
const isWeekDayMode = ({ monthDayPattern, weekDayPattern }) => {
if (monthDayPattern === '*' && weekDayPattern === '*') {
return
}
return weekDayPattern !== '*'
}
@propTypes({
monthDayPattern: propTypes.string.isRequired,
weekDayPattern: propTypes.string.isRequired
})
class DayPicker extends Component {
state = {
weekDayMode: isWeekDayMode(this.props)
}
componentWillReceiveProps (props) {
const weekDayMode = isWeekDayMode(props)
if (weekDayMode !== undefined) {
this.setState({ weekDayMode })
}
}
_setWeekDayMode = weekDayMode => {
this.props.onChange([ '*', '*' ])
this.setState({ weekDayMode })
}
_onChange = cron => {
const isMonthDayPattern = !this.state.weekDayMode || includes(cron, '/')
this.props.onChange([
isMonthDayPattern ? cron : '*',
isMonthDayPattern ? '*' : cron
])
}
render () {
const { monthDayPattern, weekDayPattern } = this.props
const { weekDayMode } = this.state
const dayModeToggle = (
<Tooltip content={_(weekDayMode ? 'schedulingSetMonthDayMode' : 'schedulingSetWeekDayMode')}>
<span className='pull-right'><Toggle onChange={this._setWeekDayMode} iconSize={1} value={weekDayMode} /></span>
</Tooltip>
)
return <TimePicker
headerAddon={dayModeToggle}
key={weekDayMode ? 'week' : 'month'}
labelId='Day'
optionRenderer={weekDayMode ? getDayName : undefined}
options={weekDayMode ? WEEK_DAYS : DAYS}
onChange={this._onChange}
range={MONTH_DAYS_RANGE}
setWeekDayMode={this._setWeekDayMode}
value={weekDayMode ? weekDayPattern : monthDayPattern}
/>
}
}
// ===================================================================
const ID_TO_PICKTIME = [
'minute',
'hour',
'monthDay',
'month',
'weekDay'
]
@propTypes({
onChange: propTypes.func
cronPattern: propTypes.string,
onChange: propTypes.func,
timezone: propTypes.string,
value: propTypes.shape({
cronPattern: propTypes.string.isRequired,
timezone: propTypes.string
})
})
export default class Scheduler extends Component {
constructor () {
super()
this.cron = {
minute: '*',
hour: '*',
monthDay: '*',
month: '*',
weekDay: '*'
}
}
constructor (props) {
super(props)
get value () {
const { cron } = this
return `${cron.minute} ${cron.hour} ${cron.monthDay} ${cron.month} ${cron.weekDay}`
}
this._onCronChange = newCrons => {
const cronPattern = this._getCronPattern().split(' ')
forEach(newCrons, (cron, unit) => {
cronPattern[PICKTIME_TO_ID[unit]] = cron
})
set value (value) {
if (!value) {
value = '* * * * *'
this.props.onChange({
cronPattern: cronPattern.join(' '),
timezone: this._getTimezone()
})
}
forEach(value.split(' '), (t, id) => {
const ref = this.refs[ID_TO_PICKTIME[id]]
forEach(UNITS, unit => {
this[`_${unit}Change`] = cron => this._onCronChange({ [unit]: cron })
})
this._dayChange = ([ monthDay, weekDay ]) => this._onCronChange({ monthDay, weekDay })
}
if (t === '*') {
ref.value = 'all'
} else if (t.indexOf('/') === 1) {
ref.value = t.split('/')[1]
} else {
ref.value = map(t.split(','), e => +e)
}
_onTimezoneChange = timezone => {
this.props.onChange({
cronPattern: this._getCronPattern(),
timezone
})
}
_update (type, value) {
const { cron } = this
const { onChange } = this.props
if (value === 'all') {
cron[type] = '*'
} else if (Array.isArray(value)) {
if (!value.length) {
cron[type] = '*'
} else {
cron[type] = join(
(type === 'monthDay' || type === 'month')
? map(value, (n) => n + 1)
: value,
','
)
}
} else {
cron[type] = `*/${value}`
}
if (onChange) {
onChange(this.value)
}
_getCronPattern = () => {
const { value, cronPattern = value.cronPattern } = this.props
return cronPattern
}
_onHourChange = value => this._update('hour', value)
_onMinuteChange = value => this._update('minute', value)
_onMonthChange = value => this._update('month', value)
_onMonthDayChange = value => this._update('monthDay', value)
_onWeekDayChange = value => this._update('weekDay', value)
_getTimezone = () => {
const { value, timezone = value && value.timezone } = this.props
return timezone
}
render () {
const cronPatternArr = this._getCronPattern().split(' ')
const timezone = this._getTimezone()
return (
<div className='card-block'>
<Row>
<Col mediumSize={6}>
<TimePicker
ref='month'
type='Month'
dataRender={getMonthName}
data={MONTHS}
onChange={this._onMonthChange}
labelId='Month'
optionRenderer={getMonthName}
options={MONTHS}
onChange={this._monthChange}
range={MONTHS_RANGE}
value={cronPatternArr[PICKTIME_TO_ID['month']]}
/>
<TimePicker
ref='monthDay'
type='MonthDay'
data={DAYS}
onChange={this._onMonthDayChange}
/>
<TimePicker
ref='weekDay'
type='WeekDay'
dataRender={getDayName}
data={WEEK_DAYS}
onChange={this._onWeekDayChange}
<DayPicker
onChange={this._dayChange}
monthDayPattern={cronPatternArr[PICKTIME_TO_ID['monthDay']]}
weekDayPattern={cronPatternArr[PICKTIME_TO_ID['weekDay']]}
/>
</Col>
<Col mediumSize={6}>
<TimePicker
ref='hour'
type='Hour'
data={HOURS}
range={[2, 12]}
onChange={this._onHourChange}
labelId='Hour'
options={HOURS}
range={HOURS_RANGE}
onChange={this._hourChange}
value={cronPatternArr[PICKTIME_TO_ID['hour']]}
/>
<TimePicker
ref='minute'
type='Minute'
data={MINS}
range={[2, 30]}
onChange={this._onMinuteChange}
labelId='Minute'
options={MINS}
range={MINUTES_RANGE}
onChange={this._minuteChange}
value={cronPatternArr[PICKTIME_TO_ID['minute']]}
/>
</Col>
</Row>
<Row>
<Col>
<hr />
<TimezonePicker value={timezone} onChange={this._onTimezoneChange} />
</Col>
</Row>
</div>
)
}

View File

@@ -0,0 +1,32 @@
import _ from 'intl'
import Component from 'base-component'
import Icon from 'icon'
import propTypes from 'prop-types-decorator'
import React from 'react'
import { omit } from 'lodash'
@propTypes({
multi: propTypes.bool,
label: propTypes.node,
onChange: propTypes.func.isRequired
})
export default class SelectFiles extends Component {
_onChange = e => {
const { multi, onChange } = this.props
const { files } = e.target
onChange(multi ? files : files[0])
}
render () {
return <label className='btn btn-secondary btn-file hidden'>
<Icon icon='file' /> {this.props.label || _('browseFiles')}
<input
{...omit(this.props, [ 'hidden', 'label', 'onChange', 'multi' ])}
hidden
onChange={this._onChange}
type='file'
/>
</label>
}
}

View File

@@ -1,42 +1,82 @@
import Component from 'base-component'
import React from 'react'
import _ from 'intl'
import assign from 'lodash/assign'
import classNames from 'classnames'
import filter from 'lodash/filter'
import forEach from 'lodash/forEach'
import groupBy from 'lodash/groupBy'
import keyBy from 'lodash/keyBy'
import keys from 'lodash/keys'
import map from 'lodash/map'
import renderXoItem from 'render-xo-item'
import sortBy from 'lodash/sortBy'
import { parse as parseRemote } from 'xo-remote-parser'
import { Select } from 'form'
import {
assign,
filter,
flatten,
forEach,
groupBy,
includes,
isArray,
isEmpty,
isInteger,
isString,
keyBy,
keys,
map,
mapValues,
pick,
sortBy,
toArray
} from 'lodash'
import _ from './intl'
import Button from './button'
import Component from './base-component'
import Icon from './icon'
import propTypes from './prop-types-decorator'
import renderXoItem from './render-xo-item'
import store from './store'
import Tooltip from './tooltip'
import uncontrollableInput from 'uncontrollable-input'
import { Select } from './form'
import {
createCollectionWrapper,
createFilter,
createGetObjectsOfType,
createGetTags,
createSelector
} from 'selectors'
createSelector,
getObject
} from './selectors'
import {
addSubscriptions,
connectStore,
mapPlus,
propTypes
} from 'utils'
resolveResourceSets
} from './utils'
import {
isSrWritable,
subscribeCurrentUser,
subscribeGroups,
subscribeIpPools,
subscribeRemotes,
subscribeResourceSets,
subscribeRoles,
subscribeUsers
} from 'xo'
} from './xo'
// ===================================================================
// react-select's line-height is 1.4
// https://github.com/JedWatson/react-select/blob/916ab0e62fc7394be8e24f22251c399a68de8b1c/less/multi.less#L33
// while bootstrap button's line-height is 1.25
// https://github.com/twbs/bootstrap/blob/959c4e527c6ef69623928db638267ba1c370479d/scss/_variables.scss#L342
const ADDON_BUTTON_STYLE = { lineHeight: '1.4' }
const getIds = value => value == null || isString(value) || isInteger(value)
? value
: isArray(value)
? map(value, getIds)
: value.id
const getOption = (object, container) => ({
label: container
? `${getLabel(object)} ${getLabel(container)}`
: getLabel(object),
value: object.id,
xoItem: object
})
const getLabel = object =>
object.name_label ||
object.name ||
@@ -45,17 +85,46 @@ const getLabel = object =>
object.value ||
object.label
const options = props => ({
defaultValue: props.multi ? [] : undefined
})
// ===================================================================
/*
* WITHOUT xoContainers :
*
* xoObjects: [
* { type: 'myType', id: 'abc', label: 'First object' },
* { type: 'myType', id: 'def', label: 'Second object' }
* ]
*
*
* WITH xoContainers :
*
* xoContainers: [
* { type: 'containerType', id: 'ghi', label: 'First container' },
* { type: 'containerType', id: 'jkl', label: 'Second container' }
* ]
*
* xoObjects: {
* ghi: [
* { type: 'objectType', id: 'mno', label: 'First object' }
* { type: 'objectType', id: 'pqr', label: 'Second object' }
* ],
* jkl: [
* { type: 'objectType', id: 'stu', label: 'Third object' }
* ]
* }
*/
@propTypes({
autoFocus: propTypes.bool,
clearable: propTypes.bool,
defaultValue: propTypes.any,
disabled: propTypes.bool,
hasSelectAll: propTypes.bool,
multi: propTypes.bool,
onChange: propTypes.func,
placeholder: propTypes.any.isRequired,
predicate: propTypes.func,
required: propTypes.bool,
value: propTypes.any,
xoContainers: propTypes.array,
@@ -65,221 +134,196 @@ const getLabel = object =>
]).isRequired
})
export class GenericSelect extends Component {
constructor (props) {
super(props)
this.state = {
value: this._setValue(props.value || props.defaultValue, props)
}
}
_getObjectsById = createSelector(
() => this.props.xoObjects,
objects => keyBy(
isArray(objects)
? objects
: flatten(toArray(objects)),
'id'
)
)
_getValue (xoObjectsById = this.state.xoObjectsById, props = this.props) {
const { value } = this.state
_getOptions = createSelector(
() => this.props.xoContainers,
() => this.props.xoObjects,
(containers, objects) => { // createCollectionWrapper with a depth?
const { name } = this.constructor
if (props.multi) {
// Returns the values of the selected objects
// if they are contained in xoObjectsById.
return mapPlus(value, (value, push) => {
const o = xoObjectsById[value.value || value]
if (o) {
push(o)
let options = []
if (!containers) {
if (__DEV__ && !isArray(objects)) {
throw new Error(`${name}: without xoContainers, xoObjects must be an array`)
}
options = map(objects, getOption)
} else if (__DEV__ && isArray(objects)) {
throw new Error(`${name}: with xoContainers, xoObjects must be an object`)
}
forEach(containers, container => {
options.push({
disabled: true,
xoItem: container
})
forEach(objects[container.id], object => {
options.push(getOption(object, container))
})
})
}
return xoObjectsById[value.value || value] || ''
}
// Supports id strings and objects.
_setValue (value, props = this.props) {
if (props.multi) {
return map(value, object => object.id || object)
}
return (value != null)
? value.id || value
: ''
}
componentWillMount () {
const { props } = this
this.setState({
...this._computeOptions(props)
})
}
componentWillReceiveProps (newProps) {
const { props } = this
const { value, xoContainers, xoObjects } = newProps
if (
xoContainers !== props.xoContainers ||
xoObjects !== props.xoObjects
) {
const {
options,
xoObjectsById
} = this._computeOptions(newProps)
const value = this._getValue(xoObjectsById, newProps)
this.setState({
options,
value: this._setValue(value, newProps),
xoObjectsById
})
}
if (value !== props.value) {
this.setState({
value: this._setValue(value, newProps)
})
}
}
_computeOptions ({ xoContainers, xoObjects }) {
if (!xoContainers) {
if (process.env.NODE_ENV !== 'production') {
if (!Array.isArray(xoObjects)) {
throw new Error('without xoContainers, xoObjects must be an array')
const values = this._getSelectValue()
const objectsById = this._getObjectsById()
const addIfMissing = val => {
if (val && !objectsById[val]) {
options.push({
disabled: true,
id: val,
label: val,
value: val,
xoItem: {
id: val,
removed: true
}
})
}
}
return {
xoObjectsById: keyBy(xoObjects, 'id'),
options: map(xoObjects, object => ({
label: getLabel(object),
value: object.id,
xoItem: object
}))
if (isArray(values)) {
forEach(values, addIfMissing)
} else {
addIfMissing(values)
}
return options
}
)
if (process.env.NODE_ENV !== 'production') {
if (Array.isArray(xoObjects)) {
throw new Error('with xoContainers, xoObjects must be an object')
}
}
_getSelectValue = createSelector(
() => this.props.value,
createCollectionWrapper(getIds)
)
const options = []
const xoObjectsById = {}
_getNewSelectedObjects = createSelector(
this._getObjectsById,
value => value,
(objectsById, value) => value == null
? value
: isArray(value)
? map(value, value => objectsById[value.value])
: objectsById[value.value]
)
forEach(xoContainers, container => {
const containerObjects = keyBy(xoObjects[container.id], 'id')
assign(xoObjectsById, containerObjects)
options.push({
disabled: true,
xoItem: container
})
options.push.apply(options, map(containerObjects, object => ({
label: `${getLabel(object)} ${getLabel(container)}`,
value: object.id,
xoItem: object
})))
})
return { xoObjectsById, options }
}
get value () {
return this._getValue()
}
set value (value) {
this.setState({
value: this._setValue(value)
})
}
_handleChange = value => {
_onChange = value => {
const { onChange } = this.props
if (onChange) {
onChange(this._getNewSelectedObjects(value))
}
}
this.setState({
value: this._setValue(value)
}, onChange && (() => { onChange(this.value) }))
_selectAll = () => {
this._onChange(
filter(this._getOptions(), ({ disabled }) => !disabled)
)
}
// GroupBy: Display option with margin if not disabled and containers exists.
_renderOption = option => (
_renderOption = option =>
<span
className={classNames(
!option.disabled && this.props.xoContainers && 'm-l-1'
!option.disabled && this.props.xoContainers && 'ml-1'
)}
>
{renderXoItem(option.xoItem)}
</span>
)
render () {
const { props, state } = this
const {
autoFocus,
disabled,
hasSelectAll,
multi,
placeholder,
required,
return (
<Select
autofocus={props.autoFocus}
clearable={props.clearable}
disabled={props.disabled}
multi={props.multi}
onChange={this._handleChange}
openOnFocus
optionRenderer={this._renderOption}
options={state.options}
placeholder={props.placeholder}
required={props.required}
value={state.value}
valueRenderer={this._renderOption}
/>
)
clearable = Boolean(multi || !required)
} = this.props
const select = <Select
{...{
autofocus: autoFocus,
clearable,
disabled,
multi,
placeholder,
required
}}
onChange={this._onChange}
openOnFocus
optionRenderer={this._renderOption}
options={this._getOptions()}
value={this._getSelectValue()}
valueRenderer={this._renderOption}
/>
if (!multi || !hasSelectAll) {
return select
}
// `hasSelectAll` should be provided by react-select after this pull request has been merged:
// https://github.com/JedWatson/react-select/pull/748
// TODO: remove once it has been merged upstream.
return <div className='input-group'>
{select}
<span className='input-group-btn'>
<Tooltip content={_('selectAll')}>
<Button onClick={this._selectAll} style={ADDON_BUTTON_STYLE}>
<Icon icon='add' />
</Button>
</Tooltip>
</span>
</div>
}
}
const makeStoreSelect = (createSelectors, props) => connectStore(
createSelectors,
{ withRef: true }
)(
class extends Component {
get value () {
return this.refs.select.value
}
set value (value) {
this.refs.select.value = value
}
render () {
return (
<GenericSelect
ref='select'
{...props}
{...this.props}
/>
)
}
}
const makeStoreSelect = (createSelectors, defaultProps) => uncontrollableInput(options)(
connectStore(createSelectors)(
props =>
<GenericSelect
{...defaultProps}
{...props}
/>
)
)
const makeSubscriptionSelect = (subscribe, props) => (
const makeSubscriptionSelect = (subscribe, props) => uncontrollableInput(options)(
class extends Component {
constructor (props) {
super(props)
this.state = {
xoObjects: []
}
this._getFilteredXoObjects = createFilter(
() => this.state.xoObjects,
() => this.props.predicate
this._getFilteredXoContainers = createFilter(
() => this.state.xoContainers,
() => this.props.containerPredicate
)
}
get value () {
return this.refs.select.value
}
set value (value) {
this.refs.select.value = value
this._getFilteredXoObjects = createSelector(
() => this.state.xoObjects,
() => this.state.xoContainers && this._getFilteredXoContainers(),
() => this.props.predicate,
(xoObjects, xoContainers, predicate) => {
if (xoContainers == null) {
return filter(xoObjects, predicate)
} else {
// Filter xoObjects with `predicate`...
const filteredObjects = mapValues(xoObjects, xoObjectsGroup =>
filter(xoObjectsGroup, predicate)
)
// ...and keep only those whose xoContainer hasn't been filtered out
return pick(filteredObjects, map(xoContainers, container => container.id))
}
}
)
}
componentWillMount () {
@@ -289,11 +333,10 @@ const makeSubscriptionSelect = (subscribe, props) => (
render () {
return (
<GenericSelect
ref='select'
{...props}
{...this.props}
xoObjects={this._getFilteredXoObjects()}
xoContainers={this.state.xoContainers}
xoContainers={this.state.xoContainers && this._getFilteredXoContainers()}
/>
)
}
@@ -416,7 +459,7 @@ export const SelectVmTemplate = makeStoreSelect(() => {
xoObjects: getVmTemplatesByPool,
xoContainers: getPools
}
}, { placeholder: _('selectVms') })
}, { placeholder: _('selectVmTemplates') })
// ===================================================================
@@ -470,11 +513,11 @@ export const SelectTag = makeStoreSelect((_, props) => ({
}), { placeholder: _('selectTags') })
export const SelectHighLevelObject = makeStoreSelect(() => {
const getHosts = createGetObjectsOfType('host')
const getNetworks = createGetObjectsOfType('network')
const getPools = createGetObjectsOfType('pool')
const getSrs = createGetObjectsOfType('SR')
const getVms = createGetObjectsOfType('VM')
const getHosts = createGetObjectsOfType('host').filter(getPredicate)
const getNetworks = createGetObjectsOfType('network').filter(getPredicate)
const getPools = createGetObjectsOfType('pool').filter(getPredicate)
const getSrs = createGetObjectsOfType('SR').filter(getPredicate)
const getVms = createGetObjectsOfType('VM').filter(getPredicate)
const getHighLevelObjects = createSelector(
getHosts,
@@ -582,3 +625,295 @@ export const SelectRemote = makeSubscriptionSelect(subscriber => {
return unsubscribeRemotes
}, { placeholder: _('selectRemotes') })
// ===================================================================
export const SelectResourceSet = makeSubscriptionSelect(subscriber => {
const unsubscribeResourceSets = subscribeResourceSets(resourceSets => {
const xoObjects = map(sortBy(resolveResourceSets(resourceSets), 'name'), resourceSet => ({...resourceSet, type: 'resourceSet'}))
subscriber({xoObjects})
})
return unsubscribeResourceSets
}, { placeholder: _('selectResourceSets') })
// ===================================================================
export class SelectResourceSetsVmTemplate extends Component {
get value () {
return this.refs.select.value
}
set value (value) {
this.refs.select.value = value
}
_getTemplates = createSelector(
() => this.props.resourceSet,
({ objectsByType }) => {
const { predicate } = this.props
const templates = objectsByType['VM-template']
return sortBy(predicate ? filter(templates, predicate) : templates, 'name_label')
}
)
render () {
return (
<GenericSelect
ref='select'
placeholder={_('selectResourceSetsVmTemplate')}
{...this.props}
xoObjects={this._getTemplates()}
/>
)
}
}
// ===================================================================
export class SelectResourceSetsSr extends Component {
get value () {
return this.refs.select.value
}
set value (value) {
this.refs.select.value = value
}
_getSrs = createSelector(
() => this.props.resourceSet,
({ objectsByType }) => {
const { predicate } = this.props
const srs = objectsByType['SR']
return sortBy(predicate ? filter(srs, predicate) : srs, 'name_label')
}
)
render () {
return (
<GenericSelect
ref='select'
placeholder={_('selectResourceSetsSr')}
{...this.props}
xoObjects={this._getSrs()}
/>
)
}
}
// ===================================================================
export class SelectResourceSetsVdi extends Component {
get value () {
return this.refs.select.value
}
set value (value) {
this.refs.select.value = value
}
_getObject (id) {
return getObject(store.getState(), id, true)
}
_getSrs = createSelector(
() => this.props.resourceSet,
({ objectsByType }) => {
const { srPredicate } = this.props
const srs = objectsByType['SR']
return srPredicate ? filter(srs, srPredicate) : srs
}
)
_getVdis = createSelector(
this._getSrs,
srs => sortBy(map(flatten(map(srs, sr => sr.VDIs)), this._getObject), 'name_label')
)
render () {
return (
<GenericSelect
ref='select'
placeholder={_('selectResourceSetsVdi')}
{...this.props}
xoObjects={this._getVdis()}
/>
)
}
}
// ===================================================================
export class SelectResourceSetsNetwork extends Component {
get value () {
return this.refs.select.value
}
set value (value) {
this.refs.select.value = value
}
_getNetworks = createSelector(
() => this.props.resourceSet,
({ objectsByType }) => {
const { predicate } = this.props
const networks = objectsByType['network']
return sortBy(predicate ? filter(networks, predicate) : networks, 'name_label')
}
)
render () {
return (
<GenericSelect
ref='select'
placeholder={_('selectResourceSetsNetwork')}
{...this.props}
xoObjects={this._getNetworks()}
/>
)
}
}
// ===================================================================
// Pass a function to @addSubscriptions to ensure subscribeIpPools and subscribeResourceSets
// are correctly imported before they are called
@addSubscriptions(() => ({
ipPools: subscribeIpPools,
resourceSets: subscribeResourceSets
}))
@propTypes({
containerPredicate: propTypes.func,
predicate: propTypes.func,
resourceSetId: propTypes.string.isRequired
})
export class SelectResourceSetIp extends Component {
get value () {
return this.refs.select.value
}
set value (value) {
this.refs.select.value = value
}
_getResourceSetIpPools = createSelector(
() => this.props.ipPools,
() => this.props.resourceSets,
() => this.props.resourceSetId,
(allIpPools, allResourceSets, resourceSetId) => {
const { ipPools } = allResourceSets[resourceSetId]
return filter(allIpPools, ({ id }) => includes(ipPools, id))
}
)
_getIpPools = createSelector(
() => this.props.ipPools,
() => this.props.containerPredicate,
(ipPools, predicate) => predicate
? filter(ipPools, predicate)
: ipPools
)
_getIps = createSelector(
this._getIpPools,
() => this.props.predicate,
() => this.props.ipPools,
(ipPools, predicate, resolvedIpPools) => {
return flatten(
map(ipPools, ipPool => {
const poolIps = map(ipPool.addresses, (address, ip) => ({
...address,
id: ip,
label: ip,
type: 'ipAddress',
used: !isEmpty(address.vifs)
}))
return predicate ? filter(poolIps, predicate) : poolIps
})
)
}
)
render () {
return (
<GenericSelect
ref='select'
placeholder={_('selectIpPool')}
{...this.props}
xoObjects={this._getIps()}
/>
)
}
}
// ===================================================================
export class SelectSshKey extends Component {
get value () {
return this.refs.select.value
}
set value (value) {
this.refs.select.value = value
}
componentWillMount () {
this.componentWillUnmount = subscribeCurrentUser(user => {
this.setState({
sshKeys: user && user.preferences && map(user.preferences.sshKeys, (key, id) => ({
id,
label: key.title,
type: 'sshKey'
}))
})
})
}
render () {
return (
<GenericSelect
ref='select'
placeholder={_('selectSshKey')}
{...this.props}
xoObjects={this.state.sshKeys || []}
/>
)
}
}
// ===================================================================
export const SelectIp = makeSubscriptionSelect(subscriber => {
const unsubscribeIpPools = subscribeIpPools(ipPools => {
const sortedIpPools = sortBy(ipPools, 'name')
const xoObjects = mapValues(
groupBy(sortedIpPools, 'id'),
ipPools => map(ipPools[0].addresses, (address, ip) => ({
...address,
id: ip,
label: ip,
type: 'ipAddress',
used: !isEmpty(address.vifs)
}))
)
const xoContainers = map(sortedIpPools, ipPool => ({
...ipPool,
type: 'ipPool'
}))
subscriber({ xoObjects, xoContainers })
})
return unsubscribeIpPools
}, { placeholder: _('selectIp') })
// ===================================================================
export const SelectIpPool = makeSubscriptionSelect(subscriber => {
const unsubscribeIpPools = subscribeIpPools(ipPools => {
subscriber({
xoObjects: map(sortBy(ipPools, 'name'), ipPool => ({ ...ipPool, type: 'ipPool' }))
})
})
return unsubscribeIpPools
}, { placeholder: _('selectIpPool') })

View File

@@ -1,20 +1,25 @@
import add from 'lodash/add'
import checkPermissions from 'xo-acl-resolver'
import filter from 'lodash/filter'
import find from 'lodash/find'
import forEach from 'lodash/forEach'
import groupBy from 'lodash/groupBy'
import isArray from 'lodash/isArray'
import isArrayLike from 'lodash/isArrayLike'
import isFunction from 'lodash/isFunction'
import keys from 'lodash/keys'
import orderBy from 'lodash/orderBy'
import pickBy from 'lodash/pickBy'
import size from 'lodash/size'
import slice from 'lodash/slice'
import { createSelector as create } from 'reselect'
import {
filter,
find,
forEach,
groupBy,
isArray,
isArrayLike,
isFunction,
keys,
map,
orderBy,
pickBy,
size,
slice
} from 'lodash'
import invoke from './invoke'
import shallowEqual from './shallow-equal'
import { EMPTY_ARRAY, EMPTY_OBJECT, invoke } from './utils'
import { EMPTY_ARRAY, EMPTY_OBJECT } from './utils'
// ===================================================================
@@ -35,12 +40,16 @@ export {
// Use case: in connect, to avoid rerendering a component where the
// objects are still the same.
const _createCollectionWrapper = selector => {
let cache
let cache, previous
return (...args) => {
const value = selector(...args)
if (!shallowEqual(value, cache)) {
cache = value
if (value !== previous) {
previous = value
if (!shallowEqual(value, cache)) {
cache = value
}
}
return cache
}
@@ -120,9 +129,9 @@ export const createCounter = (collection, predicate) =>
//
// Should only be used with a reasonable number of properties.
export const createPicker = (object, props) =>
_createCollectionWrapper(
_create2(
object, props,
_create2(
object, props,
_createCollectionWrapper(
(object, props) => {
const values = {}
forEach(props, prop => {
@@ -140,10 +149,10 @@ export const createPicker = (object, props) =>
// - predicate == null → no filtering
// - predicate === false → everything is filtered out
export const createFilter = (collection, predicate) =>
_createCollectionWrapper(
_create2(
collection,
predicate,
_create2(
collection,
predicate,
_createCollectionWrapper(
(collection, predicate) => predicate === false
? (isArrayLike(collection) ? EMPTY_ARRAY : EMPTY_OBJECT)
: predicate
@@ -166,17 +175,18 @@ export const createGroupBy = (collection, getter) =>
groupBy
)
export const createPager = (array, page, n = 25) => _createCollectionWrapper(
export const createPager = (array, page, n = 25) =>
_create2(
array,
page,
n,
(array, page, n) => {
const start = (page - 1) * n
return slice(array, start, start + n)
}
_createCollectionWrapper(
(array, page, n) => {
const start = (page - 1) * n
return slice(array, start, start + n)
}
)
)
)
export const createSort = (
collection,
@@ -184,12 +194,19 @@ export const createSort = (
order = 'asc'
) => _create2(collection, getter, order, orderBy)
export const createSumBy = (itemsSelector, iterateeSelector) =>
_create2(
itemsSelector,
iterateeSelector,
(items, iteratee) => map(items, iteratee).reduce(add, 0)
)
export const createTop = (collection, iteratee, n) =>
_createCollectionWrapper(
_create2(
collection,
iteratee,
n,
_create2(
collection,
iteratee,
n,
_createCollectionWrapper(
(objects, iteratee, n) => {
let results = orderBy(objects, iteratee, 'desc')
if (n < results.length) {
@@ -211,8 +228,40 @@ const _getId = (state, { routeParams, id }) => routeParams
export const getLang = state => state.lang
export const getStatus = state => state.status
export const getUser = state => state.user
export const getCheckPermissions = invoke(() => {
const getPredicate = create(
state => state.permissions,
state => state.objects,
(permissions, objects) => {
objects = objects.all
const getObject = id => (objects[id] || EMPTY_OBJECT)
return (id, permission) => checkPermissions(permissions, getObject, id, permission)
}
)
const isTrue = () => true
const isFalse = () => false
return state => {
const user = getUser(state)
if (!user) {
return isFalse
}
if (user.permission === 'admin') {
return isTrue
}
return getPredicate(state)
}
})
const _getPermissionsPredicate = invoke(() => {
const getPredicate = create(
state => state.permissions,
@@ -239,18 +288,29 @@ const _getPermissionsPredicate = invoke(() => {
}
})
export const isAdmin = (...args) => {
const user = getUser(...args)
return user && user.permission === 'admin'
}
// ===================================================================
// Common selector creators.
// Creates an object selector from an id selector.
export const createGetObject = (idSelector = _getId) =>
(state, props) => {
(state, props, useResourceSet) => {
const object = state.objects.all[idSelector(state, props)]
if (!object) {
return
}
if (useResourceSet) {
return object
}
const predicate = _getPermissionsPredicate(state)
if (!predicate) {
if (predicate == null) {
return object // no filtering
@@ -297,7 +357,7 @@ export const createSortForType = invoke(() => {
return (type, collection) => createSort(
collection,
autoSelector(type, getIteratees),
autoSelector(type, getOrders),
autoSelector(type, getOrders)
)
})
@@ -314,7 +374,11 @@ const _extendCollectionSelector = (selector, objectsType) => {
return selector
}
_addGroupBy(selector)
selector.find = predicate => createFinder(selector, predicate)
const _addFind = selector => {
selector.find = predicate => createFinder(selector, predicate)
return selector
}
_addFind(selector)
// groupBy can be chained.
const _addSort = selector => {
@@ -324,15 +388,19 @@ const _extendCollectionSelector = (selector, objectsType) => {
}
_addSort(selector)
// groupBy and sort can be chained.
selector.pick = idsSelector => _addGroupBy(_addSort(
createPicker(selector, idsSelector)
))
// count, groupBy and sort can be chained.
selector.filter = predicate => _addCount(_addGroupBy(_addSort(
createFilter(selector, predicate)
)))
const _addFilter = selector => {
selector.filter = predicate => _addCount(_addGroupBy(_addSort(
createFilter(selector, predicate)
)))
return selector
}
_addFilter(selector)
// filter, groupBy and sort can be chained.
selector.pick = idsSelector => _addFind(_addFilter(_addGroupBy(_addSort(
createPicker(selector, idsSelector)
))))
return selector
}
@@ -350,7 +418,7 @@ const _extendCollectionSelector = (selector, objectsType) => {
// - groupBy: returns a selector which returns the objects grouped by
// a value determined by a getter selector
// - pick: returns a selector which returns only the objects with given
// ids (groupBy and sort can be chained)
// ids (filter, find, groupBy and sort can be chained)
// - sort: returns a selector which returns the objects appropriately
// sorted (groupBy can be chained)
export const createGetObjectsOfType = type => {
@@ -390,6 +458,24 @@ export const createGetTags = collectionSelectors => {
return _extendCollectionSelector(getTags, 'tag')
}
export const createGetVmLastShutdownTime = (getVmId = (_, {vm}) => vm != null ? vm.id : undefined) => create(
getVmId,
createGetObjectsOfType('message'),
(vmId, messages) => {
let max = null
forEach(messages, message => {
if (
message.$object === vmId &&
message.name === 'VM_SHUTDOWN' &&
(max === null || message.time > max)
) {
max = message.time
}
})
return max
}
)
export const createGetObjectMessages = objectSelector =>
createGetObjectsOfType('message').filter(
create(
@@ -403,3 +489,70 @@ export const createGetObjectMessages = objectSelector =>
// const object = getObject(store.getState(), objectId)
// ...
export const getObject = createGetObject((_, id) => id)
export const createDoesHostNeedRestart = hostSelector => {
// XS < 7.1
const patchRequiresReboot = createGetObjectsOfType('pool_patch').pick(
// Returns the first patch of the host which requires it to be
// restarted.
create(
createGetObjectsOfType('host_patch').pick(
(state, props) => {
const host = hostSelector(state, props)
return host && host.patches
}
).filter(create(
(state, props) => {
const host = hostSelector(state, props)
return host && host.startTime
},
startTime => patch => patch.time > startTime
)),
hostPatches => map(hostPatches, hostPatch => hostPatch.pool_patch)
)
).find([ ({ guidance }) => find(guidance, action =>
action === 'restartHost' || action === 'restartXapi'
) ])
return create(
hostSelector,
(...args) => args,
(host, args) => host.rebootRequired || !!patchRequiresReboot(...args)
)
}
export const createGetHostMetrics = hostSelector =>
create(
hostSelector,
_createCollectionWrapper(
hosts => {
const metrics = {
count: 0,
cpus: 0,
memoryTotal: 0,
memoryUsage: 0
}
forEach(hosts, host => {
metrics.count++
metrics.cpus += host.cpus.cores
metrics.memoryTotal += host.memory.size
metrics.memoryUsage += host.memory.usage
})
return metrics
}
)
)
export const createGetVmDisks = vmSelector =>
createGetObjectsOfType('VDI').pick(
create(
createGetObjectsOfType('VBD').pick(
(state, props) => vmSelector(state, props).$VBDs
),
_createCollectionWrapper(vbds => map(vbds, vbd =>
vbd.is_cd_drive
? undefined
: vbd.VDI
))
)
)

View File

@@ -1,3 +1,5 @@
import kindOf from 'kindof'
// Tests that two collections (arrays or objects) have strictly equals
// values (items or properties)
const shallowEqual = (c1, c2) => {
@@ -5,8 +7,8 @@ const shallowEqual = (c1, c2) => {
return true
}
const type = typeof c1
if (type !== typeof c2) {
const type = kindOf(c1)
if (type !== kindOf(c2)) {
return false
}
@@ -25,6 +27,10 @@ const shallowEqual = (c1, c2) => {
return true
}
if (type !== 'object') {
return false
}
let n = 0
for (const _ in c2) { // eslint-disable-line no-unused-vars
++n

35
src/common/shortcuts.js Normal file
View File

@@ -0,0 +1,35 @@
import Component from 'base-component'
import forEach from 'lodash/forEach'
import React from 'react'
import remove from 'lodash/remove'
import { Shortcuts as ReactShortcuts } from 'react-shortcuts'
let enabled = true
const instances = []
const updateInstances = () => {
forEach(instances, instance => instance.forceUpdate())
}
export const enable = () => {
enabled = true
updateInstances()
}
export const disable = () => {
enabled = false
updateInstances()
}
export default class Shortcuts extends Component {
componentDidMount () {
instances.push(this)
}
componentWillUnmount () {
remove(instances, this)
}
render () {
return enabled ? <ReactShortcuts {...this.props} /> : null
}
}

View File

@@ -1,8 +1,9 @@
import React, { cloneElement } from 'react'
import { propTypes } from 'utils'
import propTypes from './prop-types-decorator'
const SINGLE_LINE_STYLE = { display: 'flex' }
const COL_STYLE = { margin: 'auto' }
const COL_STYLE = { marginTop: 'auto', marginBottom: 'auto' }
const SingleLineRow = propTypes({
className: propTypes.string

View File

@@ -1,8 +1,12 @@
.clickableColumn {
cursor: pointer;
cursor: pointer;
}
.clickableColumn:hover {
color: #fff;
background-color: #96b8d1;
color: #fff;
background-color: #96b8d1;
}
.clickableRow {
cursor: pointer;
}

View File

@@ -1,17 +1,27 @@
import Component from 'base-component'
import Icon from 'icon'
import React from 'react'
import SingleLineRow from 'single-line-row'
import _ from 'intl'
import ceil from 'lodash/ceil'
import classNames from 'classnames'
import debounce from 'lodash/debounce'
import findIndex from 'lodash/findIndex'
import isEmpty from 'lodash/isEmpty'
import isFunction from 'lodash/isFunction'
import map from 'lodash/map'
import { Pagination } from 'react-bootstrap-4/lib'
import React from 'react'
import { Dropdown, MenuItem, Pagination } from 'react-bootstrap-4/lib'
import DropdownMenu from 'react-bootstrap-4/lib/DropdownMenu' // https://phabricator.babeljs.io/T6662 so Dropdown.Menu won't work like https://react-bootstrap.github.io/components.html#btn-dropdowns-custom
import DropdownToggle from 'react-bootstrap-4/lib/DropdownToggle' // https://phabricator.babeljs.io/T6662 so Dropdown.Toggle won't work https://react-bootstrap.github.io/components.html#btn-dropdowns-custom
import { Portal } from 'react-overlays'
import { Container, Col } from 'grid'
import { create as createMatcher } from 'complex-matcher'
import { propTypes } from 'utils'
import Button from '../button'
import Component from '../base-component'
import Icon from '../icon'
import propTypes from '../prop-types-decorator'
import SingleLineRow from '../single-line-row'
import { BlockLink } from '../link'
import { Container, Col } from '../grid'
import { create as createMatcher } from '../complex-matcher'
import {
createCounter,
createFilter,
createPager,
createSelector,
@@ -23,14 +33,20 @@ import styles from './index.css'
// ===================================================================
@propTypes({
defaultFilter: propTypes.string,
filters: propTypes.object,
nFilteredItems: propTypes.number.isRequired,
nItems: propTypes.number.isRequired,
onChange: propTypes.func.isRequired
})
class TableFilter extends Component {
_cleanFilter = () => {
_cleanFilter = () => this._setFilter('')
_setFilter = filterValue => {
const { filter } = this.refs
filter.value = ''
filter.value = filterValue
filter.focus()
this.props.onChange('')
this.props.onChange(filterValue)
}
_onChange = event => {
@@ -38,19 +54,37 @@ class TableFilter extends Component {
}
render () {
const { props } = this
return (
<div className='input-group'>
<span className='input-group-addon'><Icon icon='search' /></span>
<span className='input-group-addon'>{props.nFilteredItems} / {props.nItems}</span>
{isEmpty(props.filters)
? <span className='input-group-addon'><Icon icon='search' /></span>
: <div className='input-group-btn'>
<Dropdown id='filter'>
<DropdownToggle bsStyle='info'>
<Icon icon='search' />
</DropdownToggle>
<DropdownMenu>
{map(props.filters, (filter, label) =>
<MenuItem key={label} onClick={() => this._setFilter(filter)}>
{_(label)}
</MenuItem>
)}
</DropdownMenu>
</Dropdown>
</div>}
<input
type='text'
ref='filter'
onChange={this._onChange}
className='form-control'
defaultValue={props.defaultFilter}
onChange={this._onChange}
ref='filter'
/>
<div className='input-group-btn'>
<button className='btn btn-secondary' onClick={this._cleanFilter}>
<Button onClick={this._cleanFilter}>
<Icon icon='clear-search' />
</button>
</Button>
</div>
</div>
)
@@ -61,7 +95,7 @@ class TableFilter extends Component {
@propTypes({
columnId: propTypes.number.isRequired,
name: propTypes.any.isRequired,
name: propTypes.node,
sort: propTypes.func,
sortIcon: propTypes.string
})
@@ -72,25 +106,25 @@ class ColumnHead extends Component {
}
render () {
const { name, sortIcon } = this.props
const { name, sortIcon, textAlign } = this.props
if (!this.props.sort) {
return <th>{name}</th>
return <th className={textAlign && `text-xs-${textAlign}`}>{name}</th>
}
let className = styles.clickableColumn
if (sortIcon === 'asc' || sortIcon === 'desc') {
className += ' bg-info'
}
const isSelected = sortIcon === 'asc' || sortIcon === 'desc'
return (
<th
className={className}
className={classNames(
textAlign && `text-xs-${textAlign}`,
styles.clickableColumn,
isSelected && classNames('text-white', 'bg-info')
)}
onClick={this._sort}
>
{name}
<span className='pull-xs-right'>
<span className='pull-right'>
<Icon icon={sortIcon} />
</span>
</th>
@@ -104,45 +138,78 @@ const DEFAULT_ITEMS_PER_PAGE = 10
@propTypes({
defaultColumn: propTypes.number,
defaultFilter: propTypes.string,
collection: propTypes.oneOfType([
propTypes.array,
propTypes.object
]).isRequired,
columns: propTypes.arrayOf(propTypes.shape({
name: propTypes.node.isRequired,
itemRenderer: propTypes.func.isRequired,
component: propTypes.func,
default: propTypes.bool,
name: propTypes.node,
itemRenderer: propTypes.func,
sortCriteria: propTypes.oneOfType([
propTypes.func,
propTypes.string
]),
sortOrder: propTypes.string
sortOrder: propTypes.string,
textAlign: propTypes.string
})).isRequired,
filterContainer: propTypes.func,
filters: propTypes.object,
itemsPerPage: propTypes.number,
paginationContainer: propTypes.func,
rowAction: propTypes.func,
rowLink: propTypes.oneOfType([
propTypes.func,
propTypes.string
]),
userData: propTypes.any
})
export default class SortedTable extends Component {
constructor (props) {
super(props)
let selectedColumn = props.defaultColumn
if (selectedColumn == null) {
selectedColumn = findIndex(props.columns, 'default')
if (selectedColumn === -1) {
selectedColumn = 0
}
}
const { defaultFilter } = props
this.state = {
selectedColumn: props.defaultColumn || 0,
filter: defaultFilter !== undefined ? props.filters[defaultFilter] : undefined,
selectedColumn,
itemsPerPage: props.itemsPerPage || DEFAULT_ITEMS_PER_PAGE
}
this._getSelectedColumn = () =>
this.props.columns[this.state.selectedColumn]
this._getTotalNumberOfItems = createCounter(
() => this.props.collection
)
this._getAllItems = createSort(
createFilter(
() => this.props.collection,
createSelector(
() => this.state.filter || '',
() => this.state.filter,
createMatcher
)
),
() => this._getSelectedColumn().sortCriteria,
createSelector(
() => this._getSelectedColumn().sortCriteria,
() => this.props.userData,
(sortCriteria, userData) =>
(typeof sortCriteria === 'function')
? object => sortCriteria(object, userData)
: sortCriteria
),
() => this.state.sortOrder
)
@@ -156,7 +223,9 @@ export default class SortedTable extends Component {
}
componentWillMount () {
this._sort(this.state.selectedColumn)
this.setState({
sortOrder: this.props.columns[this.state.selectedColumn].sortOrder === 'desc' ? 'desc' : 'asc'
})
}
componentDidMount () {
@@ -203,9 +272,14 @@ export default class SortedTable extends Component {
const {
paginationContainer,
filterContainer,
filters,
rowAction,
rowLink,
userData
} = props
const nFilteredItems = this._getAllItems().length
const paginationInstance = (
<Pagination
first
@@ -215,14 +289,20 @@ export default class SortedTable extends Component {
ellipsis
boundaryLinks
maxButtons={10}
items={ceil(this._getAllItems().length / state.itemsPerPage)}
items={ceil(nFilteredItems / state.itemsPerPage)}
activePage={this.state.activePage}
onSelect={this._onPageSelection}
/>
)
const filterInstance = (
<TableFilter onChange={this._onFilterChange} />
<TableFilter
defaultFilter={state.filter}
filters={filters}
nFilteredItems={nFilteredItems}
nItems={this._getTotalNumberOfItems()}
onChange={this._onFilterChange}
/>
)
return (
@@ -232,7 +312,9 @@ export default class SortedTable extends Component {
<tr>
{map(props.columns, (column, key) => (
<ColumnHead
textAlign={column.textAlign}
columnId={key}
key={key}
name={column.name}
sort={column.sortCriteria && this._sort}
@@ -242,15 +324,39 @@ export default class SortedTable extends Component {
</tr>
</thead>
<tbody>
{map(this._getVisibleItems(), (item, key) => (
<tr key={key}>
{map(props.columns, (column, key) => (
<td key={key}>
{column.itemRenderer(item, userData)}
</td>
))}
</tr>
))}
{map(this._getVisibleItems(), (item, i) => {
const columns = map(props.columns, ({
component: Component,
itemRenderer,
textAlign
}, key) =>
<td
className={textAlign && `text-xs-${textAlign}`}
key={key}
>
{Component !== undefined
? <Component item={item} userData={userData} />
: itemRenderer(item, userData)
}
</td>
)
const { id = i } = item
return rowLink
? <BlockLink
key={id}
tagName='tr'
to={isFunction(rowLink) ? rowLink(item, userData) : rowLink}
>{columns}</BlockLink>
: <tr
className={rowAction && styles.clickableRow}
key={id}
onClick={rowAction && (() => rowAction(item, userData))}
>
{columns}
</tr>
})}
</tbody>
</table>
{(!paginationContainer || !filterContainer) && (
@@ -259,19 +365,19 @@ export default class SortedTable extends Component {
<Col mediumSize={8}>
{paginationContainer
? (
// Rebuild container function to refresh Portal component.
<Portal container={() => paginationContainer()}>
{paginationInstance}
</Portal>
// Rebuild container function to refresh Portal component.
<Portal container={() => paginationContainer()}>
{paginationInstance}
</Portal>
) : paginationInstance
}
</Col>
<Col mediumSize={4}>
{filterContainer
? (
<Portal container={() => filterContainer()}>
{filterInstance}
</Portal>
<Portal container={() => filterContainer()}>
{filterInstance}
</Portal>
) : filterInstance
}
</Col>

View File

@@ -0,0 +1,41 @@
import React from 'react'
import styled from 'styled-components'
import ActionButton from './action-button'
import propTypes from './prop-types-decorator'
const Button = styled(ActionButton)`
background-color: ${p => p.theme[`${p.state ? 'enabled' : 'disabled'}StateBg`]};
border: 2px solid ${p => p.theme[`${p.state ? 'enabled' : 'disabled'}StateColor`]};
color: ${p => p.theme[`${p.state ? 'enabled' : 'disabled'}StateColor`]};
`
const StateButton = ({
disabledHandler,
disabledHandlerParam,
disabledLabel,
disabledTooltip,
enabledLabel,
enabledTooltip,
enabledHandler,
enabledHandlerParam,
state,
...props
}) =>
<Button
handler={state ? enabledHandler : disabledHandler}
handlerParam={state ? enabledHandlerParam : disabledHandlerParam}
tooltip={state ? enabledTooltip : disabledTooltip}
{...props}
icon={state ? 'running' : 'halted'}
size='small'
state={state}
>
{state ? enabledLabel : disabledLabel}
</Button>
export default propTypes({
state: propTypes.bool.isRequired
})(StateButton)

View File

@@ -1,33 +1,22 @@
import isFunction from 'lodash/isFunction'
// ===================================================================
const createAction = (() => {
const { defineProperty } = Object
const noop = function () {
if (arguments.length) {
throw new Error('this action expects no payload!')
}
}
return (type, payloadCreator = noop) => {
const createActionObject = payload => {
// Thunks
if (isFunction(payload)) {
return payload
}
return (type, payloadCreator) => defineProperty(
payloadCreator
? (...args) => ({
type,
payload: payloadCreator(...args)
})
: (action => function () {
if (arguments.length) {
throw new Error('this action expects no payload!')
}
return payload === undefined
? { type }
: { type, payload }
}
return defineProperty(
(...args) => createActionObject(payloadCreator(...args)),
'toString',
{ value: () => type }
)
}
return action
})({ type }),
'toString',
{ value: () => type }
)
})()
// ===================================================================

View File

@@ -102,16 +102,20 @@ export default {
for (const id in updates) {
const object = updates[id]
const previous = all[id]
if (object) {
const { type } = object
all[id] = object
get(object.type)[id] = object
} else {
const previous = all[id]
if (previous) {
delete all[id]
get(type)[id] = object
if (previous && previous.type !== type) {
delete get(previous.type)[id]
}
} else if (previous) {
delete all[id]
delete get(previous.type)[id]
}
}

View File

@@ -1,8 +1,9 @@
import _ from 'intl'
import ActionButton from 'action-button'
import Icon from 'icon'
import React from 'react'
import { Link } from 'react-router'
import _ from './intl'
import ActionButton from './action-button'
import Icon from './icon'
import Link from './link'
const STYLE = {
marginBottom: '1em',

View File

@@ -1,14 +1,44 @@
import React from 'react'
import Icon from 'icon'
import filter from 'lodash/filter'
import includes from 'lodash/includes'
import map from 'lodash/map'
import React from 'react'
import Component from './base-component'
import { propTypes } from './utils'
import Icon from './icon'
import propTypes from './prop-types-decorator'
const INPUT_STYLE = {
margin: '2px',
maxWidth: '4em'
}
const TAG_STYLE = {
backgroundColor: '#2598d9',
borderRadius: '0.5em',
color: 'white',
fontSize: '0.6em',
margin: '0.2em',
marginTop: '-0.1em',
padding: '0.3em',
verticalAlign: 'middle'
}
const LINK_STYLE = {
cursor: 'pointer'
}
const ADD_TAG_STYLE = {
cursor: 'pointer',
fontSize: '0.8em',
marginLeft: '0.2em'
}
const REMOVE_TAG_STYLE = {
cursor: 'pointer'
}
@propTypes({
labels: propTypes.arrayOf(React.PropTypes.string).isRequired,
onDelete: propTypes.func,
onAdd: propTypes.func
onAdd: propTypes.func,
onChange: propTypes.func,
onClick: propTypes.func,
onDelete: propTypes.func
})
export default class Tags extends Component {
componentWillMount () {
@@ -22,56 +52,85 @@ export default class Tags extends Component {
this.setState({ editing: false })
}
_addTag = newTag => {
const { labels, onAdd, onChange } = this.props
if (!includes(labels, newTag)) {
onAdd && onAdd(newTag)
onChange && onChange([ ...labels, newTag ])
}
}
_deleteTag = tag => {
const { onChange, onDelete } = this.props
onDelete && onDelete(tag)
onChange && onChange(filter(this.props.labels, t => t !== tag))
}
_onKeyDown = event => {
const { keyCode, target } = event
if (keyCode === 13) {
if (target.value) {
this._addTag(target.value)
target.value = ''
}
} else if (keyCode === 27) {
this._stopEdit()
} else {
return
}
event.preventDefault()
}
render () {
const {
labels,
onDelete,
onAdd
onAdd,
onChange,
onClick,
onDelete
} = this.props
const deleteTag = (onDelete || onChange) && this._deleteTag
return (
<span className='form-group' style={{ color: '#999' }}>
<Icon icon='tags' />
{' '}
<span>
{map(labels.sort(), (label, index) =>
<Tag label={label} onDelete={onDelete} key={index} />
<Tag label={label} onDelete={deleteTag} key={index} onClick={onClick} />
)}
</span>
{onAdd
? !this.state.editing
? <span className='add-tag-action' onClick={this._startEdit} style={{cursor: 'pointer'}}>
<Icon icon='add-tag' />
</span>
: <span>
<input
type='text'
autoFocus
style={{maxWidth: '4em', margin: '2px'}}
onKeyDown={event => {
const { target } = event
if (event.keyCode === 13 && target.value) {
onAdd(target.value)
target.value = ''
} else if (event.keyCode === 27) {
this._stopEdit()
}
}}
onBlur={this._stopEdit}
></input>
</span>
: []
{(onAdd || onChange) && !this.state.editing
? <span onClick={this._startEdit} style={ADD_TAG_STYLE}>
<Icon icon='add-tag' />
</span>
: <span>
<input
type='text'
autoFocus
style={INPUT_STYLE}
onKeyDown={this._onKeyDown}
onBlur={this._stopEdit}
/>
</span>
}
</span>
)
}
}
export const Tag = ({ label, onDelete }) => (
<span className='xo-tag'>
{label}{' '}
export const Tag = ({ type, label, onDelete, onClick }) => (
<span style={TAG_STYLE}>
<span onClick={onClick && (() => onClick(label))} style={onClick && LINK_STYLE}>
{label}
</span>
{' '}
{onDelete
? <span onClick={onDelete && (() => onDelete(label))} style={{cursor: 'pointer'}}>
? <span onClick={onDelete && (() => onDelete(label))} style={REMOVE_TAG_STYLE}>
<Icon icon='remove-tag' />
</span>
: []

View File

View File

@@ -0,0 +1,6 @@
export default {
disabledStateBg: '#fff',
disabledStateColor: '#c0392b',
enabledStateBg: '#fff',
enabledStateColor: '#27ae60'
}

View File

@@ -0,0 +1,93 @@
import ActionButton from 'action-button'
import map from 'lodash/map'
import moment from 'moment-timezone'
import React from 'react'
import _ from './intl'
import Component from './base-component'
import propTypes from './prop-types-decorator'
import { getXoServerTimezone } from './xo'
import { Select } from './form'
const SERVER_TIMEZONE_TAG = 'server'
const LOCAL_TIMEZONE = moment.tz.guess()
@propTypes({
defaultValue: propTypes.string,
onChange: propTypes.func.isRequired,
required: propTypes.bool,
value: propTypes.string
})
export default class TimezonePicker extends Component {
componentDidMount () {
getXoServerTimezone.then(serverTimezone => {
this.setState({
timezone: this.props.value || this.props.defaultValue || SERVER_TIMEZONE_TAG,
options: [
...map(moment.tz.names(), value => ({ label: value, value })),
{
label: _('serverTimezoneOption', {
value: serverTimezone
}),
value: SERVER_TIMEZONE_TAG
}
]
})
})
}
componentWillReceiveProps (props) {
if (props.value !== this.props.value) {
this.setState({ timezone: props.value || SERVER_TIMEZONE_TAG })
}
}
get value () {
return this.state.timezone === SERVER_TIMEZONE_TAG ? null : this.state.timezone
}
set value (value) {
this.setState({ timezone: value || SERVER_TIMEZONE_TAG })
}
_onChange = option => {
if (option && option.value === this.state.timezone) {
return
}
this.setState({
timezone: (option != null && option.value) || SERVER_TIMEZONE_TAG
}, () =>
this.props.onChange(this.state.timezone === SERVER_TIMEZONE_TAG ? null : this.state.timezone)
)
}
_useLocalTime = () => {
this._onChange({ value: LOCAL_TIMEZONE })
}
render () {
const { timezone, options } = this.state
return (
<div>
<Select
className='mb-1'
onChange={this._onChange}
options={options}
placeholder={_('selectTimezone')}
required={this.props.required}
value={timezone}
/>
<div className='pull-right'>
<ActionButton
handler={this._useLocalTime}
icon='time'
>
{_('timezonePickerUseLocalTime')}
</ActionButton>
</div>
</div>
)
}
}

View File

@@ -0,0 +1,287 @@
// Source: https://github.com/wwayne/react-tooltip/blob/master/src/utils/getPosition.js
/**
* Calculate the position of tooltip
*
* @params
* - `e` {Event} the event of current mouse
* - `target` {Element} the currentTarget of the event
* - `node` {DOM} the react-tooltip object
* - `place` {String} top / right / bottom / left
* - `effect` {String} float / solid
* - `offset` {Object} the offset to default position
*
* @return {Object
* - `isNewState` {Bool} required
* - `newState` {Object}
* - `position` {OBject} {left: {Number}, top: {Number}}
*/
export default function (e, target, node, place, effect, offset) {
const tipWidth = node.clientWidth
const tipHeight = node.clientHeight
const {mouseX, mouseY} = getCurrentOffset(e, target, effect)
const defaultOffset = getDefaultPosition(effect, target.clientWidth, target.clientHeight, tipWidth, tipHeight)
const {extraOffsetX, extraOffsetY} = calculateOffset(offset)
const windowWidth = window.innerWidth
const windowHeight = window.innerHeight
const {parentTop, parentLeft} = getParent(target)
// Get the edge offset of the tooltip
const getTipOffsetLeft = (place) => {
const offsetX = defaultOffset[place].l
return mouseX + offsetX + extraOffsetX
}
const getTipOffsetRight = (place) => {
const offsetX = defaultOffset[place].r
return mouseX + offsetX + extraOffsetX
}
const getTipOffsetTop = (place) => {
const offsetY = defaultOffset[place].t
return mouseY + offsetY + extraOffsetY
}
const getTipOffsetBottom = (place) => {
const offsetY = defaultOffset[place].b
return mouseY + offsetY + extraOffsetY
}
// Judge if the tooltip has over the window(screen)
const outsideVertical = () => {
let result = false
let newPlace
if (getTipOffsetTop('left') < 0 &&
getTipOffsetBottom('left') <= windowHeight &&
getTipOffsetBottom('bottom') <= windowHeight) {
result = true
newPlace = 'bottom'
} else if (getTipOffsetBottom('left') > windowHeight &&
getTipOffsetTop('left') >= 0 &&
getTipOffsetTop('top') >= 0) {
result = true
newPlace = 'top'
}
return {result, newPlace}
}
const outsideLeft = () => {
let {result, newPlace} = outsideVertical() // Deal with vertical as first priority
if (result && outsideHorizontal().result) {
return {result: false} // No need to change, if change to vertical will out of space
}
if (!result && getTipOffsetLeft('left') < 0 && getTipOffsetRight('right') <= windowWidth) {
result = true // If vertical ok, but let out of side and right won't out of side
newPlace = 'right'
}
return {result, newPlace}
}
const outsideRight = () => {
let {result, newPlace} = outsideVertical()
if (result && outsideHorizontal().result) {
return {result: false} // No need to change, if change to vertical will out of space
}
if (!result && getTipOffsetRight('right') > windowWidth && getTipOffsetLeft('left') >= 0) {
result = true
newPlace = 'left'
}
return {result, newPlace}
}
const outsideHorizontal = () => {
let result = false
let newPlace
if (getTipOffsetLeft('top') < 0 &&
getTipOffsetRight('top') <= windowWidth &&
getTipOffsetRight('right') <= windowWidth) {
result = true
newPlace = 'right'
} else if (getTipOffsetRight('top') > windowWidth &&
getTipOffsetLeft('top') >= 0 &&
getTipOffsetLeft('left') >= 0) {
result = true
newPlace = 'left'
}
return {result, newPlace}
}
const outsideTop = () => {
let {result, newPlace} = outsideHorizontal()
if (result && outsideVertical().result) {
return {result: false}
}
if (!result && getTipOffsetTop('top') < 0 && getTipOffsetBottom('bottom') <= windowHeight) {
result = true
newPlace = 'bottom'
}
return {result, newPlace}
}
const outsideBottom = () => {
let {result, newPlace} = outsideHorizontal()
if (result && outsideVertical().result) {
return {result: false}
}
if (!result && getTipOffsetBottom('bottom') > windowHeight && getTipOffsetTop('top') >= 0) {
result = true
newPlace = 'top'
}
return {result, newPlace}
}
// Return new state to change the placement to the reverse if possible
const outsideLeftResult = outsideLeft()
const outsideRightResult = outsideRight()
const outsideTopResult = outsideTop()
const outsideBottomResult = outsideBottom()
if (place === 'left' && outsideLeftResult.result) {
return {
isNewState: true,
newState: {place: outsideLeftResult.newPlace}
}
} else if (place === 'right' && outsideRightResult.result) {
return {
isNewState: true,
newState: {place: outsideRightResult.newPlace}
}
} else if (place === 'top' && outsideTopResult.result) {
return {
isNewState: true,
newState: {place: outsideTopResult.newPlace}
}
} else if (place === 'bottom' && outsideBottomResult.result) {
return {
isNewState: true,
newState: {place: outsideBottomResult.newPlace}
}
}
// Return tooltip offset position
return {
isNewState: false,
position: {
left: getTipOffsetLeft(place) - parentLeft,
top: getTipOffsetTop(place) - parentTop
}
}
}
// Get current mouse offset
const getCurrentOffset = (e, currentTarget, effect) => {
const boundingClientRect = currentTarget.getBoundingClientRect()
const targetTop = boundingClientRect.top
const targetLeft = boundingClientRect.left
const targetWidth = currentTarget.clientWidth
const targetHeight = currentTarget.clientHeight
if (effect === 'float') {
return {
mouseX: e.clientX,
mouseY: e.clientY
}
}
return {
mouseX: targetLeft + (targetWidth / 2),
mouseY: targetTop + (targetHeight / 2)
}
}
// List all possibility of tooltip final offset
// This is useful in judging if it is necessary for tooltip to switch position when out of window
const getDefaultPosition = (effect, targetWidth, targetHeight, tipWidth, tipHeight) => {
let top
let right
let bottom
let left
const disToMouse = 3
const triangleHeight = 2
const cursorHeight = 12 // Optimize for float bottom only, cause the cursor will hide the tooltip
if (effect === 'float') {
top = {
l: -(tipWidth / 2),
r: tipWidth / 2,
t: -(tipHeight + disToMouse + triangleHeight),
b: -disToMouse
}
bottom = {
l: -(tipWidth / 2),
r: tipWidth / 2,
t: disToMouse + cursorHeight,
b: tipHeight + disToMouse + triangleHeight + cursorHeight
}
left = {
l: -(tipWidth + disToMouse + triangleHeight),
r: -disToMouse,
t: -(tipHeight / 2),
b: tipHeight / 2
}
right = {
l: disToMouse,
r: tipWidth + disToMouse + triangleHeight,
t: -(tipHeight / 2),
b: tipHeight / 2
}
} else if (effect === 'solid') {
top = {
l: -(tipWidth / 2),
r: tipWidth / 2,
t: -(targetHeight / 2 + tipHeight + triangleHeight),
b: -(targetHeight / 2)
}
bottom = {
l: -(tipWidth / 2),
r: tipWidth / 2,
t: targetHeight / 2,
b: targetHeight / 2 + tipHeight + triangleHeight
}
left = {
l: -(tipWidth + targetWidth / 2 + triangleHeight),
r: -(targetWidth / 2),
t: -(tipHeight / 2),
b: tipHeight / 2
}
right = {
l: targetWidth / 2,
r: tipWidth + targetWidth / 2 + triangleHeight,
t: -(tipHeight / 2),
b: tipHeight / 2
}
}
return {top, bottom, left, right}
}
// Consider additional offset into position calculation
const calculateOffset = (offset) => {
let extraOffsetX = 0
let extraOffsetY = 0
if (Object.prototype.toString.apply(offset) === '[object String]') {
offset = JSON.parse(offset.toString().replace(/'/g, '"'))
}
for (let key in offset) {
if (key === 'top') {
extraOffsetY -= parseInt(offset[key], 10)
} else if (key === 'bottom') {
extraOffsetY += parseInt(offset[key], 10)
} else if (key === 'left') {
extraOffsetX -= parseInt(offset[key], 10)
} else if (key === 'right') {
extraOffsetX += parseInt(offset[key], 10)
}
}
return {extraOffsetX, extraOffsetY}
}
// Get the offset of the parent elements
const getParent = (currentTarget) => {
let currentParent = currentTarget
while (currentParent) {
if (currentParent.style.transform.length > 0) break
currentParent = currentParent.parentElement
}
const parentTop = currentParent && currentParent.getBoundingClientRect().top
const parentLeft = currentParent && currentParent.getBoundingClientRect().left
return {parentTop, parentLeft}
}

View File

@@ -1,45 +1,20 @@
.container {
position: relative;
}
.common {
opacity: 0;
transition: opacity .3s;
visibility: hidden;
}
.container:hover .common {
visibility: visible;
opacity: 1;
.tooltipEnabled {
background-color: #222;
border-radius: 3px;
border: 1px solid #fff;
color: #fff;
display: inline-block;
font-size: 13px;
margin-left: 0px;
margin-top: 0px;
opacity: 0.9;
padding: 8px 21px;
pointer-events: none;
position: fixed;
transition: opacity 0.3s ease-out, margin-top 0.3s ease-out, margin-left 0.3s ease-out;
z-index: 9999;
}
.arrow {
composes: common;
border-bottom: .5em solid rgba(0, 0, 0, .8);
border-left: .5em solid transparent;
border-right: .5em solid transparent;
font-size: 1rem;
left: 25%;
margin-left: 1em;
position: absolute;
top: 100%;
}
.tooltip {
composes: common;
background: #333;
background: rgba(0, 0, 0, .8);
border-radius: .25em;
color: #fff;
font-size: 1rem;
left: 25%;
margin-top: .5em;
padding: .5em;
position: absolute;
top: 100%;
min-width: fit-content;
max-width: 20em;
.tooltipDisabled {
display: none;
}

View File

@@ -1,30 +1,155 @@
import classNames from 'classnames'
import React, { PropTypes } from 'react'
import isString from 'lodash/isString'
import React from 'react'
import ReactDOM from 'react-dom'
import Component from '../base-component'
import getPosition from './get-position'
import propTypes from '../prop-types-decorator'
import styles from './index.css'
const Tooltip = ({
children,
className,
content,
style,
tagName: Component = 'span'
}) => (
<Component className={classNames(className, styles.container)} style={style}>
<div className={styles.arrow} />
<div className={styles.tooltip}>
{content}
</div>
{children}
</Component>
)
// ===================================================================
Tooltip.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
content: PropTypes.any.isRequired,
style: PropTypes.object,
tagName: PropTypes.string
let instance
export class TooltipViewer extends Component {
constructor () {
super()
this.state.place = 'top'
}
componentDidMount () {
if (instance) {
throw new Error('Tooltip viewer is a singleton!')
}
instance = this
}
componentWillUnmount () {
instance = undefined
}
render () {
const {
className,
content,
place,
show,
style
} = this.state
return (
<div
className={classNames(show ? styles.tooltipEnabled : styles.tooltipDisabled, className)}
style={{
marginTop: (place === 'top' && '-10px') || (place === 'bottom' && '10px'),
marginLeft: (place === 'left' && '-10px') || (place === 'right' && '10px'),
...style
}}
>
{content}
</div>
)
}
}
export { Tooltip as default }
// ===================================================================
@propTypes({
children: propTypes.oneOfType([
propTypes.element,
propTypes.string
]),
className: propTypes.string,
content: propTypes.node,
style: propTypes.object,
tagName: propTypes.string
})
export default class Tooltip extends Component {
componentDidMount () {
this._addListeners()
}
componentWillUnmount () {
this._removeListeners()
}
componentWillReceiveProps (props) {
if (props.children !== this.props.children) {
this._removeListeners()
}
}
componentDidUpdate (prevProps) {
if (prevProps.children !== this.props.children) {
this._addListeners()
}
}
_addListeners () {
const node = this._node = ReactDOM.findDOMNode(this)
node.addEventListener('mouseenter', this._showTooltip)
node.addEventListener('mouseleave', this._hideTooltip)
node.addEventListener('mousemove', this._updateTooltip)
}
_removeListeners () {
const node = this._node
this._hideTooltip()
if (!node) {
return
}
node.removeEventListener('mouseenter', this._showTooltip)
node.removeEventListener('mouseleave', this._hideTooltip)
node.removeEventListener('mousemove', this._updateTooltip)
this._node = null
}
_showTooltip = () => {
const { props } = this
instance.setState({
className: props.className,
content: props.content,
show: true,
style: props.style
})
}
_hideTooltip = () => {
instance.setState({ show: false })
}
_updateTooltip = event => {
const node = ReactDOM.findDOMNode(instance)
const result = getPosition(event, event.currentTarget, node, instance.state.place, 'solid', {})
if (result.isNewState) {
return instance.setState(result.newState, () => this._updateTooltip(event))
}
const { position } = result
node.style.left = `${position.left}px`
node.style.top = `${position.top}px`
}
render () {
const { children } = this.props
if (!children) {
return <span />
}
if (isString(children)) {
return <span>{children}</span>
}
return children
}
}

72
src/common/usage/index.js Normal file
View File

@@ -0,0 +1,72 @@
import _ from 'intl'
import classNames from 'classnames'
import React, { PropTypes, cloneElement } from 'react'
import sum from 'lodash/sum'
import Tooltip from '../tooltip'
const Usage = ({ total, children }) => {
const limit = total / 400
const othersValues = React.Children.map(children, child => {
const { value } = child.props
return value < limit && value
})
const othersTotal = sum(othersValues)
return <span className='usage'>
{React.Children.map(children, (child, index) =>
child.props.value > limit && cloneElement(child, { total })
)}
<Element
others
tooltip={_('others')}
total={total}
value={othersTotal}
/>
</span>
}
Usage.propTypes = {
total: PropTypes.number.isRequired
}
export { Usage as default }
const Element = ({ highlight, href, others, tooltip, total, value }) => (
<Tooltip content={tooltip}>
<a
href={href}
className={classNames(
'usage-element',
highlight && 'usage-element-highlight',
others && 'usage-element-others'
)}
style={{ width: (value / total) * 100 + '%' }}
/>
</Tooltip>
)
Element.propTypes = {
highlight: PropTypes.bool,
href: PropTypes.string,
others: PropTypes.bool,
tooltip: PropTypes.node,
value: PropTypes.number.isRequired
}
export { Element as UsageElement }
export const Limits = ({ used, toBeUsed, limit }) => {
const available = limit - used
return <span className='limits'>
<span
className='limits-used'
style={{ width: ((used || 0) / limit) * 100 + '%' }}
/>
<span
className={toBeUsed > available ? 'limits-over-used' : 'limits-to-be-used'}
style={{ width: (Math.min((toBeUsed || 0), available) / limit) * 100 + '%' }}
/>
</span>
}
Limits.propTypes = {
used: PropTypes.number,
toBeUsed: PropTypes.number,
limit: PropTypes.number.isRequired
}

View File

@@ -1,27 +1,33 @@
import * as actions from 'store/actions'
import escapeRegExp from 'lodash/escapeRegExp'
import every from 'lodash/every'
import forEach from 'lodash/forEach'
import getStream from 'get-stream'
import humanFormat from 'human-format'
import includes from 'lodash/includes'
import isArray from 'lodash/isArray'
import isEmpty from 'lodash/isEmpty'
import isFunction from 'lodash/isFunction'
import isPlainObject from 'lodash/isPlainObject'
import isString from 'lodash/isString'
import join from 'lodash/join'
import keys from 'lodash/keys'
import map from 'lodash/map'
import mapValues from 'lodash/mapValues'
import propTypes from 'prop-types'
import React, { cloneElement } from 'react'
import React from 'react'
import ReadableStream from 'readable-stream'
import replace from 'lodash/replace'
import startsWith from 'lodash/startsWith'
import { connect } from 'react-redux'
import _ from './intl'
import * as actions from './store/actions'
import BaseComponent from './base-component'
import invoke from './invoke'
import store from './store'
import { getObject } from './selectors'
export const EMPTY_ARRAY = Object.freeze([ ])
export const EMPTY_OBJECT = Object.freeze({ })
export { propTypes }
// ===================================================================
export const ensureArray = (value) => {
@@ -46,6 +52,8 @@ export const propsEqual = (o1, o2, props) => {
// ===================================================================
// `subscriptions` can be a function if we want to ensure that the subscription
// callbacks have been correctly initialized when there are circular dependencies
export const addSubscriptions = subscriptions => Component => {
class SubscriptionWrapper extends BaseComponent {
constructor () {
@@ -55,14 +63,23 @@ export const addSubscriptions = subscriptions => Component => {
}
componentWillMount () {
this._unsubscribes = map(subscriptions, (subscribe, prop) =>
subscribe(value => this.setState({ [prop]: value }))
this._unsubscribes = map(isFunction(subscriptions) ? subscriptions() : subscriptions, (subscribe, prop) =>
subscribe(value => this._setState({ [prop]: value }))
)
}
componentDidMount () {
this._setState = this.setState
}
componentWillUnmount () {
forEach(this._unsubscribes, unsubscribe => unsubscribe())
this._unsubscribes = null
delete this._setState
}
_setState (nextState) {
this.state = { ...this.state, nextState }
}
render () {
@@ -78,92 +95,6 @@ export const addSubscriptions = subscriptions => Component => {
// -------------------------------------------------------------------
const _bind = (fn, thisArg) => function bound () {
return fn.apply(thisArg, arguments)
}
const _defineProperty = Object.defineProperty
export const autobind = (target, key, {
configurable,
enumerable,
value: fn,
writable
}) => ({
configurable,
enumerable,
get () {
if (this === target) {
return fn
}
const bound = _bind(fn, this)
_defineProperty(this, key, {
configurable: true,
enumerable: false,
value: bound,
writable: true
})
return bound
},
set (newValue) {
// Cannot use assignment because it will call the setter on
// the prototype.
_defineProperty(this, key, {
configurable: true,
enumerable: true,
value: newValue,
writable: true
})
}
})
// -------------------------------------------------------------------
@propTypes({
tagName: propTypes.string
})
export class BlockLink extends React.Component {
static contextTypes = {
router: React.PropTypes.object
}
_style = { cursor: 'pointer' }
_onClickCapture = event => {
const { currentTarget } = event
let element = event.target
while (element !== currentTarget) {
if (includes(['A', 'INPUT', 'BUTTON', 'SELECT'], element.tagName)) {
return
}
element = element.parentNode
}
event.stopPropagation()
if (event.ctrlKey || event.button === 1) {
window.open(this.context.router.createHref(this.props.to))
} else {
this.context.router.push(this.props.to)
}
}
render () {
const { children, tagName = 'div' } = this.props
const Component = tagName
return (
<Component
style={this._style}
onClickCapture={this._onClickCapture}
>
{children}
</Component>
)
}
}
// -------------------------------------------------------------------
export const checkPropsState = (propsNames, stateNames) => Component => {
const nProps = propsNames && propsNames.length
const nState = stateNames && stateNames.length
@@ -255,32 +186,21 @@ export const connectStore = (mapStateToProps, opts = {}) => {
// -------------------------------------------------------------------
// Simple matcher to use in object filtering.
export const createSimpleMatcher = (pattern, valueGetter) => {
if (!pattern) {
return
}
pattern = pattern.toLowerCase()
return item => valueGetter(item).toLowerCase().indexOf(pattern) !== -1
}
// -------------------------------------------------------------------
export { default as Debug } from './debug'
// -------------------------------------------------------------------
// Returns the first defined (non-null, non-undefined) value.
// Returns the first defined (non-undefined) value.
export const firstDefined = function () {
const n = arguments.length
for (let i = 0; i < n; ++i) {
const arg = arguments[i]
if (arg != null) {
if (arg !== undefined) {
return arg
}
}
}
// -------------------------------------------------------------------
// Returns the current XOA Plan or the Plan name if number given
@@ -305,7 +225,7 @@ export const getXoaPlan = plan => {
export const mapPlus = (collection, cb) => {
const result = []
const push = ::result.push
forEach(collection, value => cb(value, push))
forEach(collection, (value, index) => cb(value, push, index))
return result
}
@@ -318,10 +238,10 @@ export const noop = () => {}
export const osFamily = invoke({
centos: [ 'centos' ],
debian: [ 'debian' ],
docker: [ 'coreos' ],
fedora: [ 'fedora' ],
freebsd: [ 'freebsd' ],
gentoo: [ 'gentoo' ],
linux: [ 'coreos' ],
'linux-mint': [ 'linux-mint' ],
netbsd: [ 'netbsd' ],
oracle: [ 'oracle' ],
@@ -344,28 +264,15 @@ export const osFamily = invoke({
// -------------------------------------------------------------------
// Experimental!
//
// ```js
// <If cond={user}>
// <p>user.name</p>
// <p>user.email</p>
// </If>
// ```
export const If = ({ cond, children }) => cond && children
? map(children, (child, key) => cloneElement(child, { key }))
: null
// -------------------------------------------------------------------
export { invoke }
// -------------------------------------------------------------------
export const formatSize = bytes => humanFormat(bytes, { scale: 'binary', unit: 'B' })
export const formatSizeRaw = bytes => humanFormat.raw(bytes, { scale: 'binary', unit: 'B' })
export const formatSpeed = (bytes, milliseconds) => humanFormat(
bytes * 1e3 / milliseconds,
{ scale: 'binary', unit: 'B/s' }
)
export const parseSize = size => {
let bytes = humanFormat.parse.raw(size, { scale: 'binary' })
if (bytes.unit && bytes.unit !== 'B') {
@@ -395,7 +302,7 @@ export const normalizeXenToolsStatus = status => {
// -------------------------------------------------------------------
const _NotFound = () => <h1>Page not found</h1>
const _NotFound = () => <h1>{_('errorPageNotFound')}</h1>
// Decorator to declare routes on a component.
//
@@ -457,24 +364,185 @@ export const throwFn = error => () => {
)
}
// -------------------------------------------------------------------
// ===================================================================
export function tap (cb) {
return this.then(value =>
Promise.resolve(cb(value)).then(() => value)
)
export const resolveResourceSet = resourceSet => {
if (!resourceSet) {
return
}
const { objects, ipPools, ...attrs } = resourceSet
const resolvedObjects = {}
const resolvedSet = {
...attrs,
missingObjects: [],
objectsByType: resolvedObjects,
ipPools
}
const state = store.getState()
forEach(objects, id => {
const object = getObject(state, id, true) // true: useResourceSet to bypass permissions
// Error, missing resource.
if (!object) {
resolvedSet.missingObjects.push(id)
return
}
const { type } = object
if (!resolvedObjects[type]) {
resolvedObjects[type] = [ object ]
} else {
resolvedObjects[type].push(object)
}
})
return resolvedSet
}
export function rethrow (cb) {
return this.catch(error =>
Promise.resolve(cb(error)).then(() => { throw error })
)
}
export const resolveResourceSets = resourceSets =>
map(resourceSets, resolveResourceSet)
// -------------------------------------------------------------------
// If param is an event: returns the value associated to it
// Otherwise: returns param
export function getEventValue (param) {
return param && param.target ? param.target.value : param
// Creates a string replacer based on a pattern and a list of rules
//
// ```js
// const myReplacer = buildTemplate('{name}_COPY_{name}_{id}_%', {
// '{name}': vm => vm.name_label,
// '{id}': vm => vm.id,
// '%': (_, i) => i
// })
//
// const newString = myReplacer({
// name_label: 'foo',
// id: 42,
// }, 32)
//
// newString === 'foo_COPY_foo_42_32'
// ```
export function buildTemplate (pattern, rules) {
const regExp = new RegExp(join(map(keys(rules), escapeRegExp), '|'), 'g')
return (...params) => replace(pattern, regExp, match => {
const rule = rules[match]
return isFunction(rule) ? rule(...params) : rule
})
}
// ===================================================================
export const streamToString = getStream
// ===================================================================
/* global FileReader */
// Creates a readable stream from a HTML file.
export const htmlFileToStream = file => {
const reader = new FileReader()
const stream = new ReadableStream()
let offset = 0
reader.onloadend = evt => {
stream.push(evt.target.result)
}
reader.onerror = error => {
stream.emit('error', error)
}
stream._read = function (size) {
if (offset >= file.size) {
stream.push(null)
} else {
reader.readAsBinaryString(file.slice(offset, offset + size))
offset += size
}
}
return stream
}
// ===================================================================
export const resolveId = value =>
(value != null && typeof value === 'object' && 'id' in value)
? value.id
: value
export const resolveIds = params => {
for (const key in params) {
const param = params[key]
if (param != null && typeof param === 'object' && 'id' in param) {
params[key] = param.id
}
}
return params
}
// ===================================================================
const OPs = {
'<': a => a < 0,
'<=': a => a <= 0,
'===': a => a === 0,
'>': a => a > 0,
'>=': a => a >= 0
}
const makeNiceCompare = compare => function () {
const { length } = arguments
if (length === 2) {
return compare(arguments[0], arguments[1])
}
let i = 1
let v1 = arguments[0]
let op, v2
while (i < length) {
op = arguments[i++]
v2 = arguments[i++]
if (!OPs[op](compare(v1, v2))) {
return false
}
v1 = v2
}
return true
}
export const compareVersions = makeNiceCompare((v1, v2) => {
v1 = v1.split('.')
v2 = v2.split('.')
for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
const n1 = +v1[i] || 0
const n2 = +v2[i] || 0
if (n1 < n2) return -1
if (n1 > n2) return 1
}
return 0
})
export const isXosanPack = ({ name }) =>
startsWith(name, 'XOSAN')
// ===================================================================
export const getCoresPerSocketPossibilities = (maxCoresPerSocket, vCPUs) => {
// According to : https://www.citrix.com/blogs/2014/03/11/citrix-xenserver-setting-more-than-one-vcpu-per-vm-to-improve-application-performance-and-server-consolidation-e-g-for-cad3-d-graphical-applications/
const maxVCPUs = 16
const options = []
if (maxCoresPerSocket !== undefined && vCPUs !== '') {
const ratio = vCPUs / maxVCPUs
for (let coresPerSocket = maxCoresPerSocket; coresPerSocket >= ratio; coresPerSocket--) {
if (vCPUs % coresPerSocket === 0) options.push(coresPerSocket)
}
}
return options
}

View File

@@ -1,17 +1,22 @@
import _ from 'intl'
import classNames from 'classnames'
import every from 'lodash/every'
import Icon from 'icon'
import map from 'lodash/map'
import { propTypes } from 'utils'
import React, { Component, cloneElement } from 'react'
import _ from '../intl'
import Icon from '../icon'
import propTypes from '../prop-types-decorator'
import styles from './index.css'
const Wizard = ({ children }) => {
const allDone = every(React.Children.toArray(children), (child) => child.props.done || child.props.summary)
const allDone = every(React.Children.toArray(children), child =>
child.props.done || child.props.summary
)
return <ul className={styles.wizard}>
{map(React.Children.toArray(children), (child, key) => cloneElement(child, { allDone, key }))}
{React.Children.map(children, (child, key) =>
child && cloneElement(child, { allDone, key })
)}
</ul>
}
export { Wizard as default }

View File

@@ -0,0 +1,69 @@
import forEach from 'lodash/forEach'
import XoHighLevelObjectInput from './xo-highlevel-object-input'
import XoHostInput from './xo-host-input'
import XoPoolInput from './xo-pool-input'
import XoRemoteInput from './xo-remote-input'
import XoRoleInput from './xo-role-input'
import XoSrInput from './xo-sr-input'
import XoSubjectInput from './xo-subject-input'
import XoTagInput from './xo-tag-input'
import XoVmInput from './xo-vm-input'
import { getType, getXoType } from '../json-schema-input/helpers'
// ===================================================================
const XO_TYPE_TO_COMPONENT = {
host: XoHostInput,
pool: XoPoolInput,
remote: XoRemoteInput,
role: XoRoleInput,
sr: XoSrInput,
subject: XoSubjectInput,
tag: XoTagInput,
vm: XoVmInput,
xoobject: XoHighLevelObjectInput
}
// ===================================================================
const buildStringInput = (uiSchema, key, xoType) => {
if (key === 'password') {
uiSchema.config = { password: true }
}
uiSchema.widget = XO_TYPE_TO_COMPONENT[xoType]
}
// ===================================================================
const _generateUiSchema = (schema, uiSchema, key) => {
const type = getType(schema)
if (type === 'object') {
const properties = uiSchema.properties = {}
forEach(schema.properties, (schema, key) => {
const subUiSchema = properties[key] = {}
_generateUiSchema(schema, subUiSchema, key)
})
} else if (type === 'array') {
const widget = XO_TYPE_TO_COMPONENT[getXoType(schema.items)]
if (widget) {
uiSchema.widget = widget
uiSchema.config = { multi: true }
} else {
const subUiSchema = uiSchema.items = {}
_generateUiSchema(schema.items, subUiSchema, key)
}
} else if (type === 'string') {
buildStringInput(uiSchema, key, getXoType(schema))
}
}
export const generateUiSchema = schema => {
const uiSchema = {}
_generateUiSchema(schema, uiSchema, '')
return uiSchema
}

Some files were not shown because too many files have changed in this diff Show More