mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-17 04:52:10 +01:00
Add page for import logs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
32
scm-ui/ui-api/src/import.ts
Normal file
32
scm-ui/ui-api/src/import.ts
Normal 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()));
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
@@ -39,7 +39,7 @@ type Props = {
|
||||
afterTitle?: ReactNode;
|
||||
subtitle?: string;
|
||||
loading?: boolean;
|
||||
error?: Error;
|
||||
error?: Error | null;
|
||||
showContentOnError?: boolean;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
@@ -121,5 +121,8 @@
|
||||
},
|
||||
"fileUpload": {
|
||||
"label": "Datei hochladen"
|
||||
},
|
||||
"importLog": {
|
||||
"title": "Importprotokoll"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,5 +122,8 @@
|
||||
},
|
||||
"fileUpload": {
|
||||
"label": "Upload File"
|
||||
},
|
||||
"importLog": {
|
||||
"title": "Import Log"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
|
||||
45
scm-ui/ui-webapp/src/repos/importlog/ImportLog.tsx
Normal file
45
scm-ui/ui-webapp/src/repos/importlog/ImportLog.tsx
Normal 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;
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user