mirror of
https://github.com/go-gitea/gitea.git
synced 2024-10-31 08:37:35 -04:00
Frontend refactor, PascalCase to camelCase, remove unused code (#17365)
* Frontend refactor, PascalCase to camelCase, remove unused code * fix
This commit is contained in:
parent
5879ab83b5
commit
2add8fe9be
@ -9,7 +9,6 @@ import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/unknwon/i18n"
|
||||
)
|
||||
@ -62,7 +61,7 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) {
|
||||
}
|
||||
|
||||
req = NewRequestWithValues(t, "POST", link, map[string]string{
|
||||
"_csrf": getCsrf(t, htmlDoc.doc),
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
@ -73,9 +72,3 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) {
|
||||
|
||||
return NewHTMLParser(t, resp.Body), url.Query().Get("name")
|
||||
}
|
||||
|
||||
func getCsrf(t *testing.T, doc *goquery.Document) string {
|
||||
csrf, exists := doc.Find("meta[name=\"_csrf\"]").Attr("content")
|
||||
assert.True(t, exists)
|
||||
return csrf
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func (doc *HTMLDoc) Find(selector string) *goquery.Selection {
|
||||
return doc.doc.Find(selector)
|
||||
}
|
||||
|
||||
// GetCSRF for get CSRC token value from input
|
||||
// GetCSRF for getting CSRF token value from input
|
||||
func (doc *HTMLDoc) GetCSRF() string {
|
||||
return doc.GetInputValueByName("_csrf")
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ func testUIDeleteBranch(t *testing.T, session *TestSession, ownerName, repoName,
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
req = NewRequestWithValues(t, "POST", relURL+"/delete", map[string]string{
|
||||
"_csrf": getCsrf(t, htmlDoc.doc),
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
"name": branchName,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
@ -127,7 +127,7 @@ func testDeleteRepository(t *testing.T, session *TestSession, ownerName, repoNam
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
req = NewRequestWithValues(t, "POST", relURL+"?action=delete", map[string]string{
|
||||
"_csrf": getCsrf(t, htmlDoc.doc),
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
"repo_name": repoName,
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
|
@ -645,7 +645,7 @@ func Contexter() func(next http.Handler) http.Handler {
|
||||
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
|
||||
"PageStartTime": startTime,
|
||||
"Link": link,
|
||||
"IsProd": setting.IsProd,
|
||||
"RunModeIsProd": setting.IsProd,
|
||||
},
|
||||
}
|
||||
// PageData is passed by reference, and it will be rendered to `window.config.pageData` in `head.tmpl` for JavaScript modules
|
||||
|
@ -205,7 +205,6 @@ func DeleteProject(ctx *context.Context) {
|
||||
// EditProject allows a project to be edited
|
||||
func EditProject(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
|
||||
ctx.Data["PageIsProjects"] = true
|
||||
ctx.Data["PageIsEditProjects"] = true
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
|
||||
|
||||
@ -233,7 +232,6 @@ func EditProject(ctx *context.Context) {
|
||||
func EditProjectPost(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*forms.CreateProjectForm)
|
||||
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
|
||||
ctx.Data["PageIsProjects"] = true
|
||||
ctx.Data["PageIsEditProjects"] = true
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
|
||||
|
||||
@ -335,8 +333,6 @@ func ViewProject(ctx *context.Context) {
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
|
||||
ctx.Data["Project"] = project
|
||||
ctx.Data["Boards"] = boards
|
||||
ctx.Data["PageIsProjects"] = true
|
||||
ctx.Data["RequiresDraggable"] = true
|
||||
|
||||
ctx.HTML(http.StatusOK, tplProjectsView)
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
<meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}{{MetaDescription}}{{end}}" />
|
||||
<meta name="keywords" content="{{MetaKeywords}}">
|
||||
<meta name="referrer" content="no-referrer" />
|
||||
<meta name="_csrf" content="{{.CsrfToken}}" />
|
||||
{{if .GoGetImport}}
|
||||
<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">
|
||||
<meta name="go-source" content="{{.GoGetImport}} _ {{.GoDocDirectory}} {{.GoDocFile}}">
|
||||
@ -19,25 +18,17 @@
|
||||
<script>
|
||||
<!-- /* eslint-disable */ -->
|
||||
window.config = {
|
||||
AppVer: '{{AppVer}}',
|
||||
AppSubUrl: '{{AppSubUrl}}',
|
||||
AssetUrlPrefix: '{{AssetUrlPrefix}}',
|
||||
IsProd: {{.IsProd}},
|
||||
CustomEmojis: {{CustomEmojis}},
|
||||
UseServiceWorker: {{UseServiceWorker}},
|
||||
csrf: '{{.CsrfToken}}',
|
||||
appVer: '{{AppVer}}',
|
||||
appSubUrl: '{{AppSubUrl}}',
|
||||
assetUrlPrefix: '{{AssetUrlPrefix}}',
|
||||
runModeIsProd: {{.RunModeIsProd}},
|
||||
customEmojis: {{CustomEmojis}},
|
||||
useServiceWorker: {{UseServiceWorker}},
|
||||
csrfToken: '{{.CsrfToken}}',
|
||||
pageData: {{.PageData}},
|
||||
HighlightJS: {{if .RequireHighlightJS}}true{{else}}false{{end}},
|
||||
SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}},
|
||||
Tribute: {{if .RequireTribute}}true{{else}}false{{end}},
|
||||
NotificationSettings: {
|
||||
MinTimeout: {{NotificationSettings.MinTimeout}},
|
||||
TimeoutStep: {{NotificationSettings.TimeoutStep}},
|
||||
MaxTimeout: {{NotificationSettings.MaxTimeout}},
|
||||
EventSourceUpdateTime: {{NotificationSettings.EventSourceUpdateTime}},
|
||||
},
|
||||
EnableTimetracking: {{if EnableTimetracking}}true{{else}}false{{end}},
|
||||
PageIsProjects: {{if .PageIsProjects }}true{{else}}false{{end}},
|
||||
requireTribute: {{.RequireTribute}},
|
||||
notificationSettings: {{NotificationSettings}}, {{/*a map provided by NewFuncMap in helper.go*/}}
|
||||
enableTimeTracking: {{EnableTimetracking}},
|
||||
{{if .RequireTribute}}
|
||||
tributeValues: Array.from(new Map([
|
||||
{{ range .Participants }}
|
||||
@ -54,7 +45,7 @@
|
||||
{{ end }}
|
||||
]).values()),
|
||||
{{end}}
|
||||
MermaidMaxSourceCharacters: {{MermaidMaxSourceCharacters}},
|
||||
mermaidMaxSourceCharacters: {{MermaidMaxSourceCharacters}},
|
||||
};
|
||||
</script>
|
||||
<link rel="icon" href="{{AssetUrlPrefix}}/img/logo.svg" type="image/svg+xml">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{template "base/head" .}}
|
||||
<div class="page-content repository milestones">
|
||||
<div class="page-content repository projects milestones">
|
||||
{{template "repo/header" .}}
|
||||
<div class="ui container">
|
||||
<div class="navbar">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{template "base/head" .}}
|
||||
<div class="page-content repository new milestone">
|
||||
<div class="page-content repository projects edit-project new milestone">
|
||||
{{template "repo/header" .}}
|
||||
<div class="ui container">
|
||||
<div class="navbar">
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{template "base/head" .}}
|
||||
<div class="page-content repository">
|
||||
<div class="page-content repository projects view-project">
|
||||
{{template "repo/header" .}}
|
||||
<div class="ui container">
|
||||
<div class="ui two column stackable grid">
|
||||
@ -7,7 +7,7 @@
|
||||
{{template "repo/issue/navbar" .}}
|
||||
</div>
|
||||
<div class="column right aligned">
|
||||
{{if and .CanWriteProjects (not .Repository.IsArchived) .PageIsProjects}}
|
||||
{{if and .CanWriteProjects (not .Repository.IsArchived)}}
|
||||
<a class="ui green button show-modal item" href="{{$.RepoLink}}/issues/new?project={{$.Project.ID}}">{{.i18n.Tr "repo.issues.new"}}</a>
|
||||
<a class="ui green button show-modal item" data-modal="#new-board-item">{{.i18n.Tr "new_project_board"}}</a>
|
||||
{{end}}
|
||||
@ -83,7 +83,7 @@
|
||||
<div class="ui segment board-column" style="background: {{.Color}} !important;" data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}/{{.ID}}">
|
||||
<div class="board-column-header df ac sb">
|
||||
<div class="ui large label board-label py-2">{{.Title}}</div>
|
||||
{{if and $.CanWriteProjects (not $.Repository.IsArchived) $.PageIsProjects (ne .ID 0)}}
|
||||
{{if and $.CanWriteProjects (not $.Repository.IsArchived) (ne .ID 0)}}
|
||||
<div class="ui dropdown jump item poping up" data-variation="tiny inverted">
|
||||
<div class="not-mobile px-3" tabindex="-1">
|
||||
{{svg "octicon-kebab-horizontal"}}
|
||||
@ -232,7 +232,7 @@
|
||||
{{if .Labels}}
|
||||
<div class="extra content labels-list p-0 pt-2">
|
||||
{{ range .Labels }}
|
||||
<a class="ui label" href="{{$.RepoLink}}/issues?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description | RenderEmojiPlain}}">{{.Name | RenderEmoji}}</a>
|
||||
<a class="ui label" href="{{$.RepoLink}}/issues?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}};" title="{{.Description | RenderEmojiPlain}}">{{.Name | RenderEmoji}}</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{end}}
|
||||
|
@ -22,7 +22,7 @@
|
||||
<script>
|
||||
import {SvgIcon} from '../svg.js';
|
||||
|
||||
const {AppSubUrl} = window.config;
|
||||
const {appSubUrl} = window.config;
|
||||
|
||||
// NOTE: see models/issue_label.go for similar implementation
|
||||
const srgbToLinear = (color) => {
|
||||
@ -112,7 +112,7 @@ export default {
|
||||
methods: {
|
||||
load(data, callback) {
|
||||
this.loading = true;
|
||||
$.get(`${AppSubUrl}/api/v1/repos/${data.owner}/${data.repo}/issues/${data.index}`, (issue) => {
|
||||
$.get(`${appSubUrl}/api/v1/repos/${data.owner}/${data.repo}/issues/${data.index}`, (issue) => {
|
||||
this.issue = issue;
|
||||
this.loading = false;
|
||||
this.$nextTick(() => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Vue from 'vue';
|
||||
import {initVueSvg, vueDelimiters} from './VueComponentLoader.js';
|
||||
|
||||
const {AppSubUrl, AssetUrlPrefix, pageData} = window.config;
|
||||
const {appSubUrl, assetUrlPrefix, pageData} = window.config;
|
||||
|
||||
function initVueComponents() {
|
||||
Vue.component('repo-search', {
|
||||
@ -95,7 +95,7 @@ function initVueComponents() {
|
||||
finalPage: 1,
|
||||
searchQuery,
|
||||
isLoading: false,
|
||||
staticPrefix: AssetUrlPrefix,
|
||||
staticPrefix: assetUrlPrefix,
|
||||
counts: {},
|
||||
repoTypes: {
|
||||
all: {
|
||||
@ -361,7 +361,7 @@ export function initDashboardRepoList() {
|
||||
data: () => {
|
||||
return {
|
||||
searchLimit: dashboardRepoListData.searchLimit || 0,
|
||||
subUrl: AppSubUrl,
|
||||
subUrl: appSubUrl,
|
||||
uid: dashboardRepoListData.uid || 0,
|
||||
};
|
||||
},
|
||||
|
@ -8,7 +8,7 @@ export function initVueEnv() {
|
||||
if (vueEnvInited) return;
|
||||
vueEnvInited = true;
|
||||
|
||||
const isProd = window.config.IsProd;
|
||||
const isProd = window.config.runModeIsProd;
|
||||
Vue.config.productionTip = false;
|
||||
Vue.config.devtools = !isProd;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
export function initAdminCommon() {
|
||||
if ($('.admin').length === 0) {
|
||||
@ -204,7 +204,7 @@ export function initAdminCommon() {
|
||||
}
|
||||
});
|
||||
$.post($this.data('link'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
ids
|
||||
}).done(() => {
|
||||
window.location.href = $this.data('redirect');
|
||||
|
@ -4,7 +4,7 @@ import {initCompColorPicker} from './comp/ColorPicker.js';
|
||||
|
||||
import 'jquery.are-you-sure';
|
||||
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
export function initGlobalFormDirtyLeaveConfirm() {
|
||||
// Warn users that try to leave a page after entering data into a form.
|
||||
@ -136,7 +136,7 @@ export async function initGlobalDropzone() {
|
||||
const $dropzone = $(el);
|
||||
await createDropzone(el, {
|
||||
url: $dropzone.data('upload-url'),
|
||||
headers: {'X-Csrf-Token': csrf},
|
||||
headers: {'X-Csrf-Token': csrfToken},
|
||||
maxFiles: $dropzone.data('max-file'),
|
||||
maxFilesize: $dropzone.data('max-size'),
|
||||
acceptedFiles: (['*/*', ''].includes($dropzone.data('accepts'))) ? null : $dropzone.data('accepts'),
|
||||
@ -159,7 +159,7 @@ export async function initGlobalDropzone() {
|
||||
if ($dropzone.data('remove-url')) {
|
||||
$.post($dropzone.data('remove-url'), {
|
||||
file: file.uuid,
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -194,7 +194,7 @@ export function initGlobalLinkActions() {
|
||||
}
|
||||
|
||||
const postData = {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
};
|
||||
for (const [key, value] of Object.entries(dataArray)) {
|
||||
if (key && key.startsWith('data')) {
|
||||
@ -232,7 +232,7 @@ export function initGlobalLinkActions() {
|
||||
}
|
||||
|
||||
$.post($this.data('url'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
id: $this.data('id')
|
||||
}).done((data) => {
|
||||
window.location.href = data.redirect;
|
||||
@ -247,7 +247,7 @@ export function initGlobalLinkActions() {
|
||||
const $this = $(this);
|
||||
const redirect = $this.data('redirect');
|
||||
$.post($this.data('url'), {
|
||||
_csrf: csrf
|
||||
_csrf: csrfToken
|
||||
}).done((data) => {
|
||||
if (data.redirect) {
|
||||
window.location.href = data.redirect;
|
||||
@ -270,7 +270,7 @@ export function initGlobalLinkActions() {
|
||||
$('.undo-button').on('click', function () {
|
||||
const $this = $(this);
|
||||
$.post($this.data('url'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
id: $this.data('id')
|
||||
}).done((data) => {
|
||||
window.location.href = data.redirect;
|
||||
@ -298,7 +298,7 @@ export function initGlobalButtons() {
|
||||
$('.delete-post.button').on('click', function () {
|
||||
const $this = $(this);
|
||||
$.post($this.data('request-url'), {
|
||||
_csrf: csrf
|
||||
_csrf: csrfToken
|
||||
}).done(() => {
|
||||
window.location.href = $this.data('done-url');
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {AppSubUrl, csrf} = window.config;
|
||||
const {appSubUrl, csrfToken} = window.config;
|
||||
|
||||
async function uploadFile(file, uploadUrl) {
|
||||
const formData = new FormData();
|
||||
@ -6,7 +6,7 @@ async function uploadFile(file, uploadUrl) {
|
||||
|
||||
const res = await fetch(uploadUrl, {
|
||||
method: 'POST',
|
||||
headers: {'X-Csrf-Token': csrf},
|
||||
headers: {'X-Csrf-Token': csrfToken},
|
||||
body: formData,
|
||||
});
|
||||
return await res.json();
|
||||
@ -67,7 +67,7 @@ export function initCompImagePaste($target) {
|
||||
const name = img.name.substr(0, img.name.lastIndexOf('.'));
|
||||
insertAtCursor(textarea, `![${name}]()`);
|
||||
const data = await uploadFile(img, uploadUrl);
|
||||
replaceAndKeepCursor(textarea, `![${name}]()`, `![${name}](${AppSubUrl}/attachments/${data.uuid})`);
|
||||
replaceAndKeepCursor(textarea, `![${name}]()`, `![${name}](${appSubUrl}/attachments/${data.uuid})`);
|
||||
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid);
|
||||
dropzoneFiles.appendChild(input[0]);
|
||||
}
|
||||
@ -83,7 +83,7 @@ export function initSimpleMDEImagePaste(simplemde, dropzone, files) {
|
||||
const name = img.name.substr(0, img.name.lastIndexOf('.'));
|
||||
const data = await uploadFile(img, uploadUrl);
|
||||
const pos = simplemde.codemirror.getCursor();
|
||||
simplemde.codemirror.replaceRange(`![${name}](${AppSubUrl}/attachments/${data.uuid})`, pos);
|
||||
simplemde.codemirror.replaceRange(`![${name}](${appSubUrl}/attachments/${data.uuid})`, pos);
|
||||
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid);
|
||||
files.append(input);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {initMarkupContent} from '../../markup/content.js';
|
||||
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
export function initCompMarkupContentPreviewTab($form) {
|
||||
const $tabMenu = $form.find('.tabular.menu');
|
||||
@ -8,7 +8,7 @@ export function initCompMarkupContentPreviewTab($form) {
|
||||
$tabMenu.find(`.item[data-tab="${$tabMenu.data('preview')}"]`).on('click', function () {
|
||||
const $this = $(this);
|
||||
$.post($this.data('url'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
mode: 'comment',
|
||||
context: $this.data('context'),
|
||||
text: $form.find(`.tab[data-tab="${$tabMenu.data('write')}"] textarea`).val()
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
export function initCompReactionSelector(parent) {
|
||||
let reactions = '';
|
||||
@ -20,7 +20,7 @@ export function initCompReactionSelector(parent) {
|
||||
type: 'POST',
|
||||
url,
|
||||
data: {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
content: $(this).data('content')
|
||||
}
|
||||
}).done((resp) => {
|
||||
|
@ -1,13 +1,13 @@
|
||||
import {htmlEscape} from 'escape-goat';
|
||||
|
||||
const {AppSubUrl} = window.config;
|
||||
const {appSubUrl} = window.config;
|
||||
|
||||
export function initSearchUserBox() {
|
||||
const $searchUserBox = $('#search-user-box');
|
||||
$searchUserBox.search({
|
||||
minCharacters: 2,
|
||||
apiSettings: {
|
||||
url: `${AppSubUrl}/api/v1/users/search?q={query}`,
|
||||
url: `${appSubUrl}/api/v1/users/search?q={query}`,
|
||||
onResponse(response) {
|
||||
const items = [];
|
||||
const searchQueryUppercase = $searchUserBox.find('input').val().toUpperCase();
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
export function initWebHookEditor() {
|
||||
if ($('.new.webhook').length === 0) {
|
||||
@ -30,7 +30,7 @@ export function initWebHookEditor() {
|
||||
const $this = $(this);
|
||||
$this.addClass('loading disabled');
|
||||
$.post($this.data('link'), {
|
||||
_csrf: csrf
|
||||
_csrf: csrfToken
|
||||
}).done(
|
||||
setTimeout(() => {
|
||||
window.location.href = $this.data('redirect');
|
||||
|
@ -1,9 +1,9 @@
|
||||
import emojis from '../../../assets/emoji.json';
|
||||
|
||||
const {AssetUrlPrefix} = window.config;
|
||||
const {CustomEmojis} = window.config;
|
||||
const {assetUrlPrefix} = window.config;
|
||||
const {customEmojis} = window.config;
|
||||
|
||||
const tempMap = {...CustomEmojis};
|
||||
const tempMap = {...customEmojis};
|
||||
for (const {emoji, aliases} of emojis) {
|
||||
for (const alias of aliases || []) {
|
||||
tempMap[alias] = emoji;
|
||||
@ -24,8 +24,8 @@ for (const key of emojiKeys) {
|
||||
// retrieve HTML for given emoji name
|
||||
export function emojiHTML(name) {
|
||||
let inner;
|
||||
if (Object.prototype.hasOwnProperty.call(CustomEmojis, name)) {
|
||||
inner = `<img alt=":${name}:" src="${AssetUrlPrefix}/img/emoji/${name}.png">`;
|
||||
if (Object.prototype.hasOwnProperty.call(customEmojis, name)) {
|
||||
inner = `<img alt=":${name}:" src="${assetUrlPrefix}/img/emoji/${name}.png">`;
|
||||
} else {
|
||||
inner = emojiString(name);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {svg} from '../svg.js';
|
||||
|
||||
const {AppSubUrl, csrf} = window.config;
|
||||
const {appSubUrl, csrfToken} = window.config;
|
||||
|
||||
let i18nTextEdited;
|
||||
let i18nTextOptions;
|
||||
@ -37,7 +37,7 @@ function showContentHistoryDetail(issueBaseUrl, commentId, historyId, itemTitleH
|
||||
if (optionItem === 'delete') {
|
||||
if (window.confirm(i18nTextDeleteFromHistoryConfirm)) {
|
||||
$.post(`${issueBaseUrl}/content-history/soft-delete?comment_id=${commentId}&history_id=${historyId}`, {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
}).done((resp) => {
|
||||
if (resp.ok) {
|
||||
$dialog.modal('hide');
|
||||
@ -59,7 +59,7 @@ function showContentHistoryDetail(issueBaseUrl, commentId, historyId, itemTitleH
|
||||
$.ajax({
|
||||
url: `${issueBaseUrl}/content-history/detail?comment_id=${commentId}&history_id=${historyId}`,
|
||||
data: {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
},
|
||||
}).done((resp) => {
|
||||
$dialog.find('.content').html(resp.diffHtml);
|
||||
@ -110,12 +110,12 @@ export function initIssueContentHistory() {
|
||||
if (!issueIndex || !$itemIssue.length) return;
|
||||
|
||||
const repoLink = $('#repolink').val();
|
||||
const issueBaseUrl = `${AppSubUrl}/${repoLink}/issues/${issueIndex}`;
|
||||
const issueBaseUrl = `${appSubUrl}/${repoLink}/issues/${issueIndex}`;
|
||||
|
||||
$.ajax({
|
||||
url: `${issueBaseUrl}/content-history/overview`,
|
||||
data: {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
},
|
||||
}).done((resp) => {
|
||||
i18nTextEdited = resp.i18n.textEdited;
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
export async function initLastCommitLoader() {
|
||||
const entryMap = {};
|
||||
@ -18,7 +18,7 @@ export async function initLastCommitLoader() {
|
||||
|
||||
if (entries.length > 200) {
|
||||
$.post(lastCommitLoaderURL, {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
}, (data) => {
|
||||
$('table#repo-files-table').replaceWith(data);
|
||||
});
|
||||
@ -26,7 +26,7 @@ export async function initLastCommitLoader() {
|
||||
}
|
||||
|
||||
$.post(lastCommitLoaderURL, {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
'f': entries,
|
||||
}, (data) => {
|
||||
$(data).find('tr').each((_, row) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {AppSubUrl, csrf, NotificationSettings} = window.config;
|
||||
const {appSubUrl, csrfToken, notificationSettings} = window.config;
|
||||
|
||||
let notificationSequenceNumber = 0;
|
||||
|
||||
@ -47,7 +47,7 @@ export async function initNotificationCount() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NotificationSettings.EventSourceUpdateTime > 0 && !!window.EventSource && window.SharedWorker) {
|
||||
if (notificationSettings.EventSourceUpdateTime > 0 && !!window.EventSource && window.SharedWorker) {
|
||||
// Try to connect to the event source via the shared worker first
|
||||
const worker = new SharedWorker(`${__webpack_public_path__}js/eventsource.sharedworker.js`, 'notification-worker');
|
||||
worker.addEventListener('error', (event) => {
|
||||
@ -58,7 +58,7 @@ export async function initNotificationCount() {
|
||||
});
|
||||
worker.port.postMessage({
|
||||
type: 'start',
|
||||
url: `${window.location.origin}${AppSubUrl}/user/events`,
|
||||
url: `${window.location.origin}${appSubUrl}/user/events`,
|
||||
});
|
||||
worker.port.addEventListener('message', (event) => {
|
||||
if (!event.data || !event.data.type) {
|
||||
@ -77,7 +77,7 @@ export async function initNotificationCount() {
|
||||
type: 'close',
|
||||
});
|
||||
worker.port.close();
|
||||
window.location.href = AppSubUrl;
|
||||
window.location.href = appSubUrl;
|
||||
} else if (event.data.type === 'close') {
|
||||
worker.port.postMessage({
|
||||
type: 'close',
|
||||
@ -99,7 +99,7 @@ export async function initNotificationCount() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NotificationSettings.MinTimeout <= 0) {
|
||||
if (notificationSettings.MinTimeout <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -109,13 +109,13 @@ export async function initNotificationCount() {
|
||||
}, timeout);
|
||||
};
|
||||
|
||||
fn(NotificationSettings.MinTimeout, notificationCount.text());
|
||||
fn(notificationSettings.MinTimeout, notificationCount.text());
|
||||
}
|
||||
|
||||
async function updateNotificationCountWithCallback(callback, timeout, lastCount) {
|
||||
const currentCount = $('.notification_count').text();
|
||||
if (lastCount !== currentCount) {
|
||||
callback(NotificationSettings.MinTimeout, currentCount);
|
||||
callback(notificationSettings.MinTimeout, currentCount);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -124,9 +124,9 @@ async function updateNotificationCountWithCallback(callback, timeout, lastCount)
|
||||
|
||||
if (lastCount !== newCount) {
|
||||
needsUpdate = true;
|
||||
timeout = NotificationSettings.MinTimeout;
|
||||
} else if (timeout < NotificationSettings.MaxTimeout) {
|
||||
timeout += NotificationSettings.TimeoutStep;
|
||||
timeout = notificationSettings.MinTimeout;
|
||||
} else if (timeout < notificationSettings.MaxTimeout) {
|
||||
timeout += notificationSettings.TimeoutStep;
|
||||
}
|
||||
|
||||
callback(timeout, newCount);
|
||||
@ -140,7 +140,7 @@ async function updateNotificationTable() {
|
||||
if (notificationDiv.length > 0) {
|
||||
const data = await $.ajax({
|
||||
type: 'GET',
|
||||
url: `${AppSubUrl}/notifications?${notificationDiv.data('params')}`,
|
||||
url: `${appSubUrl}/notifications?${notificationDiv.data('params')}`,
|
||||
data: {
|
||||
'div-only': true,
|
||||
'sequence-number': ++notificationSequenceNumber,
|
||||
@ -156,9 +156,9 @@ async function updateNotificationTable() {
|
||||
async function updateNotificationCount() {
|
||||
const data = await $.ajax({
|
||||
type: 'GET',
|
||||
url: `${AppSubUrl}/api/v1/notifications/new`,
|
||||
url: `${appSubUrl}/api/v1/notifications/new`,
|
||||
headers: {
|
||||
'X-Csrf-Token': csrf,
|
||||
'X-Csrf-Token': csrfToken,
|
||||
},
|
||||
});
|
||||
|
||||
@ -183,7 +183,7 @@ async function updateNotification(url, status, page, q, notificationID) {
|
||||
type: 'POST',
|
||||
url,
|
||||
data: {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
notification_id: notificationID,
|
||||
status,
|
||||
page,
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {AppSubUrl} = window.config;
|
||||
const {appSubUrl} = window.config;
|
||||
|
||||
export function initOrgTeamSettings() {
|
||||
// Change team access mode
|
||||
@ -18,7 +18,7 @@ export function initOrgTeamSearchRepoBox() {
|
||||
$searchRepoBox.search({
|
||||
minCharacters: 2,
|
||||
apiSettings: {
|
||||
url: `${AppSubUrl}/api/v1/repos/search?q={query}&uid=${$searchRepoBox.data('uid')}`,
|
||||
url: `${appSubUrl}/api/v1/repos/search?q={query}&uid=${$searchRepoBox.data('uid')}`,
|
||||
onResponse(response) {
|
||||
const items = [];
|
||||
$.each(response.data, (_i, item) => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
const {csrf, PageIsProjects} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
export default async function initProject() {
|
||||
if (!PageIsProjects) {
|
||||
if (!$('.repository.projects').length) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ export default async function initProject() {
|
||||
url: $(column).data('url'),
|
||||
data: JSON.stringify({sorting: i, color: rgbToHex($(column).css('backgroundColor'))}),
|
||||
headers: {
|
||||
'X-Csrf-Token': csrf,
|
||||
'X-Csrf-Token': csrfToken,
|
||||
'X-Remote': true,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
@ -47,7 +47,7 @@ export default async function initProject() {
|
||||
onAdd: (e) => {
|
||||
$.ajax(`${e.to.dataset.url}/${e.item.dataset.issue}`, {
|
||||
headers: {
|
||||
'X-Csrf-Token': csrf,
|
||||
'X-Csrf-Token': csrfToken,
|
||||
'X-Remote': true,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
@ -83,7 +83,7 @@ export default async function initProject() {
|
||||
url: $(this).data('url'),
|
||||
data: JSON.stringify({title: projectTitleInput.val(), color: projectColorInput.val()}),
|
||||
headers: {
|
||||
'X-Csrf-Token': csrf,
|
||||
'X-Csrf-Token': csrfToken,
|
||||
'X-Remote': true,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
@ -107,7 +107,7 @@ export default async function initProject() {
|
||||
method: 'POST',
|
||||
url: $(this).data('url'),
|
||||
headers: {
|
||||
'X-Csrf-Token': csrf,
|
||||
'X-Csrf-Token': csrfToken,
|
||||
'X-Remote': true,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
@ -123,7 +123,7 @@ export default async function initProject() {
|
||||
$.ajax({
|
||||
url: $(this).data('url'),
|
||||
headers: {
|
||||
'X-Csrf-Token': csrf,
|
||||
'X-Csrf-Token': csrfToken,
|
||||
'X-Remote': true,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
@ -144,7 +144,7 @@ export default async function initProject() {
|
||||
url: $(this).data('url'),
|
||||
data: JSON.stringify({title: boardTitle.val(), color: projectColorInput.val()}),
|
||||
headers: {
|
||||
'X-Csrf-Token': csrf,
|
||||
'X-Csrf-Token': csrfToken,
|
||||
'X-Remote': true,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
|
@ -1,11 +1,11 @@
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
function getArchive($target, url, first) {
|
||||
$.ajax({
|
||||
url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
},
|
||||
complete(xhr) {
|
||||
if (xhr.status === 200) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {initCompReactionSelector} from './comp/ReactionSelector.js';
|
||||
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
export function initRepoDiffReviewButton() {
|
||||
$(document).on('click', 'button[name="is_review"]', (e) => {
|
||||
@ -45,7 +45,7 @@ export function initRepoDiffConversationForm() {
|
||||
const action = $(this).data('action');
|
||||
const url = $(this).data('update-url');
|
||||
|
||||
const data = await $.post(url, {_csrf: csrf, origin, action, comment_id});
|
||||
const data = await $.post(url, {_csrf: csrfToken, origin, action, comment_id});
|
||||
|
||||
if ($(this).closest('.conversation-holder').length) {
|
||||
const conversation = $(data);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {initMarkupContent} from '../markup/content.js';
|
||||
import {createCodeEditor} from './codeeditor.js';
|
||||
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
let previewFileModes;
|
||||
|
||||
@ -21,7 +21,7 @@ function initEditPreviewTab($form) {
|
||||
}
|
||||
context = context.substring(0, context.lastIndexOf('/'));
|
||||
$.post($this.data('url'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
mode,
|
||||
context,
|
||||
text: $form.find(`.tab[data-tab="${$tabMenu.data('write')}"] textarea`).val()
|
||||
@ -40,7 +40,7 @@ function initEditDiffTab($form) {
|
||||
$tabMenu.find(`.item[data-tab="${$tabMenu.data('diff')}"]`).on('click', function () {
|
||||
const $this = $(this);
|
||||
$.post($this.data('url'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
context: $this.data('context'),
|
||||
content: $form.find(`.tab[data-tab="${$tabMenu.data('write')}"] textarea`).val()
|
||||
}, (data) => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {stripTags} from '../utils.js';
|
||||
|
||||
const {AppSubUrl, csrf} = window.config;
|
||||
const {appSubUrl, csrfToken} = window.config;
|
||||
|
||||
export function initRepoTopicBar() {
|
||||
const mgrBtn = $('#manage_topic');
|
||||
@ -30,7 +30,7 @@ export function initRepoTopicBar() {
|
||||
const topics = $('input[name=topics]').val();
|
||||
|
||||
$.post(saveBtn.data('link'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
topics
|
||||
}, (_data, _textStatus, xhr) => {
|
||||
if (xhr.responseJSON.status === 'ok') {
|
||||
@ -41,7 +41,7 @@ export function initRepoTopicBar() {
|
||||
const last = viewDiv.children('a').last();
|
||||
for (let i = 0; i < topicArray.length; i++) {
|
||||
const link = $('<a class="ui repo-topic large label topic"></a>');
|
||||
link.attr('href', `${AppSubUrl}/explore/repos?q=${encodeURIComponent(topicArray[i])}&topic=1`);
|
||||
link.attr('href', `${appSubUrl}/explore/repos?q=${encodeURIComponent(topicArray[i])}&topic=1`);
|
||||
link.text(topicArray[i]);
|
||||
link.insertBefore(last);
|
||||
}
|
||||
@ -90,7 +90,7 @@ export function initRepoTopicBar() {
|
||||
label: 'ui small label'
|
||||
},
|
||||
apiSettings: {
|
||||
url: `${AppSubUrl}/api/v1/topics/search?q={query}`,
|
||||
url: `${appSubUrl}/api/v1/topics/search?q={query}`,
|
||||
throttle: 500,
|
||||
cache: false,
|
||||
onResponse(res) {
|
||||
|
@ -4,7 +4,7 @@ import {createCommentSimpleMDE} from './comp/CommentSimpleMDE.js';
|
||||
import {initCompImagePaste} from './comp/ImagePaste.js';
|
||||
import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js';
|
||||
|
||||
const {AppSubUrl, csrf} = window.config;
|
||||
const {appSubUrl, csrfToken} = window.config;
|
||||
|
||||
export function initRepoIssueTimeTracking() {
|
||||
$(document).on('click', '.issue-add-time', () => {
|
||||
@ -58,7 +58,7 @@ function updateDeadline(deadlineString) {
|
||||
due_date: realDeadline,
|
||||
}),
|
||||
headers: {
|
||||
'X-Csrf-Token': csrf,
|
||||
'X-Csrf-Token': csrfToken,
|
||||
'X-Remote': true,
|
||||
},
|
||||
contentType: 'application/json',
|
||||
@ -91,9 +91,9 @@ export function initRepoIssueList() {
|
||||
const repoId = $('#repoId').val();
|
||||
const crossRepoSearch = $('#crossRepoSearch').val();
|
||||
const tp = $('#type').val();
|
||||
let issueSearchUrl = `${AppSubUrl}/api/v1/repos/${repolink}/issues?q={query}&type=${tp}`;
|
||||
let issueSearchUrl = `${appSubUrl}/api/v1/repos/${repolink}/issues?q={query}&type=${tp}`;
|
||||
if (crossRepoSearch === 'true') {
|
||||
issueSearchUrl = `${AppSubUrl}/api/v1/repos/issues/search?q={query}&priority_repo_id=${repoId}&type=${tp}`;
|
||||
issueSearchUrl = `${appSubUrl}/api/v1/repos/issues/search?q={query}&priority_repo_id=${repoId}&type=${tp}`;
|
||||
}
|
||||
$('#new-dependency-drop-list')
|
||||
.dropdown({
|
||||
@ -157,7 +157,7 @@ export function initRepoIssueCommentDelete() {
|
||||
const $this = $(this);
|
||||
if (window.confirm($this.data('locale'))) {
|
||||
$.post($this.data('url'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
}).done(() => {
|
||||
const $conversationHolder = $this.closest('.conversation-holder');
|
||||
$(`#${$this.data('comment-id')}`).remove();
|
||||
@ -258,7 +258,7 @@ export function initRepoPullRequestUpdate() {
|
||||
const redirect = $this.data('redirect');
|
||||
$this.addClass('loading');
|
||||
$.post($this.data('do'), {
|
||||
_csrf: csrf
|
||||
_csrf: csrfToken
|
||||
}).done((data) => {
|
||||
if (data.redirect) {
|
||||
window.location.href = data.redirect;
|
||||
@ -291,7 +291,7 @@ export function initRepoIssueReferenceRepositorySearch() {
|
||||
$('.issue_reference_repository_search')
|
||||
.dropdown({
|
||||
apiSettings: {
|
||||
url: `${AppSubUrl}/api/v1/repos/search?q={query}&limit=20`,
|
||||
url: `${appSubUrl}/api/v1/repos/search?q={query}&limit=20`,
|
||||
onResponse(response) {
|
||||
const filteredResponse = {success: true, results: []};
|
||||
$.each(response.data, (_r, repo) => {
|
||||
@ -306,7 +306,7 @@ export function initRepoIssueReferenceRepositorySearch() {
|
||||
},
|
||||
onChange(_value, _text, $choice) {
|
||||
const $form = $choice.closest('form');
|
||||
$form.attr('action', `${AppSubUrl}/${_text}/issues/new`);
|
||||
$form.attr('action', `${appSubUrl}/${_text}/issues/new`);
|
||||
},
|
||||
fullTextSearch: true
|
||||
});
|
||||
@ -338,7 +338,7 @@ export function updateIssuesMeta(url, action, issueIds, elementId) {
|
||||
type: 'POST',
|
||||
url,
|
||||
data: {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
action,
|
||||
issue_ids: issueIds,
|
||||
id: elementId,
|
||||
@ -556,7 +556,7 @@ export function initRepoIssueWipToggle() {
|
||||
e.preventDefault();
|
||||
const {title, wipPrefix, updateUrl} = e.currentTarget.closest('.toggle-wip').dataset;
|
||||
await $.post(updateUrl, {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
title: title?.startsWith(wipPrefix) ? title.substr(wipPrefix.length).trim() : `${wipPrefix.trim()} ${title}`,
|
||||
});
|
||||
window.location.reload();
|
||||
@ -591,7 +591,7 @@ export function initRepoIssueTitleEdit() {
|
||||
return false;
|
||||
}
|
||||
$.post(update_url, {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
target_branch: targetBranch
|
||||
}).done((data) => {
|
||||
$branchTarget.text(data.base_branch);
|
||||
@ -606,7 +606,7 @@ export function initRepoIssueTitleEdit() {
|
||||
pullrequest_targetbranch_change(pullrequest_target_update_url);
|
||||
} else {
|
||||
$.post($(this).data('update-url'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
title: $editInput.val()
|
||||
}, (data) => {
|
||||
$editInput.val(data.title);
|
||||
|
@ -27,7 +27,7 @@ import {initCommentContent, initMarkupContent} from '../markup/content.js';
|
||||
import {initCompReactionSelector} from './comp/ReactionSelector.js';
|
||||
import {initRepoSettingBranches} from './repo-settings.js';
|
||||
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
const commentMDEditors = {};
|
||||
|
||||
@ -54,7 +54,7 @@ export function initRepoCommentForm() {
|
||||
|
||||
if (editMode === 'true') {
|
||||
const form = $('#update_issueref_form');
|
||||
$.post(form.attr('action'), {_csrf: csrf, ref: selectedValue}, () => window.location.reload());
|
||||
$.post(form.attr('action'), {_csrf: csrfToken, ref: selectedValue}, () => window.location.reload());
|
||||
} else if (editMode === '') {
|
||||
$selectBranch.find('.ui .branch-name').text(selectedValue);
|
||||
}
|
||||
@ -370,7 +370,7 @@ export async function initRepository() {
|
||||
const fileUuidDict = {};
|
||||
dz = await createDropzone($dropzone[0], {
|
||||
url: $dropzone.data('upload-url'),
|
||||
headers: {'X-Csrf-Token': csrf},
|
||||
headers: {'X-Csrf-Token': csrfToken},
|
||||
maxFiles: $dropzone.data('max-file'),
|
||||
maxFilesize: $dropzone.data('max-size'),
|
||||
acceptedFiles: (['*/*', ''].includes($dropzone.data('accepts'))) ? null : $dropzone.data('accepts'),
|
||||
@ -396,7 +396,7 @@ export async function initRepository() {
|
||||
if ($dropzone.data('remove-url') && !fileUuidDict[file.uuid].submitted) {
|
||||
$.post($dropzone.data('remove-url'), {
|
||||
file: file.uuid,
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -458,7 +458,7 @@ export async function initRepository() {
|
||||
return $(this).val();
|
||||
}).get();
|
||||
$.post($editContentZone.data('update-url'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
content: $textarea.val(),
|
||||
context: $editContentZone.data('context'),
|
||||
files: $attachments,
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {AppSubUrl, csrf} = window.config;
|
||||
const {appSubUrl, csrfToken} = window.config;
|
||||
|
||||
export function initRepoMigrationStatusChecker() {
|
||||
const migrating = $('#repo_migrating');
|
||||
@ -12,9 +12,9 @@ export function initRepoMigrationStatusChecker() {
|
||||
}
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: `${AppSubUrl}/user/task/${task}`,
|
||||
url: `${appSubUrl}/user/task/${task}`,
|
||||
data: {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
},
|
||||
complete(xhr) {
|
||||
if (xhr.status === 200 && xhr.responseJSON) {
|
||||
|
@ -1,14 +1,14 @@
|
||||
import {createMonaco} from './codeeditor.js';
|
||||
import {initRepoCommonFilterSearchDropdown} from './repo-common.js';
|
||||
|
||||
const {AppSubUrl, csrf} = window.config;
|
||||
const {appSubUrl, csrfToken} = window.config;
|
||||
|
||||
export function initRepoSettingsCollaboration() {
|
||||
// Change collaborator access mode
|
||||
$('.access-mode.menu .item').on('click', function () {
|
||||
const $menu = $(this).parent();
|
||||
$.post($menu.data('url'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
uid: $menu.data('uid'),
|
||||
mode: $(this).data('value')
|
||||
});
|
||||
@ -20,8 +20,8 @@ export function initRepoSettingSearchTeamBox() {
|
||||
$searchTeamBox.search({
|
||||
minCharacters: 2,
|
||||
apiSettings: {
|
||||
url: `${AppSubUrl}/api/v1/orgs/${$searchTeamBox.data('org')}/teams/search?q={query}`,
|
||||
headers: {'X-Csrf-Token': csrf},
|
||||
url: `${appSubUrl}/api/v1/orgs/${$searchTeamBox.data('org')}/teams/search?q={query}`,
|
||||
headers: {'X-Csrf-Token': csrfToken},
|
||||
onResponse(response) {
|
||||
const items = [];
|
||||
$.each(response.data, (_i, item) => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {htmlEscape} from 'escape-goat';
|
||||
|
||||
const {AppSubUrl} = window.config;
|
||||
const {appSubUrl} = window.config;
|
||||
|
||||
export function initRepoTemplateSearch() {
|
||||
const $repoTemplate = $('#repo_template');
|
||||
@ -22,7 +22,7 @@ export function initRepoTemplateSearch() {
|
||||
$('#repo_template_search')
|
||||
.dropdown({
|
||||
apiSettings: {
|
||||
url: `${AppSubUrl}/api/v1/repos/search?q={query}&template=true&priority_owner_id=${$('#uid').val()}`,
|
||||
url: `${appSubUrl}/api/v1/repos/search?q={query}&template=true&priority_owner_id=${$('#uid').val()}`,
|
||||
onResponse(response) {
|
||||
const filteredResponse = {success: true, results: []};
|
||||
filteredResponse.results.push({
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {initMarkupContent} from '../markup/content.js';
|
||||
import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js';
|
||||
|
||||
const {csrf} = window.config;
|
||||
const {csrfToken} = window.config;
|
||||
|
||||
export function initRepoWikiForm() {
|
||||
const $editArea = $('.repository.wiki textarea#edit_area');
|
||||
@ -22,7 +22,7 @@ export function initRepoWikiForm() {
|
||||
sideBySideTimeout = null;
|
||||
}
|
||||
$.post($editArea.data('url'), {
|
||||
_csrf: csrf,
|
||||
_csrf: csrfToken,
|
||||
mode: 'gfm',
|
||||
context: $editArea.data('context'),
|
||||
text: plainText,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import {joinPaths} from '../utils.js';
|
||||
|
||||
const {UseServiceWorker, AssetUrlPrefix, AppVer} = window.config;
|
||||
const {useServiceWorker, assetUrlPrefix, appVer} = window.config;
|
||||
const cachePrefix = 'static-cache-v'; // actual version is set in the service worker script
|
||||
const workerAssetPath = joinPaths(AssetUrlPrefix, 'serviceworker.js');
|
||||
const workerAssetPath = joinPaths(assetUrlPrefix, 'serviceworker.js');
|
||||
|
||||
async function unregisterAll() {
|
||||
for (const registration of await navigator.serviceWorker.getRegistrations()) {
|
||||
@ -24,7 +24,7 @@ async function invalidateCache() {
|
||||
}
|
||||
|
||||
async function checkCacheValidity() {
|
||||
const cacheKey = AppVer;
|
||||
const cacheKey = appVer;
|
||||
const storedCacheKey = localStorage.getItem('staticCacheKey');
|
||||
|
||||
// invalidate cache if it belongs to a different gitea version
|
||||
@ -37,7 +37,7 @@ async function checkCacheValidity() {
|
||||
export default async function initServiceWorker() {
|
||||
if (!('serviceWorker' in navigator)) return;
|
||||
|
||||
if (UseServiceWorker) {
|
||||
if (useServiceWorker) {
|
||||
// unregister all service workers where scriptURL does not match the current one
|
||||
await unregisterOtherWorkers();
|
||||
try {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import prettyMilliseconds from 'pretty-ms';
|
||||
const {AppSubUrl, csrf, NotificationSettings, EnableTimetracking} = window.config;
|
||||
const {appSubUrl, csrfToken, notificationSettings, enableTimeTracking} = window.config;
|
||||
|
||||
let updateTimeInterval = null; // holds setInterval id when active
|
||||
|
||||
export async function initStopwatch() {
|
||||
if (!EnableTimetracking) {
|
||||
if (!enableTimeTracking) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ export async function initStopwatch() {
|
||||
$(this).parent().trigger('submit');
|
||||
});
|
||||
|
||||
if (NotificationSettings.EventSourceUpdateTime > 0 && !!window.EventSource && window.SharedWorker) {
|
||||
if (notificationSettings.EventSourceUpdateTime > 0 && !!window.EventSource && window.SharedWorker) {
|
||||
// Try to connect to the event source via the shared worker first
|
||||
const worker = new SharedWorker(`${__webpack_public_path__}js/eventsource.sharedworker.js`, 'notification-worker');
|
||||
worker.addEventListener('error', (event) => {
|
||||
@ -36,7 +36,7 @@ export async function initStopwatch() {
|
||||
});
|
||||
worker.port.postMessage({
|
||||
type: 'start',
|
||||
url: `${window.location.origin}${AppSubUrl}/user/events`,
|
||||
url: `${window.location.origin}${appSubUrl}/user/events`,
|
||||
});
|
||||
worker.port.addEventListener('message', (event) => {
|
||||
if (!event.data || !event.data.type) {
|
||||
@ -55,7 +55,7 @@ export async function initStopwatch() {
|
||||
type: 'close',
|
||||
});
|
||||
worker.port.close();
|
||||
window.location.href = AppSubUrl;
|
||||
window.location.href = appSubUrl;
|
||||
} else if (event.data.type === 'close') {
|
||||
worker.port.postMessage({
|
||||
type: 'close',
|
||||
@ -77,7 +77,7 @@ export async function initStopwatch() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NotificationSettings.MinTimeout <= 0) {
|
||||
if (notificationSettings.MinTimeout <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ export async function initStopwatch() {
|
||||
}, timeout);
|
||||
};
|
||||
|
||||
fn(NotificationSettings.MinTimeout);
|
||||
fn(notificationSettings.MinTimeout);
|
||||
|
||||
const currSeconds = $('.stopwatch-time').data('seconds');
|
||||
if (currSeconds) {
|
||||
@ -99,9 +99,9 @@ async function updateStopwatchWithCallback(callback, timeout) {
|
||||
const isSet = await updateStopwatch();
|
||||
|
||||
if (!isSet) {
|
||||
timeout = NotificationSettings.MinTimeout;
|
||||
} else if (timeout < NotificationSettings.MaxTimeout) {
|
||||
timeout += NotificationSettings.TimeoutStep;
|
||||
timeout = notificationSettings.MinTimeout;
|
||||
} else if (timeout < notificationSettings.MaxTimeout) {
|
||||
timeout += notificationSettings.TimeoutStep;
|
||||
}
|
||||
|
||||
callback(timeout);
|
||||
@ -110,8 +110,8 @@ async function updateStopwatchWithCallback(callback, timeout) {
|
||||
async function updateStopwatch() {
|
||||
const data = await $.ajax({
|
||||
type: 'GET',
|
||||
url: `${AppSubUrl}/api/v1/user/stopwatches`,
|
||||
headers: {'X-Csrf-Token': csrf},
|
||||
url: `${appSubUrl}/api/v1/user/stopwatches`,
|
||||
headers: {'X-Csrf-Token': csrfToken},
|
||||
});
|
||||
|
||||
if (updateTimeInterval) {
|
||||
@ -129,7 +129,7 @@ async function updateStopwatchData(data) {
|
||||
btnEl.addClass('hidden');
|
||||
} else {
|
||||
const {repo_owner_name, repo_name, issue_index, seconds} = watch;
|
||||
const issueUrl = `${AppSubUrl}/${repo_owner_name}/${repo_name}/issues/${issue_index}`;
|
||||
const issueUrl = `${appSubUrl}/${repo_owner_name}/${repo_name}/issues/${issue_index}`;
|
||||
$('.stopwatch-link').attr('href', issueUrl);
|
||||
$('.stopwatch-commit').attr('action', `${issueUrl}/times/stopwatch/toggle`);
|
||||
$('.stopwatch-cancel').attr('action', `${issueUrl}/times/stopwatch/cancel`);
|
||||
|
@ -49,7 +49,7 @@ function makeCollections({mentions, emoji}) {
|
||||
}
|
||||
|
||||
export default async function attachTribute(elementOrNodeList, {mentions, emoji} = {}) {
|
||||
if (!window.config.Tribute || !elementOrNodeList) return;
|
||||
if (!window.config.requireTribute || !elementOrNodeList) return;
|
||||
const nodes = Array.from('length' in elementOrNodeList ? elementOrNodeList : [elementOrNodeList]);
|
||||
if (!nodes.length) return;
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
const {AppSubUrl, csrf} = window.config;
|
||||
const {appSubUrl, csrfToken} = window.config;
|
||||
|
||||
export function initUserAuthU2fAuth() {
|
||||
if ($('#wait-for-key').length === 0) {
|
||||
return;
|
||||
}
|
||||
u2fApi.ensureSupport().then(() => {
|
||||
$.getJSON(`${AppSubUrl}/user/u2f/challenge`).done((req) => {
|
||||
$.getJSON(`${appSubUrl}/user/u2f/challenge`).done((req) => {
|
||||
u2fApi.sign(req.appId, req.challenge, req.registeredKeys, 30)
|
||||
.then(u2fSigned)
|
||||
.catch((err) => {
|
||||
@ -18,15 +18,15 @@ export function initUserAuthU2fAuth() {
|
||||
});
|
||||
}).catch(() => {
|
||||
// Fallback in case browser do not support U2F
|
||||
window.location.href = `${AppSubUrl}/user/two_factor`;
|
||||
window.location.href = `${appSubUrl}/user/two_factor`;
|
||||
});
|
||||
}
|
||||
|
||||
function u2fSigned(resp) {
|
||||
$.ajax({
|
||||
url: `${AppSubUrl}/user/u2f/sign`,
|
||||
url: `${appSubUrl}/user/u2f/sign`,
|
||||
type: 'POST',
|
||||
headers: {'X-Csrf-Token': csrf},
|
||||
headers: {'X-Csrf-Token': csrfToken},
|
||||
data: JSON.stringify(resp),
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
}).done((res) => {
|
||||
@ -41,9 +41,9 @@ function u2fRegistered(resp) {
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: `${AppSubUrl}/user/settings/security/u2f/register`,
|
||||
url: `${appSubUrl}/user/settings/security/u2f/register`,
|
||||
type: 'POST',
|
||||
headers: {'X-Csrf-Token': csrf},
|
||||
headers: {'X-Csrf-Token': csrfToken},
|
||||
data: JSON.stringify(resp),
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
success() {
|
||||
@ -99,8 +99,8 @@ export function initUserAuthU2fRegister() {
|
||||
}
|
||||
|
||||
function u2fRegisterRequest() {
|
||||
$.post(`${AppSubUrl}/user/settings/security/u2f/request_register`, {
|
||||
_csrf: csrf,
|
||||
$.post(`${appSubUrl}/user/settings/security/u2f/request_register`, {
|
||||
_csrf: csrfToken,
|
||||
name: $('#nickname').val()
|
||||
}).done((req) => {
|
||||
$('#nickname').closest('div.field').removeClass('error');
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {MermaidMaxSourceCharacters} = window.config;
|
||||
const {mermaidMaxSourceCharacters} = window.config;
|
||||
|
||||
function displayError(el, err) {
|
||||
el.closest('pre').classList.remove('is-loading');
|
||||
@ -26,8 +26,8 @@ export async function renderMermaid(els) {
|
||||
});
|
||||
|
||||
for (const el of els) {
|
||||
if (MermaidMaxSourceCharacters >= 0 && el.textContent.length > MermaidMaxSourceCharacters) {
|
||||
displayError(el, new Error(`Mermaid source of ${el.textContent.length} characters exceeds the maximum allowed length of ${MermaidMaxSourceCharacters}.`));
|
||||
if (mermaidMaxSourceCharacters >= 0 && el.textContent.length > mermaidMaxSourceCharacters) {
|
||||
displayError(el, new Error(`Mermaid source of ${el.textContent.length} characters exceeds the maximum allowed length of ${mermaidMaxSourceCharacters}.`));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ export function initMarkupTasklist() {
|
||||
|
||||
await $.post(updateUrl, {
|
||||
ignore_attachments: true,
|
||||
_csrf: window.config.csrf,
|
||||
_csrf: window.config.csrfToken,
|
||||
content: newContent,
|
||||
context
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
// This sets up the URL prefix used in webpack's chunk loading.
|
||||
// This file must be imported before any lazy-loading is being attempted.
|
||||
import {joinPaths} from './utils.js';
|
||||
const {AssetUrlPrefix} = window.config;
|
||||
const {assetUrlPrefix} = window.config;
|
||||
|
||||
__webpack_public_path__ = joinPaths(AssetUrlPrefix, '/');
|
||||
__webpack_public_path__ = joinPaths(assetUrlPrefix, '/');
|
||||
|
Loading…
Reference in New Issue
Block a user