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

feat: added contributors field in projects #1534

Merged
merged 2 commits into from
Dec 12, 2023
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
180 changes: 176 additions & 4 deletions .forestadmin-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,23 @@
"type": ["String"],
"validations": []
},
{
"defaultValue": null,
"enums": null,
"field": "ProjectContributors",
"integration": null,
"inverseOf": "Member",
"isFilterable": false,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": false,
"isSortable": false,
"isVirtual": false,
"reference": "ProjectContributor.uid",
"relationship": "HasMany",
"type": ["String"],
"validations": []
},
{
"defaultValue": null,
"enums": null,
Expand Down Expand Up @@ -2179,6 +2196,23 @@
"type": ["String"],
"validations": []
},
{
"defaultValue": null,
"enums": null,
"field": "ProjectContributors",
"integration": null,
"inverseOf": "Project",
"isFilterable": false,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": false,
"isSortable": false,
"isVirtual": false,
"reference": "ProjectContributor.uid",
"relationship": "HasMany",
"type": ["String"],
"validations": []
},
{
"defaultValue": null,
"enums": null,
Expand Down Expand Up @@ -2224,14 +2258,12 @@
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": true,
"isRequired": false,
"isSortable": true,
"isVirtual": false,
"reference": null,
"type": "String",
"validations": [
{"type": "is present", "message": "Failed validation rule: 'Present'"}
]
"validations": []
},
{
"defaultValue": null,
Expand Down Expand Up @@ -2618,6 +2650,129 @@
"paginationType": "page",
"segments": []
},
{
"actions": [],
"fields": [
{
"defaultValue": null,
"enums": null,
"field": "Member",
"integration": null,
"inverseOf": "ProjectContributors",
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": true,
"isSortable": true,
"isVirtual": false,
"reference": "Member.uid",
"relationship": "BelongsTo",
"type": "String",
"validations": [
{"type": "is present", "message": "Failed validation rule: 'Present'"}
]
},
{
"defaultValue": null,
"enums": null,
"field": "Project",
"integration": null,
"inverseOf": "ProjectContributors",
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": true,
"isSortable": true,
"isVirtual": false,
"reference": "Project.uid",
"relationship": "BelongsTo",
"type": "String",
"validations": [
{"type": "is present", "message": "Failed validation rule: 'Present'"}
]
},
{
"defaultValue": null,
"enums": null,
"field": "Team",
"integration": null,
"inverseOf": "ProjectContributors",
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": true,
"isSortable": true,
"isVirtual": false,
"reference": "Team.uid",
"relationship": "BelongsTo",
"type": "String",
"validations": [
{"type": "is present", "message": "Failed validation rule: 'Present'"}
]
},
{
"defaultValue": null,
"enums": null,
"field": "id",
"integration": null,
"inverseOf": null,
"isFilterable": true,
"isPrimaryKey": true,
"isReadOnly": true,
"isRequired": false,
"isSortable": true,
"isVirtual": false,
"reference": null,
"type": "Number",
"validations": []
},
{
"defaultValue": null,
"enums": null,
"field": "type",
"integration": null,
"inverseOf": null,
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": true,
"isSortable": true,
"isVirtual": false,
"reference": null,
"type": "String",
"validations": [
{"type": "is present", "message": "Failed validation rule: 'Present'"}
]
},
{
"defaultValue": null,
"enums": null,
"field": "uid",
"integration": null,
"inverseOf": null,
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": true,
"isSortable": true,
"isVirtual": false,
"reference": null,
"type": "String",
"validations": [
{"type": "is present", "message": "Failed validation rule: 'Present'"}
]
}
],
"icon": null,
"integration": null,
"isReadOnly": false,
"isSearchable": true,
"isVirtual": false,
"name": "ProjectContributor",
"onlyForRelationships": false,
"paginationType": "page",
"segments": []
},
{
"actions": [],
"fields": [
Expand Down Expand Up @@ -2799,6 +2954,23 @@
"type": "String",
"validations": []
},
{
"defaultValue": null,
"enums": null,
"field": "ProjectContributors",
"integration": null,
"inverseOf": "Team",
"isFilterable": false,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": false,
"isSortable": false,
"isVirtual": false,
"reference": "ProjectContributor.uid",
"relationship": "HasMany",
"type": ["String"],
"validations": []
},
{
"defaultValue": null,
"enums": null,
Expand Down
2 changes: 1 addition & 1 deletion apps/web-api/prisma/fixtures/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const ProjectFactory = Factory.define<Omit<Project, 'id'>>(
export const projects = async () => await ProjectFactory.createList(25);

export const projectRelations = async (projects) => {
const teamUids = await getUidsFrom(Prisma.ModelName.Team);
const teamUids = await (await getUidsFrom(Prisma.ModelName.Team));

return projects.map((project) => {
const randomTeams = sampleSize(teamUids, random(0, 5));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- CreateTable
CREATE TABLE "ProjectContributor" (
"id" SERIAL NOT NULL,
"uid" TEXT NOT NULL,
"type" TEXT NOT NULL,
"projectUid" TEXT NOT NULL,
"teamUid" TEXT NOT NULL,
"memberUid" TEXT NOT NULL,

CONSTRAINT "ProjectContributor_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "ProjectContributor_uid_key" ON "ProjectContributor"("uid");

-- AddForeignKey
ALTER TABLE "ProjectContributor" ADD CONSTRAINT "ProjectContributor_projectUid_fkey" FOREIGN KEY ("projectUid") REFERENCES "Project"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ProjectContributor" ADD CONSTRAINT "ProjectContributor_teamUid_fkey" FOREIGN KEY ("teamUid") REFERENCES "Team"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ProjectContributor" ADD CONSTRAINT "ProjectContributor_memberUid_fkey" FOREIGN KEY ("memberUid") REFERENCES "Member"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Warnings:

- Changed the type of `type` on the `ProjectContributor` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.

*/
-- CreateEnum
CREATE TYPE "ProjectContributorType" AS ENUM ('MAINTENER', 'COLLABORATOR');

-- AlterTable
ALTER TABLE "ProjectContributor" DROP COLUMN "type",
ADD COLUMN "type" "ProjectContributorType" NOT NULL;
Loading