Skip to content

Commit

Permalink
Merge pull request #169 from alces-flight/exp/teams
Browse files Browse the repository at this point in the history
Teams and Team Roles
  • Loading branch information
timalces authored Apr 5, 2024
2 parents cd28f3e + a09eff0 commit e332c92
Show file tree
Hide file tree
Showing 174 changed files with 4,451 additions and 1,229 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
@import "components/tabs";
@import "components/ct_widget";
@import "components/rack_show_page";
@import "components/new_team_role_form";

/*
Components/Widgets
Expand Down
10 changes: 10 additions & 0 deletions app/assets/stylesheets/components/_actions_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@
width: 1rem;
}
}

.disabled-action {
color: grey;
cursor: not-allowed;

&:hover {
color: grey;
background-color: white;
}
}

&.current a:before {
@include icon-style;
Expand Down
35 changes: 25 additions & 10 deletions app/assets/stylesheets/components/_cluster_types_view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
padding: 1.25rem 2.5rem;
}


.cluster-type-card {
border: solid #3b5168 1px;
border-radius: 2px;
padding: 1.5rem;
font-weight: 400;
transition: background 125ms;
}

.cluster-type-card {
display: grid;
grid-template-rows: [row1-start] auto [row1-end row2-start] auto [row2-end row3-start] auto [row3-end];
grid-template-columns: 1fr 1fr;
Expand All @@ -29,6 +25,10 @@
margin: 0 !important;
width: 100%;
min-height: 14.2rem;

&.disabled-cluster-type-card {
cursor: not-allowed;
}
}

.cluster-type-card-title {
Expand Down Expand Up @@ -88,14 +88,29 @@
margin-bottom: 0.625rem;

.cluster-type-card-title {
justify-self: left;
align-self: end;
max-width: 28em;
justify-self: left;
align-self: end;
max-width: 28em;
}

.cluster-type-card-description {
justify-self: left;
align-self: start;
max-width: 28em;
justify-self: left;
align-self: start;
max-width: 28em;
}
}

.choose-team {
display: flex;
justify-content: space-around;
margin-bottom: 1rem;
margin-top: 3rem;

.formItem {
width: 22rem;
}

select {
margin-bottom: 0;
}
}
4 changes: 2 additions & 2 deletions app/assets/stylesheets/components/_new_cluster_form.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#new_cluster {
.new_cluster {
border: none;
.formItem {
margin-bottom: 1rem;
margin-bottom: 1rem;
}

.new-cluster-field {
Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/components/_new_team_role_form.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#team-roles-table {
.resource_table {
max-width: 45.75rem;
}
}
4 changes: 4 additions & 0 deletions app/assets/stylesheets/irv/_interactive_canvas_view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
-moz-box-shadow: 3px 3px 12px 3px rgba(0,0,0,0.3);
-webkit-box-shadow: 3px 3px 12px 3px rgba(0,0,0,0.3);
box-shadow: 3px 3px 12px 3px rgba(0,0,0,0.3);

.menu-spacer:last-child {
display: none; /* Hide spacer if no subsequent options */
}
}

.disabled_context_menu_item
Expand Down
64 changes: 32 additions & 32 deletions app/cells/actions_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ActionsCell < Cell::ViewModel

attr_reader :actions, :dropdown_id

def show(title, block, opts = {})
# @title = title
def show(text, block, opts = {})
# @text = text
@is_dropdown = opts[:is_dropdown] || false
@dropdown_id = opts[:dropdown_id] || 'drop'
@side = opts[:side] || false
Expand Down Expand Up @@ -73,55 +73,55 @@ def initialize(current_user, cell)
@current_user = current_user
@cell = cell
end

#
# add
#
# Adds an action based on options hash. Valid options are: title, path, html, side
# Adds an action based on options hash. Valid options are: text, path, html, side
#
# 'side' == true will render to the sidebar only.
#
# Any other options are treated as html attributes
#
# e.g:
#
# add(title: 'View', path: user_path(@user))
# add(text: 'View', path: user_path(@user))
# # => <li><a href="/users/2">View</a></li>
#
def add(title_or_options, path = nil, &block)
if title_or_options.kind_of? String
def add(text_or_options, path = nil, &block)
if text_or_options.kind_of? String
options = {}
title = title_or_options
text = text_or_options
else
options = title_or_options
title = options[:title]
options = text_or_options
text = options[:text]
path = options[:path]
end

