diff --git a/web/components.d.ts b/web/components.d.ts index 3120ee4a2..6b2795a14 100644 --- a/web/components.d.ts +++ b/web/components.d.ts @@ -21,6 +21,7 @@ declare module 'vue' { Button: typeof import('./src/components/atomic/Button.vue')['default'] Checkbox: typeof import('./src/components/form/Checkbox.vue')['default'] CheckboxesField: typeof import('./src/components/form/CheckboxesField.vue')['default'] + Container: typeof import('./src/components/layout/Container.vue')['default'] CronTab: typeof import('./src/components/repo/settings/CronTab.vue')['default'] DeployPipelinePopup: typeof import('./src/components/layout/popups/DeployPipelinePopup.vue')['default'] DocsLink: typeof import('./src/components/atomic/DocsLink.vue')['default'] diff --git a/web/src/assets/locales/en.json b/web/src/assets/locales/en.json index d80dd5d4a..03ff4bde0 100644 --- a/web/src/assets/locales/en.json +++ b/web/src/assets/locales/en.json @@ -489,5 +489,6 @@ "oauth_error": "Error while authenticating against OAuth provider", "internal_error": "Some internal error occurred", "access_denied": "You are not allowed to login" - } + }, + "default": "default" } diff --git a/web/src/components/atomic/Button.vue b/web/src/components/atomic/Button.vue index c373fedbc..db656554d 100644 --- a/web/src/components/atomic/Button.vue +++ b/web/src/components/atomic/Button.vue @@ -1,6 +1,6 @@ diff --git a/web/src/compositions/useTabs.ts b/web/src/compositions/useTabs.ts index 0e453e2af..657016b6d 100644 --- a/web/src/compositions/useTabs.ts +++ b/web/src/compositions/useTabs.ts @@ -11,7 +11,7 @@ export function useTabsProvider({ disableHashMode, updateActiveTabProp, }: { - activeTabProp: Ref; + activeTabProp: Ref; updateActiveTabProp: (tab: string) => void; disableHashMode: Ref; }) { diff --git a/web/src/lib/api/client.ts b/web/src/lib/api/client.ts index e7c255205..b362d0efa 100644 --- a/web/src/lib/api/client.ts +++ b/web/src/lib/api/client.ts @@ -39,53 +39,33 @@ export default class ApiClient { this.csrf = csrf; } - private _request(method: string, path: string, data: unknown): Promise { - const endpoint = `${this.server}${path}`; - const xhr = new XMLHttpRequest(); - xhr.open(method, endpoint, true); - - if (this.token) { - xhr.setRequestHeader('Authorization', `Bearer ${this.token}`); - } - - if (method !== 'GET' && this.csrf) { - xhr.setRequestHeader('X-CSRF-TOKEN', this.csrf); - } - - return new Promise((resolve, reject) => { - xhr.onload = () => { - if (xhr.readyState === 4) { - if (xhr.status >= 300) { - const error: ApiError = { - status: xhr.status, - message: xhr.response, - }; - if (this.onerror) { - this.onerror(error); - } - reject(error); - return; - } - const contentType = xhr.getResponseHeader('Content-Type'); - if (contentType && contentType.startsWith('application/json')) { - resolve(JSON.parse(xhr.response)); - } else { - resolve(xhr.response); - } - } - }; - - xhr.onerror = (e) => { - reject(e); - }; - - if (data) { - xhr.setRequestHeader('Content-Type', 'application/json'); - xhr.send(JSON.stringify(data)); - } else { - xhr.send(); - } + private async _request(method: string, path: string, data: unknown): Promise { + const res = await fetch(`${this.server}${path}`, { + method, + headers: { + ...(method !== 'GET' && this.csrf ? { 'X-CSRF-TOKEN': this.csrf } : {}), + ...(this.token ? { Authorization: `Bearer ${this.token}` } : {}), + }, + body: data ? JSON.stringify(data) : undefined, }); + + if (!res.ok) { + const error: ApiError = { + status: res.status, + message: res.statusText, + }; + if (this.onerror) { + this.onerror(error); + } + throw new Error(res.statusText); + } + + const contentType = res.headers.get('Content-Type'); + if (contentType && contentType.startsWith('application/json')) { + return res.json(); + } + + return res.text(); } _get(path: string) { diff --git a/web/src/views/repo/RepoBranches.vue b/web/src/views/repo/RepoBranches.vue index 42d83ebdc..60cc8cc74 100644 --- a/web/src/views/repo/RepoBranches.vue +++ b/web/src/views/repo/RepoBranches.vue @@ -7,6 +7,7 @@ :to="{ name: 'repo-branch', params: { branch } }" > {{ branch }} + @@ -14,6 +15,7 @@