Skip to content

Commit

Permalink
chore: Improve admin create project settings flow (#3160)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg authored Dec 13, 2023
1 parent 6a44b3d commit 919c823
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
13 changes: 13 additions & 0 deletions frontend/common/utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
FlagsmithValue,
MultivariateFeatureStateValue,
MultivariateOption,
Organisation,
Project as ProjectType,
ProjectFlag,
SegmentCondition,
Expand Down Expand Up @@ -131,6 +132,18 @@ const Utils = Object.assign({}, require('./base/_utils'), {
getApproveChangeRequestPermission() {
return 'APPROVE_CHANGE_REQUEST'
},
getCreateProjectPermission(organisation: Organisation) {
if (organisation?.restrict_project_create_to_admin) {
return 'ADMIN'
}
return 'CREATE_PROJECT'
},
getCreateProjectPermissionDescription(organisation: Organisation) {
if (organisation?.restrict_project_create_to_admin) {
return 'Administrator'
}
return 'Create Project'
},
getFeatureStatesEndpoint(_project: ProjectType) {
const project = _project || ProjectStore.model
if (project && project.use_edge_identities) {
Expand Down
20 changes: 14 additions & 6 deletions frontend/web/components/pages/ProjectSelectPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,18 @@ const ProjectSelectPage = class extends Component {
<div className='col-md-6 col-xl-3'>
<Permission
level='organisation'
permission='CREATE_PROJECT'
permission={Utils.getCreateProjectPermission(
AccountStore.getOrganisation(),
)}
id={AccountStore.getOrganisation().id}
>
{({ permission }) => {
return Utils.renderWithPermission(
permission,
Constants.environmentPermissions(
'Create Project',
Constants.organisationPermissions(
Utils.getCreateProjectPermissionDescription(
AccountStore.getOrganisation(),
),
),
<Button
disabled={!permission}
Expand Down Expand Up @@ -210,14 +214,18 @@ const ProjectSelectPage = class extends Component {
<div>
<Permission
level='organisation'
permission='CREATE_PROJECT'
permission={Utils.getCreateProjectPermission(
AccountStore.getOrganisation(),
)}
id={AccountStore.getOrganisation().id}
>
{({ permission }) => {
return Utils.renderWithPermission(
permission,
Constants.environmentPermissions(
'Create Project',
Constants.organisationPermissions(
Utils.getCreateProjectPermissionDescription(
AccountStore.getOrganisation(),
),
),
<div className='col-md-6 col-xl-3'>
<Button
Expand Down
3 changes: 3 additions & 0 deletions frontend/web/styles/project/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ button.btn {
&.btn-project-create {
background-color: transparent;
border: 1px dashed $basic-alpha-24;
&:disabled {
color: $body-text;
}
&:hover {
background-color: transparent;
& .btn-project-icon {
Expand Down

3 comments on commit 919c823

@vercel
Copy link

@vercel vercel bot commented on 919c823 Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 919c823 Dec 13, 2023

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-git-main-flagsmith.vercel.app
docs.bullet-train.io
docs.flagsmith.com
docs-flagsmith.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 919c823 Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.