Skip to content

Commit

Permalink
Don't fetch user overrides in edit feature if user has no permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg committed Dec 17, 2024
1 parent 8767c78 commit 569fa9f
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions frontend/web/components/modals/CreateFlag.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { saveFeatureWithValidation } from 'components/saveFeatureWithValidation'
import PlanBasedBanner from 'components/PlanBasedAccess'
import FeatureHistory from 'components/FeatureHistory'
import WarningMessage from 'components/WarningMessage'
import { getPermission } from 'common/services/usePermission'

const CreateFlag = class extends Component {
static displayName = 'CreateFlag'
Expand Down Expand Up @@ -220,26 +221,37 @@ const CreateFlag = class extends Component {
userOverridesPage = (page) => {
if (Utils.getIsEdge()) {
if (!Utils.getShouldHideIdentityOverridesTab(ProjectStore.model)) {
data
.get(
`${Project.api}environments/${this.props.environmentId}/edge-identity-overrides?feature=${this.props.projectFlag.id}&page=${page}`,
)
.then((userOverrides) => {
this.setState({
userOverrides: userOverrides.results.map((v) => ({
...v.feature_state,
identity: {
id: v.identity_uuid,
identifier: v.identifier,
},
})),
userOverridesPaging: {
count: userOverrides.count,
currentPage: page,
next: userOverrides.next,
},
})
})
getPermission(getStore(), {
id: this.props.environmentId,
level: 'environment',
permissions: 'VIEW_IDENTITIES',
}).then((permissions) => {
if (permissions?.length) {
data
.get(
`${Project.api}environments/${this.props.environmentId}/edge-identity-overrides?feature=${this.props.projectFlag.id}&page=${page}`,
)
.then((userOverrides) => {
this.setState({
userOverrides: userOverrides.results.map((v) => ({
...v.feature_state,
identity: {
id: v.identity_uuid,
identifier: v.identifier,
},
})),
userOverridesPaging: {
count: userOverrides.count,
currentPage: page,
next: userOverrides.next,
},
})
})
.catch((e) => {
console.log('Cannot retrieve user overrides')
})
}
})
}

return
Expand Down

0 comments on commit 569fa9f

Please sign in to comment.