Skip to content

Commit

Permalink
rename a repo init function by the way and fix ts error
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Nov 27, 2024
1 parent 4fc5a8d commit 9d1513b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions web_src/js/features/repo-settings-branches.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {beforeEach, describe, expect, test, vi} from 'vitest';
import {initRepoBranchesSettings} from './repo-settings-branches.ts';
import {initRepoSettingsBranchesDrag} from './repo-settings-branches.ts';
import {POST} from '../modules/fetch.ts';
import {createSortable} from '../modules/sortable.ts';

Expand Down Expand Up @@ -31,7 +31,7 @@ describe('Repository Branch Settings', () => {
});

test('should initialize sortable for protected branches list', () => {
initRepoBranchesSettings();
initRepoSettingsBranchesDrag();

expect(createSortable).toHaveBeenCalledWith(
document.querySelector('#protected-branches-list'),
Expand All @@ -45,7 +45,7 @@ describe('Repository Branch Settings', () => {
test('should not initialize if protected branches list is not present', () => {
document.body.innerHTML = '';

initRepoBranchesSettings();
initRepoSettingsBranchesDrag();

expect(createSortable).not.toHaveBeenCalled();
});
Expand All @@ -59,7 +59,7 @@ describe('Repository Branch Settings', () => {
return {destroy: vi.fn()};
});

initRepoBranchesSettings();
initRepoSettingsBranchesDrag();

expect(POST).toHaveBeenCalledWith(
'some/repo/branches/priority',
Expand Down
2 changes: 1 addition & 1 deletion web_src/js/features/repo-settings-branches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {POST} from '../modules/fetch.ts';
import {showErrorToast} from '../modules/toast.ts';
import {queryElemChildren} from '../utils/dom.ts';

export function initRepoBranchesSettings() {
export function initRepoSettingsBranchesDrag() {
const protectedBranchesList = document.querySelector('#protected-branches-list');
if (!protectedBranchesList) return;

Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/repo-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {minimatch} from 'minimatch';
import {createMonaco} from './codeeditor.ts';
import {onInputDebounce, queryElems, toggleElem} from '../utils/dom.ts';
import {POST} from '../modules/fetch.ts';
import {initRepoBranchesSettings} from './repo-settings-branches.ts';
import {initRepoSettingsBranchesDrag} from './repo-settings-branches.ts';

const {appSubUrl, csrfToken} = window.config;

Expand Down Expand Up @@ -155,5 +155,5 @@ export function initRepoSettings() {
initRepoSettingsCollaboration();
initRepoSettingsSearchTeamBox();
initRepoSettingsGitHook();
initRepoBranchesSettings();
initRepoSettingsBranchesDrag();
}
2 changes: 1 addition & 1 deletion web_src/js/modules/sortable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {SortableOptions, SortableEvent} from 'sortablejs';

export async function createSortable(el: HTMLElement, opts: {handle?: string} & SortableOptions = {}) {
export async function createSortable(el: Element, opts: {handle?: string} & SortableOptions = {}) {
// @ts-expect-error: wrong type derived by typescript
const {Sortable} = await import(/* webpackChunkName: "sortablejs" */'sortablejs');

Expand Down

0 comments on commit 9d1513b

Please sign in to comment.