]> source.dussan.org Git - gitea.git/commitdiff
Frontend refactor, PascalCase to camelCase, remove unused code (#17365)
authorwxiaoguang <wxiaoguang@gmail.com>
Thu, 21 Oct 2021 07:37:43 +0000 (15:37 +0800)
committerGitHub <noreply@github.com>
Thu, 21 Oct 2021 07:37:43 +0000 (15:37 +0800)
* Frontend refactor, PascalCase to camelCase, remove unused code

* fix

42 files changed:
integrations/branches_test.go
integrations/html_helper.go
integrations/pull_create_test.go
modules/context/context.go
routers/web/repo/projects.go
templates/base/head.tmpl
templates/repo/projects/list.tmpl
templates/repo/projects/new.tmpl
templates/repo/projects/view.tmpl
web_src/js/components/ContextPopup.vue
web_src/js/components/DashboardRepoList.js
web_src/js/components/VueComponentLoader.js
web_src/js/features/admin-common.js
web_src/js/features/common-global.js
web_src/js/features/comp/ImagePaste.js
web_src/js/features/comp/MarkupContentPreview.js
web_src/js/features/comp/ReactionSelector.js
web_src/js/features/comp/SearchUserBox.js
web_src/js/features/comp/WebHookEditor.js
web_src/js/features/emoji.js
web_src/js/features/issue-content-history.js
web_src/js/features/lastcommitloader.js
web_src/js/features/notification.js
web_src/js/features/org-team.js
web_src/js/features/projects.js
web_src/js/features/repo-common.js
web_src/js/features/repo-diff.js
web_src/js/features/repo-editor.js
web_src/js/features/repo-home.js
web_src/js/features/repo-issue.js
web_src/js/features/repo-legacy.js
web_src/js/features/repo-migrate.js
web_src/js/features/repo-settings.js
web_src/js/features/repo-template.js
web_src/js/features/repo-wiki.js
web_src/js/features/serviceworker.js
web_src/js/features/stopwatch.js
web_src/js/features/tribute.js
web_src/js/features/user-auth-u2f.js
web_src/js/markup/mermaid.js
web_src/js/markup/tasklist.js
web_src/js/publicpath.js

index b2230e7031bf404d41d52ee170c318eca6083856..aa4df6ac6a33341fa7fd10bb5eaba1d06db80deb 100644 (file)
@@ -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
-}
index 6dc806a76ed267e1cc2023a7db9c0f218d60990c..001fc9a05b26a1683b7737d5059d7134a360b616 100644 (file)
@@ -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")
 }
index 5a0a3eda086f4f1b60b215588d2a2f9081b5dab1..948c0b9ce257e154fdd8bceada44222b94c858bc 100644 (file)
@@ -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)
index 383a69ad6332fe20d4a6308322726865013f5e74..f652d3845aede5ce7978a475889bcf36b26994bc 100644 (file)
@@ -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
index 2490efc92319a9cbc2ac59453d9c846476c8b029..e98d189c1ae14aa810f57fbfe3f08318245bfb89 100644 (file)
@@ -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)
 }
index 80bb121c6bcea3d2922e59834c3c6c0d0e9ebd87..23d1190d94589c6ad9211a2e8f0d4d9fcd5ad503 100644 (file)
@@ -3,7 +3,7 @@
 <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
-       <title>{{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} </title>
+       <title>{{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}}</title>
        <link rel="manifest" href="data:{{.ManifestData}}"/>
        <meta name="theme-color" content="{{ThemeColorMetaTag}}">
        <meta name="default-theme" content="{{DefaultTheme}}" />
@@ -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}}">
        <script>
                <!-- /* eslint-disable */ -->
                window.config = {
-                       AppVer: '{{AppVer}}',
-                       AppSubUrl: '{{AppSubUrl}}',
-                       AssetUrlPrefix: '{{AssetUrlPrefix}}',
-                       IsProd: {{.IsProd}},
-                       CustomEmojis: {{CustomEmojis}},
-                       UseServiceWorker: {{UseServiceWorker}},
-                       csrf: '{{.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}},
+                       appVer: '{{AppVer}}',
+                       appSubUrl: '{{AppSubUrl}}',
+                       assetUrlPrefix: '{{AssetUrlPrefix}}',
+                       runModeIsProd: {{.RunModeIsProd}},
+                       customEmojis: {{CustomEmojis}},
+                       useServiceWorker: {{UseServiceWorker}},
+                       csrfToken: '{{.CsrfToken}}',
+                       pageData: {{.PageData}},
+                       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">
index ec7370709f176db5edee6a7ba75fe18c2328df4c..f152d20915499bc3964890b05307feebab10ce21 100644 (file)
@@ -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">
index 3a99d56f9edab38351f7b94396f7b05a98fea0eb..e015f7d7af7c28fe88f4f6cd9bcafaef87106c74 100644 (file)
@@ -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">
index 082f4d8eb99e8a68bd3d66b8e8beee98eb2885b5..d4a2eaa4c3faa76bd1feeb26796cb968187323ad 100644 (file)
@@ -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}}
                <div class="board">
                        {{ range $board := .Boards }}
 
-                       <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="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"}}
                                                {{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}}
index be428b477650dd184b1d5f53172ae9328c1f0867..efaa7be89e126985ea34fe77fafbc8385494d4e8 100644 (file)
@@ -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(() => {
index 426d36200542b42d7934be550b712e613f8f3cdf..12e2ee3cc6129197db416e78c1f3ce224ff3b0c5 100644 (file)
@@ -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,
       };
     },
index 110782bbb1d8f8b32bee9c2100d10b3b806b43ff..2979cd6a86e4495a2ef6b2235d51c0eb50c8e3d1 100644 (file)
@@ -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;
 }
