Merge branch 'develop' into features/shareable-links

This commit is contained in:
Oleksii Kriuchykhin 2023-08-02 16:05:21 +02:00
commit b49b7c4a80
33 changed files with 32 additions and 199 deletions

View file

@ -1 +1 @@
1.27.3
1.28.0

View file

@ -162,20 +162,9 @@
}).on('shown.bs.modal', '#export-repositories-modal', function() {
if (!CHECKBOX_SELECTOR) return;
const selectedInventoriesCount = CHECKBOX_SELECTOR.selectedRows.length;
const firstDescription = $(this).find('.description-p1');
const teamName = firstDescription.data('team-name');
const exportButton = $(this).find('#export-repositories-modal-submit');
const exportURL = exportButton.data('export-url');
firstDescription.html(I18n.t(
'repositories.index.modal_export.description_p1_html',
{
team_name: teamName,
count: selectedInventoriesCount
}
));
exportButton.on('click', function() {
$.ajax({
url: exportURL,

View file

@ -48,7 +48,8 @@ var ChecklistColumnHelper = (function() {
optionClass: 'checkbox-icon',
selectAppearance: 'simple',
onChange: function() {
$hiddenField.val(JSON.stringify(dropdownSelector.getValues('#' + select)));
let currentValues = dropdownSelector.getValues('#' + select);
$hiddenField.val(currentValues.length ? JSON.stringify(currentValues) : null);
}
});
}

View file

@ -565,7 +565,7 @@ var RepositoryDatatable = (function(global) {
saveState(state);
},
stateLoadCallback: (state) => {
if (!TABLE.ColSizes) return;
if (!TABLE.ColSizes || TABLE.ColSizes.length === 0) return;
let colSizes = TABLE.ColSizes;
@ -754,8 +754,6 @@ var RepositoryDatatable = (function(global) {
});
},
stateSaveCallback: function(_, data) {
if (Object.keys(colSizeMap).length === 0) return true;
let colSizes = [];
for (let i = 0; i < data.ColReorder.length; i += 1) {

View file

@ -1,4 +1,4 @@
/* global TinyMCE Results Comments animateSpinner initFormSubmitLinks */
/* global TinyMCE Results Comments animateSpinner initFormSubmitLinks Prism */
(function() {
'use strict';
@ -82,6 +82,7 @@
TinyMCE.destroyAll();
Comments.init();
initNewReslutText();
Prism.highlightAllUnder(newResult.get(0));
});
$form.on('ajax:error', function(e, xhr) {
var data = xhr.responseJSON;

View file

@ -425,6 +425,7 @@
.task-notes-content {
margin-left: 10px;
overflow-x: auto;
.form-group.has-error {
border: 1px solid $brand-danger;

View file

@ -72,6 +72,10 @@
margin-left: 4.25em !important;
}
.ql-editor {
overflow-x: auto;
}
.result-icon {
@include font-main;
background: $color-concrete;

View file

@ -268,6 +268,10 @@
}
}
#protocol-description-container {
overflow-x: auto;
}
.delete-steps-modal {
.btn {
float: initial;

View file

@ -445,7 +445,7 @@
background: $color-white;
color: $color-silver-chalice;
display: none;
z-index: 1000;
z-index: 1;
.repository-save-changes-link {
cursor: pointer;

View file

@ -9,7 +9,6 @@
height: 3.5rem;
justify-content: space-between;
padding-bottom: 1rem;
z-index: 99;
.view-switch,

View file

@ -9,10 +9,6 @@
font-size: 13px;
}
.datepicker thead th {
padding: 8px 6px !important;
}
.timepicker-picker {
padding: 0 60px;

View file

@ -22,7 +22,7 @@
}
.view-text-element {
overflow-x: scroll;
overflow-x: auto;
pointer-events: initial;
a {

View file

@ -208,6 +208,7 @@ class RepositoriesController < ApplicationController
html: render_to_string(
partial: 'export_repositories_modal',
locals: { team_name: current_team.name,
counter: params[:counter].to_i,
export_limit: TeamZipExport.exports_limit,
num_of_requests_left: current_user.exports_left - 1 },
formats: :html

View file

@ -131,9 +131,6 @@ class Users::RegistrationsController < Devise::RegistrationsController
@team.created_by = resource # set created_by for oraganization
@team.save
# Add this user to the team as owner
UserTeam.create(user: resource, team: @team, role: :admin)
# set current team to new user
resource.current_team_id = @team.id
resource.save
@ -171,9 +168,6 @@ class Users::RegistrationsController < Devise::RegistrationsController
@team.created_by = @user # set created_by for team
@team.save!
# Add this user to the team as owner
UserTeam.create(user: @user, team: @team, role: :admin)
# set current team to new user
@user.current_team_id = @team.id
@user.save!

View file

@ -63,9 +63,14 @@ export default {
},
computed: {
hasChildren: function() {
return !this.item.disabled && (this.item.has_children || this.children.length > 0);
if (this.item.disabled) return false;
if (this.item.has_children) return true;
if (this.children && this.children.length > 0) return true;
return false
},
sortedMenuItems: function() {
if (!this.children) return [];
return this.children.sort((a, b) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
return -1;

View file

@ -63,7 +63,7 @@ module Toolbars
label: I18n.t('libraries.index.buttons.export'),
button_id: 'exportRepoBtn',
icon: 'sn-icon sn-icon-export',
path: export_modal_team_repositories_path(@current_team),
path: export_modal_team_repositories_path(@current_team, counter: @repositories.length),
type: 'remote-modal'
}
end

View file

@ -1,5 +1,5 @@
<%= form_with url: update_consumption_my_module_repository_path(@my_module, @repository, module_row_id: @module_repository_row),
method: :post,
<%= form_with url: update_consumption_my_module_repository_path(@my_module, @repository, module_row_id: @module_repository_row),
method: :post,
html: { data: { remote: true } } do |f| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="<%= t('general.close') %>">
@ -42,7 +42,7 @@
<span class="units"><%= @stock_value.repository_stock_unit_item&.data %></span>
</div>
<div class="stock-arrow">
<i class="sn-icon sn-icon-move"></i>
<i class="sn-icon sn-icon-arrow-right"></i>
</div>
<div class="stock-final-container ">
<span class="subtitle"><%= t('repository_stock_values.manage_modal.new_stock') %></span>

View file

@ -11,7 +11,8 @@
<h4 class="modal-title"><%= t('repositories.index.modal_export.title') %></h4>
</div>
<div class="modal-body">
<p class="description-p1" data-team-name="<%= team_name %>">
<p class="description-p1">
<%= t('repositories.index.modal_export.description_p1_html', team_name: team_name, count: counter) %>
</p>
<p class="bg-sn-super-light-blue p-3"><%= t('repositories.index.modal_export.description_alert') %></p>
<p class="mt-3"><%= t('repositories.index.modal_export.description_p2') %></p>

View file

@ -561,6 +561,8 @@ class Extends
newrelic.com
*.newrelic.com
*.nr-data.net
www.recaptcha.net/
www.gstatic.com/recaptcha/
)
end

View file

@ -6,7 +6,6 @@ Given(/^the following users are registered:$/) do |table|
team_role = hash.delete 'role'
user = FactoryBot.create(:user, hash)
team = FactoryBot.create(:team, name: team_name, users: [user])
UserTeam.where(user: user, team: team).first.update role: team_role
User.find_by(email: hash.fetch('email')).confirm
end
end
@ -87,7 +86,6 @@ end
Given(/^Templates project exists for the "([^"]*)" team$/) do |team_name|
team = Team.find_by(name: team_name)
user = team.user_teams.where(role: :admin).take.user
TemplatesService.new.schedule_creation_for_user(user)
end
Given(/^I'm on the projects page of "([^"]*)" team$/) do |team_name|
@ -99,9 +97,6 @@ end
Given(/^"([^"]*)" is in "([^"]*)" team as a "([^"]*)"$/) do |user_email, team_name, role|
team = Team.find_by(name: team_name)
user = User.find_by(email: user_email)
FactoryBot.create(:user_team, user: user,
team: team, role:
UserTeam.roles.fetch(role))
end
Then(/^I attach a "([^"]*)" file to "([^"]*)" field$/) do |file, field_id|

View file

@ -40,7 +40,6 @@ Given('the following users are registered with teams:') do |table|
team = Team.find_by(name: row[:team])
team ||= FactoryBot.create(:team, name: row[:team])
user = FactoryBot.create(:user, row.slice('name', 'email'))
FactoryBot.create(:user_team, user: user, team: team, role: row[:role])
end
end

View file

@ -1,88 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe Users::Settings::UserTeamsController, type: :controller do
login_user
let(:user) { subject.current_user }
let(:team) { create :team, created_by: user }
let!(:user_team) { create :user_team, :admin, user: user, team: team }
let(:another_user) { create :user }
let!(:another_user_team) do
create :user_team, :normal_user, user: another_user, team: team
end
describe 'DELETE destroy' do
let(:params) do
{
id: another_user_team.id
}
end
let(:action) { delete :destroy, params: params, format: :json }
context 'when inviting existing user not in the team' do
it 'calls create activity for inviting user' do
expect(Activities::CreateActivityService)
.to(receive(:call)
.with(hash_including(activity_type: :remove_user_from_team)))
action
end
it 'adds activity in DB' do
expect { action }
.to(change { Activity.count })
end
it 'remove user_team record from DB' do
expect { action }
.to(change { UserTeam.count })
end
end
context 'when user leaving team by himself' do
it 'calls create activity for user leaving' do
params_leave = { id: another_user_team.id, leave: true }
expect(Activities::CreateActivityService)
.to(receive(:call)
.with(hash_including(activity_type: :user_leave_team)))
delete :destroy, params: params_leave, format: :json
end
it 'adds activity in DB' do
params_leave = { id: another_user_team.id, leave: true }
expect { delete :destroy, params: params_leave, format: :json }
.to(change { Activity.count })
end
end
end
describe 'PUT update' do
let(:params) do
{
id: another_user_team.id,
user_team: {
role: 'admin'
}
}
end
let(:action) { put :update, params: params, format: :json }
context 'when updating user role in the team' do
it 'calls create activity for updating role' do
expect(Activities::CreateActivityService)
.to(receive(:call)
.with(hash_including(activity_type:
:change_users_role_on_team)))
action
end
it 'adds activity in DB' do
expect { action }
.to(change { Activity.count })
end
end
end
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
FactoryBot.define do
factory :user_team do
user
team
trait :admin do
role { 'admin' }
end
trait :guest do
role { 'guest' }
end
trait :normal_user do # default enum by DB
role { 'normal_user' }
end
end
end

View file

@ -14,10 +14,8 @@ module UserAssignments
before(:each) do
available_roles = [owner_role, viewer_role, technician_role]
create :user_team, :admin, user: user_two, team: team
create :user_assignment, user: user_two, assignable: project, user_role: viewer_role, assigned_by: user_one
create :user_team, :admin, user: user_three, team: team
create :user_assignment, user: user_three, assignable: project, user_role: technician_role, assigned_by: user_one
end

View file

@ -16,13 +16,6 @@ module UserAssignments
let!(:my_module_one) { create :my_module, experiment: experiment_one, created_by: experiment_one.created_by }
let!(:my_module_two) { create :my_module, experiment: experiment_two, created_by: experiment_two.created_by }
before do
[user_one, user_two].each do |user|
create :user_team, :admin, user: user, team: team
end
end
describe 'perform' do
it 'propagates the user assignments to project child object' do
expect {

View file

@ -1,36 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe UserTeam, type: :model do
let(:user_team) { build :user_team }
it 'is valid' do
expect(user_team).to be_valid
end
it 'should be of class UserTeam' do
expect(subject.class).to eq UserTeam
end
describe 'Database table' do
it { should have_db_column :role }
it { should have_db_column :user_id }
it { should have_db_column :team_id }
it { should have_db_column :created_at }
it { should have_db_column :updated_at }
it { should have_db_column :assigned_by_id }
end
describe 'Relations' do
it { should belong_to :user }
it { should belong_to :team }
it { should belong_to(:assigned_by).class_name('User').optional }
end
describe 'Validations' do
it { should validate_presence_of :role }
it { should validate_presence_of :user }
it { should validate_presence_of :team }
end
end

View file

@ -8,7 +8,6 @@ RSpec.describe Views::Datatables::DatatablesTeam, type: :model do
it { should have_db_column :name }
it { should have_db_column :members }
it { should have_db_column :role }
it { should have_db_column :user_team_id }
it { should have_db_column :user_id }
it { should have_db_column :can_be_left }
end

View file

@ -6,7 +6,6 @@ RSpec.describe "Api::Service::ProjectsJsonExportController", type: :request do
before :all do
@user = create(:user)
@team = create(:team, created_by: @user)
create(:user_team, user: @user, team: @team, role: 1)
@accessible_project = create(:project, name: Faker::Name.unique.name, created_by: @user, team: @team)
@accessible_experiment = create(:experiment, created_by: @user,

View file

@ -6,7 +6,6 @@ RSpec.describe "Api::Service::ProtocolsController", type: :request do
before :all do
@user = create(:user)
@team = create(:team, created_by: @user)
create(:user_team, user: @user, team: @team, role: 2)
@project = create(:project, name: Faker::Name.unique.name, created_by: @user, team: @team)
@experiment = create(:experiment, created_by: @user, last_modified_by: @user, project: @project, created_by: @user)

View file

@ -6,7 +6,6 @@ RSpec.describe "Api::Service::StepsController", type: :request do
before :all do
@user = create(:user)
@team = create(:team, created_by: @user)
create(:user_team, user: @user, team: @team, role: 2)
@project = create(:project, name: Faker::Name.unique.name, created_by: @user, team: @team)
@experiment = create(:experiment, created_by: @user, last_modified_by: @user, project: @project, created_by: @user)

View file

@ -11,7 +11,6 @@ RSpec.describe 'Api::V1::StepTextsController', type: :request do
@task = @experiment.my_modules.first
@protocol = create(:protocol, my_module: @task)
@step = create(:step, protocol: @protocol)
create(:user_team, user: @user, team: @team)
@valid_headers = {
'Authorization': 'Bearer ' + generate_token(@user.id),

View file

@ -7,7 +7,6 @@ RSpec.describe 'Api::V1::TaskAssignmentsController', type: :request do
@user = create(:user)
@user_second = create(:user)
@team = create(:team, created_by: @user)
create(:user_team, user: @user, team: @team, role: 1)
@owner_role = UserRole.find_by(name: I18n.t('user_roles.predefined.owner'))
@project = create(:project, name: Faker::Name.unique.name,
created_by: @user, team: @team)

View file

@ -4,7 +4,6 @@ describe ProjectsJsonExportService do
before :all do
@user = create(:user)
@team = create(:team, created_by: @user)
create(:user_team, user: @user, team: @team, role: 1)
@accessible_project_1 = create(:project, name: Faker::Name.unique.name, created_by: @user, team: @team)
@accessible_project_2 = create(:project, name: Faker::Name.unique.name, created_by: @user, team: @team)