-
Notifications
You must be signed in to change notification settings - Fork 429
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
feat: Clone identities (FE) #3725
Changes from 6 commits
85e999a
e3763d9
0f472fc
d264d76
2e4c304
b708ad0
33ac2d6
f7bcb11
e202e3f
40c0e6c
08f14e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,10 @@ import React, { FC, useEffect, useMemo, useState } from 'react' | |
import IdentitySelect, { IdentitySelectType } from './IdentitySelect' | ||
import Utils from 'common/utils/utils' | ||
import EnvironmentSelect from './EnvironmentSelect' | ||
import { useGetIdentityFeatureStatesQuery } from 'common/services/useIdentityFeatureState' | ||
import { | ||
useGetIdentityFeatureStatesAllQuery, | ||
useCreateCloneIdentityFeatureStatesMutation, | ||
} from 'common/services/useIdentityFeatureState' | ||
import { useGetProjectFlagsQuery } from 'common/services/useProjectFlag' | ||
import Tag from './tags/Tag' | ||
import PanelSearch from './PanelSearch' | ||
|
@@ -17,6 +20,8 @@ import Button from './base/forms/Button' | |
import ProjectStore from 'common/stores/project-store' | ||
import SegmentOverridesIcon from './SegmentOverridesIcon' | ||
import IdentityOverridesIcon from './IdentityOverridesIcon' | ||
import Tooltip from './Tooltip' | ||
import PageTitle from './PageTitle' | ||
|
||
type CompareIdentitiesType = { | ||
projectId: string | ||
|
@@ -66,14 +71,16 @@ const CompareIdentities: FC<CompareIdentitiesType> = ({ | |
permission: Utils.getViewIdentitiesPermission(), | ||
}) | ||
|
||
const { data: leftUser } = useGetIdentityFeatureStatesQuery( | ||
const { data: leftUser } = useGetIdentityFeatureStatesAllQuery( | ||
{ environment: environmentId, user: `${leftId?.value}` }, | ||
{ skip: !leftId }, | ||
) | ||
const { data: rightUser } = useGetIdentityFeatureStatesQuery( | ||
const { data: rightUser } = useGetIdentityFeatureStatesAllQuery( | ||
{ environment: environmentId, user: `${rightId?.value}` }, | ||
{ skip: !rightId }, | ||
) | ||
const [createCloneIdentityFeatureStates] = | ||
useCreateCloneIdentityFeatureStatesMutation() | ||
|
||
useEffect(() => { | ||
// Clear users whenever environment or project is changed | ||
|
@@ -120,6 +127,39 @@ const CompareIdentities: FC<CompareIdentitiesType> = ({ | |
) | ||
} | ||
|
||
const clonedentityValues = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cloneIdentityValues There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, was corrected |
||
leftIdentityName: string, | ||
rightIdentityName: string, | ||
leftIdentityId: string, | ||
rightIdentityId: string, | ||
environmentId: string, | ||
) => { | ||
return openConfirm({ | ||
body: ( | ||
<div> | ||
{'Are you sure you want to clone all the feature states from '} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does cloning clone overrides and traits? If so I think that might read better "Cloning an identity will copy any traits and identity overrides. Are you sure?" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't clone the traits. |
||
<strong>{leftIdentityName}</strong> {'to'}{' '} | ||
<strong>{rightIdentityName}</strong> | ||
{'?'} | ||
</div> | ||
), | ||
destructive: true, | ||
onYes: () => { | ||
createCloneIdentityFeatureStates({ | ||
body: { | ||
source_identity_id: leftIdentityId, | ||
}, | ||
environment_id: environmentId, | ||
identity_id: rightIdentityId, | ||
}).then(() => { | ||
toast('Clonation Completed!') | ||
}) | ||
}, | ||
title: 'Clone the values', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clone identity might be better here ? Not clear what "The values" means There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
yesText: 'Confirm', | ||
}) | ||
} | ||
|
||
return ( | ||
<div> | ||
<div className='col-md-8'> | ||
|
@@ -179,9 +219,40 @@ const CompareIdentities: FC<CompareIdentitiesType> = ({ | |
|
||
{isReady && ( | ||
<> | ||
<PageTitle | ||
title={'Changed Flags'} | ||
className='mt-3' | ||
cta={ | ||
<> | ||
{Utils.getFlagsmithHasFeature('clone_identities') && ( | ||
<> | ||
<Tooltip | ||
title={ | ||
<Button | ||
onClick={() => { | ||
kyle-ssg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
clonedentityValues( | ||
leftId?.label, | ||
rightId?.label, | ||
leftId?.value, | ||
rightId?.value, | ||
environmentId, | ||
) | ||
}} | ||
className='ms-2 me-2' | ||
> | ||
{'Clone features states'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clone identity overrides I think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This text was updated. |
||
</Button> | ||
} | ||
> | ||
{`Clone the features states from ${leftId?.label} to ${rightId?.label}`} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this text was updated. |
||
</Tooltip> | ||
</> | ||
)} | ||
</> | ||
} | ||
></PageTitle> | ||
<PanelSearch | ||
className='no-pad mt-4' | ||
title={'Changed Flags'} | ||
searchPanel={ | ||
<Row className='mb-2'> | ||
<Tag | ||
|
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.
I'm guessing this is string|null
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.
Corrected