Skip to content

Commit

Permalink
Merge branch 'dominik/tag-and-merge' into dominik/tag-and-merge-test-…
Browse files Browse the repository at this point in the history
…base-branch
  • Loading branch information
ayoy committed Feb 1, 2024
2 parents 678e47b + f0624ec commit e422d84
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 36 deletions.
51 changes: 51 additions & 0 deletions .github/actions/create-tag-and-github-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Tag Repository and Create GitHub Release
description: Tags the repository and creates a GitHub release
inputs:
prerelease:
description: "Whether the release is a prerelease"
required: false
type: boolean
default: true
GH_TOKEN:
description: "GitHub token"
required: true
type: string
outputs:
tag:
description: "Tag that has been added"
value: ${{ steps.compute-tag.outputs.tag }}
runs:
using: "composite"
steps:
- run: |
git config --global user.name "Dax the Duck"
git config --global user.email "[email protected]"
shell: bash
- id: compute-tag
run: |
version="$(cut -d ' ' -f 3 < Configuration/Version.xcconfig)"
if [[ "${{ inputs.prerelease }}" == "true" ]]; then
build_number="$(cut -d ' ' -f 3 < Configuration/BuildNumber.xcconfig)"
tag="${version}-${build_number}"
else
tag="${version}"
fi
echo "tag=${tag}" >> $GITHUB_OUTPUT
shell: bash

- id: tag-repo
run: |
git tag ${{ steps.compute-tag.outputs.tag }}
git push origin ${{ steps.compute-tag.outputs.tag }}
shell: bash

- id: create-github-release
run: |
latest_release="$(gh api /repos/${{ github.repository }}/releases/latest --jq '.tag_name')"
if [[ "${{ inputs.prerelease }}" == "true" ]]; then
gh release create ${{ steps.compute-tag.outcome.tag }} --generate-notes --prerelease --notes-start-tag ${latest_release}
else
gh release create ${{ steps.compute-tag.outcome.tag }} --generate-notes --notes-start-tag ${latest_release}
fi
shell: bash
22 changes: 5 additions & 17 deletions .github/workflows/tag_and_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,11 @@ jobs:
access-token: ${{ secrets.ASANA_ACCESS_TOKEN }}
task-id: ${{ steps.get-task-id.outputs.task-id }}

- name: Set up git
run: |
git config --global user.name "Dax the Duck"
git config --global user.email "[email protected]"
- name: Construct a tag
id: construct-tag
run: |
version="$(cut -d ' ' -f 3 < Configuration/Version.xcconfig)"
build_number="$(cut -d ' ' -f 3 < Configuration/BuildNumber.xcconfig)"
tag="${version}-${build_number}"
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Tag the repo
run: |
git tag ${{ steps.construct-tag.outputs.tag }}
git push origin ${{ steps.construct-tag.outputs.tag }}
- name: Create Tag and GitHub Release
uses: ./.github/actions/create-tag-and-github-release
with:
prerelease: true
GH_TOKEN: ${{ github.token }}

- name: Merge to base branch
id: merge
Expand Down
48 changes: 48 additions & 0 deletions DuckDuckGo/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -6626,6 +6626,54 @@
}
}
},
"pm.add.card" : {
"comment" : "Add New Credit Card button",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Add Credit Card"
}
}
}
},
"pm.add.identity" : {
"comment" : "Add New Identity button",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Add Identity"
}
}
}
},
"pm.add.login" : {
"comment" : "Add New Login button",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Add Password"
}
}
}
},
"pm.add.new" : {
"comment" : "Add New item button",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Add New"
}
}
}
},
"pm.added" : {
"comment" : "Label for login added data",
"extractionState" : "extracted_with_value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ extension UserText {
static let pmEmptyStateCardsTitle = NSLocalizedString("pm.empty.cards.title", value: "No Cards", comment: "Label for cards empty state title")
static let pmEmptyStateNotesTitle = NSLocalizedString("pm.empty.notes.title", value: "No Notes", comment: "Label for notes empty state title")

static let pmAddItem = NSLocalizedString("pm.add.new", value: "Add New", comment: "Add New item button")
static let pmAddCard = NSLocalizedString("pm.add.card", value: "Add Credit Card", comment: "Add New Credit Card button")
static let pmAddLogin = NSLocalizedString("pm.add.login", value: "Add Password", comment: "Add New Login button")
static let pmAddIdentity = NSLocalizedString("pm.add.identity", value: "Add Identity", comment: "Add New Identity button")
static let pmNewCard = NSLocalizedString("pm.new.card", value: "Credit Card", comment: "Label for new card title")
static let pmNewLogin = NSLocalizedString("pm.new.login", value: "Password", comment: "Label for new login title")
static let pmNewIdentity = NSLocalizedString("pm.new.identity", value: "Identity", comment: "Label for new identity title")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,18 @@ final class PasswordManagementItemListModel: ObservableObject {
@Published var canChangeCategory: Bool = true

private var onItemSelected: (_ old: SecureVaultItem?, _ new: SecureVaultItem?) -> Void
private var onAddItemSelected: (_ category: SecureVaultSorting.Category) -> Void
private let tld: TLD
private let urlMatcher: AutofillDomainNameUrlMatcher
private static let randomColorsCount = 15

init(passwordManagerCoordinator: PasswordManagerCoordinating,
onItemSelected: @escaping (_ old: SecureVaultItem?, _ new: SecureVaultItem?) -> Void,
urlMatcher: AutofillDomainNameUrlMatcher = AutofillDomainNameUrlMatcher(),
tld: TLD = ContentBlocking.shared.tld) {
tld: TLD = ContentBlocking.shared.tld,
onItemSelected: @escaping (_ old: SecureVaultItem?, _ new: SecureVaultItem?) -> Void,
onAddItemSelected: @escaping (_ category: SecureVaultSorting.Category) -> Void) {
self.onItemSelected = onItemSelected
self.onAddItemSelected = onAddItemSelected
self.passwordManagerCoordinator = passwordManagerCoordinator
self.urlMatcher = urlMatcher
self.tld = tld
Expand Down Expand Up @@ -479,4 +482,8 @@ final class PasswordManagementItemListModel: ObservableObject {
return tld.eTLDplus1(name) ?? title
}

func onAddItemClickedFor(_ category: SecureVaultSorting.Category) {
onAddItemSelected(category)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct PasswordManagementCreditCardItemView: View {
VStack(alignment: .leading, spacing: 0) {

HeaderView()
.padding(.top, 16)
.padding(.bottom, model.isInEditMode ? 20 : 30)

EditableCreditCardField(textFieldValue: $model.cardNumber, title: UserText.pmCardNumber)
Expand Down Expand Up @@ -94,10 +95,12 @@ struct PasswordManagementCreditCardItemView: View {
Spacer(minLength: 0)

Buttons()
.padding(.top, model.isInEditMode ? 12 : 10)
.padding(.bottom, model.isInEditMode ? 12 : 3)

}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding()
.padding(.horizontal)

}
.padding(EdgeInsets(top: 10, leading: 0, bottom: 10, trailing: 10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ struct PasswordManagementIdentityItemView: View {
}

Buttons()
.padding()
.padding(.top, editMode ? 4 : 10)
.padding(.bottom, editMode ? 12 : 3)
.padding(.horizontal)

}

Expand Down
81 changes: 81 additions & 0 deletions DuckDuckGo/SecureVault/View/PasswordManagementItemList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ struct PasswordManagementItemListView: View {
}
}
}

Spacer(minLength: 0)

Divider()

PasswordManagementAddButton()
.padding()

}
}

Expand Down Expand Up @@ -131,6 +139,7 @@ struct PasswordManagementItemListCategoryView: View {
PasswordManagementSortButton(imageName: "SortDescending")
}
}
.padding(.vertical, -4)

}
}
Expand Down Expand Up @@ -392,3 +401,75 @@ struct PasswordManagementSortButton: View {
}

}

