@@ -13,10 +13,16 @@ import {
13
13
FormInstance ,
14
14
Collapse ,
15
15
Checkbox ,
16
+ Select ,
16
17
} from "antd" ;
17
18
import React , { useEffect , useState } from "react" ;
18
19
import { useShowModal } from "../components/ModalManager" ;
19
- import { Hook , Repo } from "../../gen/ts/v1/config_pb" ;
20
+ import {
21
+ CommandPrefix_CPUNiceLevel ,
22
+ CommandPrefix_IONiceLevel ,
23
+ Hook ,
24
+ Repo ,
25
+ } from "../../gen/ts/v1/config_pb" ;
20
26
import { URIAutocomplete } from "../components/URIAutocomplete" ;
21
27
import { MinusCircleOutlined , PlusOutlined } from "@ant-design/icons" ;
22
28
import { formatErrorAlert , useAlertApi } from "../components/Alerts" ;
@@ -31,6 +37,7 @@ import { ConfirmButton } from "../components/SpinButton";
31
37
import { useConfig } from "../components/ConfigProvider" ;
32
38
import Cron from "react-js-cron" ;
33
39
import { ScheduleFormItem } from "../components/ScheduleFormItem" ;
40
+ import { proto3 } from "@bufbuild/protobuf" ;
34
41
35
42
export const AddRepoModal = ( { template } : { template : Repo | null } ) => {
36
43
const [ confirmLoading , setConfirmLoading ] = useState ( false ) ;
@@ -97,14 +104,15 @@ export const AddRepoModal = ({ template }: { template: Repo | null }) => {
97
104
} ) ;
98
105
99
106
if ( template !== null ) {
107
+ const configCopy = config . clone ( ) ;
100
108
// We are in the edit repo flow, update the repo in the config
101
- const idx = config . repos ! . findIndex ( ( r ) => r . id === template ! . id ) ;
109
+ const idx = configCopy . repos ! . findIndex ( ( r ) => r . id === template ! . id ) ;
102
110
if ( idx === - 1 ) {
103
111
alertsApi . error ( "Can't update repo, not found" ) ;
104
112
return ;
105
113
}
106
- config . repos ! [ idx ] = repo ;
107
- setConfig ( await backrestService . setConfig ( config ) ) ;
114
+ configCopy . repos ! [ idx ] = repo ;
115
+ setConfig ( await backrestService . setConfig ( configCopy ) ) ;
108
116
showModal ( null ) ;
109
117
alertsApi . success ( "Updated repo " + repo . uri ) ;
110
118
@@ -486,6 +494,50 @@ export const AddRepoModal = ({ template }: { template: Repo | null }) => {
486
494
< ScheduleFormItem name = { [ "checkPolicy" , "schedule" ] } />
487
495
</ Form . Item >
488
496
497
+ { /* Repo.commandPrefix */ }
498
+ < Form . Item
499
+ label = {
500
+ < Tooltip
501
+ title = {
502
+ < span >
503
+ Modifiers for the backup operation e.g. set the CPU or IO
504
+ priority. Currently only available on unix systems.
505
+ </ span >
506
+ }
507
+ >
508
+ Command Modifiers
509
+ </ Tooltip >
510
+ }
511
+ >
512
+ < Row >
513
+ < Col span = { 12 } >
514
+ < Form . Item name = { [ "commandPrefix" , "ioNice" ] } required = { false } >
515
+ < Select
516
+ allowClear
517
+ style = { { width : "100%" } }
518
+ placeholder = "Select an IO priority"
519
+ options = { proto3
520
+ . getEnumType ( CommandPrefix_IONiceLevel )
521
+ . values . map ( ( v ) => ( { label : v . name , value : v . name } ) ) }
522
+ />
523
+ </ Form . Item >
524
+ </ Col >
525
+
526
+ < Col span = { 12 } >
527
+ < Form . Item name = { [ "commandPrefix" , "cpuNice" ] } required = { false } >
528
+ < Select
529
+ allowClear
530
+ style = { { width : "100%" } }
531
+ placeholder = "Select a CPU priority"
532
+ options = { proto3
533
+ . getEnumType ( CommandPrefix_CPUNiceLevel )
534
+ . values . map ( ( v ) => ( { label : v . name , value : v . name } ) ) }
535
+ />
536
+ </ Form . Item >
537
+ </ Col >
538
+ </ Row >
539
+ </ Form . Item >
540
+
489
541
< Form . Item
490
542
label = {
491
543
< Tooltip
0 commit comments