-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
177 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import React, { Component } from 'react' | ||
import data from 'common/data/base/_data' | ||
import UserSelect from './UserSelect' | ||
import ConfigProvider from 'common/providers/ConfigProvider' | ||
import Icon from './Icon' | ||
import { close } from 'ionicons/icons' | ||
import { IonIcon } from '@ionic/react' | ||
import GroupSelect from './GroupSelect' | ||
import { getProjectFlag } from 'common/services/useProjectFlag' | ||
import { getStore } from 'common/store' | ||
|
||
class TheComponent extends Component { | ||
state = {} | ||
componentDidMount() { | ||
this.getData() | ||
} | ||
|
||
getData = () => { | ||
getProjectFlag(getStore(), { | ||
id: this.props.id, | ||
project: this.props.projectId, | ||
}).then((res) => { | ||
const groupOwners = (res.data.group_owners || []).map((v) => v.id) | ||
this.setState({ groupOwners }) | ||
}) | ||
} | ||
|
||
addOwner = (id) => { | ||
this.setState({ groupOwners: (this.state.groupOwners || []).concat(id) }) | ||
data.post( | ||
`${Project.api}projects/${this.props.projectId}/features/${this.props.id}/add-group-owners/`, | ||
{ | ||
group_ids: [id], | ||
}, | ||
) | ||
} | ||
|
||
removeOwner = (id) => { | ||
this.setState({ | ||
groupOwners: (this.state.groupOwners || []).filter((v) => v !== id), | ||
}) | ||
data.post( | ||
`${Project.api}projects/${this.props.projectId}/features/${this.props.id}/remove-group-owners/`, | ||
{ | ||
group_ids: [id], | ||
}, | ||
) | ||
} | ||
|
||
getGroupOwners = (users, groupOwners) => | ||
users ? users.filter((v) => groupOwners.includes(v.id)) : [] | ||
|
||
render() { | ||
const hasPermission = Utils.getPlansPermission('FLAG_OWNERS') | ||
|
||
return ( | ||
<OrganisationProvider> | ||
{({ groups }) => { | ||
const ownerUsers = this.getGroupOwners( | ||
groups, | ||
this.state.groupOwners || [], | ||
) | ||
const res = ( | ||
<div> | ||
<Row | ||
className='clickable' | ||
onClick={() => { | ||
if (hasPermission) this.setState({ showUsers: true }) | ||
}} | ||
> | ||
<label className='cols-sm-2 control-label'> | ||
Assigned groups{' '} | ||
<Icon name='setting' width={20} fill={'#656D7B'} /> | ||
</label> | ||
</Row> | ||
<Row style={{ rowGap: '12px' }}> | ||
{hasPermission && | ||
ownerUsers.map((u) => ( | ||
<Row | ||
key={u.id} | ||
onClick={() => this.removeOwner(u.id)} | ||
className='chip mr-2' | ||
> | ||
<span className='font-weight-bold'>{u.name}</span> | ||
<span className='chip-icon ion'> | ||
<IonIcon icon={close} /> | ||
</span> | ||
</Row> | ||
))} | ||
{!ownerUsers.length && ( | ||
<div>This flag has no assigned groups</div> | ||
)} | ||
</Row> | ||
<GroupSelect | ||
groups={groups} | ||
value={this.state.groupOwners} | ||
isOpen={this.state.showUsers} | ||
size={null} | ||
onAdd={this.addOwner} | ||
onRemove={this.removeOwner} | ||
onToggle={() => | ||
this.setState({ showUsers: !this.state.showUsers }) | ||
} | ||
/> | ||
</div> | ||
) | ||
return hasPermission ? ( | ||
res | ||
) : ( | ||
<div> | ||
{res} | ||
The add flag assignees feature is available with our{' '} | ||
<strong>Scale-up</strong> plan. | ||
</div> | ||
) | ||
}} | ||
</OrganisationProvider> | ||
) | ||
} | ||
} | ||
|
||
export default ConfigProvider(TheComponent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b0a00d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
flagsmith-frontend-production-native.vercel.app
flagsmith-frontend-preview-flagsmith.vercel.app
b0a00d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-flagsmith.vercel.app
docs-git-main-flagsmith.vercel.app
docs.bullet-train.io
docs.flagsmith.com
b0a00d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
flagsmith-frontend-staging-flagsmith.vercel.app
flagsmith-staging-frontend.vercel.app
staging.flagsmith.com