-
Notifications
You must be signed in to change notification settings - Fork 2
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: Update Memeooor agent #629
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1612a85
feat: add UpdateAgent functionality with modals and service patching
truemiller 81870e2
feat: enhance UpdateAgentPage with back button and improved field han…
truemiller 7469205
feat: implement ConfirmUpdateModal and refactor related components an…
truemiller d6af7ef
feat: make form fields required and improve modal confirmation messages
truemiller 52e0198
feat: make back button properties optional in CardTitle component
truemiller 70512aa
feat: enhance EditButton functionality to toggle editing state
truemiller f5ba035
feat: implement unsaved changes warning on back button click in Updat…
truemiller 1850b09
feat: add form validations, style fixes
Tanya-atatakai 98de9b9
release: 0.2.0-rc59
Tanya-atatakai d46150e
feat: refactor CardTitle and UpdateAgentPage components for improved …
mohandast52 4e0b8d5
feat: add loading state to validation process in MemeUpdateForm and i…
mohandast52 7b8b2cb
Merge branch 'fix/meme-staging' of github.com-personal:valory-xyz/ola…
mohandast52 f7a880d
feat: replace local theme with LOCAL_FORM_THEME in SetupYourAgent and…
mohandast52 9efc409
feat: refactor MemeUpdateForm and UpdateAgentPage components for impr…
mohandast52 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
87 changes: 87 additions & 0 deletions
87
frontend/components/SetupPage/hooks/useMemeFormValidate.ts
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,87 @@ | ||
import { useCallback, useState } from 'react'; | ||
|
||
import { useElectronApi } from '@/hooks/useElectronApi'; | ||
|
||
import { | ||
validateGeminiApiKey, | ||
validateTwitterCredentials, | ||
} from '../SetupYourAgent/validation'; | ||
|
||
type ValidationStatus = 'valid' | 'invalid' | 'unknown'; | ||
|
||
type FieldValues = { | ||
personaDescription: string; | ||
geminiApiKey: string; | ||
xEmail: string; | ||
xUsername: string; | ||
xPassword: string; | ||
}; | ||
|
||
export const useMemeFormValidate = () => { | ||
const electronApi = useElectronApi(); | ||
|
||
const [isValidating, setIsValidating] = useState(false); | ||
const [submitButtonText, setSubmitButtonText] = useState('Continue'); | ||
const [geminiApiKeyValidationStatus, setGeminiApiKeyValidationStatus] = | ||
useState<ValidationStatus>('unknown'); | ||
const [ | ||
twitterCredentialsValidationStatus, | ||
setTwitterCredentialsValidationStatus, | ||
] = useState<ValidationStatus>('unknown'); | ||
|
||
const handleValidate = useCallback( | ||
async (values: Record<keyof FieldValues, string>) => { | ||
setIsValidating(true); | ||
|
||
setGeminiApiKeyValidationStatus('unknown'); | ||
setTwitterCredentialsValidationStatus('unknown'); | ||
setSubmitButtonText('Validating Gemini API key...'); | ||
|
||
try { | ||
const isGeminiApiValid = await validateGeminiApiKey( | ||
values.geminiApiKey, | ||
); | ||
setGeminiApiKeyValidationStatus(isGeminiApiValid ? 'valid' : 'invalid'); | ||
if (!isGeminiApiValid) return; | ||
|
||
// validate the twitter credentials | ||
setSubmitButtonText('Validating Twitter credentials...'); | ||
const { isValid: isTwitterCredentialsValid, cookies } = | ||
electronApi?.validateTwitterLogin | ||
? await validateTwitterCredentials( | ||
values.xEmail, | ||
values.xUsername, | ||
values.xPassword, | ||
electronApi.validateTwitterLogin, | ||
) | ||
: { isValid: false, cookies: undefined }; | ||
setTwitterCredentialsValidationStatus( | ||
isTwitterCredentialsValid ? 'valid' : 'invalid', | ||
); | ||
if (!isTwitterCredentialsValid) return; | ||
if (!cookies) return; | ||
|
||
// wait for agent setup to complete | ||
setSubmitButtonText('Setting up agent...'); | ||
|
||
return cookies; | ||
} catch (error) { | ||
console.error('Error validating meme form:', error); | ||
} finally { | ||
setIsValidating(false); | ||
} | ||
}, | ||
[electronApi.validateTwitterLogin], | ||
); | ||
|
||
return { | ||
isValidating, | ||
submitButtonText, | ||
setSubmitButtonText, | ||
geminiApiKeyValidationStatus, | ||
setGeminiApiKeyValidationStatus, | ||
twitterCredentialsValidationStatus, | ||
setTwitterCredentialsValidationStatus, | ||
handleValidate, | ||
}; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
any reason to do it? 😅