-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30fd4a8
commit 2b70b64
Showing
9 changed files
with
367 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) [2022] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React from "react"; | ||
|
||
import { EOS_VOLUME as Icon } from "eos-icons-react"; | ||
|
||
import Category from "./Category"; | ||
import StorageActions from "./StorageActions"; | ||
|
||
export default function StorageSettingsSection({ proposal }) { | ||
return ( | ||
<Category title="Actions" icon={Icon}> | ||
<StorageActions actions={proposal.actions} /> | ||
</Category> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Copyright (c) [2022] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React, { useReducer } from "react"; | ||
|
||
import { | ||
Form, | ||
FormGroup, | ||
Switch, | ||
TextInput | ||
} from "@patternfly/react-core"; | ||
|
||
const reducer = (state, action) => { | ||
switch (action.type) { | ||
case "LVM_CHANGE" : { | ||
return { ...state, lvm: action.payload.lvm }; | ||
} | ||
|
||
case "ENCRYPTION_CHANGE": { | ||
return { ...state, encryption: action.payload.encryption }; | ||
} | ||
|
||
case "PASSWORD_CHANGE": { | ||
return { ...state, encryptionPassword: action.payload.encryptionPassword }; | ||
} | ||
|
||
default: { | ||
return state; | ||
} | ||
} | ||
}; | ||
|
||
export default function StorageSettingsForm({ id, proposal, onSubmit }) { | ||
const [state, dispatch] = useReducer(reducer, { | ||
lvm: proposal.lvm, | ||
encryption: proposal.encryptionPassword.length !== 0, | ||
encryptionPassword: proposal.encryptionPassword | ||
}); | ||
|
||
const onLvmChange = (value) => { | ||
dispatch({ type: "LVM_CHANGE", payload: { lvm: value } }); | ||
}; | ||
|
||
const onEncryptionChange = (value) => { | ||
dispatch({ type: "ENCRYPTION_CHANGE", payload: { encryption: value } }); | ||
}; | ||
|
||
const onPasswordChange = (value) => { | ||
dispatch({ type: "PASSWORD_CHANGE", payload: { encryptionPassword: value } }); | ||
}; | ||
|
||
const accept = (e) => { | ||
e.preventDefault(); | ||
|
||
const lvm = state.lvm; | ||
const encryptionPassword = state.encryption ? state.encryptionPassword : ""; | ||
|
||
onSubmit({ lvm, encryptionPassword }); | ||
}; | ||
|
||
return ( | ||
<Form id={id} onSubmit={accept}> | ||
<Switch | ||
id="lvm" | ||
label="Use LVM" | ||
isReversed | ||
isChecked={state.lvm} | ||
onChange={onLvmChange} | ||
/> | ||
<fieldset> | ||
<legend> | ||
<Switch | ||
id="encryption" | ||
label="Encrypt devices" | ||
isReversed | ||
isChecked={state.encryption} | ||
onChange={onEncryptionChange} | ||
/> | ||
</legend> | ||
<FormGroup fieldId="encryptionPassword" label="Encryption password"> | ||
<TextInput | ||
id="encryptionPassword" | ||
type="password" | ||
isDisabled={!state.encryption} | ||
aria-label="password" | ||
value={state.encryptionPassword} | ||
onChange={onPasswordChange} | ||
/> | ||
</FormGroup> | ||
</fieldset> | ||
</Form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) [2022] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React, { useState } from "react"; | ||
|
||
import { | ||
Button, | ||
} from "@patternfly/react-core"; | ||
|
||
import { | ||
EOS_VOLUME as SectionIcon, | ||
EOS_SETTINGS as EditIcon | ||
} from "eos-icons-react"; | ||
|
||
import Category from "./Category"; | ||
import StorageVolumes from "./StorageVolumes"; | ||
import StorageSettingsForm from "./StorageSettingsForm"; | ||
import Popup from "./Popup"; | ||
|
||
export default function StorageSettingsSection({ proposal, calculateProposal }) { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const onSettingsChange = ({ lvm, encryptionPassword }) => { | ||
calculateProposal({ lvm, encryptionPassword }); | ||
}; | ||
|
||
const onVolumesChange = volumes => { | ||
calculateProposal({ volumes }); | ||
}; | ||
|
||
return ( | ||
<Category title="Settings" icon={SectionIcon}> | ||
<Button | ||
isSmall | ||
variant="plain" | ||
icon={<EditIcon />} | ||
aria-label="settings" | ||
onClick={() => setIsOpen(true)} | ||
/> | ||
<Popup title="Edit proposal settings" isOpen={isOpen}> | ||
<StorageSettingsForm id="settings-form" proposal={proposal} onSubmit={onSettingsChange} /> | ||
<Popup.Actions> | ||
<Popup.Confirm form="settings-form" type="submit">Accept</Popup.Confirm> | ||
<Popup.Cancel onClick={() => setIsOpen(false)} autoFocus /> | ||
</Popup.Actions> | ||
</Popup> | ||
<StorageVolumes volumes={proposal.volumes} onChange={onVolumesChange} /> | ||
</Category> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) [2022] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React, { useState } from "react"; | ||
|
||
import { | ||
Form, | ||
} from "@patternfly/react-core"; | ||
|
||
import DeviceSelector from "./DeviceSelector"; | ||
|
||
export default function StorageTargetForm({ id, proposal, onSubmit }) { | ||
const [candidateDevices, setCandidateDevices] = useState(proposal.candidateDevices); | ||
|
||
const accept = (e) => { | ||
e.preventDefault(); | ||
onSubmit({ candidateDevices }); | ||
}; | ||
|
||
return ( | ||
<Form id={id} onSubmit={accept}> | ||
<DeviceSelector | ||
key={candidateDevices[0]} | ||
value={candidateDevices[0]} | ||
options={proposal.availableDevices} | ||
onChange={(value) => setCandidateDevices([value])} | ||
/> | ||
</Form> | ||
); | ||
} |
Oops, something went wrong.