From 9fc10c0bdba5f81f6118a68167007cb675797cd4 Mon Sep 17 00:00:00 2001 From: Konstantin Schaper Date: Tue, 30 Nov 2021 09:49:16 +0100 Subject: [PATCH] implement hook & fix build (#1877) --- scm-plugins/scm-git-plugin/build.gradle | 2 +- scm-plugins/scm-hg-plugin/build.gradle | 2 +- .../scm-integration-test-plugin/build.gradle | 2 +- scm-plugins/scm-legacy-plugin/build.gradle | 2 +- scm-plugins/scm-svn-plugin/build.gradle | 2 +- scm-ui/ui-api/src/index.ts | 1 + scm-ui/ui-api/src/loginInfo.ts | 43 +++++++++++++++++++ 7 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 scm-ui/ui-api/src/loginInfo.ts diff --git a/scm-plugins/scm-git-plugin/build.gradle b/scm-plugins/scm-git-plugin/build.gradle index 7ce2d8a5d7..63d1cde6f4 100644 --- a/scm-plugins/scm-git-plugin/build.gradle +++ b/scm-plugins/scm-git-plugin/build.gradle @@ -23,7 +23,7 @@ */ plugins { - id 'org.scm-manager.smp' version '0.10.0' + id 'org.scm-manager.smp' version '0.10.1' } def jgitVersion = '5.11.1.202105131744-r-scm1' diff --git a/scm-plugins/scm-hg-plugin/build.gradle b/scm-plugins/scm-hg-plugin/build.gradle index 11be32f537..1e0e807128 100644 --- a/scm-plugins/scm-hg-plugin/build.gradle +++ b/scm-plugins/scm-hg-plugin/build.gradle @@ -23,7 +23,7 @@ */ plugins { - id 'org.scm-manager.smp' version '0.10.0' + id 'org.scm-manager.smp' version '0.10.1' } dependencies { diff --git a/scm-plugins/scm-integration-test-plugin/build.gradle b/scm-plugins/scm-integration-test-plugin/build.gradle index 7ad48e0ffe..04d5fa70b7 100644 --- a/scm-plugins/scm-integration-test-plugin/build.gradle +++ b/scm-plugins/scm-integration-test-plugin/build.gradle @@ -23,7 +23,7 @@ */ plugins { - id 'org.scm-manager.smp' version '0.10.0' + id 'org.scm-manager.smp' version '0.10.1' } dependencies { diff --git a/scm-plugins/scm-legacy-plugin/build.gradle b/scm-plugins/scm-legacy-plugin/build.gradle index 4b7f6b1746..497058e67d 100644 --- a/scm-plugins/scm-legacy-plugin/build.gradle +++ b/scm-plugins/scm-legacy-plugin/build.gradle @@ -23,7 +23,7 @@ */ plugins { - id 'org.scm-manager.smp' version '0.10.0' + id 'org.scm-manager.smp' version '0.10.1' } dependencies { diff --git a/scm-plugins/scm-svn-plugin/build.gradle b/scm-plugins/scm-svn-plugin/build.gradle index c7ea159da3..f1b82ac6bb 100644 --- a/scm-plugins/scm-svn-plugin/build.gradle +++ b/scm-plugins/scm-svn-plugin/build.gradle @@ -23,7 +23,7 @@ */ plugins { - id 'org.scm-manager.smp' version '0.10.0' + id 'org.scm-manager.smp' version '0.10.1' } def svnkitVersion = '1.10.3-scm1' diff --git a/scm-ui/ui-api/src/index.ts b/scm-ui/ui-api/src/index.ts index 2d9ec81a26..1d25c4b1ca 100644 --- a/scm-ui/ui-api/src/index.ts +++ b/scm-ui/ui-api/src/index.ts @@ -58,6 +58,7 @@ export * from "./history"; export * from "./contentType"; export * from "./annotations"; export * from "./search"; +export * from "./loginInfo"; export { default as ApiProvider } from "./ApiProvider"; export * from "./ApiProvider"; diff --git a/scm-ui/ui-api/src/loginInfo.ts b/scm-ui/ui-api/src/loginInfo.ts new file mode 100644 index 0000000000..f24f5c2e5e --- /dev/null +++ b/scm-ui/ui-api/src/loginInfo.ts @@ -0,0 +1,43 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { ApiResult, useIndexLink } from "./base"; +import { useQuery } from "react-query"; +import { LoginInfo } from "@scm-manager/ui-types"; + +export const useLoginInfo = (disabled = false): ApiResult => { + const loginInfoLink = useIndexLink("loginInfo"); + const { error, isLoading, data } = useQuery( + ["loginInfo"], + () => fetch(loginInfoLink!).then(response => response.json()), + { + enabled: !disabled && !!loginInfoLink, + refetchOnWindowFocus: false + } + ); + return { + data, + error, + isLoading + }; +};