improve admin release and deployment safeguards
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
listSources,
|
||||
type GiteaCommit
|
||||
} from './application-api';
|
||||
import { getStoredSelectedComponentId, setStoredSelectedComponentId } from '../../lib/selected-app';
|
||||
import { getStoredSelectedComponentId, selectedComponentChangedEventName, setStoredSelectedComponentId } from '../../lib/selected-app';
|
||||
|
||||
const giteaBaseUrl = import.meta.env.VITE_GITEA_BASE_URL ?? 'http://localhost:3000';
|
||||
const giteaAppOrg = import.meta.env.VITE_GITEA_APP_ORG ?? import.meta.env.GITEA_APP_ORG ?? 'platform';
|
||||
@@ -352,6 +352,25 @@ export function SourceManagementPage() {
|
||||
});
|
||||
}, [filteredSources, selectedAppId]);
|
||||
|
||||
useEffect(() => {
|
||||
const storedSourceId = getStoredSelectedComponentId(selectedAppId);
|
||||
if (!storedSourceId || storedSourceId === selectedSourceId) return;
|
||||
if (!filteredSources.some((source) => source.id === storedSourceId)) return;
|
||||
setSelectedSourceId(storedSourceId);
|
||||
}, [filteredSources, selectedAppId, selectedSourceId]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleSelectedComponentChange = (event: Event) => {
|
||||
const detail = (event as CustomEvent<{ appId?: string; componentId?: string }>).detail;
|
||||
if (detail?.appId !== selectedAppId || !detail.componentId) return;
|
||||
if (!filteredSources.some((source) => source.id === detail.componentId)) return;
|
||||
setSelectedSourceId(detail.componentId);
|
||||
};
|
||||
|
||||
window.addEventListener(selectedComponentChangedEventName, handleSelectedComponentChange);
|
||||
return () => window.removeEventListener(selectedComponentChangedEventName, handleSelectedComponentChange);
|
||||
}, [filteredSources, selectedAppId]);
|
||||
|
||||
useEffect(() => {
|
||||
setCommitPage(1);
|
||||
}, [selectedSourceId, selectedBranch, commitRange]);
|
||||
|
||||
Reference in New Issue
Block a user