-
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
dApp commit history #38
Merged
Merged
Changes from 35 commits
Commits
Show all changes
54 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 78c9978
refactor: rename the file of project.ts and restruct
0xExp-po 86283b9
chore: add commit history view in project info
0xExp-po 812f952
Merge branch 'tupui:main' into dapp-dev
0xExp-po 2340066
Merge branch 'dapp-dev' of https://github.com/0xExp-po/soroban-versio…
0xExp-po b3f26ac
style: set color theme as extend in tailwindconfig
0xExp-po b026f26
feat: create formatTime and Date function
0xExp-po a8a5153
feat: add commit history section
0xExp-po 7d1b143
feat: create get commit function
0xExp-po 2453634
chore: update github service
0xExp-po d482522
chore: update commit history table
0xExp-po 6809121
chore: remove change project name function
0xExp-po 4989e60
chore: highlight latest commit in history
0xExp-po a4c866b
chore: fix type script error
0xExp-po 461eccd
chore: change scroll bar style
0xExp-po 3731700
refactor: divide project service to state service
0xExp-po 152fbbf
feat: create project repo info state variable
0xExp-po 98cad04
feat: initialize state variables by local storage
0xExp-po 2d7ab70
feat: divide project service to state service (2)
0xExp-po 7e6b48c
chore: update ui of project info view
0xExp-po dda12e5
feat: fix bug wallet connection after set project
0xExp-po 3069ad7
feat: create utils functions related get link
0xExp-po 042a38f
chore: jump to latest commit
0xExp-po e27177d
chore: fix scroll bar error and jump delay time
0xExp-po f743a74
feat: add astro/react
0xExp-po 4755873
feat: display real commit history
0xExp-po 4c2010c
chore: delete commit history demo data
0xExp-po 5dc8193
Merge branch 'tupui:main' into dapp-dev
0xExp-po 2845f8f
chore: display update commit section only for maintainer
0xExp-po 62ba7f0
Fix button handlers and re-registration, missing loadedProjectInfo an…
tupui 91384c1
Merge branch 'dapp-dev' of https://github.com/0xExp-po/soroban-versio…
0xExp-po 43ba04e
Fix button handlers, re-registration, missing loadedProjectInfo and h…
tupui e65bba2
Merge branch 'dapp-dev' of https://github.com/0xExp-po/soroban-versio…
0xExp-po 323be3b
Fix buttons
tupui 37f4293
fix:change registerProject function
0xExp-po 8da7530
chore: create package-lock
0xExp-po ff704dd
Merge from origin/dapp-dev
0xExp-po deb7f0e
chore: change loadedProjectInfo name to loadProjectInfo
0xExp-po d35d037
fix: load project latestsha function invoking
0xExp-po e736ac1
Merge branch 'tupui:main' into dapp-dev
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
import { getCommitHistory } from '../service/GithubService'; | ||
import CommitRecord from './CommitRecord.astro'; | ||
import { formatDate } from '../service/utils'; | ||
import type { FormattedCommit } from '../types/github'; | ||
|
||
const commitHistory = await getCommitHistory('tupui', 'soroban-versioning'); | ||
--- | ||
|
||
<div class="commit-history-container space-y-4 relative pl-8 before:content-[''] before:absolute before:left-[0.5rem] before:top-0 before:bottom-0 before:w-0.5 before:bg-zinc-700"> | ||
{commitHistory && commitHistory.length > 0 && commitHistory.map((day: { date: string; commits: FormattedCommit[] }) => ( | ||
<div class="day-group relative"> | ||
<h3 class="text-lg font-semibold pb-4 relative"> | ||
<div class="commit-dot absolute left-[-2.2rem] top-0 w-[25px] h-[25px] bg-[#f3f3f3] rounded-full before:content-[''] before:absolute before:left-[50%] before:top-[50%] before:transform before:-translate-x-1/2 before:-translate-y-1/2 before:w-[15px] before:h-[15px] before:border-[2px] before:rounded-full"></div> | ||
<span class="pr-2 relative z-10">{formatDate(day.date)}</span> | ||
</h3> | ||
<div class="space-y-4 relative"> | ||
{day.commits.map((commit: FormattedCommit) => ( | ||
<div class="relative"> | ||
<div class="absolute left-[-1.25rem] top-1/2 w-2 h-2 rounded-full transform -translate-y-1/2"></div> | ||
<CommitRecord | ||
message={commit.message} | ||
date={commit.commit_date} | ||
authorName={commit.author.name} | ||
authorGithubLink={commit.author.html_url} | ||
sha={commit.sha} | ||
commitLink={commit.html_url} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
|
||
<style> | ||
.commit-history-container { | ||
max-width: 900px; | ||
margin: 0 auto; | ||
} | ||
</style> |
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,120 @@ | ||
--- | ||
interface Props { | ||
message: string; | ||
date: string; | ||
authorName: string; | ||
authorGithubLink: string; | ||
sha: string; | ||
commitLink: string; | ||
} | ||
|
||
const { message, date, authorName, authorGithubLink, sha, commitLink } = Astro.props; | ||
|
||
import { formatTime } from '../service/utils'; | ||
|
||
const formattedMessage = message.split(/\r?\n/).map((line: string) => line.trim()).filter(Boolean); | ||
const firstLine = formattedMessage[0]; | ||
const hasMoreLines = formattedMessage.length > 1; | ||
--- | ||
|
||
<div class="commit-record relative bg-white p-4 rounded-lg border border-gray-200 shadow-sm flex justify-between items-start" data-sha={sha}> | ||
<div class="commit-info flex-grow overflow-hidden mr-4"> | ||
<div class="flex items-center"> | ||
<a href={commitLink} target="_blank" rel="noopener noreferrer" class="commit-message text-lg font-medium hover:underline hover:text-blue-500 truncate">{firstLine}</a> | ||
{hasMoreLines && ( | ||
<button class="expand-button ml-2 text-xs bg-zinc-200 hover:bg-zinc-300 text-gray-700 font-semibold py-1 px-2 rounded-md transition-colors duration-200 flex-shrink-0"> | ||
. . . | ||
</button> | ||
)} | ||
</div> | ||
{hasMoreLines && ( | ||
<div class="expanded-message hidden mt-2 text-sm text-gray-700 whitespace-pre-wrap">{formattedMessage.slice(1).join('\n')}</div> | ||
)} | ||
<div class="commit-details text-sm text-gray-600 mt-1"> | ||
<a href={authorGithubLink} target="_blank" rel="noopener noreferrer" class="author-name font-semibold hover:underline hover:text-blue-500">{authorName}</a> | ||
<span class="mx-1">committed on</span> | ||
<span class="commit-date">{formatTime(date)}</span> | ||
</div> | ||
</div> | ||
<div class="commit-sha flex items-center space-x-2 flex-shrink-0"> | ||
<a href={commitLink} target="_blank" rel="noopener noreferrer" class="sha text-sm font-mono text-gray-500 hover:bg-zinc-400 transition-colors duration-200 px-2 py-1 rounded">{sha.substring(0, 7)}</a> | ||
<button class="copy-button hover:bg-zinc-400 transition-colors duration-200 p-1 rounded" data-sha={sha}> | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 text-gray-400 hover:text-gray-600"> | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M15.666 3.888A2.25 2.25 0 0013.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 01-.75.75H9a.75.75 0 01-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184" /> | ||
</svg> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
import { getProjectHash } from '../service/ProjectService'; | ||
|
||
function setupCopyButton(button: HTMLButtonElement) { | ||
button.addEventListener('click', async () => { | ||
const sha = button.getAttribute('data-sha'); | ||
if (sha) { | ||
try { | ||
await navigator.clipboard.writeText(sha); | ||
const svg = button.querySelector('svg'); | ||
if (svg) { | ||
svg.classList.remove('text-gray-400', 'hover:text-gray-600'); | ||
svg.classList.add('text-green-500'); | ||
svg.innerHTML = ` | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5" /> | ||
`; | ||
} | ||
setTimeout(() => { | ||
if (svg) { | ||
svg.classList.remove('text-green-500'); | ||
svg.classList.add('text-gray-400', 'hover:text-gray-600'); | ||
svg.innerHTML = ` | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M15.666 3.888A2.25 2.25 0 0013.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 01-.75.75H9a.75.75 0 01-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184" /> | ||
`; | ||
} | ||
}, 2000); | ||
} catch (err) { | ||
console.error('Failed to copy: ', err); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
function setupExpandButtons() { | ||
const expandButtons = document.querySelectorAll('.expand-button'); | ||
expandButtons.forEach(button => { | ||
button.addEventListener('click', () => { | ||
const record = button.closest('.commit-record'); | ||
const expandedMessage = record?.querySelector('.expanded-message'); | ||
if (expandedMessage) { | ||
expandedMessage.classList.toggle('hidden'); | ||
button.textContent = expandedMessage.classList.contains('hidden') ? '. . .' : 'Less'; | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
async function highlightLatestCommit() { | ||
const latestSha = await getProjectHash(); | ||
if (latestSha) { | ||
const commitRecords = document.querySelectorAll('.commit-record'); | ||
commitRecords.forEach((record) => { | ||
const recordSha = record.getAttribute('data-sha'); | ||
if (recordSha === latestSha) { | ||
record.classList.add('border-2', 'border-blue-300', 'bg-zinc-300'); | ||
const indicator = document.createElement('div'); | ||
indicator.className = 'absolute top-0.5 left-1 text-xs font-bold tracking-tighter leading-3 bg-lime rounded-sm p-0.5'; | ||
indicator.textContent = 'latest commit'; | ||
record.insertBefore(indicator, record.firstChild); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
document.addEventListener('astro:page-load', () => { | ||
highlightLatestCommit(); | ||
const copyButtons = document.querySelectorAll('.copy-button'); | ||
copyButtons.forEach(button => setupCopyButton(button as HTMLButtonElement)); | ||
setupExpandButtons(); | ||
}); | ||
</script> | ||
|
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
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.
I am not sure I understand why this is set to
'tupui', 'soroban-versioning'
. We want to fetch the history of the project people would select, not oftupui/soroban-versioning
. This is missing a props or something else so that it points to the GitHub of the selected project (url in the config like in the Project info section).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.
yes, you're right
that's why I said I used demo data
I've developed function to get dynamic info user selects and testing now
after test, I'll push it too