Skip to content

Commit

Permalink
Merge pull request #1081 from lyncasterc/feature/edit-custom-device-name
Browse files Browse the repository at this point in the history
Add ability to edit a custom device's name
  • Loading branch information
manojVivek authored Sep 19, 2023
2 parents 835ff44 + abeb136 commit c9c2d43
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ const DeviceDetailsModal = ({
const isCustom = device != null ? device.isCustom ?? false : true;

const handleAddDevice = async (): Promise<void> => {
if (device == null && existingDevices.find((d) => d.name === name)) {
const existingDevice = existingDevices.find((d) => d.name === name);
const doesDeviceExist =
existingDevice != null && (isNew || existingDevice.id !== device.id);

if (doesDeviceExist) {
// eslint-disable-next-line no-alert
return alert(
'Device With the name already exists, try with a different name'
Expand Down Expand Up @@ -133,11 +137,8 @@ const DeviceDetailsModal = ({
placeholder="My Mobile Device"
value={name}
onChange={(e) => setName(e.target.value)}
disabled={!isCustom || !isNew}
disabled={!isCustom}
/>
{!isNew && isCustom ? (
<p>Note: Device name cannot be modified once created!</p>
) : null}
<Input
label="Device Width"
type="number"
Expand Down

0 comments on commit c9c2d43

Please sign in to comment.