-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Settings Dialog with configurable extension settings, fixed top…
…ic issue in subscribe view disconnection. (#16) * Updated to match vsc style, closes #8 * added automatic broker disconnection on inactivity + Settings Context * 0.0.5 * Added Settings Dialog, closes #13 + prevent from losing topics on disconnect * 0.0.6 * minor updates
- Loading branch information
Showing
10 changed files
with
294 additions
and
88 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,135 @@ | ||
import { Button, Input } from "@nextui-org/react"; | ||
|
||
import { | ||
ModalBody, | ||
Modal, | ||
ModalContent, | ||
ModalFooter, | ||
ModalHeader, | ||
} from "../Shared/components/Modal"; | ||
import { useSettings } from "../Shared/components/SettingsContext"; | ||
import { DEFAULT_SETTINGS } from "../Shared/constants"; | ||
|
||
const getInteger = (value: string, min=0) => { | ||
return Math.max(Math.abs(parseInt(value) || 0), min); | ||
}; | ||
|
||
const SettingsView = ({ | ||
show, | ||
onClose, | ||
}: { | ||
show: boolean; | ||
onClose: () => void; | ||
}) => { | ||
const { | ||
settings: { | ||
maxDisplayMessages, | ||
maxPayloadLength, | ||
maxPropertyLength, | ||
brokerDisconnectTimeout, | ||
}, | ||
setSettings, | ||
} = useSettings(); | ||
|
||
const resetSettings = () => { | ||
setSettings(DEFAULT_SETTINGS); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
isOpen={show} | ||
placement="center" | ||
onOpenChange={(open) => { | ||
if (!open) { | ||
onClose(); | ||
} | ||
}} | ||
> | ||
<ModalContent> | ||
{(onModalClose) => ( | ||
<> | ||
<ModalHeader> | ||
Solace Try Me Extension Settings | ||
</ModalHeader> | ||
<ModalBody className="flex flex-col gap-4"> | ||
<Input | ||
type="number" | ||
label="Maximum number of visible messages" | ||
value={maxDisplayMessages.toString()} | ||
onChange={(e) => | ||
setSettings((prev) => ({ | ||
...prev, | ||
maxDisplayMessages: getInteger(e.target.value, 1), | ||
})) | ||
} | ||
max={1000} | ||
min={1} | ||
step={1} | ||
/> | ||
<Input | ||
type="number" | ||
label="Maximum visible payload length" | ||
value={maxPayloadLength.toString()} | ||
onChange={(e) => | ||
setSettings((prev) => ({ | ||
...prev, | ||
maxPayloadLength: getInteger(e.target.value, 1), | ||
})) | ||
} | ||
min={100} | ||
step={50} | ||
/> | ||
<Input | ||
type="number" | ||
label="Maximum visible property length" | ||
value={maxPropertyLength.toString()} | ||
onChange={(e) => | ||
setSettings((prev) => ({ | ||
...prev, | ||
maxPropertyLength: getInteger(e.target.value, 5), | ||
})) | ||
} | ||
min={5} | ||
step={5} | ||
/> | ||
<Input | ||
type="number" | ||
className="no-wrap" | ||
label="Automatic broker disconnection after inactivity (minutes) " | ||
value={(brokerDisconnectTimeout / 1000 / 60).toString()} | ||
onChange={(e) => | ||
setSettings((prev) => ({ | ||
...prev, | ||
brokerDisconnectTimeout: getInteger(e.target.value, 1) * 1000 * 60, | ||
})) | ||
} | ||
min={1} | ||
step={1} | ||
/> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button | ||
radius="sm" | ||
color="danger" | ||
variant="light" | ||
onPress={onModalClose} | ||
> | ||
Close | ||
</Button> | ||
<Button | ||
radius="sm" | ||
color="secondary" | ||
variant="light" | ||
onPress={resetSettings} | ||
> | ||
Reset to Default | ||
</Button> | ||
</ModalFooter> | ||
</> | ||
)} | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default SettingsView; |
Oops, something went wrong.