Skip to content
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
3 changes: 2 additions & 1 deletion packages/app_center/lib/deb/deb_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class DebModel extends _$DebModel {

for (final packageUpdate in updates ?? <PackageKitPackageId>[]) {
final packageName = packageUpdate.name;
final results = await packageKit.resolve([packageName]);
final results =
await packageKit.resolve([packageName], installedOnly: true);
hasUpdate = results[packageName]?.info == PackageKitInfo.installed;
break;
}
Expand Down
69 changes: 61 additions & 8 deletions packages/app_center/lib/deb/deb_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:app_center/l10n.dart';
import 'package:app_center/layout.dart';
import 'package:app_center/packagekit/packagekit.dart';
import 'package:app_center/store/store_app.dart';
import 'package:app_center/widgets/hyperlink_text.dart';
import 'package:app_center/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -96,14 +95,13 @@ class _DebView extends ConsumerWidget {
)
: null,
),
actionBar: Row(
actionBar: Wrap(
runSpacing: kSpacing,
spacing: kSpacing,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
_DebActionButtons(debModel: debModel),
const SizedBox(width: 32),
HyperlinkText(
text: '${l10n.debPageDocumentationLinkLabel} >',
link: debManageDocsUrl,
),
_MoreActionsButton(debData: debModel),
],
),
infoBar: DebInfoBar(debData: debModel),
Expand Down Expand Up @@ -186,12 +184,67 @@ class _DebActionButtons extends ConsumerWidget {
primaryActionButton
else
Text(l10n.debPageErrorNoPackageInfo),
if (debModel.activeTransactionId != null) cancelButton,
if (debModel.activeTransactionId != null) ...[
const SizedBox(width: kSpacing),
cancelButton,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not part of your pr, but I've just noticed we aren't clearing the transaction ID when we cancel a deb install, so you get stuck in this state if you cancel an install / cancel the polkit prompt:

Image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this isn't a regression, so wont block your PR on it 🙂

],
].nonNulls.toList(),
);
}
}

class _MoreActionsButton extends ConsumerWidget {
const _MoreActionsButton({required this.debData});

final DebData debData;

@override
Widget build(BuildContext context, WidgetRef ref) {
final l10n = AppLocalizations.of(context);
final primaryAction = debData.hasUpdate
? DebAction.update
: debData.isInstalled
? DebAction.remove
: DebAction.install;

final secondaryActions = [
if (debData.hasUpdate) DebAction.update,
if (debData.isInstalled || debData.hasUpdate) DebAction.remove,
]..remove(primaryAction);

return secondaryActions.isNotEmpty
? YaruPopupMenuButton(
semanticLabel: l10n.appMoreActionsSemanticLabel,
childPadding: EdgeInsets.symmetric(horizontal: 2),
itemBuilder: (context) => [
...secondaryActions.map((action) {
final color = action == DebAction.remove
? Theme.of(context).colorScheme.error
: null;
return PopupMenuItem(
onTap: action.callback(
ref,
debData,
),
child: IntrinsicWidth(
child: ListTile(
mouseCursor: SystemMouseCursors.click,
title: Text(
action.label(l10n),
style: TextStyle(color: color),
),
),
),
);
}),
],
onSelected: (value) => {},
child: Icon(YaruIcons.view_more),
)
: SizedBox.shrink();
}
}

enum DebAction {
cancel,
install,
Expand Down
15 changes: 5 additions & 10 deletions packages/app_center/lib/deb/local_deb_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,12 @@ class _LocalDebPage extends StatelessWidget {
),
),
),
actionBar: Row(
actionBar: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
spacing: kSpacing,
runSpacing: kSpacing,
children: [
_LocalDebActionButtons(debData: debData),
const SizedBox(width: 32),
Html(
shrinkWrap: true,
data:
'<a href="$debManageDocsUrl">${l10n.debPageDocumentationLinkLabel} &gt;</a>',
style: {'body': Style(margin: Margins.zero)},
onLinkTap: (url, attributes, element) => launchUrlString(url!),
),
],
),
infoBar: LocalDebInfoBar(localDebData: debData),
Expand Down Expand Up @@ -174,7 +169,7 @@ class _LocalDebActionButtons extends ConsumerWidget {
children: [
primaryActionButton,
if (debData.activeTransactionId != null) ...[
const SizedBox(width: 8),
const SizedBox(width: kSpacing),
cancelButton,
],
],
Expand Down
1 change: 1 addition & 0 deletions packages/app_center/lib/snapd/snap_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class _MoreActionsButton extends ConsumerWidget {

return secondaryActions.isNotEmpty
? YaruPopupMenuButton(
semanticLabel: l10n.appMoreActionsSemanticLabel,
childPadding: EdgeInsets.symmetric(horizontal: 2),
itemBuilder: (context) => [
...secondaryActions.map((action) {
Expand Down
1 change: 1 addition & 0 deletions packages/app_center/lib/src/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
"appConfinementUnrestricted": "Unrestricted",
"appLicenseUnknown": "Unknown",
"appPublishedUnknown": "Unknown",
"appMoreActionsSemanticLabel": "More actions",
"packageFormatDebLabel": "Debian packages",
"packageFormatSnapLabel": "Snap packages",
"snapActionCancelLabel": "Cancel",
Expand Down
Loading