From 1f687ab89e91ef8fb112047ea41d0981434f5213 Mon Sep 17 00:00:00 2001 From: ekachxaidze98 <65679299+ekachxaidze98@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:26:52 +0400 Subject: [PATCH 1/2] CORE: disabled tabs issue (#695) --- components/application/index.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/application/index.jsx b/components/application/index.jsx index 398bc966..1ca312ba 100644 --- a/components/application/index.jsx +++ b/components/application/index.jsx @@ -238,8 +238,8 @@ const Application = observer( Date: Fri, 13 Sep 2024 19:37:57 +0400 Subject: [PATCH 2/2] Core set call issue (#696) * CORE: fix set call * fix: disable article call --- components/application/repository-select.jsx | 2 +- store/data-provider/works.js | 2 +- store/root.js | 24 +++++++++++++------- templates/settings/repository.jsx | 20 ++++++++-------- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/components/application/repository-select.jsx b/components/application/repository-select.jsx index f6b1c799..2edcf1f7 100644 --- a/components/application/repository-select.jsx +++ b/components/application/repository-select.jsx @@ -75,7 +75,7 @@ const RepositorySelect = ({ store }) => { } useEffect(() => { - store.getSetsEnabledList() + store.getSetsEnabledList(providerId) }, [providerId]) useEffect(() => { diff --git a/store/data-provider/works.js b/store/data-provider/works.js index 49a4d158..bf410e56 100644 --- a/store/data-provider/works.js +++ b/store/data-provider/works.js @@ -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 { diff --git a/store/root.js b/store/root.js index 12df4e5d..6d2fc280 100644 --- a/store/root.js +++ b/store/root.js @@ -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() @@ -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() @@ -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: { @@ -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: { diff --git a/templates/settings/repository.jsx b/templates/settings/repository.jsx index 82fb5da3..da30ad40 100644 --- a/templates/settings/repository.jsx +++ b/templates/settings/repository.jsx @@ -161,7 +161,7 @@ const RepositoryPageTemplate = observer( }, []) useEffect(() => { - getSetsEnabledList() + getSetsEnabledList(providerId) }, [providerId]) const uploadRef = useRef(null) @@ -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) => { @@ -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) @@ -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 { @@ -382,6 +383,7 @@ const RepositoryPageTemplate = observer( const handleButtonClick = async (item) => { try { await enableSet({ + providerId, id: item.id, setSpec: item.setSpec, setName: item.setName, @@ -643,7 +645,7 @@ const RepositoryPageTemplate = observer( handleDropdownClick(providerId)} onChange={handleSetInputChange} value={inputValue} className={styles.selectInput}