Merge pull request #1275 from mattermost/PLT-951

PLT-951 PLT-972 fixing issues with team directory
This commit is contained in:
Joram Wilander
2015-11-02 21:30:29 -05:00
6 changed files with 76 additions and 49 deletions

View File

@@ -32,7 +32,7 @@ func NewSqlTeamStore(sqlStore *SqlStore) TeamStore {
func (s SqlTeamStore) UpgradeSchemaIfNeeded() {
// REMOVE AFTER 1.2 SHIP see PLT-828
s.RemoveColumnIfExists("Teams", "AllowValet")
s.CreateColumnIfNotExists("Teams", "InviteId", "varchar(26)", "varchar(26)", "")
s.CreateColumnIfNotExists("Teams", "InviteId", "varchar(32)", "varchar(32)", "")
s.CreateColumnIfNotExists("Teams", "AllowOpenInvite", "tinyint(1)", "boolean", "0")
s.CreateColumnIfNotExists("Teams", "AllowTeamListing", "tinyint(1)", "boolean", "0")
}

View File

@@ -185,7 +185,7 @@ export default class Login extends React.Component {
if (this.props.inviteId) {
userSignUp = (
<div>
<span>{'Do not have an account? '}
<span>{`Don't have an account? `}
<a
href={'/signup_user_complete/?id=' + this.props.inviteId}
className='signup-team-login'

View File

@@ -12,11 +12,6 @@ export default class TeamSignUp extends React.Component {
this.updatePage = this.updatePage.bind(this);
if (global.window.mm_config.EnableTeamListing === 'true') {
this.state = {page: 'team_listing'};
return;
}
var count = 0;
if (global.window.mm_config.EnableSignUpWithEmail === 'true') {
@@ -41,50 +36,83 @@ export default class TeamSignUp extends React.Component {
}
render() {
if (this.state.page === 'team_listing') {
var teamListing = null;
if (global.window.mm_config.EnableTeamListing === 'true') {
if (this.props.teams.length === 0) {
if (global.window.mm_config.EnableTeamCreation !== 'true') {
teamListing = (<div>{'There are no teams include in the Team Directory and team creation has been disabled.'}</div>);
}
} else {
teamListing = (
<div>
<h3>{'Choose a Team'}</h3>
<div className='signup-team-all'>
{
this.props.teams.map((team) => {
return (
<div
key={'team_' + team.name}
className='signup-team-dir'
>
<a
href={'/' + team.name}
>
<div className='signup-team-dir__group'>
<span className='signup-team-dir__name'>{team.display_name}</span>
<span
className='glyphicon glyphicon-menu-right right signup-team-dir__arrow'
aria-hidden='true'
/>
</div>
</a>
</div>
);
})
}
</div>
</div>
);
}
}
if (global.window.mm_config.EnableTeamCreation !== 'true') {
if (teamListing == null) {
return (<div>{'Team creation has been disabled. Please contact an administrator for access.'}</div>);
}
return (
<div>
<h3>{'Choose a Team'}</h3>
<div className='signup-team-all'>
{
this.props.teams.map((team) => {
return (
<div
key={'team_' + team.name}
className='signup-team-dir'
>
<a
href={'/' + team.name}
>
<div className='signup-team-dir__group'>
<span className='signup-team-dir__name'>{team.display_name}</span>
<span
className='glyphicon glyphicon-menu-right right signup-team-dir__arrow'
aria-hidden='true'
/>
</div>
</a>
</div>
);
})
}
</div>
{teamListing}
</div>
);
}
if (this.state.page === 'choose') {
return (
<ChoosePage
updatePage={this.updatePage}
/>
<div>
{teamListing}
<ChoosePage
updatePage={this.updatePage}
/>
</div>
);
}
if (this.state.page === 'email') {
return <EmailSignUpPage />;
return (
<div>
{teamListing}
<EmailSignUpPage />
</div>
);
} else if (this.state.page === 'gitlab') {
return <SSOSignupPage service={Constants.GITLAB_SERVICE} />;
return (
<div>
{teamListing}
<SSOSignupPage service={Constants.GITLAB_SERVICE} />
</div>
);
}
}
}

View File

@@ -54,7 +54,6 @@ export default class GeneralTab extends React.Component {
handleTeamListingRadio(listing) {
if (global.window.mm_config.EnableTeamListing !== 'true' && listing) {
ReactDOM.findDOMNode(this.refs.teamListingRadioNo).checked = true;
this.setState({clientError: 'Team directory has been disabled. Please ask a system admin to enable it.'});
} else {
this.setState({allow_team_listing: listing});
@@ -278,13 +277,13 @@ export default class GeneralTab extends React.Component {
</label>
<br/>
</div>
<div><br/>{'When allowed the team will appear on the main page as part of team directory.'}</div>
<div><br/>{'Including this team will display the team name from the Team Directory section of the Home Page, and provide a link to the sign-in page.'}</div>
</div>
];
teamListingSection = (
<SettingItemMax
title='Allow in Team Directory'
title='Include this team in the Team Directory'
inputs={inputs}
submit={this.handleTeamListingSubmit}
server_error={serverError}
@@ -302,7 +301,7 @@ export default class GeneralTab extends React.Component {
teamListingSection = (
<SettingItemMin
title='Allow in Team Directory'
title='Include this team in the Team Directory'
describe={describe}
updateSection={this.onUpdateTeamListingSection}
/>
@@ -337,13 +336,13 @@ export default class GeneralTab extends React.Component {
</label>
<br/>
</div>
<div><br/>{'When allowed the team signup link will be included on the login page and anyone can signup to this team.'}</div>
<div><br/>{'When allowed, a link to account creation will be included on the sign-in page of this team and allow any visitor to sign-up.'}</div>
</div>
];
openInviteSection = (
<SettingItemMax
title='Allow Open Invitations'
title='Allow anyone to sign-up from login page'
inputs={inputs}
submit={this.handleOpenInviteSubmit}
server_error={serverError}
@@ -360,7 +359,7 @@ export default class GeneralTab extends React.Component {
openInviteSection = (
<SettingItemMin
title='Allow Open Invitations'
title='Allow anyone to sign-up from login page'
describe={describe}
updateSection={this.onUpdateOpenInviteSection}
/>
@@ -387,7 +386,7 @@ export default class GeneralTab extends React.Component {
maxLength='32'
/>
</div>
<div><br/>{'When allowing open invites this code is used as part of the signup process. Changing this code will invalidate the previous open signup link.'}</div>
<div><br/>{'Your Invite Code is used in the URL sent to people to join your team. Regenerating your Invite Code will invalidate the URLs in previous invitations, unless "Allow anyone to sign-up from login page" is enabled.'}</div>
<div className='help-text'>
<button
className='btn btn-default'
@@ -413,7 +412,7 @@ export default class GeneralTab extends React.Component {
inviteSection = (
<SettingItemMin
title={`Invite Code`}
describe={`Click 'Edit' to re-generate invite Code.`}
describe={`Click 'Edit' to regenerate Invite Code.`}
updateSection={this.onUpdateInviteIdSection}
/>
);

View File

@@ -316,7 +316,7 @@
.signup-team-all {
width: 280px;
box-shadow: 3px 3px 1px #d5d5d5;
margin: 0px 0px 0px 5px;
margin: 0px 0px 50px 5px;
}
.signup-team-dir {

View File

@@ -170,7 +170,7 @@ func root(c *api.Context, w http.ResponseWriter, r *http.Request) {
page.Props[team.Name] = team.DisplayName
}
if len(teams) == 1 && *utils.Cfg.TeamSettings.EnableTeamListing {
if len(teams) == 1 && *utils.Cfg.TeamSettings.EnableTeamListing && !utils.Cfg.TeamSettings.EnableTeamCreation {
http.Redirect(w, r, c.GetSiteURL()+"/"+teams[0].Name, http.StatusTemporaryRedirect)
return
}