Skip to content

Commit

Permalink
Merge pull request #37 from shundhammer/huha-changes-dialog
Browse files Browse the repository at this point in the history
Implemented "Changes" dialog
  • Loading branch information
shundhammer committed Jan 30, 2019
2 parents 900e050 + 023c213 commit b793ca0
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
8 changes: 8 additions & 0 deletions package/yast2-apparmor.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Jan 30 15:51:08 UTC 2019 - Stefan Hundhammer <shundhammer@suse.com>

- Implemented "changes" dialog for "scan audit logs" (bsc#1120043)
- Properly line up radio buttons
- Allow to translate "OK" button
- 4.1.7

-------------------------------------------------------------------
Mon Jan 28 13:16:50 UTC 2019 - Stefan Hundhammer <shundhammer@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-apparmor.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-apparmor
Version: 4.1.6
Version: 4.1.7
Release: 0
Summary: YaST2 - Plugins for AppArmor Profile Management
Url: https://github.com/yast/yast-apparmor
Expand Down
56 changes: 53 additions & 3 deletions src/lib/apparmor/apparmor_ui_dialog.rb
Expand Up @@ -125,7 +125,7 @@ def run
VSpacing(0.3),
InputField(Id(:str), Opt(:hstretch), @text, @default),
VSpacing(0.3),
PushButton('&OK')
PushButton(Label.OKButton)
)
)
Yast::UI.UserInput()
Expand Down Expand Up @@ -214,10 +214,10 @@ def options_radio_buttons
return box if @options.nil?
@options.each_with_index do |opt, i|
log.info "opt #{opt} i #{i}"
box << RadioButton(Id(i.to_s), opt.to_s, i == 0)
box << Left(RadioButton(Id(i.to_s), opt.to_s, i == 0))
box << VSpacing(1)
end
VBox(RadioButtonGroup(Id(:options), box))
VBox(RadioButtonGroup(Id(:options), HSquash(box)))
end

def menu_to_text_key(menu)
Expand All @@ -238,6 +238,54 @@ def menu_buttons
end
end

# Dialog that shows the changes (the diff) between the old and the new profile
class ChangesDialog
include Yast::UIShortcuts
include Yast::I18n
include Yast::Logger
include Yast

def initialize(hm)
log.info "Hash map #{hm}"
@header = hm["header"]
@filename = hm["filename"]
end

def run
UI.OpenDialog(
Opt(:decorated, :defaultsize),
VBox(
dialog_header,
VSpacing(0.3),
RichText(Opt(:plainText), changes_content),
VSpacing(0.3),
PushButton(Label.OKButton)
)
)

Yast::UI.UserInput
Yast::UI.CloseDialog

{
"dialog" => "changes",
"response" => "ignored"
}
end

private

def dialog_header
return Empty() if @header.nil?
# Not using a Heading widget here for consistency with the rest of this module
Label(@header)
end

def changes_content
return "" if @filename.nil?
File.read(@filename)
end
end

# Checks JSON version of the tool and if we are compatible
class AAJSONVersion
include Yast::I18n
Expand Down Expand Up @@ -277,6 +325,7 @@ def execute
l = get_dialog(hm)
r = l.run
unless r.nil?
log.info("Sending reply #{r.to_json}")
f.puts r.to_json
f.flush
end
Expand All @@ -295,6 +344,7 @@ def execute
'getstring' => GetStringDialog,
'getfile' => GetFileDialog,
'promptuser' => PromptDialog,
'changes' => ChangesDialog,
'apparmor-json-version' => AAJSONVersion
}

Expand Down

0 comments on commit b793ca0

Please sign in to comment.