Skip to content

Commit

Permalink
fix/speed_up_identity_overrides
Browse files Browse the repository at this point in the history
ref: #4931

Signed-off-by: Tiago Fonseca <[email protected]>
  • Loading branch information
tiagoapolo committed Dec 23, 2024
1 parent b151941 commit affb7f3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions frontend/common/types/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ export type ProjectFlag = {
id: number
initial_value: FlagsmithValue
is_archived: boolean
is_num_identity_overrides_complete: boolean
is_server_key_only: boolean
multivariate_options: MultivariateOption[]
name: string
Expand Down
3 changes: 3 additions & 0 deletions frontend/web/components/CompareIdentities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ const CompareIdentities: FC<CompareIdentitiesType> = ({
/>
<IdentityOverridesIcon
count={data.num_identity_overrides}
showPlusIndicator={
data.is_num_identity_overrides_complete === false
}
/>
</Row>
</div>
Expand Down
5 changes: 5 additions & 0 deletions frontend/web/components/FeatureRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class TheComponent extends Component {
const changeRequestsEnabled = Utils.changeRequestsEnabled(
environment && environment.minimum_change_request_approvals,
)
const showPlusIndicator =
projectFlag?.is_num_identity_overrides_complete === false

const onChange = () => {
if (disableControls) {
return
Expand Down Expand Up @@ -230,6 +233,7 @@ class TheComponent extends Component {
)
}}
count={projectFlag.num_identity_overrides}
showPlusIndicator={showPlusIndicator}
/>
</Row>
</Flex>
Expand Down Expand Up @@ -292,6 +296,7 @@ class TheComponent extends Component {
this.editFeature(projectFlag, environmentFlags[id], 1)
}}
count={projectFlag.num_identity_overrides}
showPlusIndicator={showPlusIndicator}
/>
{projectFlag.is_server_key_only && (
<Tooltip
Expand Down
12 changes: 10 additions & 2 deletions frontend/web/components/IdentityOverridesIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import UsersIcon from './svg/UsersIcon'

type IdentityOverridesIconType = {
count: number | null
showPlusIndicator?: boolean
onClick?: (e: FormEvent) => void
}

const IdentityOverridesIcon: FC<IdentityOverridesIconType> = ({
count,
onClick,
showPlusIndicator,
}) => {
if (!count) {
return null
}
const plusIndicatorText = showPlusIndicator ? '+' : ''
return (
<div onClick={onClick}>
<Tooltip
Expand All @@ -23,12 +26,17 @@ const IdentityOverridesIcon: FC<IdentityOverridesIconType> = ({
style={{ border: 'none' }}
>
<UsersIcon className='chip-svg-icon' />
<span>{count}</span>
<span>
{count}
{plusIndicatorText}
</span>
</span>
}
place='top'
>
{`${count} Identity Override${count !== 1 ? 's' : ''}`}
{`${count}${plusIndicatorText} Identity Override${
count !== 1 || showPlusIndicator ? 's' : ''
}`}
</Tooltip>
</div>
)
Expand Down
2 changes: 2 additions & 0 deletions frontend/web/components/pages/ProjectSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const ProjectSettingsPage = class extends Component {
{ organisation_id: AccountStore.getOrganisation().id },
{ forceRefetch: true },
).then((roles) => {
if (!roles.data?.results?.length) return

getRoleProjectPermissions(
getStore(),
{
Expand Down

0 comments on commit affb7f3

Please sign in to comment.