index 4f12c1846dc12394cf9d1c4e8f0ef77e8f8a74b1..1a3f800080406b2c18bf723c3140b29e97cf70d2 100644 (file)
@@ -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');
index 79cdac5def0327300c0e5ebb6918bbcb5cf4b1d9..bf4e97769d457668517ec2f5f9d050b5d8318bdd 100644 (file)
@@ -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');
     });
index b6881dd282ead5cf3373484d7c9bbef375eaf6f4..30c5820f62f99326e2724b16c68d1da6a16e25cb 100644 (file)
@@ -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);
     }
index 0b05c4efaea5d0454394cbe3b98c4244473a23f8..ed0995296bd2ddd07055b7f2e921b171978b5a93 100644 (file)
@@ -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()
index d11c9667b947a8957e83ab0e1de50878752216c2..d77b8d3d4ef86d299ba519a8454d7d3a9bb368e3 100644 (file)
@@ -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) => {
index 9019f17de39a32a563d0127484f79180248cdb70..0e7d122391a881e8d5123aa906a2dd99a1322993 100644 (file)
@@ -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();
index 6911c6cb1675df8f6e877fcaa1df7dcb8b69bda9..ddff73ee377083df0700cccbb369844505e73c67 100644 (file)
@@ -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');
index 254a0b5c4d9282f8505d5b822f56782f38607f44..304c564f3d19a96c47925278515df9d01a13f39a 100644 (file)
@@ -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);
   }
index 6ead06741706633d2ebe7d3582e6c258dc455a52..3b830f50f8661036a8e07b390ec93149b26fdb4a 100644 (file)
@@ -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;
index 964255f229251340c5f902826a0484782017e3a0..04e1e452ae699a3e5b79e6f90f2c7f6a8015dd80 100644 (file)
@@ -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) => {
index d1d829c90bd9ac61512b6b5fac1fe5c84a0d3612..71ebb538d4af0c17bc131592cd356980980317d1 100644 (file)
@@ -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,
index d6492965ff210b475d0559b4b475662fd361b715..ea0ea5fe74a73a1c969eb998c819351b21e26953 100644 (file)
@@ -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) => {
index c02b81d1c635834aa1b1936330a6d808182bbe1b..736c09661ddafbc3e9edfe542c8be4bd70185281 100644 (file)
@@ -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',
index c050dba34c8131fd89ee51e56534c13dbb932dae..2ae4f9c94eddf6e5246e616e62fb3fe9f08abe97 100644 (file)
@@ -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) {
index 52b68a7d4fe6e6fea9c989cebe5050209362410d..c3fb78a683ec97b1cee4287c695dc8373f9e03c8 100644 (file)
@@ -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);
index 831b621fde84a96ee838bf179e293923980cea9e..e2acaafd12a6d7ea5dd1ad9b8ca02c111a51c06b 100644 (file)
@@ -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) => {
index 142698f0747bbc23c14f89f33b0325525d5c0a2b..f8bf9318ce1f6c1f7ce7fef652855552f90626c9 100644 (file)
@@ -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) {
index 858398aac9888d007ee49d3dfb33bd33c5519ba2..c95b6c13079b8c10381c1f1ab8d2016ab550e43b 100644 (file)
@@ -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);
index a1c405d719af1bf0ca7f301a7a8fe0661aa6a287..2e98a7183e8c2dbb6d03bfeb2fe179e117ab7446 100644 (file)
@@ -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,
index 872dbc34f55b8e4da342dfae134434078765b3f4..2779fcd24c8f53c3a15f0fa7f49b16ed0de4554f 100644 (file)
@@ -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) {
index e06344893643d5aaf027054fcb6d16344fba1fc6..bd42bcb441fe3644959d42ddf20b3ade67c6a330 100644 (file)
@@ -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) => {
index 9385e2acb8aa13cc80643ca911f5129007e871d1..5c100a89c5fd8894b1f23db2643e3309a3899d4c 100644 (file)
@@ -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({
index aad3161fdb84684348800b00e1636040e5aa44d6..ddd4e30a8a43c093100a28825a165662f5491784 100644 (file)
@@ -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,
index 37cd15c5bd4bc85d567e04ab9d04bdcecfe72874..f3998d98f91f584add25a704a6bc875debdae72f 100644 (file)
@@ -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 {
index eb59e587a7b30b42854db603db2ee3c9691e1b14..8364569892a1145a9a23164017a799a62497e0c7 100644 (file)
@@ -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`);
index 6fdb2f5df04a387e7197ab9b1b7fada8f88a5b75..053804c43d48620dc56bb4afe353ab6d11474194 100644 (file)
@@ -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;
 
index 25255213a89c1ad2435ae677dfe22784fe0b64ab..15beaaa207f5fe1df9ad8408f3599e96100b30dd 100644 (file)
@@ -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');
index 0319cbb6f02fdeec0cd859ab1dfd91c413c6d6c1..f9f069ed1e01ada4764aec95e7395a903d61366b 100644 (file)
@@ -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;
     }
 
index ea1a1f824a13ef177852dee2a9478de90f1c610b..f8ca5b0406e6c5d6e94c0761f0083db8606ffc6a 100644 (file)
@@ -47,7 +47,7 @@ export function initMarkupTasklist() {
 
           await $.post(updateUrl, {
             ignore_attachments: true,
-            _csrf: window.config.csrf,
+            _csrf: window.config.csrfToken,
             content: newContent,
             context
           });
index b68a91d860228d6af677b264bf75b88857ca8eee..44448a8447c49274a391068410be403d9bf58b9f 100644 (file)
@@ -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, '/');