Skip to content

Commit

Permalink
Merge branch 'master' into CORE-4990-add-error-view
Browse files Browse the repository at this point in the history
  • Loading branch information
ekachxaidze98 committed Sep 16, 2024
2 parents 1c99e0b + db3f9c4 commit 157dbb3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
4 changes: 2 additions & 2 deletions components/application/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ const Application = observer(
<ActivitySelect.Option
key={path}
disabled={
!globalStore.dataProvider?.issues
?.harvestingStatus?.lastHarvestingDate &&
globalStore.dataProvider?.issues?.harvestingStatus
?.lastHarvestingDate === null &&
disabledTabs.includes(path)
}
value={path}
Expand Down
2 changes: 1 addition & 1 deletion components/application/repository-select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const RepositorySelect = ({ store }) => {
}

useEffect(() => {
store.getSetsEnabledList()
store.getSetsEnabledList(providerId)
}, [providerId])

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion store/data-provider/works.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Works extends Store {
@action
changeVisibility = async (rowId) => {
const [, workId] = rowId.split('-', 2)
const row = this.data.find((r) => r.originalId === +workId)
const row = this.workRecords.data.find((r) => r.originalId === +workId)
const { disabled } = row
row.disabled = !disabled
try {
Expand Down
24 changes: 16 additions & 8 deletions store/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,13 @@ class Root extends Store {
}

@action
getSetsWholeList = async () => {
getSetsWholeList = async (id) => {
this.loadingWholeSets = true
try {
const response = await fetch(
`${process.env.API_URL}/data-providers/${this.dataProvider.id}/set/available`
`${process.env.API_URL}/data-providers/${
this.dataProvider.id || id
}/set/available`
)
if (response.ok) {
const data = await response.json()
Expand All @@ -444,11 +446,13 @@ class Root extends Store {
}

@action
getSetsEnabledList = async () => {
getSetsEnabledList = async (id) => {
this.loadingSets = true
try {
const response = await fetch(
`${process.env.API_URL}/data-providers/${this.dataProvider.id}/set`
`${process.env.API_URL}/data-providers/${
this.dataProvider.id || id
}/set`
)
if (response.ok) {
const data = await response.json()
Expand All @@ -463,10 +467,12 @@ class Root extends Store {
}

@action
enableSet = async (body) => {
enableSet = async (body, id) => {
try {
const response = await fetch(
`${process.env.API_URL}/data-providers/${this.dataProvider.id}/set/settings`,
`${process.env.API_URL}/data-providers/${
this.dataProvider.id || id
}/set/settings`,
{
method: 'PATCH',
headers: {
Expand All @@ -484,11 +490,13 @@ class Root extends Store {
}

@action
deleteSet = async (idSet) => {
deleteSet = async (idSet, id) => {
this.loadingSets = true
try {
const response = await fetch(
`${process.env.API_URL}/data-providers/${this.dataProvider.id}/set/settings/${idSet}`,
`${process.env.API_URL}/data-providers/${
this.dataProvider.id || id
}/set/settings/${idSet}`,
{
method: 'DELETE',
headers: {
Expand Down
20 changes: 11 additions & 9 deletions templates/settings/repository.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const RepositoryPageTemplate = observer(
}, [])

useEffect(() => {
getSetsEnabledList()
getSetsEnabledList(providerId)
}, [providerId])

const uploadRef = useRef(null)
Expand Down Expand Up @@ -320,9 +320,9 @@ const RepositoryPageTemplate = observer(
setLicenseInputValue(event.target.value)
}

const handleDropdownClick = async () => {
const handleDropdownClick = async (id) => {
setIsOpen(!isOpen)
if (!wholeSetData.length) await getSetsWholeList()
if (!wholeSetData.length) await getSetsWholeList(id)
}

const handleSelect = (item) => {
Expand All @@ -336,13 +336,14 @@ const RepositoryPageTemplate = observer(
try {
setLoadingWholeSetsBtn(true)
await enableSet({
providerId,
setSpec: selectedItem.setSpec,
setName: selectedItem.setName,
setNameDisplay: selectedItem.setNameDisplay,
})
setSelectedItem(null)
await getSetsWholeList()
await getSetsEnabledList()
await getSetsWholeList(providerId)
await getSetsEnabledList(providerId)
setInputValue('')
} catch (error) {
console.error('Error patching settings:', error)
Expand All @@ -355,9 +356,9 @@ const RepositoryPageTemplate = observer(
const handleDelete = async (id) => {
try {
setLoadingRemoveAction(true, id)
await deleteSet(id)
await getSetsWholeList()
await getSetsEnabledList()
await deleteSet(id, providerId)
await getSetsWholeList(providerId)
await getSetsEnabledList(providerId)
} catch (error) {
console.error('Error patching settings:', error)
} finally {
Expand All @@ -382,6 +383,7 @@ const RepositoryPageTemplate = observer(
const handleButtonClick = async (item) => {
try {
await enableSet({
providerId,
id: item.id,
setSpec: item.setSpec,
setName: item.setName,
Expand Down Expand Up @@ -643,7 +645,7 @@ const RepositoryPageTemplate = observer(
<TextField
id="selectInput"
label="Add new set"
onClick={handleDropdownClick}
onClick={() => handleDropdownClick(providerId)}
onChange={handleSetInputChange}
value={inputValue}
className={styles.selectInput}
Expand Down

0 comments on commit 157dbb3

Please sign in to comment.