diff --git a/scm-core/src/main/java/sonia/scm/plugin/AvailablePlugin.java b/scm-core/src/main/java/sonia/scm/plugin/AvailablePlugin.java index db8d96ca15..c05e970e50 100644 --- a/scm-core/src/main/java/sonia/scm/plugin/AvailablePlugin.java +++ b/scm-core/src/main/java/sonia/scm/plugin/AvailablePlugin.java @@ -25,7 +25,7 @@ public class AvailablePlugin implements Plugin { return pending; } - public AvailablePlugin install() { + AvailablePlugin install() { Preconditions.checkState(!pending, "installation is already pending"); return new AvailablePlugin(pluginDescriptor, true); } diff --git a/scm-ui/ui-components/src/apiclient.ts b/scm-ui/ui-components/src/apiclient.ts index babb0b64d7..473bf3b925 100644 --- a/scm-ui/ui-components/src/apiclient.ts +++ b/scm-ui/ui-components/src/apiclient.ts @@ -27,13 +27,17 @@ const extractXsrfToken = () => { }; const applyFetchOptions: (p: RequestInit) => RequestInit = o => { - const headers: { [key: string]: string } = { - Cache: "no-cache", - // identify the request as ajax request - "X-Requested-With": "XMLHttpRequest", - // identify the web interface - "X-SCM-Client": "WUI" - }; + if (!o.headers) { + o.headers = {}; + } + + // @ts-ignore We are sure that here we only get headers of type Record + const headers: Record = o.headers; + headers["Cache"] = "no-cache"; + // identify the request as ajax request + headers["X-Requested-With"] = "XMLHttpRequest"; + // identify the web interface + headers["X-SCM-Client"] = "WUI"; const xsrf = extractXsrfToken(); if (xsrf) { @@ -80,23 +84,32 @@ class ApiClient { return fetch(createUrl(url), applyFetchOptions({})).then(handleFailure); } - post(url: string, payload?: any, contentType = "application/json") { - return this.httpRequestWithJSONBody("POST", url, contentType, payload); + post(url: string, payload?: any, contentType = "application/json", additionalHeaders: Record = {}) { + return this.httpRequestWithJSONBody("POST", url, contentType, additionalHeaders, payload); } - postBinary(url: string, fileAppender: (p: FormData) => void) { + postText(url: string, payload: string, additionalHeaders: Record = {}) { + return this.httpRequestWithTextBody("POST", url, additionalHeaders, payload); + } + + putText(url: string, payload: string, additionalHeaders: Record = {}) { + return this.httpRequestWithTextBody("PUT", url, additionalHeaders, payload); + } + + postBinary(url: string, fileAppender: (p: FormData) => void, additionalHeaders: Record = {}) { const formData = new FormData(); fileAppender(formData); const options: RequestInit = { method: "POST", - body: formData + body: formData, + headers: additionalHeaders }; return this.httpRequestWithBinaryBody(options, url); } - put(url: string, payload: any, contentType = "application/json") { - return this.httpRequestWithJSONBody("PUT", url, contentType, payload); + put(url: string, payload: any, contentType = "application/json", additionalHeaders: Record = {}) { + return this.httpRequestWithJSONBody("PUT", url, contentType, additionalHeaders, payload); } head(url: string) { @@ -115,9 +128,16 @@ class ApiClient { return fetch(createUrl(url), options).then(handleFailure); } - httpRequestWithJSONBody(method: string, url: string, contentType: string, payload?: any): Promise { + httpRequestWithJSONBody( + method: string, + url: string, + contentType: string, + additionalHeaders: Record, + payload?: any + ): Promise { const options: RequestInit = { - method: method + method: method, + headers: additionalHeaders }; if (payload) { options.body = JSON.stringify(payload); @@ -125,13 +145,27 @@ class ApiClient { return this.httpRequestWithBinaryBody(options, url, contentType); } + httpRequestWithTextBody( + method: string, + url: string, + additionalHeaders: Record = {}, + payload: string + ) { + const options: RequestInit = { + method: method, + headers: additionalHeaders + }; + options.body = payload; + return this.httpRequestWithBinaryBody(options, url, "text/plain"); + } + httpRequestWithBinaryBody(options: RequestInit, url: string, contentType?: string) { options = applyFetchOptions(options); if (contentType) { if (!options.headers) { - options.headers = new Headers(); + options.headers = {}; } - // @ts-ignore + // @ts-ignore We are sure that here we only get headers of type Record options.headers["Content-Type"] = contentType; } diff --git a/scm-ui/ui-components/src/repos/Diff.tsx b/scm-ui/ui-components/src/repos/Diff.tsx index cb4ad30f9f..d7123903a3 100644 --- a/scm-ui/ui-components/src/repos/Diff.tsx +++ b/scm-ui/ui-components/src/repos/Diff.tsx @@ -1,11 +1,14 @@ import React from "react"; import DiffFile from "./DiffFile"; import { DiffObjectProps, File } from "./DiffTypes"; +import Notification from "../Notification"; +import { WithTranslation, withTranslation } from "react-i18next"; -type Props = DiffObjectProps & { - diff: File[]; - defaultCollapse?: boolean; -}; +type Props = WithTranslation & + DiffObjectProps & { + diff: File[]; + defaultCollapse?: boolean; + }; class Diff extends React.Component { static defaultProps: Partial = { @@ -13,15 +16,17 @@ class Diff extends React.Component { }; render() { - const { diff, ...fileProps } = this.props; + const { diff, t, ...fileProps } = this.props; return ( <> - {diff.map((file, index) => ( - - ))} + {diff.length === 0 ? ( + {t("diff.noDiffFound")} + ) : ( + diff.map((file, index) => ) + )} ); } } -export default Diff; +export default withTranslation("repos")(Diff); diff --git a/scm-ui/ui-components/src/repos/LoadingDiff.tsx b/scm-ui/ui-components/src/repos/LoadingDiff.tsx index 1cfbc00b14..45b62f9b35 100644 --- a/scm-ui/ui-components/src/repos/LoadingDiff.tsx +++ b/scm-ui/ui-components/src/repos/LoadingDiff.tsx @@ -43,6 +43,7 @@ class LoadingDiff extends React.Component { fetchDiff = () => { const { url } = this.props; + this.setState({loading: true}); apiClient .get(url) .then(response => response.text()) diff --git a/scm-ui/ui-scripts/src/webpack.config.js b/scm-ui/ui-scripts/src/webpack.config.js index 639872c6b8..2dd5b4c470 100644 --- a/scm-ui/ui-scripts/src/webpack.config.js +++ b/scm-ui/ui-scripts/src/webpack.config.js @@ -7,41 +7,6 @@ const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); const root = path.resolve(process.cwd(), "scm-ui"); module.exports = [ - { - context: root, - entry: "./ui-styles/src/scm.scss", - module: { - rules: [ - { - test: /\.(css|scss|sass)$/i, - use: [ - { - loader: MiniCssExtractPlugin.loader - }, - "css-loader", - "sass-loader" - ] - }, - { - test: /\.(png|svg|jpg|gif|woff2?|eot|ttf)$/, - use: ["file-loader"] - } - ] - }, - plugins: [ - new MiniCssExtractPlugin({ - filename: "ui-styles.css", - ignoreOrder: false - }) - ], - optimization: { - minimizer: [new OptimizeCSSAssetsPlugin({})] - }, - output: { - path: path.join(root, "target", "assets"), - filename: "ui-styles.bundle.js" - } - }, { context: root, entry: { @@ -142,6 +107,41 @@ module.exports = [ } } }, + { + context: root, + entry: "./ui-styles/src/scm.scss", + module: { + rules: [ + { + test: /\.(css|scss|sass)$/i, + use: [ + { + loader: MiniCssExtractPlugin.loader + }, + "css-loader", + "sass-loader" + ] + }, + { + test: /\.(png|svg|jpg|gif|woff2?|eot|ttf)$/, + use: ["file-loader"] + } + ] + }, + plugins: [ + new MiniCssExtractPlugin({ + filename: "ui-styles.css", + ignoreOrder: false + }) + ], + optimization: { + minimizer: [new OptimizeCSSAssetsPlugin({})] + }, + output: { + path: path.join(root, "target", "assets"), + filename: "ui-styles.bundle.js" + } + }, { context: path.resolve(root), entry: { diff --git a/scm-ui/ui-webapp/public/locales/de/repos.json b/scm-ui/ui-webapp/public/locales/de/repos.json index e156cc903e..4dfba695ab 100644 --- a/scm-ui/ui-webapp/public/locales/de/repos.json +++ b/scm-ui/ui-webapp/public/locales/de/repos.json @@ -177,7 +177,8 @@ }, "diff": { "sideBySide": "Zweispaltig", - "combined": "Kombiniert" + "combined": "Kombiniert", + "noDiffFound": "Kein Diff zwischen den ausgewählten Branches gefunden." }, "fileUpload": { "clickHere": "Klicken Sie hier um Ihre Datei hochzuladen.", diff --git a/scm-ui/ui-webapp/public/locales/en/repos.json b/scm-ui/ui-webapp/public/locales/en/repos.json index 0466bab77f..e2ccf8326e 100644 --- a/scm-ui/ui-webapp/public/locales/en/repos.json +++ b/scm-ui/ui-webapp/public/locales/en/repos.json @@ -184,7 +184,8 @@ "copy": "copied" }, "sideBySide": "side-by-side", - "combined": "combined" + "combined": "combined", + "noDiffFound": "No Diff between the selected branches found." }, "fileUpload": { "clickHere": "Click here to select your file", diff --git a/scm-ui/ui-webapp/public/locales/es/repos.json b/scm-ui/ui-webapp/public/locales/es/repos.json index ef9bd2badc..c3bf57c630 100644 --- a/scm-ui/ui-webapp/public/locales/es/repos.json +++ b/scm-ui/ui-webapp/public/locales/es/repos.json @@ -184,7 +184,8 @@ "copy": "copiado" }, "sideBySide": "dos columnas", - "combined": "combinado" + "combined": "combinado", + "noDiffFound": "No se encontraron diferencias entre las ramas seleccionadas." }, "fileUpload": { "clickHere": "Haga click aquí para seleccionar su fichero", diff --git a/scm-webapp/src/main/resources/locales/en/plugins.json b/scm-webapp/src/main/resources/locales/en/plugins.json index 0be1c1f803..83b463b8b6 100644 --- a/scm-webapp/src/main/resources/locales/en/plugins.json +++ b/scm-webapp/src/main/resources/locales/en/plugins.json @@ -198,9 +198,9 @@ } }, "namespaceStrategies": { - "UsernameNamespaceStrategy": "Username", - "CustomNamespaceStrategy": "Custom", - "CurrentYearNamespaceStrategy": "Current year", + "UsernameNamespaceStrategy": "Username", + "CustomNamespaceStrategy": "Custom", + "CurrentYearNamespaceStrategy": "Current year", "RepositoryTypeNamespaceStrategy": "Repository type" } }