From 499f0623210f916901783f1daa1080052dfaa665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Thu, 25 Feb 2021 09:20:18 +0100 Subject: [PATCH] Show import log in import events --- CHANGELOG.md | 4 ++++ build.gradle | 10 +++++----- .../RepositoryImportEventSubscriber.java | 6 ++++-- src/main/js/events/RepositoryImportEvent.tsx | 17 +++++++++++++++++ src/main/resources/locales/de/plugins.json | 3 ++- src/main/resources/locales/en/plugins.json | 3 ++- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebe0c61..a4a3920 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Added +- Link to import log for repository import events ([#22](https://github.com/scm-manager/scm-landingpage-plugin/pull/22)) + ## 1.3.1 - 2021-01-29 ### Fixed - Fix "change committed" link in the latest activities ([#21](https://github.com/scm-manager/scm-landingpage-plugin/pull/21)) diff --git a/build.gradle b/build.gradle index c70be20..d959805 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,18 @@ /* * 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 @@ -31,7 +31,7 @@ dependencies { } scmPlugin { - scmVersion = "2.11.0" + scmVersion = "2.13.1-SNAPSHOT" displayName = "Landingpage" description = "Creates a personal landingpage for each user" author = "Cloudogu GmbH" diff --git a/src/main/java/com/cloudogu/scm/landingpage/myevents/RepositoryImportEventSubscriber.java b/src/main/java/com/cloudogu/scm/landingpage/myevents/RepositoryImportEventSubscriber.java index 2289f80..c5f3013 100644 --- a/src/main/java/com/cloudogu/scm/landingpage/myevents/RepositoryImportEventSubscriber.java +++ b/src/main/java/com/cloudogu/scm/landingpage/myevents/RepositoryImportEventSubscriber.java @@ -57,7 +57,7 @@ public void handleEvent(sonia.scm.repository.RepositoryImportEvent event) { String repository = eventRepo.getNamespace() + "/" + eventRepo.getName(); User creator = SecurityUtils.getSubject().getPrincipals().oneByType(User.class); - store.add(new RepositoryImportEvent(permission, repository, creator.getName(), creator.getDisplayName(), creator.getMail(), event.isFailed())); + store.add(new RepositoryImportEvent(permission, repository, creator.getName(), creator.getDisplayName(), creator.getMail(), event.isFailed(), event.getLogId())); } @XmlRootElement @@ -70,14 +70,16 @@ static class RepositoryImportEvent extends MyEvent { private String creatorDisplayName; private String creatorMail; private boolean failed; + private String logId; - RepositoryImportEvent(String permission, String repository, String creatorName, String creatorDisplayName, String creatorMail, boolean failed) { + RepositoryImportEvent(String permission, String repository, String creatorName, String creatorDisplayName, String creatorMail, boolean failed, String logId) { super(RepositoryImportEvent.class.getSimpleName(), permission); this.repository = repository; this.creatorName = creatorName; this.creatorDisplayName = creatorDisplayName; this.creatorMail = creatorMail; this.failed = failed; + this.logId = logId; } } } diff --git a/src/main/js/events/RepositoryImportEvent.tsx b/src/main/js/events/RepositoryImportEvent.tsx index 772c1ba..ce66340 100644 --- a/src/main/js/events/RepositoryImportEvent.tsx +++ b/src/main/js/events/RepositoryImportEvent.tsx @@ -27,6 +27,7 @@ import styled from "styled-components"; import { CardColumnSmall, Icon, DateFromNow, AvatarImage } from "@scm-manager/ui-components"; import { binder } from "@scm-manager/ui-extensions"; import { MyEventComponent, MyEventType } from "../types"; +import { Link } from "react-router-dom"; type RepositoryImportEventType = MyEventType & { repository: string; @@ -35,6 +36,7 @@ type RepositoryImportEventType = MyEventType & { creatorMail: string; date: Date; failed: boolean; + logId?: string; }; const StyledGravatar = styled(AvatarImage)` @@ -65,10 +67,25 @@ const RepositoryImportEvent: MyEventComponent = ({ ev )} ); + + let logLink; + if (event.logId) { + logLink = ( + <> + {" ("} + + {t("scm-landingpage-plugin.myevents.repositoryImport.logLink")} + + ) + + ); + } + const footerLeft = ( <> {t("scm-landingpage-plugin.myevents.repositoryImport.description")}{" "} {event.creatorDisplayName} + {logLink} ); diff --git a/src/main/resources/locales/de/plugins.json b/src/main/resources/locales/de/plugins.json index 11707a4..8d444db 100644 --- a/src/main/resources/locales/de/plugins.json +++ b/src/main/resources/locales/de/plugins.json @@ -45,7 +45,8 @@ "repositoryImport": { "titleFailed": "Import fehlgeschlagen: {{repository}}", "titleSuccess": "Import abgeschlossen: {{repository}}", - "description": "Gestartet von" + "description": "Gestartet von", + "logLink": "Importprotokoll" }, "repositoryRenamed": { "title": "Repository wurde umbenannt:" diff --git a/src/main/resources/locales/en/plugins.json b/src/main/resources/locales/en/plugins.json index 7135a73..310190c 100644 --- a/src/main/resources/locales/en/plugins.json +++ b/src/main/resources/locales/en/plugins.json @@ -45,7 +45,8 @@ "repositoryImport": { "titleFailed": "Import failed: {{repository}}", "titleSuccess": "Import finished: {{repository}}", - "description": "Started by" + "description": "Started by", + "logLink": "import log" }, "repositoryRenamed": { "title": "Repository was renamed:"