Skip to content

Commit

Permalink
GUI support for "ignore access requests" team settings option (keybas…
Browse files Browse the repository at this point in the history
…e#10162)

* 'Ignore access requests' checkbox

* switch to new name

* Switch to new RPC
  • Loading branch information
cjb authored Jan 10, 2018
1 parent bf8c880 commit 1d1159e
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 13 deletions.
29 changes: 26 additions & 3 deletions shared/actions/teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,21 @@ const _getDetails = function*(action: TeamsGen.GetDetailsPayload): Saga.SagaGene
}
)

const state: TypedState = yield Saga.select()
const yourOperations = Constants.getCanPerform(state, teamname)

let tarsDisabled = false
// Find out whether team access requests are enabled. Throws if you aren't admin.
if (yourOperations.changeTarsDisabled) {
tarsDisabled = yield Saga.call(RPCTypes.teamsGetTarsDisabledRpcPromise, {
name: teamname,
})
}

const publicityMap = {
anyMemberShowcase: publicity.teamShowcase.anyMemberShowcase,
description: publicity.teamShowcase.description,
ignoreAccessRequests: tarsDisabled,
member: publicity.isMemberShowcased,
team: publicity.teamShowcase.isShowcased,
}
Expand Down Expand Up @@ -618,9 +630,11 @@ const _setPublicity = function(action: TeamsGen.SetPublicityPayload, state: Type
})
const teamPublicitySettings = state.entities.getIn(['teams', 'teamNameToPublicitySettings', teamname], {
anyMemberShowcase: false,
ignoreAccessRequests: false,
member: false,
team: false,
})
const ignoreAccessRequests = teamPublicitySettings.ignoreAccessRequests
const openTeam = teamSettings.open
const openTeamRole = Constants.teamRoleByEnum[teamSettings.joinAs]
const publicityAnyMember = teamPublicitySettings.anyMemberShowcase
Expand All @@ -640,9 +654,18 @@ const _setPublicity = function(action: TeamsGen.SetPublicityPayload, state: Type
})
)
}
if (ignoreAccessRequests !== settings.ignoreAccessRequests) {
calls.push(
// $FlowIssue doesn't like callAndWrap
Saga.callAndWrap(RPCTypes.teamsSetTarsDisabledRpcPromise, {
disabled: settings.ignoreAccessRequests,
name: teamname,
})
)
}
if (publicityAnyMember !== settings.publicityAnyMember) {
calls.push(
// $FlowIssue doens't like callAndWrap
// $FlowIssue doesn't like callAndWrap
Saga.callAndWrap(RPCTypes.teamsSetTeamShowcaseRpcPromise, {
anyMemberShowcase: settings.publicityAnyMember,
name: teamname,
Expand All @@ -651,7 +674,7 @@ const _setPublicity = function(action: TeamsGen.SetPublicityPayload, state: Type
}
if (publicityMember !== settings.publicityMember) {
calls.push(
// $FlowIssue doens't like callAndWrap
// $FlowIssue doesn't like callAndWrap
Saga.callAndWrap(RPCTypes.teamsSetTeamMemberShowcaseRpcPromise, {
isShowcased: settings.publicityMember,
name: teamname,
Expand All @@ -660,7 +683,7 @@ const _setPublicity = function(action: TeamsGen.SetPublicityPayload, state: Type
}
if (publicityTeam !== settings.publicityTeam) {
calls.push(
// $FlowIssue doens't like callAndWrap
// $FlowIssue doesn't like callAndWrap
Saga.callAndWrap(RPCTypes.teamsSetTeamShowcaseRpcPromise, {
isShowcased: settings.publicityTeam,
name: teamname,
Expand Down
2 changes: 2 additions & 0 deletions shared/constants/types/teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {ConversationIDKey} from './chat'
export type TeamRoleType = 'reader' | 'writer' | 'admin' | 'owner'

export type PublicitySettings = {
ignoreAccessRequests: boolean,
openTeam: boolean,
openTeamRole: TeamRoleType,
publicityAnyMember: boolean,
Expand All @@ -18,6 +19,7 @@ export type Teamname = string
export type _PublicitySettings = {
anyMemberShowcase: boolean,
description: string,
ignoreAccessRequests: boolean,
member: boolean,
team: boolean,
}
Expand Down
23 changes: 20 additions & 3 deletions shared/teams/team/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type StateProps = {
_implicitAdminUsernames: I.Set<string>,
_requests: I.Set<Types.RequestInfo>,
_newTeamRequests: I.List<string>,
ignoreAccessRequests: boolean,
loading: boolean,
openTeam: boolean,
openTeamRole: Types.TeamRoleType,
Expand Down Expand Up @@ -57,6 +58,10 @@ const mapStateToProps = (state: TypedState, {routeProps, routeState}): StateProp
description: state.entities.getIn(['teams', 'teamNameToPublicitySettings', teamname, 'description'], ''),
openTeam: state.entities.getIn(['teams', 'teamNameToTeamSettings', teamname], {open: false}).open,
_newTeamRequests: state.entities.getIn(['teams', 'newTeamRequests'], I.List()),
ignoreAccessRequests: state.entities.getIn(
['teams', 'teamNameToPublicitySettings', teamname, 'ignoreAccessRequests'],
false
),
loading: state.entities.getIn(['teams', 'teamNameToLoading', teamname], true),
memberCount: state.entities.getIn(['teams', 'teammembercounts', teamname], 0),
name: teamname,
Expand Down Expand Up @@ -213,6 +218,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
/>
)
const publicitySettingsChanged =
ownProps.newIgnoreAccessRequests !== stateProps.ignoreAccessRequests ||
ownProps.newPublicityAnyMember !== stateProps.publicityAnyMember ||
ownProps.newPublicityMember !== stateProps.publicityMember ||
ownProps.newPublicityTeam !== stateProps.publicityTeam ||
Expand Down Expand Up @@ -249,6 +255,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {

export default compose(
withState('showMenu', 'setShowMenu', false),
withState('newIgnoreAccessRequests', 'setIgnoreAccessRequests', props => props.ignoreAccessRequests),
withState('newPublicityAnyMember', 'setPublicityAnyMember', props => props.publicityAnyMember),
withState('newPublicityMember', 'setPublicityMember', props => props.publicityMember),
withState('newPublicityTeam', 'setPublicityTeam', props => props.publicityTeam),
Expand All @@ -257,8 +264,16 @@ export default compose(
withState('publicitySettingsChanged', 'setPublicitySettingsChanged', false),
connect(mapStateToProps, mapDispatchToProps, mergeProps),
withPropsOnChange(
['publicityAnyMember', 'publicityMember', 'publicityTeam', 'openTeam', 'openTeamRole'],
[
'ignoreAccessRequests',
'publicityAnyMember',
'publicityMember',
'publicityTeam',
'openTeam',
'openTeamRole',
],
props => {
props.setIgnoreAccessRequests(props.ignoreAccessRequests)
props.setPublicityAnyMember(props.publicityAnyMember)
props.setPublicityMember(props.publicityMember)
props.setPublicityTeam(props.publicityTeam)
Expand All @@ -269,11 +284,12 @@ export default compose(
withHandlers({
onSavePublicity: props => () =>
props.savePublicity({
ignoreAccessRequests: props.newIgnoreAccessRequests,
openTeam: props.newOpenTeam,
openTeamRole: props.newOpenTeamRole,
publicityAnyMember: props.newPublicityAnyMember,
publicityMember: props.newPublicityMember,
publicityTeam: props.newPublicityTeam,
openTeam: props.newOpenTeam,
openTeamRole: props.newOpenTeamRole,
}),
}),
lifecycle({
Expand All @@ -284,6 +300,7 @@ export default compose(
// Now that we've calculated old vs. new state (for greying out Save button),
// we can present just one set of props to the display component.
renameProps({
newIgnoreAccessRequests: 'ignoreAccessRequests',
newOpenTeam: 'openTeam',
newOpenTeamRole: 'openTeamRole',
newPublicityAnyMember: 'publicityAnyMember',
Expand Down
25 changes: 18 additions & 7 deletions shared/teams/team/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type RequestRowProps = Types.RequestInfo

export type Props = {
description: string,
ignoreAccessRequests: boolean,
invites: Array<InviteRowProps>,
isTeamOpen: boolean,
newTeamRequests: Array<Types.Teamname>,
Expand All @@ -55,6 +56,7 @@ export type Props = {
requests: Array<RequestRowProps>,
selectedTab: Types.TabKey,
showAddYourselfBanner: boolean,
setIgnoreAccessRequests: (checked: boolean) => void,
setPublicityAnyMember: (checked: boolean) => void,
setPublicityMember: (checked: boolean) => void,
setPublicityTeam: (checked: boolean) => void,
Expand Down Expand Up @@ -231,6 +233,7 @@ class Team extends React.PureComponent<Props> {
render() {
const {
description,
ignoreAccessRequests,
invites,
name,
members,
Expand All @@ -256,6 +259,7 @@ class Team extends React.PureComponent<Props> {
publicityMember,
publicitySettingsChanged,
publicityTeam,
setIgnoreAccessRequests,
setOpenTeam,
setPublicityAnyMember,
setPublicityMember,
Expand Down Expand Up @@ -380,7 +384,7 @@ class Team extends React.PureComponent<Props> {
</Text>
<Text type="BodySmall">
{yourOperations.setMemberShowcase
? 'Your profile on the Keybase website will mention this team. Description + number of members will be public.'
? 'Your profile will mention this team. Team description and number of members will be public.'
: "Admins aren't allowing members to publish this team on their profile."}
</Text>
</Box>
Expand Down Expand Up @@ -419,12 +423,7 @@ class Team extends React.PureComponent<Props> {

<Box style={stylesSettingsTabRow}>
<Box style={stylesPublicitySettingsBox}>
<Checkbox
checked={openTeam}
label=""
onCheck={setOpenTeam}
style={{paddingRight: globalMargins.xtiny}}
/>
<Checkbox checked={openTeam} label="" onCheck={setOpenTeam} />
</Box>
<Box
style={{...globalStyles.flexBoxColumn, flexShrink: 1, paddingRight: globalMargins.small}}
Expand All @@ -442,6 +441,18 @@ class Team extends React.PureComponent<Props> {
</Text>
</Box>
</Box>

{yourOperations.changeTarsDisabled && (
<Box style={stylesSettingsTabRow}>
<Box style={stylesPublicitySettingsBox}>
<Checkbox checked={ignoreAccessRequests} label="" onCheck={setIgnoreAccessRequests} />
</Box>
<Box style={{...globalStyles.flexBoxColumn, flexShrink: 1}}>
<Text type="Body">Ignore requests to join this team</Text>
<Text type="BodySmall">You won't be bothered by hordes of fans.</Text>
</Box>
</Box>
)}
</Box>
)}

Expand Down

0 comments on commit 1d1159e

Please sign in to comment.