Skip to content

Commit 10992d7

Browse files
authored
Merge branch 'trunk' into issue/WOOMOB-12-update-disabled-state-text-of-package-buttons
2 parents 1043861 + c5eddf4 commit 10992d7

File tree

56 files changed

+10222
-371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+10222
-371
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Auto-merge Dependabot PATCH updates
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
auto-merge:
13+
runs-on: ubuntu-latest
14+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'woocommerce/woocommerce-android'
15+
env:
16+
PR_URL: ${{ github.event.pull_request.html_url }}
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- uses: actions/checkout@v5
20+
21+
- name: Fetch Dependabot metadata
22+
id: metadata
23+
uses: dependabot/fetch-metadata@v2
24+
with:
25+
github-token: "${{ secrets.GITHUB_TOKEN }}"
26+
27+
- name: Assign closest open milestone to PR
28+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
29+
run: |
30+
set -e
31+
number=$(gh api repos/$GITHUB_REPOSITORY/milestones \
32+
--jq '[.[]
33+
| select(.state=="open" and .due_on!=null and (.due_on | fromdateiso8601) >= now)
34+
]
35+
| sort_by(.due_on)
36+
| .[0].number')
37+
38+
if [ -n "$number" ]; then
39+
echo "Assigning milestone #$number to PR #${{ github.event.pull_request.number }}"
40+
gh pr edit "${{ github.event.pull_request.number }}" --milestone "$number"
41+
else
42+
echo "No future open milestones found."
43+
fi
44+
45+
- name: Approve the PR
46+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
47+
run: |
48+
set -e
49+
gh pr review --approve "$PR_URL"
50+
51+
- name: Enable auto-merge for Dependabot PRs
52+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
53+
run: |
54+
set -e
55+
gh pr merge --auto --merge "$PR_URL"

