mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-07-22 10:21:15 +00:00
fix: always load tab on remount
it fixes a bug, which leads to missing tab content load when opening package info
This commit is contained in:
@@ -58,11 +58,7 @@ export default function PackageInfoDialog({
|
|||||||
const { showSuccess, showError } = useNotification();
|
const { showSuccess, showError } = useNotification();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const [localPackageBase, setLocalPackageBase] = useState(packageBase);
|
const localPackageBase = packageBase;
|
||||||
if (packageBase !== null && packageBase !== localPackageBase) {
|
|
||||||
setLocalPackageBase(packageBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useState<TabKey>("logs");
|
const [activeTab, setActiveTab] = useState<TabKey>("logs");
|
||||||
const [refreshDatabase, setRefreshDatabase] = useState(true);
|
const [refreshDatabase, setRefreshDatabase] = useState(true);
|
||||||
|
|
||||||
@@ -157,38 +153,42 @@ export default function PackageInfoDialog({
|
|||||||
|
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
{pkg &&
|
{pkg &&
|
||||||
<>
|
|
||||||
<PackageDetailsGrid dependencies={dependencies} pkg={pkg} />
|
<PackageDetailsGrid dependencies={dependencies} pkg={pkg} />
|
||||||
|
}
|
||||||
|
{localPackageBase &&
|
||||||
<PackagePatchesList
|
<PackagePatchesList
|
||||||
editable={isAuthorized}
|
editable={isAuthorized}
|
||||||
onDelete={key => void handleDeletePatch(key)}
|
onDelete={key => void handleDeletePatch(key)}
|
||||||
patches={patches}
|
patches={patches}
|
||||||
/>
|
/>
|
||||||
|
}
|
||||||
|
|
||||||
|
{localPackageBase && currentRepository &&
|
||||||
|
<>
|
||||||
<Box sx={{ borderBottom: 1, borderColor: "divider", mt: 2 }}>
|
<Box sx={{ borderBottom: 1, borderColor: "divider", mt: 2 }}>
|
||||||
<Tabs onChange={(_, tab: TabKey) => setActiveTab(tab)} value={activeTab}>
|
<Tabs onChange={(_, tab: TabKey) => setActiveTab(tab)} value={activeTab}>
|
||||||
{tabs.map(({ key, label }) => <Tab key={key} label={label} value={key} />)}
|
{tabs.map(({ key, label }) => <Tab key={key} label={label} value={key} />)}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{activeTab === "logs" && localPackageBase && currentRepository &&
|
{activeTab === "logs" &&
|
||||||
<BuildLogsTab
|
<BuildLogsTab
|
||||||
packageBase={localPackageBase}
|
packageBase={localPackageBase}
|
||||||
repository={currentRepository}
|
repository={currentRepository}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
{activeTab === "changes" && localPackageBase && currentRepository &&
|
{activeTab === "changes" &&
|
||||||
<ChangesTab packageBase={localPackageBase} repository={currentRepository} />
|
<ChangesTab packageBase={localPackageBase} repository={currentRepository} />
|
||||||
}
|
}
|
||||||
{activeTab === "pkgbuild" && localPackageBase && currentRepository &&
|
{activeTab === "pkgbuild" &&
|
||||||
<PkgbuildTab packageBase={localPackageBase} repository={currentRepository} />
|
<PkgbuildTab packageBase={localPackageBase} repository={currentRepository} />
|
||||||
}
|
}
|
||||||
{activeTab === "events" && localPackageBase && currentRepository &&
|
{activeTab === "events" &&
|
||||||
<EventsTab packageBase={localPackageBase} repository={currentRepository} />
|
<EventsTab packageBase={localPackageBase} repository={currentRepository} />
|
||||||
}
|
}
|
||||||
{activeTab === "artifacts" && localPackageBase && currentRepository &&
|
{activeTab === "artifacts" &&
|
||||||
<ArtifactsTab
|
<ArtifactsTab
|
||||||
currentVersion={pkg.version}
|
currentVersion={pkg?.version}
|
||||||
packageBase={localPackageBase}
|
packageBase={localPackageBase}
|
||||||
repository={currentRepository}
|
repository={currentRepository}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import { useCallback, useMemo } from "react";
|
|||||||
import { DETAIL_TABLE_PROPS } from "utils";
|
import { DETAIL_TABLE_PROPS } from "utils";
|
||||||
|
|
||||||
interface ArtifactsTabProps {
|
interface ArtifactsTabProps {
|
||||||
currentVersion: string;
|
currentVersion?: string;
|
||||||
packageBase: string;
|
packageBase: string;
|
||||||
repository: RepositoryId;
|
repository: RepositoryId;
|
||||||
}
|
}
|
||||||
@@ -78,6 +78,7 @@ export default function ArtifactsTab({
|
|||||||
})).reverse();
|
})).reverse();
|
||||||
},
|
},
|
||||||
queryKey: QueryKeys.artifacts(packageBase, repository),
|
queryKey: QueryKeys.artifacts(packageBase, repository),
|
||||||
|
refetchOnMount: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleRollback = useCallback(async (version: string): Promise<void> => {
|
const handleRollback = useCallback(async (version: string): Promise<void> => {
|
||||||
@@ -101,7 +102,7 @@ export default function ArtifactsTab({
|
|||||||
<Tooltip title={params.row.version === currentVersion ? "Current version" : "Rollback to this version"}>
|
<Tooltip title={params.row.version === currentVersion ? "Current version" : "Rollback to this version"}>
|
||||||
<span>
|
<span>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={params.row.version === currentVersion}
|
disabled={currentVersion === params.row.version}
|
||||||
onClick={() => void handleRollback(params.row.version)}
|
onClick={() => void handleRollback(params.row.version)}
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export default function BuildLogsTab({
|
|||||||
enabled: !!packageBase,
|
enabled: !!packageBase,
|
||||||
queryFn: () => client.fetch.fetchPackageLogs(packageBase, repository),
|
queryFn: () => client.fetch.fetchPackageLogs(packageBase, repository),
|
||||||
queryKey: QueryKeys.logs(packageBase, repository),
|
queryKey: QueryKeys.logs(packageBase, repository),
|
||||||
|
refetchOnMount: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Build version selectors from all logs
|
// Build version selectors from all logs
|
||||||
@@ -116,6 +117,7 @@ export default function BuildLogsTab({
|
|||||||
)
|
)
|
||||||
: skipToken,
|
: skipToken,
|
||||||
queryKey: QueryKeys.logsVersion(packageBase, repository, activeVersion?.version ?? "", activeVersion?.processId ?? ""),
|
queryKey: QueryKeys.logsVersion(packageBase, repository, activeVersion?.version ?? "", activeVersion?.processId ?? ""),
|
||||||
|
refetchOnMount: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Derive displayed logs: prefer fresh polled data when available
|
// Derive displayed logs: prefer fresh polled data when available
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export default function EventsTab({ packageBase, repository }: EventsTabProps):
|
|||||||
enabled: !!packageBase,
|
enabled: !!packageBase,
|
||||||
queryFn: () => client.fetch.fetchPackageEvents(repository, packageBase, 30),
|
queryFn: () => client.fetch.fetchPackageEvents(repository, packageBase, 30),
|
||||||
queryKey: QueryKeys.events(repository, packageBase),
|
queryKey: QueryKeys.events(repository, packageBase),
|
||||||
|
refetchOnMount: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = useMemo<EventRow[]>(() => events.map((event, index) => ({
|
const rows = useMemo<EventRow[]>(() => events.map((event, index) => ({
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export function usePackageChanges(packageBase: string, repository: RepositoryId)
|
|||||||
enabled: !!packageBase,
|
enabled: !!packageBase,
|
||||||
queryFn: () => client.fetch.fetchPackageChanges(packageBase, repository),
|
queryFn: () => client.fetch.fetchPackageChanges(packageBase, repository),
|
||||||
queryKey: QueryKeys.changes(packageBase, repository),
|
queryKey: QueryKeys.changes(packageBase, repository),
|
||||||
|
refetchOnMount: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
Reference in New Issue
Block a user