Add page for import logs

This commit is contained in:
René Pfeuffer
2021-02-24 16:22:35 +01:00
parent 75ed038084
commit c3a5dd4ffb
10 changed files with 94 additions and 1 deletions

View File

@@ -39,10 +39,12 @@ import sonia.scm.event.Event;
@EqualsAndHashCode(callSuper = true)
public class RepositoryImportEvent extends RepositoryEvent {
private final String logId;
private final boolean failed;
public RepositoryImportEvent(HandlerEventType eventType, Repository repository, boolean failed) {
super(eventType, repository);
this.logId = repository.getId();
this.failed = failed;
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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, useRequiredIndexLink } from "./base";
import { useQuery } from "react-query";
import { apiClient } from "./apiclient";
export const useImportLog = (logId: string) : ApiResult<string> => {
const link = useRequiredIndexLink("importLog").replace("{logId}", logId);
return useQuery<string, Error>(["importLog", logId], () => apiClient.get(link).then(response => response.text()));
}

View File

@@ -43,6 +43,7 @@ export * from "./plugins";
export * from "./repository-roles";
export * from "./permissions";
export * from "./sources";
export * from "./import";
export { default as ApiProvider } from "./ApiProvider";
export * from "./ApiProvider";

View File

@@ -39,7 +39,7 @@ type Props = {
afterTitle?: ReactNode;
subtitle?: string;
loading?: boolean;
error?: Error;
error?: Error | null;
showContentOnError?: boolean;
children: ReactNode;
};

View File

@@ -121,5 +121,8 @@
},
"fileUpload": {
"label": "Datei hochladen"
},
"importLog": {
"title": "Importprotokoll"
}
}

View File

@@ -122,5 +122,8 @@
},
"fileUpload": {
"label": "Upload File"
},
"importLog": {
"title": "Import Log"
}
}

View File

@@ -48,6 +48,7 @@ import Admin from "../admin/containers/Admin";
import Profile from "./Profile";
import NamespaceRoot from "../repos/namespaces/containers/NamespaceRoot";
import ImportRepository from "../repos/containers/ImportRepository";
import ImportLog from "../repos/importlog/ImportLog";
type Props = {
me: Me;
@@ -96,6 +97,7 @@ class Main extends React.Component<Props> {
<ProtectedRoute exact path="/groups/:page" component={Groups} authenticated={authenticated} />
<ProtectedRoute path="/admin" component={Admin} authenticated={authenticated} />
<ProtectedRoute path="/me" component={Profile} authenticated={authenticated} />
<ProtectedRoute path="/importlog/:logId" component={ImportLog} authenticated={authenticated} />
<ExtensionPoint
name="main.route"
renderAll={true}

View File

@@ -0,0 +1,45 @@
/*
* 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 React, { FC } from "react";
import { useImportLog, useIndex } from "@scm-manager/ui-api";
import { useParams } from "react-router-dom";
import { Page } from "@scm-manager/ui-components";
import { useTranslation } from "react-i18next";
type Params = {
logId: string;
}
const ImportLog: FC = () => {
const {logId} = useParams<Params>();
const {isLoading, data, error} = useImportLog(logId);
const [t] = useTranslation("commons");
return <Page title={t("importLog.title")} loading={isLoading} error={error}>
<pre>{data ? data : null}</pre>
</Page>;
}
export default ImportLog;

View File

@@ -116,6 +116,7 @@ public class IndexDtoGenerator extends HalAppenderMapper {
builder.single(link("repositoryTypes", resourceLinks.repositoryTypeCollection().self()));
builder.single(link("namespaceStrategies", resourceLinks.namespaceStrategies().self()));
builder.single(link("repositoryRoles", resourceLinks.repositoryRoleCollection().self()));
builder.single(link("importLog", resourceLinks.repository().importLog("IMPORT_LOG_ID").replace("IMPORT_LOG_ID", "{logId}")));
} else {
builder.single(link("login", resourceLinks.authentication().jsonLogin()));
}

View File

@@ -377,6 +377,10 @@ class ResourceLinks {
return repositoryImportLinkBuilder.method("getRepositoryImportResource").parameters().method("importFullRepository").parameters(type).href();
}
String importLog(String importLogId) {
return repositoryImportLinkBuilder.method("getRepositoryImportResource").parameters().method("getImportLog").parameters(importLogId).href();
}
String archive(String namespace, String name) {
return repositoryLinkBuilder.method("getRepositoryResource").parameters(namespace, name).method("archive").parameters().href();
}