-
Notifications
You must be signed in to change notification settings - Fork 4
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
update dapp code according to tupui's review #37
Merged
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e4e0f1a
feat: add getProject function in project.ts
0xExp-po c39cd48
chore: add check project/select path function in set project page
0xExp-po 80b8ab7
feat: add project info component commit page
0xExp-po 600acac
refactor: update components file structure
0xExp-po e88e57c
feat: create modal component
0xExp-po 0eed507
feat: add update config function
0xExp-po b4ca722
feat: add update config function in commit page
0xExp-po 3c94b9e
chore: keep displaying connected wallet
0xExp-po 6f472cd
Update dapp/src/components/ProjectInfo.astro
0xExp-po 570f912
chore: update project link and remove console
0xExp-po 3f7e912
Merge branch 'dapp-dev' of https://github.com/0xExp-po/soroban-versio…
0xExp-po 3b05c21
Linter
tupui d599bef
chore: update project info component ui
0xExp-po 23ad649
chore: update 'update config' button function
0xExp-po 38309b6
chore: add theme props to loading component
0xExp-po 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
--- | ||
import Topic from "./utils/Topic.astro"; | ||
import Modal from "./utils/Modal.astro"; | ||
--- | ||
|
||
<div class="relative flex flex-col items-center md:flex-row justify-between"> | ||
<Topic title="Project Information" description="" id="project-name-topic"/> | ||
<div id="open-update-config-modal-button" class="mb-1.5 mt-12 pr-3 hidden"> | ||
<button | ||
update-config | ||
aria-controls="update-config-modal" | ||
class="w-full p-3 bg-zinc-900 rounded-[14px] justify-center gap-2.5 inline-flex" | ||
> | ||
<span class="text-center text-white text-xl font-normal leading-7"> | ||
Update Config | ||
</span> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div | ||
class="relative flex flex-col items-center md:flex-row my-6 bg-zinc-100 rounded-[45px]" | ||
> | ||
<div class="row items-center py-12 px-4 md:px-20 md:w-8/12 md:py-10"> | ||
<div class="space-y-6 md:w-full"> | ||
<div id="project-maintainers" class="space-y-2"> | ||
<h3 class="text-lg font-semibold">Maintainers:</h3> | ||
<ul class="list-disc list-inside"></ul> | ||
</div> | ||
<div id="project-link" class="flex items-center space-x-2"> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"> | ||
<path fill-rule="evenodd" d="M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z" clip-rule="evenodd" /> | ||
</svg> | ||
<a href="#" id="github-link" class="text-blue-600 hover:underline" target="_blank" rel="noopener noreferrer">Link to GitHub</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<Modal id="update-config-modal" title="Update Config"> | ||
<div id="modal-content" class="space-y-4 w-[600px]"> | ||
<h2 id="modal-project-name" class="text-3xl font-bold mb-4">Project Name</h2> | ||
|
||
<label class="block mb-2 text-base font-medium text-black"> | ||
Maintainers | ||
<input | ||
type="text" | ||
id="modal-maintainers" | ||
class="block p-3 w-full text-base text-black bg-white rounded-lg border shadow-sm focus:ring-black focus:border-black" | ||
placeholder="List of maintainers' addresses as G...,G..." | ||
required | ||
/> | ||
</label> | ||
|
||
<label class="block mb-2 text-base font-medium text-black"> | ||
URL | ||
<input | ||
type="text" | ||
id="modal-config-url" | ||
class="block p-3 w-full text-base text-black bg-white rounded-lg border shadow-sm focus:ring-black focus:border-black" | ||
placeholder="Information file URL" | ||
required | ||
/> | ||
</label> | ||
|
||
<label class="block mb-2 text-base font-medium text-black"> | ||
Information file hash | ||
<input | ||
type="text" | ||
id="modal-config-hash" | ||
class="block p-3 w-full text-base text-black bg-white rounded-lg border shadow-sm focus:ring-black focus:border-black" | ||
placeholder="Information file hash" | ||
required | ||
minlength="40" | ||
maxlength="40" | ||
/> | ||
</label> | ||
|
||
<div id="wrap-update-button"> | ||
<button | ||
id="update-config-button" | ||
class="w-full py-5 bg-zinc-900 rounded-[14px] justify-center gap-2.5 inline-flex" | ||
> | ||
<span class="text-center text-white text-xl font-normal leading-7"> | ||
Update Config | ||
</span> | ||
</button> | ||
</div> | ||
</div> | ||
</Modal> | ||
|
||
<script> | ||
import { loadedProjectInfo, updateConfig } from "./project"; | ||
import { loadedPublicKey } from "./stellar-wallets-kit"; | ||
|
||
document.addEventListener("astro:page-load", () => { | ||
const topicElement = document.getElementById("project-name-topic"); | ||
const topicDescriptionElement = topicElement?.querySelector("p"); | ||
const modal = document.getElementById("update-config-modal") as HTMLDialogElement; | ||
|
||
function updateProjectInfo() { | ||
const projectInfo = loadedProjectInfo(); | ||
if (projectInfo) { | ||
console.log("projectInfo:", projectInfo); | ||
if (topicDescriptionElement) { | ||
topicDescriptionElement.textContent = projectInfo.name; | ||
} | ||
const maintainersList = document.getElementById("project-maintainers"); | ||
if (maintainersList) { | ||
const ul = maintainersList.querySelector("ul"); | ||
if (ul) { | ||
ul.innerHTML = ''; | ||
projectInfo.maintainers.forEach((maintainer: string) => { | ||
const li = document.createElement("li"); | ||
li.textContent = maintainer; | ||
ul.appendChild(li); | ||
}); | ||
} | ||
} | ||
const githubLink = document.getElementById("github-link") as HTMLAnchorElement; | ||
if (githubLink) { | ||
githubLink.href = `${projectInfo.config.url}`; | ||
} | ||
|
||
// Update modal content | ||
const modalProjectName = document.getElementById("modal-project-name"); | ||
if (modalProjectName) { | ||
modalProjectName.textContent = projectInfo.name; | ||
} | ||
|
||
const modalMaintainers = document.getElementById("modal-maintainers") as HTMLInputElement; | ||
if (modalMaintainers) { | ||
modalMaintainers.value = projectInfo.maintainers.join(','); | ||
} | ||
const modalConfigUrl = document.getElementById("modal-config-url") as HTMLInputElement; | ||
if (modalConfigUrl) { | ||
modalConfigUrl.value = projectInfo.config.url; | ||
} | ||
const modalConfigHash = document.getElementById("modal-config-hash") as HTMLInputElement; | ||
if (modalConfigHash) { | ||
modalConfigHash.value = projectInfo.config.hash; | ||
} | ||
|
||
// Check if the connected wallet is a maintainer | ||
const connectedPublicKey = loadedPublicKey(); | ||
const isMaintainer = connectedPublicKey ? projectInfo.maintainers.includes(connectedPublicKey) : false; | ||
const updateConfigButton = document.getElementById("open-update-config-modal-button"); | ||
if (updateConfigButton) { | ||
updateConfigButton.classList.toggle("hidden", !isMaintainer); | ||
} | ||
} | ||
} | ||
|
||
updateProjectInfo(); | ||
|
||
const button = document.querySelector( | ||
"[update-config]", | ||
) as HTMLButtonElement; | ||
if (button) { | ||
button.addEventListener("click", async () => { | ||
console.log("Update config button clicked"); | ||
modal.showModal(); | ||
}); | ||
} | ||
|
||
const updateButton = document.getElementById("update-config-button"); | ||
if (updateButton) { | ||
updateButton.addEventListener("click", async () => { | ||
const modalMaintainers = (document.getElementById("modal-maintainers") as HTMLInputElement).value; | ||
const modalConfigUrl = (document.getElementById("modal-config-url") as HTMLInputElement).value; | ||
const modalConfigHash = (document.getElementById("modal-config-hash") as HTMLInputElement).value; | ||
|
||
const updateStatus = await updateConfig( | ||
modalMaintainers, | ||
modalConfigUrl, | ||
modalConfigHash | ||
); | ||
|
||
if (updateStatus) { | ||
updateProjectInfo(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a follow up, I think it should also reload the project info. And same as with the other buttons, it should add the spinner component so users know something happened after they clicked the button. |
||
(document.getElementById("update-config-modal") as HTMLDialogElement).close(); | ||
} else { | ||
alert("Failed to update project config. Please try again."); | ||
} | ||
}); | ||
} | ||
}); | ||
</script> | ||
tupui marked this conversation as resolved.
Show resolved
Hide resolved
|
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 was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
dapp/src/components/Navbar.astro → dapp/src/components/layout/Navbar.astro
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
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.
Sorry maybe I was not clear. This should look like this.
And when you get the name it should appear in another div right above the list of maintainers. So around L25 here.
Can be like you have in the modal to update the config basically.