mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-09-28 06:22:01 +00:00
58838f225c
Rewrite of the UI using Typescript, Vue3, Windicss and Vite. The design should be close to the current one with some changes: - latest pipeline in a sidebar on the right - secrets and registry as part of the repo-settings (secrets and registry entries shouldn't be used as much so they can be "hidden" under settings IMO) - start page shows list of active repositories with button to enable / add new ones (currently you see all repositories and in most cases you only add new repositories once in a while)
37 lines
805 B
TypeScript
37 lines
805 B
TypeScript
import { computed, ref } from 'vue';
|
|
|
|
import useNotifications from '~/compositions/useNotifications';
|
|
|
|
const notifications = useNotifications();
|
|
|
|
export type UseSubmitOptions = {
|
|
showErrorNotification: false;
|
|
};
|
|
|
|
export function useAsyncAction<T extends unknown[]>(
|
|
action: (...a: T) => void | Promise<void>,
|
|
options?: UseSubmitOptions,
|
|
) {
|
|
const isLoading = ref(false);
|
|
|
|
async function doSubmit(...a: T) {
|
|
if (isLoading.value) {
|
|
return;
|
|
}
|
|
|
|
isLoading.value = true;
|
|
try {
|
|
await action(...a);
|
|
} catch (error) {
|
|
if (options?.showErrorNotification) {
|
|
notifications.notify({ title: (error as Error).message, type: 'error' });
|
|
}
|
|
}
|
|
isLoading.value = false;
|
|
}
|
|
|
|
return {
|
|
doSubmit,
|
|
isLoading: computed(() => isLoading.value),
|
|
};
|
|
}
|