Skip to content

Commit 5072417

Browse files
authored
fix: rename CopyButton for admin pages AdminCopyButton (#1222)
It looks like the transpiled result of `islands/CopyButton.tsx` is overwritten by the result of `routes/admin/(_islands)/CopyButton.tsx` during the build process. This PR tries to fix the issue by renaming the admin version to AdminCopyButton. The built script assets look like: BEFORE ``` AuditURLQuerySearch.js GitHubUserLink.js ScopeMemberRole.js chunk-CS7BFPU5.js Authorize.js GlobalSearch.js TicketMessageInput.js chunk-EL7WOSTS.js BreadcrumbsSticky.js HeaderLogo.js TicketModal.js chunk-FD4CNUX4.js CopyButton.js HomepageHeroParticles.js UserMenu.js chunk-FOUP4XVY.js CreatePackage.js LocalSymbolSearch.js apexcharts.esm-IDJUS2H7.js chunk-JSNILFVT.js CreateToken.js OverallStatus.js chunk-26HBMVF5.js chunk-RTVFZVGS.js DarkModeToggle.js PackageDescriptionEditor.js chunk-2HTBGNW6.js chunk-TZGWON76.js DependencyGraph.js PackageGitHubSettings.js chunk-3IKIH2UU.js chunk-VS66CSKJ.js DevelopmentLogin.js PublishingTaskRequeue.js chunk-4UTZPDT3.js chunk-WOT6VMZA.js DownloadChart.js RevokeToken.js chunk-6UWR3SRP.js fresh-runtime.js DownloadWidget.js ScopeDescriptionForm.js chunk-B2UJ3RWN.js metafile.json EditModal.js ScopeInviteForm.js chunk-BGFMN264.js GitHubActionsLink.js ScopeMemberLeave.js chunk-CD3SP5L4.js ``` AFTER ``` AdminCopyButton.js GitHubActionsLink.js ScopeMemberLeave.js chunk-CS7BFPU5.js AuditURLQuerySearch.js GitHubUserLink.js ScopeMemberRole.js chunk-FD4CNUX4.js Authorize.js GlobalSearch.js TicketMessageInput.js chunk-FOUP4XVY.js BreadcrumbsSticky.js HeaderLogo.js TicketModal.js chunk-RE76VC7A.js CopyButton.js HomepageHeroParticles.js UserMenu.js chunk-RTBY5TDF.js CreatePackage.js LocalSymbolSearch.js apexcharts.esm-IDJUS2H7.js chunk-RTVFZVGS.js CreateToken.js OverallStatus.js chunk-26HBMVF5.js chunk-T65JOWSX.js DarkModeToggle.js PackageDescriptionEditor.js chunk-4ECDJ3EW.js chunk-TZGWON76.js DependencyGraph.js PackageGitHubSettings.js chunk-4UTZPDT3.js chunk-VS66CSKJ.js DevelopmentLogin.js PublishingTaskRequeue.js chunk-4XSVJRE3.js chunk-WOT6VMZA.js DownloadChart.js RevokeToken.js chunk-B2UJ3RWN.js chunk-WZKL7APY.js DownloadWidget.js ScopeDescriptionForm.js chunk-BGFMN264.js fresh-runtime.js EditModal.js ScopeInviteForm.js chunk-CD3SP5L4.js metafile.json ``` In AFTER result, CopyButton.js has completely different contents as BEFORE one (and it seems using `props.text` correctly instead of `props.value` related #1219
1 parent dbf3885 commit 5072417

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

frontend/routes/admin/(_islands)/CopyButton.tsx renamed to frontend/routes/admin/(_islands)/AdminCopyButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface CopyButtonProps {
1010
children?: ComponentChildren;
1111
}
1212

13-
export function CopyButton(props: CopyButtonProps) {
13+
export function AdminCopyButton(props: CopyButtonProps) {
1414
const timer = useRef<number | null>(null);
1515
const checked = useSignal(false);
1616

frontend/routes/admin/packages.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { AdminNav } from "./(_components)/AdminNav.tsx";
66
import { URLQuerySearch } from "./(_components)/URLQuerySearch.tsx";
77
import { define } from "../../util.ts";
88
import twas from "twas";
9-
import { CopyButton } from "./(_islands)/CopyButton.tsx";
9+
import { AdminCopyButton } from "./(_islands)/AdminCopyButton.tsx";
1010

1111
export default define.page<typeof handler>(function Packages({ data, url }) {
1212
return (
@@ -59,12 +59,12 @@ export default define.page<typeof handler>(function Packages({ data, url }) {
5959
<TableData flex>
6060
{pkg.githubRepository && (
6161
<>
62-
<CopyButton
62+
<AdminCopyButton
6363
value={pkg.githubRepository.id.toString()}
6464
label="copy GitHub ID"
6565
>
6666
ID
67-
</CopyButton>
67+
</AdminCopyButton>
6868
<a
6969
href={`github.com/${pkg.githubRepository.owner}/${pkg.githubRepository.name}`}
7070
class="underline underline-offset-2"

frontend/routes/admin/publishingTasks.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { List, PublishingTask } from "../../utils/api_types.ts";
77
import { URLQuerySearch } from "./(_components)/URLQuerySearch.tsx";
88
import twas from "twas";
99
import PublishingTaskRequeue from "../../islands/PublishingTaskRequeue.tsx";
10-
import { CopyButton } from "./(_islands)/CopyButton.tsx";
10+
import { AdminCopyButton } from "./(_islands)/AdminCopyButton.tsx";
1111

1212
export default define.page<typeof handler>(function PublishingTasks({
1313
data,
@@ -46,9 +46,9 @@ export default define.page<typeof handler>(function PublishingTasks({
4646
{data.publishingTasks.map((publishingTask) => (
4747
<TableRow key={publishingTask.id}>
4848
<TableData flex>
49-
<CopyButton value={publishingTask.id} label="copy ID">
49+
<AdminCopyButton value={publishingTask.id} label="copy ID">
5050
ID
51-
</CopyButton>
51+
</AdminCopyButton>
5252
<div>
5353
<span
5454
class={`font-bold ${
@@ -71,12 +71,12 @@ export default define.page<typeof handler>(function PublishingTasks({
7171
<TableData flex>
7272
{publishingTask.user && (
7373
<>
74-
<CopyButton
74+
<AdminCopyButton
7575
value={publishingTask.user.id}
7676
label="copy user ID"
7777
>
7878
ID
79-
</CopyButton>
79+
</AdminCopyButton>
8080
<a
8181
href={`/admin/users?search=${publishingTask.user.id}`}
8282
class="underline underline-offset-2"

frontend/routes/admin/scopes/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { URLQuerySearch } from "../(_components)/URLQuerySearch.tsx";
77
import { define } from "../../../util.ts";
88
import TbArrowRight from "tb-icons/TbArrowRight";
99
import twas from "twas";
10-
import { CopyButton } from "../(_islands)/CopyButton.tsx";
10+
import { AdminCopyButton } from "../(_islands)/AdminCopyButton.tsx";
1111
import { EditModal } from "../(_islands)/EditModal.tsx";
1212

1313
export default define.page<typeof handler>(function Scopes({ data, url }) {
@@ -56,9 +56,9 @@ export default define.page<typeof handler>(function Scopes({ data, url }) {
5656
</a>
5757
</TableData>
5858
<TableData flex>
59-
<CopyButton value={scope.creator.id} label="copy user ID">
59+
<AdminCopyButton value={scope.creator.id} label="copy user ID">
6060
ID
61-
</CopyButton>
61+
</AdminCopyButton>
6262
<a
6363
href={`/admin/users?search=${scope.creator.id}`}
6464
class="underline underline-offset-2"

frontend/routes/admin/users.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { AdminNav } from "./(_components)/AdminNav.tsx";
66
import { URLQuerySearch } from "./(_components)/URLQuerySearch.tsx";
77
import { define } from "../../util.ts";
88
import twas from "twas";
9-
import { CopyButton } from "./(_islands)/CopyButton.tsx";
9+
import { AdminCopyButton } from "./(_islands)/AdminCopyButton.tsx";
1010
import { EditModal } from "./(_islands)/EditModal.tsx";
1111

1212
export default define.page<typeof handler>(function Users({ data, url }) {
@@ -38,7 +38,9 @@ export default define.page<typeof handler>(function Users({ data, url }) {
3838
{data.users.map((user) => (
3939
<TableRow key={user.id}>
4040
<TableData flex>
41-
<CopyButton value={user.id} label="copy user ID">ID</CopyButton>
41+
<AdminCopyButton value={user.id} label="copy user ID">
42+
ID
43+
</AdminCopyButton>
4244
<a href={`/user/${user.id}`} class="underline underline-offset-2">
4345
{user.name}
4446
</a>

0 commit comments

Comments
 (0)