Skip to content
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

fix: fix un exist branch page loop request error #1090

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions shell/app/common/components/load-more.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import { debounce, throttle } from 'lodash';
import React from 'react';
import { isPromise } from 'common/utils';
import { Spin } from 'core/nusi';
import i18n from 'i18n';

Expand Down
11 changes: 8 additions & 3 deletions shell/app/layout/stores/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ const messageStore = createStore({
state: initState,
effects: {
async getMessageList({ call, update, select }, payload: { pageNo: number; pageSize?: number }) {
const { list } = await call(getMessageList, payload, { paging: { key: 'msgPaging' } });
const oldList: LAYOUT.IMsg[] = select((s) => s.list);
update({ list: payload.pageNo === 1 ? list : oldList.concat(list) });
try {
const { list } = await call(getMessageList, payload, { paging: { key: 'msgPaging' } });
const oldList: LAYOUT.IMsg[] = select((s) => s.list);
update({ list: payload.pageNo === 1 ? list : oldList.concat(list) });
} catch (e) {
const prevMsgPaging = select((s) => s.msgPaging);
update({ msgPaging: { ...prevMsgPaging, hasMore: false } });
}
},
async getMessageStats({ call, update, select }) {
const orgId = orgStore.getState((s) => s.currentOrg.id);
Expand Down
10 changes: 7 additions & 3 deletions shell/app/modules/application/pages/repo/repo-commit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { map, isEmpty } from 'lodash';
import { map } from 'lodash';
import React from 'react';
import { Spin, Button, Timeline, Input } from 'core/nusi';
import { Copy, LoadMore, Holder, Avatar, IF, ErdaCustomIcon } from 'common';
Expand Down Expand Up @@ -72,9 +72,13 @@ const RepoCommit = () => {
const { appId } = routeInfoStore.useStore((s) => s.params);
const [isFetching] = useLoading(repoStore, ['getCommitList']);
const [searchValue, setSearchValue] = React.useState('');

const branchesStr = JSON.stringify(info?.branches);

React.useEffect(() => {
!isEmpty(info?.branches) && getCommitList({ pageNo: 1 });
}, [getCommitList, info]);
branchesStr && getCommitList({ pageNo: 1 });
}, [branchesStr, getCommitList]);

React.useEffect(() => {
return () => {
resetCommitPaging();
Expand Down
2 changes: 1 addition & 1 deletion shell/app/modules/application/pages/repo/repo-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const RepoTree = ({ tree, info, isFetchingInfo, isFetchingTree }: ITreeProps) =>
const { before, after } = getSplitPathBy('tree');

return (
<div className="repo-tree-holder">
<div className="repo-tree-holder relative">
<EmptyHolder
tip={`${i18n.t('application:current branch or path')}:${after} ${i18n.t('does not exist')}。`}
action={<Link to={before.slice(0, -'/tree'.length)}>{i18n.t('back to repo home')}</Link>}
Expand Down
58 changes: 34 additions & 24 deletions shell/app/modules/application/stores/dataTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,41 +89,51 @@ const dataTask = createStore({
},
async getBusinessProcesses({ call, update, select }, payload) {
const { gitRepo } = appStore.getState((s) => s.detail);
const originalList = select((s) => s.businessProcessList);
const [originalList, businessProcessPaging] = select((s) => [s.businessProcessList, s.businessProcessPaging]);

const { pageNo = 1, pageSize = PAGINATION.pageSize, searchKey, ...rest } = payload;
const params = !isEmpty(searchKey) ? { pageNo, pageSize, keyWord: searchKey } : { pageNo, pageSize };
const { list, total } =
(await call(
getBusinessProcesses,
{ ...params, ...rest, remoteUri: gitRepo },
{ paging: { key: 'businessProcessPaging' } },
)) || {};
let newList = list;
if (pageNo !== 1) {
newList = originalList.concat(list);
try {
const { list, total } =
(await call(
getBusinessProcesses,
{ ...params, ...rest, remoteUri: gitRepo },
{ paging: { key: 'businessProcessPaging' } },
)) || {};
let newList = list;
if (pageNo !== 1) {
newList = originalList.concat(list);
}
update({ businessProcessList: newList });
return { total, list: newList };
} catch (e) {
update({ businessProcessPaging: { ...businessProcessPaging, hasMore: false } });
return { total: 0, list: [] };
}
update({ businessProcessList: newList });
return { total, list: newList };
},
async getOutputTables({ call, update, select }, payload) {
const { gitRepo } = appStore.getState((s) => s.detail);
const originalList = select((s) => s.outputTableList);
const [originalList, outputTablePaging] = select((s) => [s.outputTableList, s.outputTablePaging]);

const { pageNo = 1, pageSize = PAGINATION.pageSize, searchKey, ...rest } = payload;
const params = !isEmpty(searchKey) ? { pageNo, pageSize, keyWord: searchKey } : { pageNo, pageSize };
const { list, total } =
(await call(
getOutputTables,
{ ...params, ...rest, remoteUri: gitRepo },
{ paging: { key: 'outputTablePaging' } },
)) || {};
let newList = originalList;
if (pageNo !== 1) {
newList = originalList.concat(list);
try {
const { list, total } =
(await call(
getOutputTables,
{ ...params, ...rest, remoteUri: gitRepo },
{ paging: { key: 'outputTablePaging' } },
)) || {};
let newList = originalList;
if (pageNo !== 1) {
newList = originalList.concat(list);
}
update({ outputTableList: newList });
return { total, list: newList };
} catch (error) {
update({ outputTablePaging: { ...outputTablePaging, hasMore: false } });
return { total: 0, list: [] };
}
update({ outputTableList: newList });
return { total, list: newList };
},
async getTableAttrs({ call, update }, payload) {
const { list: tableAttrsList = [], total } = await call(getTableAttrs, payload, {
Expand Down
44 changes: 27 additions & 17 deletions shell/app/modules/application/stores/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,27 +483,36 @@ const repoStore = createStore({
async getMrList({ call, select, update }, payload: REPOSITORY.QueryMrs) {
const appDetail = await getAppDetail();
const { pageNo = 1 } = payload;
const originalList = select((state) => state.mrList);
const { list, total } = await call(
getMRs,
{ repoPrefix: appDetail.gitRepoAbbrev, ...payload },
{ paging: { key: 'mrPaging' } },
);
const mrList = pageNo === 1 ? list : [...originalList, ...list];
update({ mrList });
return { list: mrList, total };
const [originalList, mrPaging] = select((state) => [state.mrList, state.mrPaging]);
try {
const { list, total } = await call(
getMRs,
{ repoPrefix: appDetail.gitRepoAbbrev, ...payload },
{ paging: { key: 'mrPaging' } },
);
const mrList = pageNo === 1 ? list : [...originalList, ...list];
update({ mrList });
return { list: mrList, total };
} catch (e) {
update({ mrPaging: { ...mrPaging, hasMore: false } });
return { list: [], total: 0 };
}
},
async getCommitList({ call, select, update }, payload: REPOSITORY.QueryCommit) {
const appDetail = await getAppDetail();
const { commitPaging: paging, commit: prevList } = select((state) => state);
const result = await call(getCommits, {
repoPrefix: appDetail.gitRepoAbbrev,
...paging,
...(payload || {}),
});
const newList = payload.pageNo && payload.pageNo > 1 ? prevList.concat(result) : result;
const hasMore = result.length === paging.pageSize;
update({ commit: newList, commitPaging: { ...paging, ...payload, hasMore } });
try {
const result = await call(getCommits, {
repoPrefix: appDetail.gitRepoAbbrev,
...paging,
...(payload || {}),
});
const newList = payload.pageNo && payload.pageNo > 1 ? prevList.concat(result) : result;
const hasMore = result.length === paging.pageSize;
update({ commit: newList, commitPaging: { ...paging, ...payload, hasMore } });
} catch (e) {
update({ commitPaging: { ...paging, ...payload, hasMore: false } });
laojun marked this conversation as resolved.
Show resolved Hide resolved
}
},
async getCommitDetail({ getParams, call, update }) {
const params = getParams();
Expand Down Expand Up @@ -784,6 +793,7 @@ const repoStore = createStore({
return {
...state,
mrList: [],
mrPaging: getDefaultPaging(),
};
},
},
Expand Down
15 changes: 10 additions & 5 deletions shell/app/modules/publisher/stores/publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,16 @@ const publisher = createStore({
},
// 版本
async getVersionList({ call, update, select }, payload: Parameters<typeof getVersionList>[0]) {
const result = await call(getVersionList, payload, { paging: { key: 'versionPaging' } });
const prevList = select((s) => s.versionList);
const newList = payload.pageNo && payload.pageNo > 1 ? prevList.concat(result.list) : result.list;
update({ versionList: newList });
return { ...result };
const [prevList, versionPaging] = select((s) => [s.versionList, s.versionPaging]);
try {
const result = await call(getVersionList, payload, { paging: { key: 'versionPaging' } });
const newList = payload.pageNo && payload.pageNo > 1 ? prevList.concat(result.list) : result.list;
update({ versionList: newList });
return { ...result };
} catch (e) {
update({ versionPaging: { ...versionPaging, hasMore: false } });
return { list: [], total: 0 };
}
},
async addVersion({ call }, payload: Parameters<typeof addVersion>[0]) {
const res = await call(addVersion, payload, { successMsg: i18n.t('added successfully') });
Expand Down