diff --git a/Gemfile b/Gemfile
index e1c48b798..23e6b12d4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -92,6 +92,7 @@ group :development, :test do
gem 'rubocop', require: false
gem 'scss_lint', require: false
gem 'starscope', require: false
+ gem 'bullet'
end
group :test do
diff --git a/Gemfile.lock b/Gemfile.lock
index a4c3f3265..f29f17386 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -105,6 +105,9 @@ GEM
momentjs-rails (>= 2.8.1)
bootstrap_form (2.7.0)
builder (3.2.3)
+ bullet (5.6.1)
+ activesupport (>= 3.0.0)
+ uniform_notifier (~> 1.10.0)
byebug (9.0.6)
capybara (2.15.1)
addressable
@@ -431,6 +434,7 @@ GEM
execjs (>= 0.3.0, < 3)
underscore-rails (1.8.3)
unicode-display_width (1.3.0)
+ uniform_notifier (1.10.0)
warden (1.2.7)
rack (>= 1.0)
webpacker (2.0)
@@ -467,6 +471,7 @@ DEPENDENCIES
bootstrap-select-rails
bootstrap3-datetimepicker-rails (~> 4.15.35)
bootstrap_form
+ bullet
byebug
capybara
commit_param_routing
@@ -543,4 +548,4 @@ RUBY VERSION
ruby 2.4.1p111
BUNDLED WITH
- 1.15.3
+ 1.15.4
diff --git a/app/controllers/client_api/teams/teams_controller.rb b/app/controllers/client_api/teams/teams_controller.rb
new file mode 100644
index 000000000..4e2999d1c
--- /dev/null
+++ b/app/controllers/client_api/teams/teams_controller.rb
@@ -0,0 +1,50 @@
+module ClientApi
+ module Teams
+ class TeamsController < ApplicationController
+ include ClientApi::Users::UserTeamsHelper
+
+ def index
+ success_response('/client_api/teams/index',
+ teams: current_user.teams_data)
+ end
+
+ def details
+ team_service = ClientApi::TeamsService.new(id: params[:team_id],
+ current_user: current_user)
+ success_response('/client_api/teams/details',
+ team_service.team_page_details_data)
+ rescue MissingTeamError
+ error_response
+ end
+
+ def change_team
+ team_service = ClientApi::TeamsService.new(id: params[:team_id],
+ current_user: current_user)
+ team_service.change_current_team!
+ success_response('/client_api/teams/index', team_service.teams_data)
+ rescue MissingTeamError
+ error_response
+ end
+
+ private
+
+ def success_response(template, locals)
+ respond_to do |format|
+ format.json do
+ render template: template,
+ status: :ok,
+ locals: locals
+ end
+ end
+ end
+
+ def error_response
+ respond_to do |format|
+ format.json do
+ render json: { message: 'Bad boy!' }, status: :bad_request
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/app/controllers/client_api/teams_controller.rb b/app/controllers/client_api/teams_controller.rb
deleted file mode 100644
index 0ffba958a..000000000
--- a/app/controllers/client_api/teams_controller.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-module ClientApi
- class TeamsController < ApplicationController
- include ClientApi::Users::UserTeamsHelper
- MissingTeamError = Class.new(StandardError)
-
- def index
- success_response
- end
-
- def change_team
- change_current_team
- success_response
- rescue MissingTeamError
- error_response
- end
-
- private
-
- def success_response
- respond_to do |format|
- format.json do
- render template: '/client_api/teams/index',
- status: :ok,
- locals: teams
- end
- end
- end
-
- def error_response
- respond_to do |format|
- format.json do
- render json: { message: 'Bad boy!' }, status: :bad_request
- end
- end
- end
-
- def teams
- { teams: current_user.teams_data }
- end
-
- def change_current_team
- team_id = params.fetch(:team_id) { raise MissingTeamError }
- unless current_user.teams.pluck(:id).include? team_id
- raise MissingTeamError
- end
- current_user.update_attribute(:current_team_id, team_id)
- end
-
- end
-end
diff --git a/app/javascript/packs/app/dom_routes.js b/app/javascript/packs/app/dom_routes.js
new file mode 100644
index 000000000..f04d2ae72
--- /dev/null
+++ b/app/javascript/packs/app/dom_routes.js
@@ -0,0 +1,3 @@
+// Settings page
+export const SETTINGS_TEAMS_ROUTE = "/settings/teams";
+export const SETTINGS_TEAM_ROUTE = "/settings/teams/:id";
diff --git a/app/javascript/packs/app/routes.js b/app/javascript/packs/app/routes.js
index 4f926c2d5..82a85b535 100644
--- a/app/javascript/packs/app/routes.js
+++ b/app/javascript/packs/app/routes.js
@@ -3,7 +3,8 @@ export const ACTIVITIES_PATH = "/client_api/activities";
// teams
export const TEAMS_PATH = "/client_api/teams";
-export const CHANGE_TEAM_PATH = "/client_api/change_team";
+export const CHANGE_TEAM_PATH = "/client_api/teams/change_team";
+export const TEAM_DETAILS_PATH = "/client_api/teams/:team_id/details";
// search
export const SEARCH_PATH = "/search";
@@ -23,7 +24,7 @@ export const CONTACT_US_LINK =
"http://scinote.net/story-of-scinote/#contact-scinote";
// user teams
-export const LEAVE_TEAM_PATH = "/client_api/users/leave_team"
+export const LEAVE_TEAM_PATH = "/client_api/users/leave_team";
// settings
export const SETTINGS_ACCOUNT_PROFILE = "/settings/account/profile";
diff --git a/app/javascript/packs/src/settings/components/MainNav.jsx b/app/javascript/packs/src/settings/components/MainNav.jsx
index a875b129d..8e9049fa3 100644
--- a/app/javascript/packs/src/settings/components/MainNav.jsx
+++ b/app/javascript/packs/src/settings/components/MainNav.jsx
@@ -6,10 +6,15 @@ import { FormattedMessage } from "react-intl";
import Navigation from "../../../shared/navigation";
import { SETTINGS_ACCOUNT_PROFILE, SETTINGS_TEAMS } from "../../../app/routes";
+import {
+ SETTINGS_TEAMS_ROUTE,
+ SETTINGS_TEAM_ROUTE
+} from "../../../app/dom_routes";
import NotFound from "../../../shared/404/NotFound";
-import SettingsAccount from ".././components/account/SettingsAccount";
-import SettingsTeams from ".././components/team/SettingsTeams";
+import SettingsAccount from "./account/SettingsAccount";
+import SettingsTeams from "./teams/SettingsTeams";
+import SettingsTeamPageContainer from "./team/SettingsTeamPageContainer";
export default class MainNav extends Component {
constructor(props) {
@@ -57,7 +62,11 @@ export default class MainNav extends Component {
render={() => }
/>
-
+
+
diff --git a/app/javascript/packs/src/settings/components/team/SettingsTeamPageContainer.jsx b/app/javascript/packs/src/settings/components/team/SettingsTeamPageContainer.jsx
new file mode 100644
index 000000000..22ad41961
--- /dev/null
+++ b/app/javascript/packs/src/settings/components/team/SettingsTeamPageContainer.jsx
@@ -0,0 +1,54 @@
+import React, { Component } from "react";
+import PropTypes, { number, string, bool } from "prop-types";
+import styled from "styled-components";
+import { FormattedMessage } from "react-intl";
+import axios from "../../../../app/axios";
+
+import { TEAM_DETAILS_PATH } from "../../../../app/routes";
+import {
+ BORDER_LIGHT_COLOR,
+ COLOR_CONCRETE
+} from "../../../../app/constants/colors";
+
+const Wrapper = styled.div`
+ background: white;
+ box-sizing: border-box;
+ border: 1px solid ${BORDER_LIGHT_COLOR};
+ border-top: none;
+ margin: 0;
+ padding: 16px 15px 50px 15px;
+`;
+
+const TabTitle = styled.div`
+ background-color: ${COLOR_CONCRETE};
+ padding: 15px;
+`;
+
+class SettingsTeamPageContainer extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ team: {},
+ users: []
+ };
+ }
+
+ componentDidMount() {
+ const path = TEAM_DETAILS_PATH.replace(":team_id", this.props.params.id);
+ axios.get(path).then(response => {
+
+ });
+ }
+
+ render() {
+ return (
+
+
+
+
+
+ );
+ }
+}
+
+export default SettingsTeamPageContainer;
diff --git a/app/javascript/packs/src/settings/components/team/actions/UserTeamsActions.js b/app/javascript/packs/src/settings/components/team/actions/UserTeamsActions.js
deleted file mode 100644
index 33f07eb5a..000000000
--- a/app/javascript/packs/src/settings/components/team/actions/UserTeamsActions.js
+++ /dev/null
@@ -1,2 +0,0 @@
-
-import { LEAVE_TEAM_PATH } from '../../../../../app/routes'
diff --git a/app/javascript/packs/src/settings/components/team/SettingsTeams.jsx b/app/javascript/packs/src/settings/components/teams/SettingsTeams.jsx
similarity index 100%
rename from app/javascript/packs/src/settings/components/team/SettingsTeams.jsx
rename to app/javascript/packs/src/settings/components/teams/SettingsTeams.jsx
diff --git a/app/javascript/packs/src/settings/components/team/components/TeamsDataTable.jsx b/app/javascript/packs/src/settings/components/teams/components/TeamsDataTable.jsx
similarity index 88%
rename from app/javascript/packs/src/settings/components/team/components/TeamsDataTable.jsx
rename to app/javascript/packs/src/settings/components/teams/components/TeamsDataTable.jsx
index e638f9516..6b20c459b 100644
--- a/app/javascript/packs/src/settings/components/team/components/TeamsDataTable.jsx
+++ b/app/javascript/packs/src/settings/components/teams/components/TeamsDataTable.jsx
@@ -3,9 +3,11 @@ import PropTypes, { func, number, string, bool } from "prop-types";
import { connect } from "react-redux";
import { Button } from "react-bootstrap";
import _ from "lodash";
+import { Link } from "react-router-dom";
import { FormattedMessage } from "react-intl";
import { leaveTeamModalShow } from "../../../../../shared/actions/LeaveTeamActions";
import DataTable from "../../../../../shared/data_table";
+import { SETTINGS_TEAMS_ROUTE } from "../../../../../app/dom_routes";
class TeamsDataTable extends Component {
constructor(props) {
@@ -13,6 +15,7 @@ class TeamsDataTable extends Component {
this.leaveTeamModal = this.leaveTeamModal.bind(this);
this.leaveTeamButton = this.leaveTeamButton.bind(this);
+ this.linkToTeam = this.linkToTeam.bind(this);
}
leaveTeamModal(e, id) {
@@ -36,6 +39,14 @@ class TeamsDataTable extends Component {
);
}
+ linkToTeam(name, col) {
+ return (
+
+ {name}
+
+ );
+ }
+
render() {
const options = {
defaultSortName: "name",
@@ -50,6 +61,7 @@ class TeamsDataTable extends Component {
name: "Name",
isKey: false,
textId: "name",
+ dataFormat: this.linkToTeam,
position: 0,
dataSort: true
},
diff --git a/app/javascript/packs/src/settings/components/team/components/TeamsPageDetails.jsx b/app/javascript/packs/src/settings/components/teams/components/TeamsPageDetails.jsx
similarity index 100%
rename from app/javascript/packs/src/settings/components/team/components/TeamsPageDetails.jsx
rename to app/javascript/packs/src/settings/components/teams/components/TeamsPageDetails.jsx
diff --git a/app/services/client_api/teams_service.rb b/app/services/client_api/teams_service.rb
new file mode 100644
index 000000000..35da8baa9
--- /dev/null
+++ b/app/services/client_api/teams_service.rb
@@ -0,0 +1,23 @@
+module ClientApi
+ class TeamsService
+ MissingTeamError = Class.new(StandardError)
+ def initialize(arg)
+ team_id = arg.fetch(:team_id) { raise MissingTeamError }
+ @team = Team.find_by_id(team_id)
+ @current_user = arg.fetch(:current_user) { raise MissingTeamError }
+ raise MissingTeamError unless @current_user.teams.include? @team
+ end
+
+ def change_current_team!
+ @current_user.update_attribute(:current_team_id, @team.id)
+ end
+
+ def team_page_details_data
+ { team: @team, users: @team.users.eager_load(:user_teams) }
+ end
+
+ def teams_data
+ { teams: @current_user.teams_data }
+ end
+ end
+end
diff --git a/app/views/client_api/teams/details.json.jbuilder b/app/views/client_api/teams/details.json.jbuilder
new file mode 100644
index 000000000..2a495034f
--- /dev/null
+++ b/app/views/client_api/teams/details.json.jbuilder
@@ -0,0 +1,15 @@
+json.team_details do
+ json.id team.id
+ json.created_at team.created_at
+ json.created_by team.created_by
+ json.space_taken team.space_taken
+ json.description team.description
+ json.users users do |user|
+ # json.id team.fetch('id')
+ # json.name team.fetch('name')
+ # json.members team.fetch('members')
+ # json.role retrive_role_name(team.fetch('role') { nil })
+ # json.current_team team.fetch('current_team')
+ # json.can_be_leaved team.fetch('can_be_leaved')
+ end
+end
diff --git a/config/routes.rb b/config/routes.rb
index a19e10477..09de8ed86 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -17,8 +17,11 @@ Rails.application.routes.draw do
# activities
get '/activities', to: 'activities#index'
# teams
- get '/teams', to: 'teams#index'
- post '/change_team', to: 'teams#change_team'
+ get '/teams', to: 'teams/teams#index'
+ namespace :teams do
+ get '/:team_id/details', to: 'teams#details'
+ post '/change_team', to: 'teams#change_team'
+ end
# notifications
get '/recent_notifications', to: 'notifications#recent_notifications'
# users