Skip to content

Commit

Permalink
Fix [Create vector] tags request should be send when changing project (
Browse files Browse the repository at this point in the history
  • Loading branch information
Taras-Hlukhovetskyi authored Jan 28, 2025
1 parent ec96cd4 commit 8d9cf91
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/components/AddToFeatureVectorPage/AddToFeatureVectorFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
import React from 'react'
import React, { useState } from 'react'
import { useForm } from 'react-final-form'
import { useSelector } from 'react-redux'
import { useParams } from 'react-router-dom'
Expand All @@ -27,18 +27,25 @@ import { FormInput, FormOnChange } from 'igz-controls/components'
import FormTagFilter from '../../common/FormTagFilter/FormTagFilter'
import { FormSelect } from 'iguazio.dashboard-react-controls/dist/components'

import { ENTITIES_FILTER, LABELS_FILTER, PROJECT_FILTER, TAG_FILTER } from '../../constants'
import { ENTITIES_FILTER, LABELS_FILTER, PROJECT_FILTER, TAG_FILTER, TAG_FILTER_LATEST } from '../../constants'
import { generateProjectsList } from '../../utils/projects'

const AddToFeatureVectorFilters = ({ content }) => {
const AddToFeatureVectorFilters = ({ content, fetchTags }) => {
const form = useForm()
const [tagFilterKey, setTagFilterKey] = useState('')
const projectStore = useSelector(store => store.projectStore)
const params = useParams()

const handleInputChange = (value, inputName) => {
form.change(inputName, value || '')
}

const handleProjectChange = (value) => {
fetchTags(value)
form.change(TAG_FILTER, TAG_FILTER_LATEST)
setTagFilterKey(value)
}

return (
<div>
<div className="form-row">
Expand All @@ -48,7 +55,8 @@ const AddToFeatureVectorFilters = ({ content }) => {
options={generateProjectsList(projectStore.projectsNames.data, params.projectName)}
preventWidthOverflow
/>
</div>
<FormOnChange name={PROJECT_FILTER} handler={handleProjectChange} />
</div>
<div className="form-row">
<FormInput label="Entity" name={ENTITIES_FILTER} placeholder="Search by entity" />
<FormOnChange name={ENTITIES_FILTER} handler={value => handleInputChange(value, ENTITIES_FILTER)} />
Expand All @@ -63,14 +71,15 @@ const AddToFeatureVectorFilters = ({ content }) => {
<FormOnChange name={LABELS_FILTER} handler={value => handleInputChange(value, LABELS_FILTER)} />
</div>
<div className="form-row">
<FormTagFilter content={content} label="Version tag" name={TAG_FILTER} />
<FormTagFilter content={content} label="Version tag" name={TAG_FILTER} key={tagFilterKey} />
</div>
</div>
)
}

AddToFeatureVectorFilters.propTypes = {
content: PropTypes.arrayOf(PropTypes.object).isRequired
content: PropTypes.arrayOf(PropTypes.object).isRequired,
fetchTags: PropTypes.func.isRequired
}

export default AddToFeatureVectorFilters
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ const AddToFeatureVectorPage = ({
actionsMenu={actionsMenu}
content={content}
featureStore={featureStore}
fetchTags={fetchTags}
filters={addToFeatureVectorFilters}
filtersConfig={filtersConfig}
filtersStore={filtersStore}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const AddToFeatureVectorView = React.forwardRef(
actionsMenu,
content,
featureStore,
fetchTags,
filters,
filtersConfig,
filtersStore,
Expand Down Expand Up @@ -72,7 +73,7 @@ const AddToFeatureVectorView = React.forwardRef(
tab={ADD_TO_FEATURE_VECTOR_TAB}
withoutExpandButton
>
<AddToFeatureVectorFilters content={content} />
<AddToFeatureVectorFilters content={content} fetchTags={fetchTags} />
</ActionBar>
</div>
</div>
Expand Down Expand Up @@ -133,6 +134,7 @@ AddToFeatureVectorView.propTypes = {
actionsMenu: PropTypes.array.isRequired,
content: PropTypes.arrayOf(PropTypes.object).isRequired,
featureStore: PropTypes.object.isRequired,
fetchTags: PropTypes.func.isRequired,
filters: PropTypes.object.isRequired,
filtersConfig: PropTypes.object.isRequired,
filtersStore: PropTypes.object.isRequired,
Expand Down

0 comments on commit 8d9cf91

Please sign in to comment.