Skip to content

Commit

Permalink
1. adds refresh button
Browse files Browse the repository at this point in the history
2. updates user identity list after segment update/creation
  • Loading branch information
tiagoapolo committed Jan 8, 2025
1 parent 32154df commit e16ae16
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
11 changes: 11 additions & 0 deletions frontend/web/components/PanelSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Icon from './Icon'
import classNames from 'classnames'
import { IonIcon } from '@ionic/react'
import { chevronDown, chevronUp } from 'ionicons/icons'
import Button from './base/forms/Button'
const PanelSearch = class extends Component {
static displayName = 'PanelSearch'

Expand All @@ -19,6 +20,7 @@ const PanelSearch = class extends Component {
listClassName: OptionalString,
nextPage: OptionalFunc,
noResultsText: OptionalString,
onRefresh: OptionalFunc,
paging: OptionalObject,
renderNoResults: propTypes.any,
renderRow: RequiredFunc,
Expand Down Expand Up @@ -209,6 +211,15 @@ const PanelSearch = class extends Component {
</Popover>
</Row>
)}
{this.props.onRefresh && (
<Button
theme='text'
size='xSmall'
onClick={() => this.props.onRefresh()}
>
<Icon name='refresh' fill='#6837FC' width={16} /> Refresh
</Button>
)}
{!!this.props.filterRow && (
<Row>
<Row onClick={() => this.input.focus()}>
Expand Down
17 changes: 9 additions & 8 deletions frontend/web/components/modals/CreateSegment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ const CreateSegment: FC<CreateSegmentType> = ({
}
}

const fetchUserIdentityList = () => {
if (!environmentId) return
identities?.results.forEach((identity) =>
AppActions.getIdentitySegments(projectId, identity.id),
)
}

const [valueChanged, setValueChanged] = useState(false)
const [metadataValueChanged, setMetadataValueChanged] = useState(false)
const onClosing = useCallback(() => {
Expand Down Expand Up @@ -281,25 +288,19 @@ const CreateSegment: FC<CreateSegmentType> = ({
if (createSuccess && createSegmentData) {
setSegment(createSegmentData)
onComplete?.(createSegmentData)
fetchUserIdentityList()
}
//eslint-disable-next-line
}, [createSuccess])
useEffect(() => {
if (updateSuccess && updateSegmentData) {
setSegment(updateSegmentData)
onComplete?.(updateSegmentData)
fetchUserIdentityList()
}
//eslint-disable-next-line
}, [updateSuccess])

useEffect(() => {
if (tab === UserTabs.USERS && environmentId) {
identities?.results.forEach((identity) =>
AppActions.getIdentitySegments(projectId, identity.id),
)
}
}, [tab, identities, projectId, environmentId])

const operators: Operator[] | null = _operators || Utils.getSegmentOperators()
if (operators) {
_operators = operators
Expand Down
11 changes: 9 additions & 2 deletions frontend/web/components/modals/CreateSegmentUsersTabContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import PanelSearch from 'components/PanelSearch'
import InfoMessage from 'components/InfoMessage'
import InputGroup from 'components/base/forms/InputGroup'
import Utils from 'common/utils/utils'
import { Segment } from 'common/types/responses'
import { Res, Segment } from 'common/types/responses'
import Icon from 'components/Icon'
import AppActions from 'common/dispatcher/app-actions'

interface CreateSegmentUsersTabContentProps {
projectId: string | number
environmentId: string
setEnvironmentId: (environmentId: string) => void
identitiesLoading: boolean
identities: any
identities: Res['identities']
page: any
setPage: (page: any) => void
name: string
Expand Down Expand Up @@ -92,6 +93,12 @@ const CreateSegmentUsersTabContent: React.FC<
pages: undefined,
})
}}
onRefresh={() => {
if (!environmentId) return
identities?.results.forEach((identity) =>
AppActions.getIdentitySegments(projectId, identity.id),
)
}}
renderRow={(
{ id, identifier }: { id: string; identifier: string },
index: number,
Expand Down

0 comments on commit e16ae16

Please sign in to comment.