Merge pull request #2889 from biosistemika/develop

HOTFIX for empty team case
This commit is contained in:
Miha Mencin 2020-10-06 13:43:31 +02:00 committed by GitHub
commit 2f145bb04e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 23 deletions

View file

@ -1,5 +1,3 @@
@import url(https://fonts.googleapis.com/css?family=Lato:400,400i,700&subset=latin-ext);
//==============================================================================
// Colors
//==============================================================================

View file

@ -37,7 +37,7 @@ class ApplicationController < ActionController::Base
# Sets current team for all controllers
def current_team
@current_team ||= Team.find_by(id: current_user.current_team_id)
@current_team ||= current_user.teams.find_by(id: current_user.current_team_id)
end
def to_user_date_format
@ -83,13 +83,12 @@ class ApplicationController < ActionController::Base
private
def update_current_team
@current_team = Team.find_by_id(current_user.current_team_id)
if (current_team.nil? || !current_user.is_member_of_team?(current_team)) &&
current_user.teams.count.positive?
return if current_team.present? && current_team.id == current_user.current_team_id
current_user.update(
current_team_id: current_user.teams.first.id
)
if current_user.current_team_id
@current_team = current_user.teams.find_by(id: current_user.current_team_id)
elsif current_user.teams.any?
current_user.update(current_team_id: current_user.teams.first.id)
end
end

View file

@ -1,7 +1,7 @@
module TeamsHelper
# resets the current team if needed
def current_team_switch(team)
if team != current_team
if team != current_team && current_user.is_member_of_team?(team)
current_user.current_team_id = team.id
current_user.save
update_current_team
@ -18,11 +18,7 @@ module TeamsHelper
end
end
def team_created_by(team)
User.find_by_id(team.created_by_id)
end
def switch_team_with_param
current_team_switch(Team.find_by(id: params[:team])) if params[:team]
current_team_switch(current_user.teams.find_by(id: params[:team])) if params[:team]
end
end

View file

@ -0,0 +1 @@
require('typeface-lato');

View file

@ -1,8 +1,10 @@
<% provide :head_title, t('nav.label.dashboard') %>
<% if current_team %>
<div class="dashboard-container">
<%= render "calendar" %>
<%= render "current_tasks" %>
<%= render "recent_work" %>
<%= render "quick_start" %>
</div>
<% end %>

View file

@ -17,6 +17,7 @@
<%= favicon_link_tag "favicon-16.png", type: "image/png", size: "16x16" %>
<%= favicon_link_tag "favicon-32.png", type: "image/png", size: "32x32" %>
<%= favicon_link_tag "favicon-48.png", type: "image/png", size: "48x48" %>
<%= stylesheet_pack_tag 'fonts' %>
<%= stylesheet_pack_tag 'fontawesome' %>
<%= csrf_meta_tags %>

View file

@ -44,7 +44,9 @@
<div class="created-by grid-block">
<span class="fas fa-user fa-lg"></span>
<span class="hidden-xs hidden-sm"><%= t("users.settings.teams.edit.header_created_by") %></span>
<b><%= t("users.settings.teams.edit.header_created_by_name_email", name: team_created_by(@team).name, email: team_created_by(@team).email) %></b>
<b>
<%= t('users.settings.teams.edit.header_created_by_name_email', name: @team.created_by.full_name, email: @team.created_by.email) if @team.created_by %>
</b>
</div>
<div class="space-usage grid-block">

View file

@ -51,6 +51,7 @@
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@fortawesome/fontawesome-free": "^5.2.0",
"@joeattardi/emoji-button": "^2.5.4",
"@rails/webpacker": "^4.0.7",
"autoprefixer": "^7.2.6",
"axios": "0.18.1",
@ -62,7 +63,6 @@
"compression-webpack-plugin": "^1.1.11",
"croppie": "^2.6.4",
"css-loader": "2.1.1",
"@joeattardi/emoji-button": "^2.5.4",
"extract-text-webpack-plugin": "^3.0.2",
"fabric": "1.6.7",
"file-loader": "^4.0.0",
@ -110,6 +110,7 @@
"tui-color-picker": "^2.2.0",
"tui-image-editor": "git://github.com/biosistemika/tui.image-editor",
"twemoji": "^12.1.4",
"typeface-lato": "^0.0.75",
"webpack": "^4.35.2",
"webpack-cli": "^3.3.5",
"webpack-manifest-plugin": "^1.3.2",

View file

@ -9766,6 +9766,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
typeface-lato@^0.0.75:
version "0.0.75"
resolved "https://registry.yarnpkg.com/typeface-lato/-/typeface-lato-0.0.75.tgz#8aa11c5611dc38416837c089b265a2abd1f7dd31"
integrity sha512-iA5uJD4PSTyIE4BDiSOexQeXkDkiJuX4Hu3wh3saJ06EB2TvJayab1Lbbmqq2je/LQv7KCQZHZmC0k4hedd8sw==
typescript-eslint-parser@^16.0.0:
version "16.0.1"
resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-16.0.1.tgz#b40681c7043b222b9772748b700a000b241c031b"