private struct PasswordManagementAddButton: View {

@EnvironmentObject var model: PasswordManagementItemListModel

var body: some View {

switch model.sortDescriptor.category {
case .allItems:
ZStack {
// Setting Menu label to empty string and overlaying with this as Menu will not allow the image + text to be centered
Text(UserText.pmAddItem)

Menu {
createMenuItem(imageName: "LoginGlyph", text: UserText.pmNewLogin, category: .logins)
createMenuItem(imageName: "IdentityGlyph", text: UserText.pmNewIdentity, category: .identities)
createMenuItem(imageName: "CreditCardGlyph", text: UserText.pmNewCard, category: .cards)
} label: {
Text("")
}
.modifier(HideMenuIndicatorModifier())
}
.padding(.vertical, -4)
case .logins:
createButton(text: UserText.pmAddLogin, category: model.sortDescriptor.category)
case .identities:
createButton(text: UserText.pmAddIdentity, category: model.sortDescriptor.category)
case .cards:
createButton(text: UserText.pmAddCard, category: model.sortDescriptor.category)
}

}

private func createMenuItem(imageName: String, text: String, category: SecureVaultSorting.Category) -> some View {

Button {
model.onAddItemClickedFor(category)
} label: {
HStack {
Image(imageName)
Text(text)
}
}

}

private func createButton(text: String, category: SecureVaultSorting.Category) -> some View {

Button {
model.onAddItemClickedFor(category)
} label: {
Text(text)
.frame(maxWidth: .infinity)
.offset(y: 1)
}
.padding(.vertical, -4)

}
}

private struct HideMenuIndicatorModifier: ViewModifier {

func body(content: Content) -> some View {
if #available(macOS 12, *) {
content
.menuIndicator(.hidden)
} else {
content
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ struct PasswordManagementLoginItemView: View {
}

Buttons()
.padding()
.padding(.top, editMode ? 12 : 10)
.padding(.bottom, editMode ? 12 : 3)
.padding(.horizontal)

}
}
Expand Down
16 changes: 14 additions & 2 deletions DuckDuckGo/SecureVault/View/PasswordManagementViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,9 @@ final class PasswordManagementViewController: NSViewController {
var passwordManagerSelectionCancellable: AnyCancellable?

// swiftlint:disable function_body_length
// swiftlint:disable:next cyclomatic_complexity
private func createListView() {
let listModel = PasswordManagementItemListModel(passwordManagerCoordinator: self.passwordManagerCoordinator) { [weak self] previousValue, newValue in
let listModel = PasswordManagementItemListModel(passwordManagerCoordinator: self.passwordManagerCoordinator, onItemSelected: { [weak self] previousValue, newValue in
guard let newValue = newValue,
let id = newValue.secureVaultID,
let window = self?.view.window else {
Expand Down Expand Up @@ -748,7 +749,18 @@ final class PasswordManagementViewController: NSViewController {
} else {
loadNewItemWithID()
}
}
}, onAddItemSelected: { [weak self] category in
switch category {
case .logins:
self?.createNewLogin()
case .identities:
self?.createNewIdentity()
case .cards:
self?.createNewCreditCard()
default:
break
}
})

self.listModel = listModel
self.listView = NSHostingView(rootView: PasswordManagementItemListView().environmentObject(listModel))
Expand Down
Loading

0 comments on commit e422d84

Please sign in to comment.