Skip to content

Commit

Permalink
Implemented read-only proposal with recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Dec 19, 2016
1 parent bd0438c commit 7f8f929
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/installation/proposal_runner.rb
Expand Up @@ -807,7 +807,7 @@ def html_header(submod)
title = @store.title_for(submod)

# do not add a link if the module is read-only or link is already included
heading = if @store.read_only?(submod) || title.include?("<a")
heading = if @store.read_only_no_recovery?(submod) || title.include?("<a")
title
else
Yast::HTML.Link(title, @store.id_for(submod))
Expand Down
38 changes: 32 additions & 6 deletions src/lib/installation/proposal_store.rb
Expand Up @@ -250,12 +250,32 @@ def title_for(client)
title.gsub(/<a.*?>(.*?)<\/a>/, "\\1")
end

# Returns the read-only flag
def read_only?(client)
read_only_no_recovery?(client) || read_only_with_recovery?(client)
end

# Checks if the client's proposal is configured as "hard" read-only
#
# "hard" read-only means that the proposal is always read-only
# "soft" read-only means that the proposal is made changeable when an error
# in proposal is detected.
#
# @param [String] client
# @return [String] a title provided by the description API
def read_only?(client)
read_only_proposals.include?(client)
# @return [Boolean] if the client is marked as "hard" read only
def read_only_no_recovery?(client)
read_only_proposals[:hard].include?(client)
end

# Checks if the client's proposal is configured as "soft" read-only
#
# "hard" read-only means that the proposal is always read-only
# "soft" read-only means that the proposal is made changeable when an error
# in proposal is detected.
#
# @param [String] client
# @return [Boolean] if the client is marked as "soft" read only
def read_only_with_recovery?(client)
read_only_proposals[:soft].include?(client)
end

# Calls client('AskUser'), to change a setting interactively (if link is the
Expand Down Expand Up @@ -300,13 +320,19 @@ def client_for_link(link)
def read_only_proposals
return @read_only_proposals if @read_only_proposals

@read_only_proposals = []
@read_only_proposals = { hard: [], soft: [] }

properties.fetch("proposal_modules", []).each do |proposal|
next unless proposal["read_only"]

name = full_module_name(proposal["name"])
@read_only_proposals << name

case proposal["read_only"]
when "hard"
@read_only_proposals[:hard] << name
when "soft"
@read_only_proposals[:soft] << name
end
end

log.info "Found read-only proposals: #{@read_only_proposals}"
Expand Down

0 comments on commit 7f8f929

Please sign in to comment.