-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(spaceward): Intents enhancements #166
Conversation
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
WalkthroughWalkthroughThe recent updates to the Spaceward project encompass various enhancements aimed at improving modal functionalities, address validation, and intent creation processes. These changes also focus on enhancing user interaction through features like select all functionality, error messaging, and improved UI handling. Additionally, there have been refactoring efforts to enhance code clarity and maintainability across the codebase. Changes
Recent Review DetailsConfiguration used: .coderabbit.yaml Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
const CreateIntent = ({ | ||
intent, | ||
onIntentRemove, | ||
handleChangeIntent, | ||
handleRemoveCondition, | ||
}: { | ||
intent: Intent; | ||
onIntentRemove: (id: number) => void; | ||
handleChangeIntent?: (id: number, newCondition: Condition) => void; | ||
handleRemoveCondition: (id: number, conditionToRemove: Condition) => void; | ||
}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider destructuring intent
and conditions
from props for cleaner code and to avoid repetitive code like intent.conditions
.
- const CreateIntent = ({ intent, onIntentRemove, handleChangeIntent, handleRemoveCondition }: { intent: Intent; onIntentRemove: (id: number) => void; handleChangeIntent?: (id: number, newCondition: Condition) => void; handleRemoveCondition: (id: number, conditionToRemove: Condition) => void; }) => {
+ const CreateIntent = ({ intent: { id, conditions }, onIntentRemove, handleChangeIntent, handleRemoveCondition }: { intent: Intent; onIntentRemove: (id: number) => void; handleChangeIntent?: (id: number, newCondition: Condition) => void; handleRemoveCondition: (id: number, conditionToRemove: Condition) => void; }) => {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const CreateIntent = ({ | |
intent, | |
onIntentRemove, | |
handleChangeIntent, | |
handleRemoveCondition, | |
}: { | |
intent: Intent; | |
onIntentRemove: (id: number) => void; | |
handleChangeIntent?: (id: number, newCondition: Condition) => void; | |
handleRemoveCondition: (id: number, conditionToRemove: Condition) => void; | |
}) => { | |
const CreateIntent = ({ | |
intent: { id, conditions }, | |
onIntentRemove, | |
handleChangeIntent, | |
handleRemoveCondition, | |
}: { | |
intent: Intent; | |
onIntentRemove: (id: number) => void; | |
handleChangeIntent?: (id: number, newCondition: Condition) => void; | |
handleRemoveCondition: (id: number, conditionToRemove: Condition) => void; | |
}) => { |
{isAddPerson && ( | ||
<Portal domId="intent-modal"> | ||
<div className="bg-[rgba(64,64,64,0.40)] absolute left-0 top-0 w-full h-full backdrop-blur-[20px] flex items-center justify-center min-h-[600px]"> | ||
<button | ||
onClick={() => { | ||
setIsPersonsModal(true); | ||
setIsAddPerson(false); | ||
}} | ||
className="absolute top-8 left-8 opacity-[0.5] hover:opacity-[100%] transition-all" | ||
> | ||
<img src="/images/goback.svg" alt="" /> | ||
</button> | ||
<button | ||
onClick={() => { | ||
setIsAddPerson(false); | ||
}} | ||
className="absolute top-8 right-8 opacity-[0.5] hover:opacity-[100%] transition-all" | ||
> | ||
<img src="/images/button-close.svg" alt="" /> | ||
</button> | ||
|
||
<div className="max-w-[520px] w-[520px] text-center tracking-widepb-5"> | ||
<div className="font-bold text-5xl mb-6 leading-[56px]"> | ||
Add a person | ||
</div> | ||
<div>Enter an address</div> | ||
|
||
<form | ||
action="" | ||
className="mt-12 text-left flex items-center justify-between gap-2 bg-[rgba(229,238,255,0.15)] border-[1px] border-white px-4 h-[60px]" | ||
> | ||
<div className="w-full"> | ||
<label | ||
className="text-[rgba(229,238,255,0.60)] text-xs" | ||
htmlFor="address" | ||
> | ||
Address | ||
</label> | ||
<input | ||
className="block w-full bg-transparent outline-none foces:outline-none" | ||
id="address" | ||
onChange={(e) => handleInput(e)} | ||
value={addPersonValue} | ||
/> | ||
</div> | ||
<button className="font-medium text-[rgba(229,238,255,0.60)] px-2 hover:text-white transition-all duratioin-200"> | ||
Paste | ||
</button> | ||
</form> | ||
|
||
<div className="mt-12 pt-6"> | ||
<button | ||
onClick={() => { | ||
setIsPersonsModal(false); | ||
}} | ||
className={clsx( | ||
`bg-[#FFF] h-14 flex items-center justify-center w-full font-semibold text-[#000] hover:bg-[#FFAEEE] transition-all duration-200`, | ||
!addPersonValue && | ||
`opacity-[0.3] pointer-events-none`, | ||
)} | ||
> | ||
Add Person | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</Portal> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding a person, consider validating the input address format to ensure it is a valid blockchain address before allowing the user to submit.
+ if (!isValidAddress(addPersonValue)) {
+ alert('Please enter a valid address.');
+ return;
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
{isAddPerson && ( | |
<Portal domId="intent-modal"> | |
<div className="bg-[rgba(64,64,64,0.40)] absolute left-0 top-0 w-full h-full backdrop-blur-[20px] flex items-center justify-center min-h-[600px]"> | |
<button | |
onClick={() => { | |
setIsPersonsModal(true); | |
setIsAddPerson(false); | |
}} | |
className="absolute top-8 left-8 opacity-[0.5] hover:opacity-[100%] transition-all" | |
> | |
<img src="/images/goback.svg" alt="" /> | |
</button> | |
<button | |
onClick={() => { | |
setIsAddPerson(false); | |
}} | |
className="absolute top-8 right-8 opacity-[0.5] hover:opacity-[100%] transition-all" | |
> | |
<img src="/images/button-close.svg" alt="" /> | |
</button> | |
<div className="max-w-[520px] w-[520px] text-center tracking-widepb-5"> | |
<div className="font-bold text-5xl mb-6 leading-[56px]"> | |
Add a person | |
</div> | |
<div>Enter an address</div> | |
<form | |
action="" | |
className="mt-12 text-left flex items-center justify-between gap-2 bg-[rgba(229,238,255,0.15)] border-[1px] border-white px-4 h-[60px]" | |
> | |
<div className="w-full"> | |
<label | |
className="text-[rgba(229,238,255,0.60)] text-xs" | |
htmlFor="address" | |
> | |
Address | |
</label> | |
<input | |
className="block w-full bg-transparent outline-none foces:outline-none" | |
id="address" | |
onChange={(e) => handleInput(e)} | |
value={addPersonValue} | |
/> | |
</div> | |
<button className="font-medium text-[rgba(229,238,255,0.60)] px-2 hover:text-white transition-all duratioin-200"> | |
Paste | |
</button> | |
</form> | |
<div className="mt-12 pt-6"> | |
<button | |
onClick={() => { | |
setIsPersonsModal(false); | |
}} | |
className={clsx( | |
`bg-[#FFF] h-14 flex items-center justify-center w-full font-semibold text-[#000] hover:bg-[#FFAEEE] transition-all duration-200`, | |
!addPersonValue && | |
`opacity-[0.3] pointer-events-none`, | |
)} | |
> | |
Add Person | |
</button> | |
</div> | |
</div> | |
</div> | |
</Portal> | |
)} | |
{isAddPerson && ( | |
<Portal domId="intent-modal"> | |
<div className="bg-[rgba(64,64,64,0.40)] absolute left-0 top-0 w-full h-full backdrop-blur-[20px] flex items-center justify-center min-h-[600px]"> | |
<button | |
onClick={() => { | |
setIsPersonsModal(true); | |
setIsAddPerson(false); | |
}} | |
className="absolute top-8 left-8 opacity-[0.5] hover:opacity-[100%] transition-all" | |
> | |
<img src="/images/goback.svg" alt="" /> | |
</button> | |
<button | |
onClick={() => { | |
setIsAddPerson(false); | |
}} | |
className="absolute top-8 right-8 opacity-[0.5] hover:opacity-[100%] transition-all" | |
> | |
<img src="/images/button-close.svg" alt="" /> | |
</button> | |
<div className="max-w-[520px] w-[520px] text-center tracking-widepb-5"> | |
<div className="font-bold text-5xl mb-6 leading-[56px]"> | |
Add a person | |
</div> | |
<div>Enter an address</div> | |
<form | |
action="" | |
className="mt-12 text-left flex items-center justify-between gap-2 bg-[rgba(229,238,255,0.15)] border-[1px] border-white px-4 h-[60px]" | |
> | |
<div className="w-full"> | |
<label | |
className="text-[rgba(229,238,255,0.60)] text-xs" | |
htmlFor="address" | |
> | |
Address | |
</label> | |
<input | |
className="block w-full bg-transparent outline-none foces:outline-none" | |
id="address" | |
onChange={(e) => handleInput(e)} | |
value={addPersonValue} | |
/> | |
</div> | |
<button className="font-medium text-[rgba(229,238,255,0.60)] px-2 hover:text-white transition-all duratioin-200"> | |
Paste | |
</button> | |
</form> | |
<div className="mt-12 pt-6"> | |
<button | |
onClick={() => { | |
if (!isValidAddress(addPersonValue)) { | |
alert('Please enter a valid address.'); | |
return; | |
} | |
setIsPersonsModal(false); | |
}} | |
className={clsx( | |
`bg-[#FFF] h-14 flex items-center justify-center w-full font-semibold text-[#000] hover:bg-[#FFAEEE] transition-all duration-200`, | |
!addPersonValue && | |
`opacity-[0.3] pointer-events-none`, | |
)} | |
> | |
Add Person | |
</button> | |
</div> | |
</div> | |
</div> | |
</Portal> | |
)} |
Summary by CodeRabbit
New Features
CreateIntent
component for creating and managing intents with various approval settings.AddPersonModal
.ChangePersonModal
.Enhancements
IntentComponent
.Bug Fixes
CreateIntentModal
by removing an unnecessary line.Refactor
monitorTx
function withinkeplr.tsx
.Chores
.gitignore
to include*.local
files.