Browse Source

支持privacy

visuddhinanda 1 year ago
parent
commit
31ca51e832

+ 2 - 0
api-v8/app/Http/Controllers/ProjectController.php

@@ -43,6 +43,7 @@ class ProjectController extends Controller
             case 'community':
                 $table = Project::where('owner_id', '<>', $studioId)
                     ->whereNull('parent_id')
+                    ->where('privacy', 'public')
                     ->where('type', $request->get('type', 'instance'));
                 break;
             default:
@@ -161,6 +162,7 @@ class ProjectController extends Controller
         $project->description = $request->get('description');
         $project->parent_id = $request->get('parent_id');
         $project->editor_id = $user['user_uid'];
+        $project->privacy = $request->get('privacy');
 
 
         if (Str::isUuid($request->get('parent_id'))) {

+ 1 - 0
api-v8/app/Http/Resources/ProjectResource.php

@@ -30,6 +30,7 @@ class ProjectResource extends JsonResource
             'description' => $this->description,
             "owner" => StudioApi::getById($this->owner_id),
             "editor" => UserApi::getByUuid($this->editor_id),
+            'privacy' => $this->privacy,
             'created_at' => $this->created_at,
             'updated_at' => $this->updated_at,
         ];

+ 1 - 1
dashboard-v4/dashboard/src/components/api/ai.ts

@@ -1,7 +1,7 @@
 import { IStudio } from "../auth/Studio";
 import { IUser } from "../auth/User";
 
-export type TPrivacy = "private" | "public";
+export type TPrivacy = "private" | "public" | "disable";
 
 export interface IKimiResponse {
   id: string;

+ 3 - 0
dashboard-v4/dashboard/src/components/api/task.ts

@@ -14,6 +14,7 @@
 
 import { IStudio } from "../auth/Studio";
 import { IUser } from "../auth/User";
+import { TPrivacy } from "./ai";
 
 export type TTaskStatus =
   | "pending"
@@ -152,6 +153,7 @@ export interface IProjectData {
   owner: IStudio;
   editor: IUser;
   status: ITaskStatusInProject[];
+  privacy: TPrivacy;
   created_at: string;
   updated_at: string;
   deleted_at?: string | null;
@@ -165,6 +167,7 @@ export interface IProjectUpdateRequest {
   studio_name?: string;
   title: string;
   type: TProjectType;
+  privacy?: TPrivacy;
   weight?: number;
   description?: string | null;
   parent_id?: string | null;

+ 7 - 0
dashboard-v4/dashboard/src/components/task/ProjectEdit.tsx

@@ -11,6 +11,7 @@ import {
 } from "../api/task";
 import { get, patch } from "../../request";
 import { useIntl } from "react-intl";
+import Publicity from "../studio/Publicity";
 
 interface IWidget {
   projectId?: string;
@@ -59,6 +60,12 @@ const ProjectEdit = ({ projectId }: IWidget) => {
           readonly
         />
       </ProForm.Group>
+      <ProForm.Group>
+        <Publicity
+          name="privacy"
+          disable={["disable", "public_no_list", "blocked"]}
+        />
+      </ProForm.Group>
       <ProForm.Group>
         <ProFormTextArea
           width="md"