Skip to content

Commit

Permalink
Move Import all Pools into import menu
Browse files Browse the repository at this point in the history
The "Import all Pools" menu item is now part of the Import Pools
submenu. This makes more sense and takes up less space.
  • Loading branch information
cbreak-black committed Aug 2, 2019
1 parent 016d114 commit 0b45b8c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
6 changes: 0 additions & 6 deletions ZetaWatch/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@
</connections>
</menu>
</menuItem>
<menuItem title="Import all Pools" id="ex0-MP-SYc">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="importAllPools:" target="8rf-zp-5r9" id="cyT-XV-d7K"/>
</connections>
</menuItem>
<menuItem title="Mount all Filesystems" id="Gk5-sm-R9o">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
Expand Down
30 changes: 23 additions & 7 deletions ZetaWatch/ZetaImportMenuDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ @implementation ZetaImportMenuDelegate
- (void)menuNeedsUpdate:(NSMenu*)menu
{
[menu removeAllItems];
NSMenuItem * importAllItem = [menu addItemWithTitle:@"Import all Pools" action:@selector(importAllPools:) keyEquivalent:@""];
importAllItem.target = self;
[menu addItem:[NSMenuItem separatorItem]];
[menu addItemWithTitle:@"Searching for importable Pools..." action:NULL keyEquivalent:@""];
[_authorization importablePoolsWithReply:^(NSError * error, NSDictionary * importablePools)
{
Expand All @@ -34,7 +37,7 @@ - (void)importablePoolsDiscovered:(NSDictionary*)importablePools
{
if ([importablePools count] > 0)
{
NSMenuItem * item = [_importMenu itemAtIndex:0];
NSMenuItem * item = [_importMenu itemAtIndex:2];
[item setTitle:[NSString stringWithFormat:
@"%lu importable Pools found", [importablePools count]]];
for (NSString * name in importablePools)
Expand All @@ -48,14 +51,14 @@ - (void)importablePoolsDiscovered:(NSDictionary*)importablePools
}
else
{
NSMenuItem * item = [_importMenu itemAtIndex:0];
NSMenuItem * item = [_importMenu itemAtIndex:2];
[item setTitle:@"No importable Pools found"];
}
}

- (void)importablePoolsError:(NSError*)error
{
NSMenuItem * item = [_importMenu itemAtIndex:0];
NSMenuItem * item = [_importMenu itemAtIndex:2];
[item setTitle:[error localizedDescription]];
}

Expand All @@ -64,11 +67,24 @@ - (IBAction)importPool:(id)sender
NSDictionary * pools = @{ @"poolGUID": [sender representedObject] };
[_authorization importPools:pools withReply:^(NSError * error)
{
if (error)
[self errorFromHelper:error];
else
[[self poolWatcher] checkForChanges];
[self handlePoolChangeReply:error];
}];
}

- (IBAction)importAllPools:(id)sender
{
[_authorization importPools:@{} withReply:^(NSError * error)
{
[self handlePoolChangeReply:error];
}];
}

- (void)handlePoolChangeReply:(NSError*)error
{
if (error)
[self errorFromHelper:error];
else
[[self poolWatcher] checkForChanges];
}

@end
8 changes: 0 additions & 8 deletions ZetaWatch/ZetaMenuDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,6 @@ - (void)handleMetaDataChangeReply:(NSError*)error

#pragma mark ZFS Maintenance

- (IBAction)importAllPools:(id)sender
{
[_authorization importPools:@{} withReply:^(NSError * error)
{
[self handlePoolChangeReply:error];
}];
}

- (IBAction)exportPool:(id)sender
{
NSDictionary * opts = @{@"pool": [sender representedObject]};
Expand Down

0 comments on commit 0b45b8c

Please sign in to comment.