Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only allow organisation admins to create projects #441

Merged
merged 1 commit into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions frontend/common/project.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// Dev is unused
// module.exports = global.Project = {
// api: 'https://api-dev.flagsmith.com/api/v1/',
// flagsmithClientAPI: 'https://api.flagsmith.com/api/v1/',
// flagsmith: '8KzETdDeMY7xkqkSkY3Gsg', // This is our Bullet Train API key - Bullet Train runs on Bullet Train!
// debug: false,
// env: 'dev', // This is used for Sentry tracking
// maintenance: false, // trigger maintenance mode
// demoAccount: {
// email: 'kyle+bullet-train@solidstategroup.com',
// password: 'demo_account',
// },
// chargebee: {
// site: 'flagsmith-test',
// },
// };

module.exports = global.Project = {
api: 'https://api-staging.flagsmith.com/api/v1/',
flagsmithClientAPI: 'https://api.flagsmith.com/api/v1/',
Expand Down
24 changes: 20 additions & 4 deletions frontend/env/project_dev.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
// Dev is unused
// module.exports = global.Project = {
// api: 'https://api-dev.flagsmith.com/api/v1/',
// flagsmithClientAPI: 'https://api.flagsmith.com/api/v1/',
// flagsmith: '8KzETdDeMY7xkqkSkY3Gsg', // This is our Bullet Train API key - Bullet Train runs on Bullet Train!
// debug: false,
// env: 'dev', // This is used for Sentry tracking
// maintenance: false, // trigger maintenance mode
// demoAccount: {
// email: 'kyle+bullet-train@solidstategroup.com',
// password: 'demo_account',
// },
// chargebee: {
// site: 'flagsmith-test',
// },
// };

module.exports = global.Project = {
api: 'https://api-dev.flagsmith.com/api/v1/',
api: 'https://api-staging.flagsmith.com/api/v1/',
flagsmithClientAPI: 'https://api.flagsmith.com/api/v1/',
flagsmith: '8KzETdDeMY7xkqkSkY3Gsg', // This is our Bullet Train API key - Bullet Train runs on Bullet Train!
debug: false,
env: 'dev', // This is used for Sentry tracking
flagsmith: 'ENktaJnfLVbLifybz34JmX', // This is our Bullet Train API key - Bullet Train runs on Bullet Train!
env: 'staging', // This is used for Sentry tracking
maintenance: false, // trigger maintenance mode
demoAccount: {
email: 'kyle+bullet-train@solidstategroup.com',
Expand Down
36 changes: 33 additions & 3 deletions frontend/web/components/pages/OrganisationSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,24 @@ const OrganisationSettingsPage = class extends Component {
}

save = (e) => {
e.preventDefault();
const { name, webhook_notification_email } = this.state;
if (AccountStore.isSaving || (!name && webhook_notification_email === undefined)) {
e && e.preventDefault();
const { name, webhook_notification_email, restrict_project_create_to_admin } = this.state;
if (AccountStore.isSaving) {
return;
}

const org = AccountStore.getOrganisation();
AppActions.editOrganisation({
name: name || org.name,
restrict_project_create_to_admin: typeof restrict_project_create_to_admin === 'boolean' ? restrict_project_create_to_admin : undefined,
webhook_notification_email: webhook_notification_email !== undefined ? webhook_notification_email : org.webhook_notification_email,
});
}

setAdminCanCreateProject = (restrict_project_create_to_admin) => {
this.setState({ restrict_project_create_to_admin }, this.save);
}

saveDisabled = () => {
const { name, webhook_notification_email } = this.state;
if (AccountStore.isSaving || (!name && webhook_notification_email === undefined)) {
Expand Down Expand Up @@ -701,6 +706,31 @@ const OrganisationSettingsPage = class extends Component {
/>
)}
</FormGroup>
{this.props.hasFeature('restrict_project_create_to_admin') && (
<FormGroup className="mt-5">
<Row>
<Column>
<h3>Admin Settings</h3>
<Row>
Only allow organisation admins to create projects
<Switch
checked={organisation.restrict_project_create_to_admin} onChange={() => this.setAdminCanCreateProject(!organisation.restrict_project_create_to_admin)}
/>
</Row>
</Column>
<Button
id="delete-org-btn"
onClick={() => this.confirmRemove(organisation, () => {
deleteOrganisation();
})}
className="btn btn--with-icon ml-auto btn--remove"
>
<RemoveIcon/>
</Button>
</Row>

</FormGroup>
)}
<FormGroup className="mt-5">
<Row>
<Column>
Expand Down