Skip to content
New issue

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

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

Already on GitHub? # to your account

[HACK week] Webhooks #14027

Draft
wants to merge 19 commits into
base: trunk
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Extract vms to their own files
  • Loading branch information
iamgabrielma committed Sep 25, 2024
commit 1dc30c90a12a8cc9130990464c5a827a4886aa00
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import Foundation
import SwiftUI

struct WebhookRowView: View {
private let viewModel: WebhookRowViewModel

init(viewModel: WebhookRowViewModel) {
self.viewModel = viewModel
}

var statusLabelColor: Color {
switch viewModel.webhook.status {
case "active":
Color.green
case "paused":
Color.yellow
case "disabled":
Color.gray
default:
Color.white
}
}

var body: some View {
VStack(alignment: .leading) {
HStack {
if let name = viewModel.webhook.name {
Text(name)
}
Spacer()
Text(viewModel.webhook.status)
.background(statusLabelColor)
}
Text("Topic: \(viewModel.webhook.topic)")
.font(.caption)
Text("Delivery: \(viewModel.webhook.deliveryURL)")
.font(.caption)
}
.padding(.vertical, 2)
.padding(.horizontal)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation
import Yosemite

struct WebhookRowViewModel: Identifiable {
var id = UUID()
let webhook: Webhook

init(webhook: Webhook) {
self.webhook = webhook
}
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,6 @@
import SwiftUI
import Yosemite

struct WebhookRowViewModel: Identifiable {
var id = UUID()
let webhook: Webhook

init(webhook: Webhook) {
self.webhook = webhook
}
}

struct WebhookRowView: View {
private let viewModel: WebhookRowViewModel

init(viewModel: WebhookRowViewModel) {
self.viewModel = viewModel
}

var statusLabelColor: Color {
switch viewModel.webhook.status {
case "active":
Color.green
case "paused":
Color.yellow
case "disabled":
Color.gray
default:
Color.white
}
}

var body: some View {
VStack(alignment: .leading) {
HStack {
if let name = viewModel.webhook.name {
Text(name)
}
Spacer()
Text(viewModel.webhook.status)
.background(statusLabelColor)
}
Text("Topic: \(viewModel.webhook.topic)")
.font(.caption)
Text("Delivery: \(viewModel.webhook.deliveryURL)")
.font(.caption)
}
.padding(.vertical, 2)
.padding(.horizontal)
}
}

enum WebhooksViewState: String, CaseIterable, Identifiable {
case listAll = "List all Webhooks"
case createNew = "Create new Webhook"
8 changes: 8 additions & 0 deletions WooCommerce/WooCommerce.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -1499,6 +1499,8 @@
680BA59A2A4C377900F5559D /* UpgradeViewState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 680BA5992A4C377900F5559D /* UpgradeViewState.swift */; };
680E36B52BD8B9B900E8BCEA /* OrderSubscriptionTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 680E36B42BD8B9B900E8BCEA /* OrderSubscriptionTableViewCell.xib */; };
680E36B72BD8C49F00E8BCEA /* OrderSubscriptionTableViewCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 680E36B62BD8C49F00E8BCEA /* OrderSubscriptionTableViewCellViewModel.swift */; };
681842D62CA4006700246C90 /* WebhookRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681842D52CA4006700246C90 /* WebhookRowView.swift */; };
681842D82CA400AD00246C90 /* WebhookRowViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 681842D72CA400AD00246C90 /* WebhookRowViewModel.swift */; };
682210ED2909666600814E14 /* CustomerSearchUICommandTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 682210EC2909666600814E14 /* CustomerSearchUICommandTests.swift */; };
6827140F28A3988300E6E3F6 /* DismissableNoticeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6827140E28A3988300E6E3F6 /* DismissableNoticeView.swift */; };
6832C7CA26DA5C4500BA4088 /* LabeledTextViewTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6832C7C926DA5C4500BA4088 /* LabeledTextViewTableViewCell.swift */; };
@@ -4521,6 +4523,8 @@
680BA5992A4C377900F5559D /* UpgradeViewState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpgradeViewState.swift; sourceTree = "<group>"; };
680E36B42BD8B9B900E8BCEA /* OrderSubscriptionTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OrderSubscriptionTableViewCell.xib; sourceTree = "<group>"; };
680E36B62BD8C49F00E8BCEA /* OrderSubscriptionTableViewCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderSubscriptionTableViewCellViewModel.swift; sourceTree = "<group>"; };
681842D52CA4006700246C90 /* WebhookRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebhookRowView.swift; sourceTree = "<group>"; };
681842D72CA400AD00246C90 /* WebhookRowViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebhookRowViewModel.swift; sourceTree = "<group>"; };
682210EC2909666600814E14 /* CustomerSearchUICommandTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerSearchUICommandTests.swift; sourceTree = "<group>"; };
6827140E28A3988300E6E3F6 /* DismissableNoticeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DismissableNoticeView.swift; sourceTree = "<group>"; };
6832C7C926DA5C4500BA4088 /* LabeledTextViewTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabeledTextViewTableViewCell.swift; sourceTree = "<group>"; };
@@ -9339,7 +9343,9 @@
isa = PBXGroup;
children = (
6809106E2CA25FAE0057B02A /* WebhooksView.swift */,
681842D52CA4006700246C90 /* WebhookRowView.swift */,
680910792CA2B37F0057B02A /* WebhooksViewModel.swift */,
681842D72CA400AD00246C90 /* WebhookRowViewModel.swift */,
);
path = Webhooks;
sourceTree = "<group>";
@@ -14826,6 +14832,7 @@
027EB56E29C0602D003CE551 /* StoreOnboardingLaunchStoreViewModel.swift in Sources */,
26C6439327B5DBE900DD00D1 /* OrderSynchronizer.swift in Sources */,
CE0F17D222A8308900964A63 /* FancyAlertController+PurchaseNote.swift in Sources */,
681842D82CA400AD00246C90 /* WebhookRowViewModel.swift in Sources */,
684AB83A2870677F003DFDD1 /* CardReaderManualsView.swift in Sources */,
CEA455C12BB3446D00D932CF /* BundlesReportCardViewModel.swift in Sources */,
0230B4D62C33454900F2F660 /* PointOfSaleCardPresentPaymentCaptureErrorMessageView.swift in Sources */,
@@ -16201,6 +16208,7 @@
EE1905842B579B6700617C53 /* BlazeCampaignCreationLoadingView.swift in Sources */,
020DD49123239DD6005822B1 /* PaginatedListViewControllerStateCoordinator.swift in Sources */,
EE66BB0E2B29BF2800518DAF /* ThemeInstaller.swift in Sources */,
681842D62CA4006700246C90 /* WebhookRowView.swift in Sources */,
0202B6952387AD1B00F3EBE0 /* UITabBar+Order.swift in Sources */,
26C98F9829C1247000F96503 /* WPComSitePlan+FreeTrial.swift in Sources */,
3120491726DD807900A4EC4F /* LabelAndButtonTableViewCell.swift in Sources */,