Skip to content

Commit

Permalink
fix: per inherit error
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Jul 25, 2024
1 parent d0cc043 commit 14cd205
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/preview-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

jobs:
build-fastgpt-images:
preview-fastgpt-images:
runs-on: ubuntu-20.04
steps:
- name: Checkout
Expand Down
12 changes: 12 additions & 0 deletions docSite/content/zh-cn/docs/development/upgrading/488.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ weight: 816
- fastgpt 镜像 tag 修改成 v4.8.8-alpha
- 商业版镜像 tag 修改成 v4.8.8-alpha

### 3. 执行初始化

从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`;{{host}} 替换成**FastGPT 域名**

```bash
curl --location --request POST 'https://{{host}}/api/admin/initv48 8' \
--header 'rootkey: {{rootkey}}' \
--header 'Content-Type: application/json'
```

会初始化知识库的继承权限

-------

## V4.8.8 更新说明
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ConfigPerModal = ({
>
<ModalBody>
<HStack>
<Avatar src={avatar} w={'1.75rem'} />
<Avatar src={avatar} w={'1.75rem'} borderRadius={'md'} />
<Box>{name}</Box>
</HStack>
{!isInheritPermission && (
Expand Down
33 changes: 33 additions & 0 deletions projects/app/src/pages/api/admin/initv488.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { jsonRes } from '@fastgpt/service/common/response';
import { connectToDatabase } from '@/service/mongo';
import { authCert } from '@fastgpt/service/support/permission/auth/common';
import { MongoDataset } from '@fastgpt/service/core/dataset/schema';

/* pg 中的数据搬到 mongo dataset.datas 中,并做映射 */
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
await connectToDatabase();
await authCert({ req, authRoot: true });

await MongoDataset.updateMany(
{},
{
$set: {
inheritPermission: true
}
}
);

jsonRes(res, {
message: 'success'
});
} catch (error) {
console.log(error);

jsonRes(res, {
code: 500,
error
});
}
}
2 changes: 1 addition & 1 deletion projects/app/src/pages/api/core/app/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async function handler(req: ApiRequestProps<AppUpdateParams, { appId: string }>)
defaultPermission: updatedDefaultPermission
}),
// Not root, update default permission
...(isDefaultPermissionChanged && { inheritPermission: false }),
...(app.parentId && isDefaultPermissionChanged && { inheritPermission: false }),
...(teamTags && { teamTags }),
...(formatNodes && {
modules: formatNodes
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/pages/api/core/dataset/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function handler(
defaultPermission: updatedDefaultPermission
}),
// update the defaultPermission
...(isDefaultPermissionChanged && { inheritPermission: false })
...(dataset.parentId && isDefaultPermissionChanged && { inheritPermission: false })
},
{ session }
);
Expand Down
1 change: 0 additions & 1 deletion projects/app/src/pages/app/list/components/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { AppUpdateParams } from '@/global/core/app/api';
import dynamic from 'next/dynamic';
import { useI18n } from '@/web/context/I18n';
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import { useThrottleEffect } from 'ahooks';
const MoveModal = dynamic(() => import('@/components/common/folder/MoveModal'));

type AppListContextType = {
Expand Down
19 changes: 7 additions & 12 deletions projects/app/src/pages/dataset/list/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {

const { parentId = null } = router.query as { parentId?: string | null };

const { data: myDatasets = [], runAsync: loadMyDatasets } = useRequest2(
const {
data: myDatasets = [],
runAsync: loadMyDatasets,
loading: isFetchingDatasets
} = useRequest2(
() =>
getDatasets({
parentId
Expand All @@ -83,7 +87,7 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
() => (parentId ? getDatasetById(parentId) : Promise.resolve(undefined)),
{
manual: false,
refreshDeps: [parentId, myDatasets]
refreshDeps: [parentId]
}
);

Expand All @@ -95,16 +99,8 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
}
);

const { runAsync: refetchDatasets, loading: isFetchingDatasets } = useRequest2(
() => loadMyDatasets(),
{
manual: false,
refreshDeps: [parentId]
}
);

const { runAsync: onUpdateDataset } = useRequest2(putDatasetById, {
onSuccess: () => Promise.all([refetchDatasets(), refetchPaths(), loadMyDatasets()])
onSuccess: () => Promise.all([refetchFolderDetail(), refetchPaths(), loadMyDatasets()])
});

const onMoveDataset = useCallback(
Expand Down Expand Up @@ -138,7 +134,6 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
});

const contextValue = {
refetchDatasets,
isFetchingDatasets,
setMoveDatasetId,
paths,
Expand Down

0 comments on commit 14cd205

Please sign in to comment.