html = (block_given? ? block.call : options[:html])
opts = options.reject {|k, v| [:title, :html, :path, :can, :cannot, :on].include?(k)}
opts = options.reject {|k, v| [:text, :html, :path, :can, :cannot, :on].include?(k)}

if html
add_custom(html, opts)
else
add_item(title, path, opts)
add_item(text, path, opts)
end
end

def add_with_auth(options, &block)
resource_or_class = options[:on]

if options.has_key? :cannot
action_name = options[:cannot]
permission = :cannot?
elsif options.has_key? :can
action_name = options[:can]
permission = :can?
end

opts = options.reject {|k, v| [:can, :cannot, :on].include?(k)}
ability = @current_user.ability

if ability.send(permission, action_name, resource_or_class)
if block_given?
add(opts, &block)
Expand All @@ -130,32 +130,32 @@ def add_with_auth(options, &block)
end
end
end

#
# divider
#
# Adds a label with a title that separates menu items.
# Adds a label with content that separates menu items.
#
def divider(title = nil)
def divider(text = nil)
unless @dropdown_actions.empty?
divider = ActionDivider.new(title)
divider = ActionDivider.new(text)
@dropdown_actions << divider
end
end

private

def side?
@cell.side?
end

#
# add_item
#
# Adds a basic link action
#
def add_item(title, path, opts = {})
action = Action.new(title, path, opts, @cell)
def add_item(text, path, opts = {})
action = Action.new(text, path, opts, @cell)
if side?
@actions << action
else
Expand All @@ -178,12 +178,12 @@ def add_custom(html, opts = {})
end
end
end

class ActionItem
def li_opts
@opts.reject {|k, v| [:path, :side, :method, :confirm].include?(k) }
end

def matches_request?(request)
request.fullpath == @path unless @opts[:method].to_s == 'delete'
end
Expand All @@ -194,24 +194,24 @@ def divider?
end

class Action < ActionItem
attr_reader :title, :path, :opts
def initialize(title, path, opts = {}, cell)
@title = title
attr_reader :text, :path, :opts
def initialize(text, path, opts = {}, cell)
@text = text
@path = path
@opts = opts
@cell = cell
end

def html
@cell.link_to @title, @path, @opts
@cell.link_to @text, @path, @opts
end
end

class ActionDivider < ActionItem
attr_reader :title
attr_reader :text

def initialize(title)
@title = title
def initialize(text)
@text = text
@path = nil
@opts = {}
end
Expand Down
10 changes: 8 additions & 2 deletions app/cells/cluster_form_errors/show.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<% if has_errors? %>
<% if has_errors_without_input_field? %>
<div class="alert-box alert">
Please correct the <%= "error".pluralize(error_count) %> below and try again.
Unable to launch cluster: <%= inputless_errors_text %>
</div>
<% end %>

<% if has_input_field_errors? %>
<div class="alert-box alert">
Please correct the <%= "error".pluralize(input_field_error_count) %> below and try again.
</div>
<% end %>
33 changes: 26 additions & 7 deletions app/cells/cluster_form_errors_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,44 @@ def show(cluster)

private

def has_errors?
error_count > 0
def attributes_without_input_field
[:team]
end

def error_count
def has_input_field_errors?
input_field_error_count > 0
end

def input_field_error_count
if @cluster.errors.any?
# If the cluster has any errors set against it, it is expected that these
# will contain any field errors too.
@cluster.errors.count
@cluster.errors.count - inputless_error_count

elsif @cluster.fields.any? { |f| !f.errors.empty? }
# If the cluster does not have any errors, it is still possible that the
# fields do. These can be set from the cluster builder response.
@cluster.fields
.select { |f| !f.errors.empty? }
.map { |f| f.errors.count }
.sum
.select { |f| !f.errors.empty? }
.map { |f| f.errors.count }
.sum
else
0
end
end

def has_errors_without_input_field?
@cluster.errors.any? && attributes_without_input_field.any? { |attribute| !@cluster.errors[attribute].empty? }
end

def inputless_error_count
attributes_without_input_field.select { |attribute| !@cluster.errors[attribute].empty? }.length
end

def inputless_errors_text
@cluster.errors.select { |error| attributes_without_input_field.include?(error.attribute) }
.map(&:full_message)
.join("; ")

end
end
Loading

0 comments on commit e332c92

Please sign in to comment.