Skip to content

Commit

Permalink
Current -> environment
Browse files Browse the repository at this point in the history
  • Loading branch information
rahafjrw committed Nov 27, 2024
1 parent feeea95 commit 9e75369
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Sources/App/Views/Blog/BlogActions+Index+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import Foundation
import Plot
import Dependencies

extension BlogActions {

Expand Down Expand Up @@ -108,7 +109,8 @@ extension BlogActions {
}

override func navMenuItems() -> [NavMenuItem] {
if Current.environment() == .production {
@Dependency(\.environment) var environment
if environment.current() == .production {
return [.supporters, .searchLink, .addPackage, .faq]
} else {
return [.supporters, .searchLink, .addPackage, .faq, .portal]
Expand Down
8 changes: 5 additions & 3 deletions Sources/App/Views/Home/HomeIndex+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

import Plot
import Dependencies


enum HomeIndex {
Expand Down Expand Up @@ -114,10 +115,11 @@ enum HomeIndex {
}

override func navMenuItems() -> [NavMenuItem] {
if Current.environment() == .production {
[.supporters, .addPackage, .blog, .faq]
@Dependency(\.environment) var environment
if environment.current() == .production {
return [.supporters, .addPackage, .blog, .faq]
} else {
[.supporters, .addPackage, .blog, .faq, .portal]
return [.supporters, .addPackage, .blog, .faq, .portal]
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/App/Views/PublicPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ class PublicPage {
/// The items to be rendered in the site navigation menu.
/// - Returns: An array of `NavMenuItem` items used in `header`.
func navMenuItems() -> [NavMenuItem] {
if Current.environment() == .production {
@Dependency(\.environment) var environment
if environment.current() == .production {
return [.supporters, .addPackage, .blog, .faq, .search]
} else {
return [.supporters, .addPackage, .blog, .faq, .search, .portal]
Expand Down
4 changes: 3 additions & 1 deletion Sources/App/Views/Search/SearchShow+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

import Plot
import Dependencies


extension SearchShow {
Expand Down Expand Up @@ -64,7 +65,8 @@ extension SearchShow {
}

override func navMenuItems() -> [NavMenuItem] {
if Current.environment() == .production {
@Dependency(\.environment) var environment
if environment.current() == .production {
return [.supporters, .addPackage, .blog, .faq]
} else {
return [.supporters, .addPackage, .blog, .faq, .portal]
Expand Down
2 changes: 1 addition & 1 deletion Sources/App/routes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func routes(_ app: Application) throws {
let auth = app.routes.grouped([app.sessions.middleware, UserSessionAuthenticator()])
let redirect = auth.grouped(AuthenticatedUser.redirectMiddleware(path: SiteURL.login.relativeURL()))

if Current.environment() != .production {
if environment.current() != .production {
do {
redirect.get(SiteURL.portal.pathComponents, use: PortalController.show)
.excludeFromOpenAPI()
Expand Down

0 comments on commit 9e75369

Please sign in to comment.