RELEASE-NOTES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
- [WEAR] Updated UserAgent of API requests to use `http.agent` System Property to fix performance issues related to WebView usage on app launch [https://github.com/woocommerce/woocommerce-android/pull/14431]
1313
- [***] POS: A new settings to customize the POS [https://github.com/woocommerce/woocommerce-android/pull/14527]
1414
- [*] [Login] Improved the detection of WooCommerce API version during login flow [https://github.com/woocommerce/woocommerce-android/pull/14524]
15+
- [*] Add more filter options to orders filters sales channel [https://github.com/woocommerce/woocommerce-android/pull/14546]
1516
- [*] Automatically populate the weight field in the create shipment flow [https://github.com/woocommerce/woocommerce-android/pull/14525]
17+
- [*] [Shipping Labels] Fixed displaying incorrect hazardous material option for purchased labels [https://github.com/woocommerce/woocommerce-android/pull/14571]
1618
- [*] Shipping Labels: Updated the disabled button text on the package selection screen [https://github.com/woocommerce/woocommerce-android/pull/14558]
1719

1820
23.1

WooCommerce/src/main/kotlin/com/woocommerce/android/model/ShippingLabel.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.woocommerce.android.model
22

33
import android.os.Parcelable
4+
import com.woocommerce.android.ui.orders.shippinglabels.creation.ShippingLabelHazmatCategory
45
import com.woocommerce.android.ui.orders.wooshippinglabels.models.ShippingLabelModel
56
import com.woocommerce.android.ui.orders.wooshippinglabels.models.ShippingLabelStatus
67
import kotlinx.parcelize.IgnoredOnParcel
@@ -25,6 +26,7 @@ data class ShippingLabel(
2526
val currency: String = "",
2627
val productNames: List<String> = emptyList(),
2728
val productIds: List<Long> = emptyList(),
29+
val hazmatCategory: ShippingLabelHazmatCategory? = null,
2830
val originAddress: Address? = null,
2931
val destinationAddress: Address? = null,
3032
val refund: Refund? = null,
@@ -96,6 +98,7 @@ fun ShippingLabel.toShippingLabelModel(): ShippingLabelModel {
9698
usedDate = null,
9799
refund = refund?.let { ShippingLabelModel.Refund(status = it.status, requestDate = it.refundDate) },
98100
products = products,
101+
hazmatCategory = hazmatCategory,
99102
originAddress = originAddress,
100103
destinationAddress = destinationAddress
101104
)

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/filters/OrderFilterCategoriesViewModel.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory.DA
1616
import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory.ORDER_STATUS
1717
import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory.PRODUCT
1818
import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory.SALES_CHANNEL
19+
import com.woocommerce.android.ui.orders.filters.data.SalesChannel
1920
import com.woocommerce.android.ui.orders.filters.domain.GetDateRangeFilterOptions
2021
import com.woocommerce.android.ui.orders.filters.domain.GetOrderStatusFilterOptions
2122
import com.woocommerce.android.ui.orders.filters.domain.GetTrackingForFilterSelection
@@ -390,9 +391,19 @@ class OrderFilterCategoriesViewModel @Inject constructor(
390391

391392
return mutableListOf(
392393
OrderFilterOptionUiModel(
393-
key = "pos",
394+
key = SalesChannel.POS.key,
394395
displayName = resourceProvider.getString(R.string.point_of_sale),
395-
isSelected = currentSelection.contains("pos")
396+
isSelected = currentSelection.contains(SalesChannel.POS.key)
397+
),
398+
OrderFilterOptionUiModel(
399+
key = SalesChannel.WEB_CHECKOUT.key,
400+
displayName = resourceProvider.getString(R.string.orderfilters_sales_channel_filter_web_checkout),
401+
isSelected = currentSelection.contains(SalesChannel.WEB_CHECKOUT.key)
402+
),
403+
OrderFilterOptionUiModel(
404+
key = SalesChannel.WP_ADMIN.key,
405+
displayName = resourceProvider.getString(R.string.orderfilters_sales_channel_filter_wp_admin),
406+
isSelected = currentSelection.contains(SalesChannel.WP_ADMIN.key)
396407
)
397408
).apply {
398409
addFilterOptionAll(resourceProvider)

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/filters/data/OrderFilterDataModels.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ enum class OrderListFilterCategory {
88
SALES_CHANNEL
99
}
1010

11+
enum class SalesChannel(val key: String, val apiValue: String) {
12+
POS("pos", "pos-rest-api"),
13+
WEB_CHECKOUT("checkout", "checkout"),
14+
WP_ADMIN("admin", "admin");
15+
16+
companion object {
17+
fun fromKey(key: String): SalesChannel? = entries.find { it.key == key }
18+
}
19+
}
20+
1121
enum class DateRange(val filterKey: String) {
1222
TODAY("Today"),
1323
LAST_2_DAYS("Last2Days"),

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/filters/domain/GetWCOrderListDescriptorWithFilters.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.woocommerce.android.ui.orders.filters.data.OrderFiltersRepository
1111
import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory
1212
import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory.DATE_RANGE
1313
import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory.SALES_CHANNEL
14+
import com.woocommerce.android.ui.orders.filters.data.SalesChannel
1415
import com.woocommerce.android.util.DateUtils
1516
import org.wordpress.android.fluxc.model.WCOrderListDescriptor
1617
import javax.inject.Inject
@@ -30,7 +31,10 @@ class GetWCOrderListDescriptorWithFilters @Inject constructor(
3031
.joinToString(separator = ",")
3132

3233
val salesChannelFilters = orderFiltersRepository.getCurrentFilterSelection(SALES_CHANNEL)
33-
val createdViaFilter = if (salesChannelFilters.contains("pos")) "pos-rest-api" else null
34+
val createdViaFilter = salesChannelFilters
35+
.firstNotNullOfOrNull { key ->
36+
SalesChannel.fromKey(key)?.apiValue
37+
}
3438

3539
return WCOrderListDescriptor(
3640
site = selectedSite.get(),

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModel.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class WooShippingLabelCreationViewModel @Inject constructor(
183183

184184
init {
185185
launch { observeShippingLabelInformation() }
186+
launch { getHazmatSelection() }
186187
launch { getDestinationAddress() }
187188
launch { trackScreenShownEvent() }
188189
launch { getSavedShipments() }
@@ -323,6 +324,14 @@ class WooShippingLabelCreationViewModel @Inject constructor(
323324
}
324325
}
325326

327+
private suspend fun getHazmatSelection() {
328+
shipments.filter { it.isNotEmpty() }.first().let { shipmentList ->
329+
hazmatStatesFlow.value = shipmentList.map { shipment ->
330+
shipment.label?.hazmatCategory?.let { Declared(it) } ?: NoSelection
331+
}
332+
}
333+
}
334+
326335
private suspend fun getDestinationAddress() {
327336
combine(
328337
order.drop(1),

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/models/ShippingLabelModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.woocommerce.android.model.Address
66
import com.woocommerce.android.model.Order
77
import com.woocommerce.android.model.ShippingLabel
88
import com.woocommerce.android.ui.orders.shippinglabels.ShipmentTrackingUrls
9+
import com.woocommerce.android.ui.orders.shippinglabels.creation.ShippingLabelHazmatCategory
910
import com.woocommerce.android.ui.orders.wooshippinglabels.rates.datasource.WooShippingRatesDatasourceMapper.Companion.CARRIER_DHL_EXPRESS_KEY
1011
import kotlinx.parcelize.IgnoredOnParcel
1112
import kotlinx.parcelize.Parcelize
@@ -38,6 +39,7 @@ data class ShippingLabelModel(
3839
val usedDate: Long?,
3940
val refund: Refund?,
4041
val products: List<Order.Item> = emptyList(),
42+
val hazmatCategory: ShippingLabelHazmatCategory? = null,
4143
val originAddress: Address? = null,
4244
val destinationAddress: Address? = null,
4345
val error: String? = null,

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/networking/DTOs.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ data class ShippingLabelDataDTO(
9595
)
9696

9797
data class StoredDataDTO(
98+
@SerializedName("selected_hazmat")
99+
@JsonAdapter(MapOrEmptyMapDeserializer::class)
100+
val selectedHazmat: Map<String, HazmatDTO>,
98101
@SerializedName("selected_origin")
99102
@JsonAdapter(MapOrEmptyMapDeserializer::class)
100103
val selectedOrigin: Map<String, OriginAddressDTO>,

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/networking/WooShippingLabelRepository.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,15 @@ class WooShippingLabelRepository @Inject constructor(
118118
labelId = labelId,
119119
).also {
120120
it.result?.shippingLabel?.let { labelDTO ->
121-
// The API doesn't return the origin and destination addresses,
121+
// The API doesn't return the hazmat category, origin and destination addresses,
122122
// we get it from the already cached labels in the database after the purchase request
123123
val currentLabel = wooShippingDao.getLabel(
124124
selectedSite.get().localId(),
125125
LocalOrRemoteId.RemoteId(orderId),
126126
labelId
127127
)
128128
val updatedLabel = mapper(labelDTO, site, orderId).copy(
129+
hazmatCategory = currentLabel?.hazmatCategory,
129130
originAddress = currentLabel?.originAddress,
130131
destinationAddress = currentLabel?.destinationAddress
131132
)

0 commit comments

Comments
 (0)