diff --git a/assets/release_notes.md b/assets/release_notes.md index 7318fcd7..045ce4c8 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -1,3 +1,7 @@ +### 0.18.1 - April 2025 +--- +- Fix bug associated with handling invalid URLs + ### 0.18.0 - April 2025 --- - Adds ability to create new companies from the app diff --git a/lib/api.dart b/lib/api.dart index 4dfe3561..0bbb542a 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -287,65 +287,67 @@ class InvenTreeAPI { int get apiVersion => (serverInfo["apiVersion"] ?? 1) as int; // Consolidated search request API v102 or newer - bool get supportsConsolidatedSearch =>apiVersion >= 102; + bool get supportsConsolidatedSearch => apiVersion >= 102; // ReturnOrder supports API v104 or newer - bool get supportsReturnOrders =>apiVersion >= 104; + bool get supportsReturnOrders => apiVersion >= 104; // "Contact" model exposed to API - bool get supportsContactModel =>apiVersion >= 104; + bool get supportsContactModel => apiVersion >= 104; // Status label endpoints API v105 or newer - bool get supportsStatusLabelEndpoints =>apiVersion >= 105; + bool get supportsStatusLabelEndpoints => apiVersion >= 105; // Regex search API v106 or newer - bool get supportsRegexSearch =>apiVersion >= 106; + bool get supportsRegexSearch => apiVersion >= 106; // Order barcodes API v107 or newer - bool get supportsOrderBarcodes =>apiVersion >= 107; + bool get supportsOrderBarcodes => apiVersion >= 107; // Project codes require v109 or newer - bool get supportsProjectCodes =>apiVersion >= 109; + bool get supportsProjectCodes => apiVersion >= 109; // Does the server support extra fields on stock adjustment actions? - bool get supportsStockAdjustExtraFields =>apiVersion >= 133; + bool get supportsStockAdjustExtraFields => apiVersion >= 133; // Does the server support receiving items against a PO using barcodes? - bool get supportsBarcodePOReceiveEndpoint =>apiVersion >= 139; + bool get supportsBarcodePOReceiveEndpoint => apiVersion >= 139; // Does the server support adding line items to a PO using barcodes? - bool get supportsBarcodePOAddLineEndpoint =>apiVersion >= 153; + bool get supportsBarcodePOAddLineEndpoint => apiVersion >= 153; // Does the server support allocating stock to sales order using barcodes? - bool get supportsBarcodeSOAllocateEndpoint =>apiVersion >= 160; + bool get supportsBarcodeSOAllocateEndpoint => apiVersion >= 160; // Does the server support the "modern" test results API // Ref: https://github.com/inventree/InvenTree/pull/6430/ - bool get supportsModernTestResults =>apiVersion >= 169; + bool get supportsModernTestResults => apiVersion >= 169; // Does the server support "null" top-level filtering for PartCategory and StockLocation endpoints? - bool get supportsNullTopLevelFiltering =>apiVersion < 174; + bool get supportsNullTopLevelFiltering => apiVersion < 174; // Does the server support "active" status on Company and SupplierPart API endpoints? - bool get supportsCompanyActiveStatus =>apiVersion >= 189; + bool get supportsCompanyActiveStatus => apiVersion >= 189; // Does the server support the "modern" (consolidated) label printing API? - bool get supportsModernLabelPrinting =>apiVersion >= 201; + bool get supportsModernLabelPrinting => apiVersion >= 201; // Does the server support the "modern" (consolidated) attachment API? // Ref: https://github.com/inventree/InvenTree/pull/7420 - bool get supportsModernAttachments =>apiVersion >= 207; + bool get supportsModernAttachments => apiVersion >= 207; + + bool get supportsUserPermissions => apiVersion >= 207; // Does the server support the "destination" field on the PurchaseOrder model? // Ref: https://github.com/inventree/InvenTree/pull/8403 - bool get supportsPurchaseOrderDestination =>apiVersion >= 276; + bool get supportsPurchaseOrderDestination => apiVersion >= 276; // Does the server support the "start_date" field for orders? // Ref: https://github.com/inventree/InvenTree/pull/8966 - bool get supportsStartDate =>apiVersion >= 306; + bool get supportsStartDate => apiVersion >= 306; // Supports separate search against "supplier" / "customer" / "manufacturer" - bool get supportsSplitCompanySearch =>apiVersion >= 315; + bool get supportsSplitCompanySearch => apiVersion >= 315; // Cached list of plugins (refreshed when we connect to the server) List _plugins = []; @@ -725,7 +727,12 @@ class InvenTreeAPI { } roles = (data["roles"] ?? {}) as Map; - permissions = (data["permissions"] ?? {}) as Map; + + if (supportsUserPermissions && data.containsKey("permissions")) { + permissions = (data["permissions"] ?? {}) as Map; + } else { + permissions = {}; + } return true; } @@ -1194,6 +1201,15 @@ class InvenTreeAPI { var _url = makeApiUrl(url); + if (_url.isEmpty) { + showServerError( + url, + L10().invalidHost, + L10().invalidHostDetails + ); + return null; + } + // Add any required query parameters to the URL using ?key=value notation if (urlParams.isNotEmpty) { String query = "?"; @@ -1210,13 +1226,12 @@ class InvenTreeAPI { Uri? _uri = Uri.tryParse(_url); - if (_uri == null) { - showServerError(url, L10().invalidHost, L10().invalidHostDetails); - return null; - } - - if (_uri.host.isEmpty) { - showServerError(url, L10().invalidHost, L10().invalidHostDetails); + if (_uri == null || _uri.host.isEmpty) { + showServerError( + _url, + L10().invalidHost, + L10().invalidHostDetails + ); return null; } diff --git a/lib/widget/dialogs.dart b/lib/widget/dialogs.dart index 7812c7ff..90b0e290 100644 --- a/lib/widget/dialogs.dart +++ b/lib/widget/dialogs.dart @@ -228,13 +228,15 @@ Future showServerError(String url, String title, String description) async playAudioFile("sounds/server_error.mp3"); } + description += "\nURL: $url"; + showSnackIcon( title, success: false, actionText: L10().details, onAction: () { showErrorDialog( - L10().serverError, + title, description: description, icon: TablerIcons.server ); diff --git a/pubspec.yaml b/pubspec.yaml index ef926b5b..d5684f0e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: inventree description: InvenTree stock management -version: 0.18.0+97 +version: 0.18.1+98 environment: sdk: ">=2.19.5 <3.13.0"