~jan0sch/smederee
Showing details for patch 6620db4aa31c86d3a860c8d6e74815b0513021b4.
diff -rN -u old-smederee/modules/hub/src/main/resources/messages_en.properties new-smederee/modules/hub/src/main/resources/messages_en.properties --- old-smederee/modules/hub/src/main/resources/messages_en.properties 2025-01-31 22:51:22.901376484 +0000 +++ new-smederee/modules/hub/src/main/resources/messages_en.properties 2025-01-31 22:51:22.901376484 +0000 @@ -175,6 +175,13 @@ repository.changes.patch.summary.modified.details={0} with {1} added and {2} removed lines repository.changes.patch.summary.removed={0} files removed repository.changes.description=Showing {0} changes starting from {1}. +repository.changes.description.empty=There are no recorded patches yet. + +repository.delete.title=Here you can delete your repository if you want to. + +repository.edit.title=Edit the repository settings. + +repository.labels.edit.title=Edit your repository labels. repository.menu.changes.next=Next repository.menu.changes=Changes diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala --- old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala 2025-01-31 22:51:22.901376484 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala 2025-01-31 22:51:22.901376484 +0000 @@ -990,63 +990,68 @@ } // TODO Replace with whatever we implement as proper permission model. ;-) repo = loadedRepo.filter(r => r.isPrivate === false || r.owner === user.toVcsRepositoryOwner) - _ <- Sync[F].raiseUnless(repo.nonEmpty)(new Error("Repository not found!")) - editAction <- Sync[F].delay( - linkConfig.createFullUri( - Uri(path = - Uri.Path( - Vector( - Uri.Path.Segment(s"~$repositoryOwnerName"), - Uri.Path.Segment(repositoryName.toString), - Uri.Path.Segment("edit") + resp <- repo match { + case None => NotFound() + case Some(repo) => + for { + editAction <- Sync[F].delay( + linkConfig.createFullUri( + Uri(path = + Uri.Path( + Vector( + Uri.Path.Segment(s"~$repositoryOwnerName"), + Uri.Path.Segment(repositoryName.toString), + Uri.Path.Segment("edit") + ) + ) + ) ) ) - ) - ) - ) - repoUri <- Sync[F].delay( - linkConfig.createFullUri( - Uri(path = - Uri.Path( - Vector( - Uri.Path.Segment(s"~$repositoryOwnerName"), - Uri.Path.Segment(repositoryName.toString) + repoUri <- Sync[F].delay( + linkConfig.createFullUri( + Uri(path = + Uri.Path( + Vector( + Uri.Path.Segment(s"~$repositoryOwnerName"), + Uri.Path.Segment(repositoryName.toString) + ) + ) + ) ) ) - ) - ) - ) - formData <- Sync[F].delay { - urlForm.values.map { t => - val (key, values) = t - ( - key, - values.headOption.getOrElse("") - ) // Pick the first value (a field might get submitted multiple times)! - } - } - form <- Sync[F].delay(EditVcsRepositoryForm.validate(formData)) - resp <- form match { - case Validated.Invalid(errors) => - BadRequest( - views.html.editRepository()( - editAction, - csrf, - Option(s"~$repositoryOwnerName/$repositoryName - edit"), - user - )(formData, FormErrors.fromNec(errors)) - ) - case Validated.Valid(updatedVcsRepository) => - for { - _ <- repo.traverse { repo => - val repoMetadata = repo.copy( - isPrivate = updatedVcsRepository.isPrivate, - description = updatedVcsRepository.description, - website = updatedVcsRepository.website - ) - vcsMetadataRepo.updateVcsRepository(repoMetadata) + formData <- Sync[F].delay { + urlForm.values.map { t => + val (key, values) = t + ( + key, + values.headOption.getOrElse("") + ) // Pick the first value (a field might get submitted multiple times)! + } + } + form <- Sync[F].delay(EditVcsRepositoryForm.validate(formData)) + resp <- form match { + case Validated.Invalid(errors) => + BadRequest( + views.html.editRepository()( + editAction, + csrf, + repoUri, + Option(s"~$repositoryOwnerName/$repositoryName - edit"), + user, + repo + )(formData, FormErrors.fromNec(errors)) + ) + case Validated.Valid(updatedVcsRepository) => + val repoMetadata = repo.copy( + isPrivate = updatedVcsRepository.isPrivate, + description = updatedVcsRepository.description, + website = updatedVcsRepository.website + ) + for { + _ <- vcsMetadataRepo.updateVcsRepository(repoMetadata) + resp <- SeeOther(Location(repoUri)) + } yield resp } - resp <- SeeOther(Location(repoUri)) } yield resp } } yield resp @@ -1112,16 +1117,29 @@ ) ) ) + repoUri <- Sync[F].delay( + linkConfig.createFullUri( + Uri(path = + Uri.Path( + Vector( + Uri.Path.Segment(s"~$repositoryOwnerName"), + Uri.Path.Segment(repositoryName.toString) + ) + ) + ) + ) + ) resp <- repo match { case None => NotFound() case Some(repo) => Ok( views.html.deleteRepository()( deleteAction, - repo, + repoUri, csrf, Option(s"~$repositoryOwnerName/$repositoryName - delete"), - user + user, + repo ) ) } @@ -1154,18 +1172,32 @@ ) ) ) + repoUri <- Sync[F].delay( + linkConfig.createFullUri( + Uri(path = + Uri.Path( + Vector( + Uri.Path.Segment(s"~$repositoryOwnerName"), + Uri.Path.Segment(repositoryName.toString) + ) + ) + ) + ) + ) formData <- Sync[F].delay(repo.map(EditVcsRepositoryForm.fromVcsRepository).map(_.toMap)) - resp <- formData match { - case None => NotFound() - case Some(formData) => + resp <- (formData, repo) match { + case (Some(formData), Some(repo)) => Ok( views.html.editRepository()( editAction, csrf, + repoUri, Option(s"~$repositoryOwnerName/$repositoryName - edit"), - user + user, + repo )(formData) ) + case _ => NotFound() } } yield resp } diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/deleteRepository.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/deleteRepository.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/deleteRepository.scala.html 2025-01-31 22:51:22.901376484 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/deleteRepository.scala.html 2025-01-31 22:51:22.901376484 +0000 @@ -1,8 +1,27 @@ -@(baseUri: Uri = Uri(path = Uri.Path.Root), lang: LanguageCode = LanguageCode("en"))(deleteAction: Uri, vcsRepository: VcsRepository, csrf: Option[CsrfToken] = None, title: Option[String] = None, user: Account) +@(baseUri: Uri = Uri(path = Uri.Path.Root), + lang: LanguageCode = LanguageCode("en") +)(deleteAction: Uri, + repositoryBaseUri: Uri, + csrf: Option[CsrfToken] = None, + title: Option[String] = None, + user: Account, + vcsRepository: VcsRepository +) @main(baseUri, lang)()(csrf, title, user.some) { @defining(lang.toLocale) { implicit locale => <div class="content"> <div class="pure-g"> + <div class="pure-u-1"> + <div class="l-box-left-right"> + <h2><a href="@{baseUri.addSegment(s"~${vcsRepository.owner.name}")}">~@vcsRepository.owner.name</a>/@vcsRepository.name</h2> + @showRepositoryMenu(baseUri)(deleteAction.some, repositoryBaseUri, user.some, vcsRepository) + <div class="repo-summary-description"> + @Messages("repository.delete.title") + </div> + </div> + </div> + </div> + <div class="pure-g"> <div class="pure-u-1-1 pure-u-md-1-1"> <div class="l-box"> <div class="repo-delete-form"> diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/editRepository.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/editRepository.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/editRepository.scala.html 2025-01-31 22:51:22.901376484 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/editRepository.scala.html 2025-01-31 22:51:22.901376484 +0000 @@ -1,10 +1,31 @@ @import EditVcsRepositoryForm._ -@(baseUri: Uri = Uri(path = Uri.Path.Root), lang: LanguageCode = LanguageCode("en"))(action: Uri, csrf: Option[CsrfToken] = None, title: Option[String] = None, user: Account)(formData: Map[String, String] = Map.empty, formErrors: FormErrors = FormErrors.empty) +@(baseUri: Uri = Uri(path = Uri.Path.Root), + lang: LanguageCode = LanguageCode("en") +)(action: Uri, + csrf: Option[CsrfToken] = None, + repositoryBaseUri: Uri, + title: Option[String] = None, + user: Account, + vcsRepository: VcsRepository +)(formData: Map[String, String] = Map.empty, + formErrors: FormErrors = FormErrors.empty +) @main(baseUri, lang)()(csrf, title, user.some) { @defining(lang.toLocale) { implicit locale => <div class="content"> <div class="pure-g"> + <div class="pure-u-1"> + <div class="l-box-left-right"> + <h2><a href="@{baseUri.addSegment(s"~${vcsRepository.owner.name}")}">~@vcsRepository.owner.name</a>/@vcsRepository.name</h2> + @showRepositoryMenu(baseUri)(action.some, repositoryBaseUri, user.some, vcsRepository) + <div class="repo-summary-description"> + @Messages("repository.edit.title") + </div> + </div> + </div> + </div> + <div class="pure-g"> <div class="pure-u-1-1 pure-u-md-1-1"> <div class="l-box"> <div class="form-errors"> @@ -58,4 +79,3 @@ </div> } } - diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryHistory.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryHistory.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryHistory.scala.html 2025-01-31 22:51:22.901376484 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryHistory.scala.html 2025-01-31 22:51:22.901376484 +0000 @@ -19,8 +19,12 @@ <h2><a href="@{baseUri.addSegment(s"~${vcsRepository.owner.name}")}">~@vcsRepository.owner.name</a>/@vcsRepository.name</h2> @showRepositoryMenu(baseUri)(repositoryBaseUri.addSegment("history").some, repositoryBaseUri, user, vcsRepository) <div class="repo-summary-description"> - @for(firstEntry <- history.headOption) { - @Messages("repository.changes.description", history.size, firstEntry.hash.toString) + @if(history.isEmpty) { + @Messages("repository.changes.description.empty") + } else { + @for(firstEntry <- history.headOption) { + @Messages("repository.changes.description", history.size, firstEntry.hash.toString) + } } </div> </div> diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryMenu.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryMenu.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryMenu.scala.html 2025-01-31 22:51:22.901376484 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryMenu.scala.html 2025-01-31 22:51:22.901376484 +0000 @@ -15,10 +15,14 @@ @defining(repositoryBaseUri.addSegment("history")) { uri => <li class="pure-menu-item@if(activeUri.exists(_ === uri)){ pure-menu-active}else{}"><a class="pure-menu-link" href="@uri">@icon(baseUri)("list") @Messages("repository.menu.changes")</a></li> } - @if(activeUri.exists(_ === repositoryBaseUri)) { + @if(activeUri.exists(uri => uri === repositoryBaseUri || uri === repositoryBaseUri.addSegment("edit") || uri === repositoryBaseUri.addSegment("delete"))) { @if(user.exists(_.uid === vcsRepository.owner.uid)) { - <li class="pure-menu-item"><a class="pure-menu-link" href="@repositoryBaseUri.addSegment("edit")">@icon(baseUri)("edit-2") @Messages("repository.menu.edit")</a></li> - <li class="pure-menu-item"><a class="pure-menu-link" href="@repositoryBaseUri.addSegment("delete")">@icon(baseUri)("trash-2") @Messages("repository.menu.delete")</a></li> + @defining(repositoryBaseUri.addSegment("edit")) { uri => + <li class="pure-menu-item@if(activeUri.exists(_ === uri)){ pure-menu-active}else{}"><a class="pure-menu-link" href="@uri">@icon(baseUri)("edit-2") @Messages("repository.menu.edit")</a></li> + } + @defining(repositoryBaseUri.addSegment("delete")) { uri => + <li class="pure-menu-item@if(activeUri.exists(_ === uri)){ pure-menu-active}else{}"><a class="pure-menu-link" href="@uri">@icon(baseUri)("trash-2") @Messages("repository.menu.delete")</a></li> + } } else { } } else { } @for(website <- vcsRepository.website) { diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryOverview.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryOverview.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryOverview.scala.html 2025-01-31 22:51:22.901376484 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryOverview.scala.html 2025-01-31 22:51:22.901376484 +0000 @@ -19,11 +19,9 @@ <div class="l-box-left-right"> <h2><a href="@{baseUri.addSegment(s"~${vcsRepository.owner.name}")}">~@vcsRepository.owner.name</a>/@vcsRepository.name</h2> @showRepositoryMenu(baseUri)(actionBaseUri.some, actionBaseUri, user, vcsRepository) - @for(description <- vcsRepository.description) { - <div class="repo-summary-description"> - <strong>@Messages("repository.description.title")</strong> @description - </div> - } + <div class="repo-summary-description"> + <strong>@Messages("repository.description.title")</strong> @vcsRepository.description + </div> @for(parentRepo <- vcsRepositoryParentFork) { <div class="repo-summary-description"> <i>@Messages("repository.description.forked-from") <a href="@{baseUri.addSegment(s"~${parentRepo.owner.name.toString}").addSegment(parentRepo.name.toString)}">~@{parentRepo.owner.name}/@{parentRepo.name}</a></i>