mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-27 02:40:30 +00:00
Always use a static back route (#2028)
Fixes: https://github.com/woodpecker-ci/woodpecker/issues/1998 --------- Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
c0216deb43
commit
2e954801b8
6 changed files with 17 additions and 21 deletions
9
web/src/compositions/useRouteBack.ts
Normal file
9
web/src/compositions/useRouteBack.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { RouteLocationRaw, useRouter } from 'vue-router';
|
||||
|
||||
export function useRouteBack(to: RouteLocationRaw) {
|
||||
const router = useRouter();
|
||||
|
||||
return async () => {
|
||||
await router.replace(to);
|
||||
};
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import { RouteLocationRaw, useRouter } from 'vue-router';
|
||||
|
||||
export function useRouteBackOrDefault(to: RouteLocationRaw) {
|
||||
const router = useRouter();
|
||||
|
||||
return async () => {
|
||||
if ((window.history.state as { back: string }).back === null) {
|
||||
await router.replace(to);
|
||||
return;
|
||||
}
|
||||
router.back();
|
||||
};
|
||||
}
|
|
@ -37,7 +37,7 @@ import useApiClient from '~/compositions/useApiClient';
|
|||
import { useAsyncAction } from '~/compositions/useAsyncAction';
|
||||
import useNotifications from '~/compositions/useNotifications';
|
||||
import { useRepoSearch } from '~/compositions/useRepoSearch';
|
||||
import { useRouteBackOrDefault } from '~/compositions/useRouteBackOrDefault';
|
||||
import { useRouteBack } from '~/compositions/useRouteBack';
|
||||
import { Repo } from '~/lib/api/types';
|
||||
|
||||
const router = useRouter();
|
||||
|
@ -62,5 +62,5 @@ const { doSubmit: activateRepo, isLoading: isActivatingRepo } = useAsyncAction(a
|
|||
await router.push({ name: 'repo', params: { repoId: _repo.id } });
|
||||
});
|
||||
|
||||
const goBack = useRouteBackOrDefault({ name: 'repos' });
|
||||
const goBack = useRouteBack({ name: 'repos' });
|
||||
</script>
|
||||
|
|
|
@ -25,7 +25,7 @@ import Tab from '~/components/layout/scaffold/Tab.vue';
|
|||
import OrgSecretsTab from '~/components/org/settings/OrgSecretsTab.vue';
|
||||
import { inject } from '~/compositions/useInjectProvide';
|
||||
import useNotifications from '~/compositions/useNotifications';
|
||||
import { useRouteBackOrDefault } from '~/compositions/useRouteBackOrDefault';
|
||||
import { useRouteBack } from '~/compositions/useRouteBack';
|
||||
|
||||
const notifications = useNotifications();
|
||||
const router = useRouter();
|
||||
|
@ -41,5 +41,5 @@ onMounted(async () => {
|
|||
}
|
||||
});
|
||||
|
||||
const goBack = useRouteBackOrDefault({ name: 'repos-owner' });
|
||||
const goBack = useRouteBack({ name: 'org' });
|
||||
</script>
|
||||
|
|
|
@ -49,7 +49,7 @@ import GeneralTab from '~/components/repo/settings/GeneralTab.vue';
|
|||
import RegistriesTab from '~/components/repo/settings/RegistriesTab.vue';
|
||||
import SecretsTab from '~/components/repo/settings/SecretsTab.vue';
|
||||
import useNotifications from '~/compositions/useNotifications';
|
||||
import { useRouteBackOrDefault } from '~/compositions/useRouteBackOrDefault';
|
||||
import { useRouteBack } from '~/compositions/useRouteBack';
|
||||
import { Repo, RepoPermissions } from '~/lib/api/types';
|
||||
|
||||
const notifications = useNotifications();
|
||||
|
@ -73,5 +73,5 @@ onMounted(async () => {
|
|||
}
|
||||
});
|
||||
|
||||
const goBack = useRouteBackOrDefault({ name: 'repo' });
|
||||
const goBack = useRouteBack({ name: 'repo' });
|
||||
</script>
|
||||
|
|
|
@ -91,7 +91,7 @@ import { useAsyncAction } from '~/compositions/useAsyncAction';
|
|||
import { useFavicon } from '~/compositions/useFavicon';
|
||||
import useNotifications from '~/compositions/useNotifications';
|
||||
import usePipeline from '~/compositions/usePipeline';
|
||||
import { useRouteBackOrDefault } from '~/compositions/useRouteBackOrDefault';
|
||||
import { useRouteBack } from '~/compositions/useRouteBack';
|
||||
import { Repo, RepoPermissions } from '~/lib/api/types';
|
||||
import { usePipelineStore } from '~/store/pipelines';
|
||||
|
||||
|
@ -196,5 +196,5 @@ const activeTab = computed({
|
|||
},
|
||||
});
|
||||
|
||||
const goBack = useRouteBackOrDefault({ name: 'repo' });
|
||||
const goBack = useRouteBack({ name: 'repo' });
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue