mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-25 10:36:55 +00:00
Access repos by their ids (#1691)
closes #1295 closes #648 # TODO - [x] add new routes with `:repoID` - [x] load repo in middleware using `:repoID` if present - [x] update UI routes `:owner/:name` to `:repoID` - [x] load repos using id in UI - [x] add lookup endpoint `:owner/:name` to `:repoID` - [x] redirect `:owner/:name` to `:repoID` in UI - [x] use badge with `:repoID` route in UI - [x] update `woodpecker-go` - [x] check cli - [x] add migrations / deprecation notes - [x] check if #648 got solved directly - [x] Test - [x] create repo - [x] repo pages - [x] ui redirects - [x] forge status links
This commit is contained in:
@@ -96,8 +96,7 @@ import { Repo, RepoPermissions } from '~/lib/api/types';
|
||||
import { usePipelineStore } from '~/store/pipelines';
|
||||
|
||||
const props = defineProps<{
|
||||
repoOwner: string;
|
||||
repoName: string;
|
||||
repoId: string;
|
||||
pipelineId: string;
|
||||
}>();
|
||||
|
||||
@@ -110,15 +109,15 @@ const i18n = useI18n();
|
||||
|
||||
const pipelineStore = usePipelineStore();
|
||||
const pipelineId = toRef(props, 'pipelineId');
|
||||
const repoOwner = toRef(props, 'repoOwner');
|
||||
const repoName = toRef(props, 'repoName');
|
||||
const _repoId = toRef(props, 'repoId');
|
||||
const repoId = computed(() => parseInt(_repoId.value, 10));
|
||||
const repo = inject<Ref<Repo>>('repo');
|
||||
const repoPermissions = inject<Ref<RepoPermissions>>('repo-permissions');
|
||||
if (!repo || !repoPermissions) {
|
||||
throw new Error('Unexpected: "repo" & "repoPermissions" should be provided at this place');
|
||||
}
|
||||
|
||||
const pipeline = pipelineStore.getPipeline(repoOwner, repoName, pipelineId);
|
||||
const pipeline = pipelineStore.getPipeline(repoId, pipelineId);
|
||||
const { since, duration, created } = usePipeline(pipeline);
|
||||
provide('pipeline', pipeline);
|
||||
|
||||
@@ -131,7 +130,7 @@ async function loadPipeline(): Promise<void> {
|
||||
throw new Error('Unexpected: Repo is undefined');
|
||||
}
|
||||
|
||||
await pipelineStore.loadPipeline(repo.value.owner, repo.value.name, parseInt(pipelineId.value, 10));
|
||||
await pipelineStore.loadPipeline(repo.value.id, parseInt(pipelineId.value, 10));
|
||||
|
||||
favicon.updateStatus(pipeline.value?.status);
|
||||
}
|
||||
@@ -152,7 +151,7 @@ const { doSubmit: cancelPipeline, isLoading: isCancelingPipeline } = useAsyncAct
|
||||
// throw new Error('Unexpected: Step not found');
|
||||
// }
|
||||
|
||||
await apiClient.cancelPipeline(repo.value.owner, repo.value.name, parseInt(pipelineId.value, 10));
|
||||
await apiClient.cancelPipeline(repo.value.id, parseInt(pipelineId.value, 10));
|
||||
notifications.notify({ title: i18n.t('repo.pipeline.actions.cancel_success'), type: 'success' });
|
||||
});
|
||||
|
||||
@@ -161,7 +160,7 @@ const { doSubmit: restartPipeline, isLoading: isRestartingPipeline } = useAsyncA
|
||||
throw new Error('Unexpected: Repo is undefined');
|
||||
}
|
||||
|
||||
const newPipeline = await apiClient.restartPipeline(repo.value.owner, repo.value.name, pipelineId.value, {
|
||||
const newPipeline = await apiClient.restartPipeline(repo.value.id, pipelineId.value, {
|
||||
fork: true,
|
||||
});
|
||||
notifications.notify({ title: i18n.t('repo.pipeline.actions.restart_success'), type: 'success' });
|
||||
@@ -172,7 +171,7 @@ const { doSubmit: restartPipeline, isLoading: isRestartingPipeline } = useAsyncA
|
||||
});
|
||||
|
||||
onMounted(loadPipeline);
|
||||
watch([repoName, repoOwner, pipelineId], loadPipeline);
|
||||
watch([repoId, pipelineId], loadPipeline);
|
||||
onBeforeUnmount(() => {
|
||||
favicon.updateStatus('default');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user