Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CODEWONERS #2

Merged
merged 8 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions Sources/LogsSheetKit/LogsSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@
// Copyright © 2022 Riiid Inc. All rights reserved.
//

import Combine
import SPIndicator
import SwiftUI

public struct LogsSheet: View {
@Environment(\.presentationMode) private var presentationMode: Binding<PresentationMode>

private let logs: [ActionLog]
private let clearAction: () -> Void

@State private var isAscending: Bool = false
@State private var showCopiedIndicator: Bool = false
@State private var searchText: String = ""
@ObservedObject var logsManager: LogsSheetManager = LogsSheetManager.shared

public init(logs: [ActionLog], clearAction: @escaping () -> Void) {
self.logs = logs
self.clearAction = clearAction
}
public init() { }

private var filteredLogs: [ActionLog] {
let sortedLogs: [ActionLog] = logs
let sortedLogs: [ActionLog] = logsManager.logs
.sorted(by: {
isAscending
? $0.timeStamp < $1.timeStamp
Expand Down Expand Up @@ -77,7 +73,7 @@ public struct LogsSheet: View {
ToolbarItemGroup(placement: .bottomBar) {
Button(
action: {
UIPasteboard.general.string = logs
UIPasteboard.general.string = logsManager.logs
.map { dateFormatter.string(from: $0.timeStamp) + "\n" + $0.message }
.joined(separator: "\n")
showCopiedIndicator = true
Expand All @@ -86,14 +82,21 @@ public struct LogsSheet: View {
Text("Copy All")
}
)
.disabled(logsManager.logs.isEmpty)

Spacer()

Button(
action: clearAction,
action: {
logsManager.logs.removeAll()
} ,
label: {
Text("Clear")
}
)
.disabled(logsManager.logs.isEmpty)
}

ToolbarItem(placement: .automatic) {
Button(
action: { isAscending.toggle() },
Expand Down Expand Up @@ -128,19 +131,10 @@ private let dateFormatter: ISO8601DateFormatter = {
// MARK: Previewer

struct LogsSheet_Previews: PreviewProvider {
static private let logsStub: [ActionLog] = [
ActionLog(message: "stub action log"),
ActionLog(message: "stub action log"),
ActionLog(message: "stub action log")
]

static var previews: some View {
Group {
LogsSheet(logs: [], clearAction: {})
LogsSheet()
.previewDisplayName("LogsSheet | empty")

LogsSheet(logs: logsStub, clearAction: {})
.previewDisplayName("LogsSheet | non empty")
}
}
}
20 changes: 20 additions & 0 deletions Sources/LogsSheetKit/LogsSheetManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// LogsSheetManager.swift
//
//
// Created by Yessen Yermukhanbet on 2022/10/06.
//

import Foundation
import Combine

public class LogsSheetManager: ObservableObject {
public static var shared: LogsSheetManager = LogsSheetManager()

@Published var logs: [ActionLog] = []

public func log(message: String) {
let log: ActionLog = ActionLog(message: message)
LogsSheetManager.shared.logs.append(log)
}
}
54 changes: 54 additions & 0 deletions docs/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @tisohjung @SongJiyeon @yermukhanbet @korJAEYOUNGYUN

# Order is important; the last matching pattern takes the most
# precedence. When someone opens a pull request that only
# modifies JS files, only @js-owner and not the global
# owner(s) will be requested for a review.
# *.js @js-owner

# You can also use email addresses if you prefer. They'll be
# used to look up users just like we do for commit author
# emails.
# *.go docs@example.com

# Teams can be specified as code owners as well. Teams should
# be identified in the format @org/team-name. Teams must have
# explicit write access to the repository. In this example,
# the octocats team in the octo-org organization owns all .txt files.
# *.txt @octo-org/octocats

# In this example, @doctocat owns any files in the build/logs
# directory at the root of the repository and any of its
# subdirectories.
# /build/logs/ @doctocat

# The `docs/*` pattern will match files like
# `docs/getting-started.md` but not further nested files like
# `docs/build-app/troubleshooting.md`.
# docs/* docs@example.com

# In this example, @octocat owns any file in an apps directory
# anywhere in your repository.
# apps/ @octocat

# In this example, @doctocat owns any file in the `/docs`
# directory in the root of your repository and any of its
# subdirectories.
# /docs/ @doctocat

# In this example, any change inside the `/scripts` directory
# will require approval from @doctocat or @octocat.
# /scripts/ @doctocat @octocat

# In this example, @octocat owns any file in the `/apps`
# directory in the root of your repository except for the `/apps/github`
# subdirectory, as its owners are left empty.
# /apps/ @octocat
# /apps/github