From 88e6aae09aec28f8eb4e3c9e4398887f57c0231d Mon Sep 17 00:00:00 2001 From: gearnode Date: Tue, 18 Feb 2025 11:31:02 +0100 Subject: [PATCH] Add description to vendor Signed-off-by: gearnode --- apps/console/src/pages/VendorOverviewPage.tsx | 9 ++- ...dorListPageCreateVendorMutation.graphql.ts | 3 +- .../VendorOverviewPageQuery.graphql.ts | 34 ++++++--- pkg/api/console/v1/schema.graphql | 3 + pkg/api/console/v1/schema/schema.go | 76 ++++++++++++++++++- pkg/api/console/v1/types/types.go | 3 + pkg/api/console/v1/types/vendor.go | 1 + .../coredata/migrations/20250218T112800Z.sql | 2 + pkg/probo/coredata/vendor.go | 7 ++ 9 files changed, 119 insertions(+), 19 deletions(-) create mode 100644 pkg/probo/coredata/migrations/20250218T112800Z.sql diff --git a/apps/console/src/pages/VendorOverviewPage.tsx b/apps/console/src/pages/VendorOverviewPage.tsx index 2726043d3..ae052a213 100644 --- a/apps/console/src/pages/VendorOverviewPage.tsx +++ b/apps/console/src/pages/VendorOverviewPage.tsx @@ -22,6 +22,7 @@ const vendorOverviewPageQuery = graphql` ... on Vendor { id name + description serviceStartDate serviceTerminationDate serviceCriticality @@ -55,9 +56,9 @@ function VendorOverviewPageContent({

- {data.node?.name} + {data.node.name}

-

View and manage vendor details

+

{data.node.description}

@@ -76,7 +77,7 @@ function VendorOverviewPageContent({

- {new Date(data.node?.serviceStartDate).toLocaleDateString()} + {new Date(data.node.serviceStartDate).toLocaleDateString()}

@@ -87,7 +88,7 @@ function VendorOverviewPageContent({

- {new Date(data.node?.serviceTerminationDate).toLocaleDateString()} + {new Date(data.node.serviceTerminationDate).toLocaleDateString()}

)} diff --git a/apps/console/src/pages/__generated__/VendorListPageCreateVendorMutation.graphql.ts b/apps/console/src/pages/__generated__/VendorListPageCreateVendorMutation.graphql.ts index bb967181b..917eed081 100644 --- a/apps/console/src/pages/__generated__/VendorListPageCreateVendorMutation.graphql.ts +++ b/apps/console/src/pages/__generated__/VendorListPageCreateVendorMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<055f5292e2ca7bfecd0d701ce34c8d34>> * @lightSyntaxTransform * @nogrep */ @@ -10,6 +10,7 @@ import { ConcreteRequest } from 'relay-runtime'; export type CreateVendorInput = { + description: string; name: string; organizationId: string; }; diff --git a/apps/console/src/pages/__generated__/VendorOverviewPageQuery.graphql.ts b/apps/console/src/pages/__generated__/VendorOverviewPageQuery.graphql.ts index a2319d976..8205e10a8 100644 --- a/apps/console/src/pages/__generated__/VendorOverviewPageQuery.graphql.ts +++ b/apps/console/src/pages/__generated__/VendorOverviewPageQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<939b83dd396154844197ee10514be613>> + * @generated SignedSource<<5e9e499f91b8d971375b191b9ce35f5d>> * @lightSyntaxTransform * @nogrep */ @@ -17,6 +17,7 @@ export type VendorOverviewPageQuery$variables = { export type VendorOverviewPageQuery$data = { readonly node: { readonly createdAt?: any; + readonly description?: string; readonly id?: string; readonly name?: string; readonly riskTier?: RiskTier; @@ -65,45 +66,52 @@ v4 = { "alias": null, "args": null, "kind": "ScalarField", - "name": "serviceStartDate", + "name": "description", "storageKey": null }, v5 = { "alias": null, "args": null, "kind": "ScalarField", - "name": "serviceTerminationDate", + "name": "serviceStartDate", "storageKey": null }, v6 = { "alias": null, "args": null, "kind": "ScalarField", - "name": "serviceCriticality", + "name": "serviceTerminationDate", "storageKey": null }, v7 = { "alias": null, "args": null, "kind": "ScalarField", - "name": "riskTier", + "name": "serviceCriticality", "storageKey": null }, v8 = { "alias": null, "args": null, "kind": "ScalarField", - "name": "statusPageUrl", + "name": "riskTier", "storageKey": null }, v9 = { "alias": null, "args": null, "kind": "ScalarField", - "name": "createdAt", + "name": "statusPageUrl", "storageKey": null }, v10 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "createdAt", + "storageKey": null +}, +v11 = { "alias": null, "args": null, "kind": "ScalarField", @@ -136,7 +144,8 @@ return { (v7/*: any*/), (v8/*: any*/), (v9/*: any*/), - (v10/*: any*/) + (v10/*: any*/), + (v11/*: any*/) ], "type": "Vendor", "abstractKey": null @@ -180,7 +189,8 @@ return { (v7/*: any*/), (v8/*: any*/), (v9/*: any*/), - (v10/*: any*/) + (v10/*: any*/), + (v11/*: any*/) ], "type": "Vendor", "abstractKey": null @@ -191,16 +201,16 @@ return { ] }, "params": { - "cacheID": "c9d7bade02d1802838f6ac3b02ef7c9a", + "cacheID": "04e4ae3f0c7613bf50b59368d02ba937", "id": null, "metadata": {}, "name": "VendorOverviewPageQuery", "operationKind": "query", - "text": "query VendorOverviewPageQuery(\n $vendorId: ID!\n) {\n node(id: $vendorId) {\n __typename\n ... on Vendor {\n id\n name\n serviceStartDate\n serviceTerminationDate\n serviceCriticality\n riskTier\n statusPageUrl\n createdAt\n updatedAt\n }\n id\n }\n}\n" + "text": "query VendorOverviewPageQuery(\n $vendorId: ID!\n) {\n node(id: $vendorId) {\n __typename\n ... on Vendor {\n id\n name\n description\n serviceStartDate\n serviceTerminationDate\n serviceCriticality\n riskTier\n statusPageUrl\n createdAt\n updatedAt\n }\n id\n }\n}\n" } }; })(); -(node as any).hash = "92a640f674261d28028d752f027ec141"; +(node as any).hash = "474b8b7350d917a50c91a0b8239370ea"; export default node; diff --git a/pkg/api/console/v1/schema.graphql b/pkg/api/console/v1/schema.graphql index 8929d564e..cc0973182 100644 --- a/pkg/api/console/v1/schema.graphql +++ b/pkg/api/console/v1/schema.graphql @@ -115,6 +115,7 @@ type VendorEdge { type Vendor implements Node { id: ID! name: String! + description: String! createdAt: Datetime! updatedAt: Datetime! serviceStartDate: Datetime! @@ -318,6 +319,7 @@ type Mutation { input CreateVendorInput { organizationId: ID! name: String! + description: String! } input DeleteVendorInput { @@ -350,6 +352,7 @@ enum RiskTier @goModel(model: "github.com/getprobo/probo/pkg/probo/coredata.Risk input UpdateVendorInput { id: ID! name: String + description: String serviceStartDate: Datetime serviceTerminationDate: Datetime serviceCriticality: ServiceCriticality diff --git a/pkg/api/console/v1/schema/schema.go b/pkg/api/console/v1/schema/schema.go index ca13a2958..c5e1561e7 100644 --- a/pkg/api/console/v1/schema/schema.go +++ b/pkg/api/console/v1/schema/schema.go @@ -246,6 +246,7 @@ type ComplexityRoot struct { Vendor struct { CreatedAt func(childComplexity int) int + Description func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int RiskTier func(childComplexity int) int @@ -1127,6 +1128,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Vendor.CreatedAt(childComplexity), true + case "Vendor.description": + if e.complexity.Vendor.Description == nil { + break + } + + return e.complexity.Vendor.Description(childComplexity), true + case "Vendor.id": if e.complexity.Vendor.ID == nil { break @@ -1438,6 +1446,7 @@ type VendorEdge { type Vendor implements Node { id: ID! name: String! + description: String! createdAt: Datetime! updatedAt: Datetime! serviceStartDate: Datetime! @@ -1641,6 +1650,7 @@ type Mutation { input CreateVendorInput { organizationId: ID! name: String! + description: String! } input DeleteVendorInput { @@ -1673,6 +1683,7 @@ enum RiskTier @goModel(model: "github.com/getprobo/probo/pkg/probo/coredata.Risk input UpdateVendorInput { id: ID! name: String + description: String serviceStartDate: Datetime serviceTerminationDate: Datetime serviceCriticality: ServiceCriticality @@ -4890,6 +4901,8 @@ func (ec *executionContext) fieldContext_Mutation_createVendor(ctx context.Conte return ec.fieldContext_Vendor_id(ctx, field) case "name": return ec.fieldContext_Vendor_name(ctx, field) + case "description": + return ec.fieldContext_Vendor_description(ctx, field) case "createdAt": return ec.fieldContext_Vendor_createdAt(ctx, field) case "updatedAt": @@ -7140,6 +7153,44 @@ func (ec *executionContext) fieldContext_Vendor_name(_ context.Context, field gr return fc, nil } +func (ec *executionContext) _Vendor_description(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Vendor_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Vendor_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Vendor", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Vendor_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Vendor_createdAt(ctx, field) if err != nil { @@ -7567,6 +7618,8 @@ func (ec *executionContext) fieldContext_VendorEdge_node(_ context.Context, fiel return ec.fieldContext_Vendor_id(ctx, field) case "name": return ec.fieldContext_Vendor_name(ctx, field) + case "description": + return ec.fieldContext_Vendor_description(ctx, field) case "createdAt": return ec.fieldContext_Vendor_createdAt(ctx, field) case "updatedAt": @@ -9194,7 +9247,7 @@ func (ec *executionContext) unmarshalInputCreateVendorInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"organizationId", "name"} + fieldsInOrder := [...]string{"organizationId", "name", "description"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -9215,6 +9268,13 @@ func (ec *executionContext) unmarshalInputCreateVendorInput(ctx context.Context, return it, err } it.Name = data + case "description": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Description = data } } @@ -9282,7 +9342,7 @@ func (ec *executionContext) unmarshalInputUpdateVendorInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"id", "name", "serviceStartDate", "serviceTerminationDate", "serviceCriticality", "riskTier", "statusPageUrl"} + fieldsInOrder := [...]string{"id", "name", "description", "serviceStartDate", "serviceTerminationDate", "serviceCriticality", "riskTier", "statusPageUrl"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -9303,6 +9363,13 @@ func (ec *executionContext) unmarshalInputUpdateVendorInput(ctx context.Context, return it, err } it.Name = data + case "description": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Description = data case "serviceStartDate": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceStartDate")) data, err := ec.unmarshalODatetime2ᚖtimeᚐTime(ctx, v) @@ -11162,6 +11229,11 @@ func (ec *executionContext) _Vendor(ctx context.Context, sel ast.SelectionSet, o if out.Values[i] == graphql.Null { out.Invalids++ } + case "description": + out.Values[i] = ec._Vendor_description(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "createdAt": out.Values[i] = ec._Vendor_createdAt(ctx, field, obj) if out.Values[i] == graphql.Null { diff --git a/pkg/api/console/v1/types/types.go b/pkg/api/console/v1/types/types.go index ecce84622..9606fea19 100644 --- a/pkg/api/console/v1/types/types.go +++ b/pkg/api/console/v1/types/types.go @@ -69,6 +69,7 @@ type CreatePeopleInput struct { type CreateVendorInput struct { OrganizationID gid.GID `json:"organizationId"` Name string `json:"name"` + Description string `json:"description"` } type DeletePeopleInput struct { @@ -240,6 +241,7 @@ type TaskStateTransitionEdge struct { type UpdateVendorInput struct { ID gid.GID `json:"id"` Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` ServiceStartDate *time.Time `json:"serviceStartDate,omitempty"` ServiceTerminationDate *time.Time `json:"serviceTerminationDate,omitempty"` ServiceCriticality *coredata.ServiceCriticality `json:"serviceCriticality,omitempty"` @@ -250,6 +252,7 @@ type UpdateVendorInput struct { type Vendor struct { ID gid.GID `json:"id"` Name string `json:"name"` + Description string `json:"description"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` ServiceStartDate time.Time `json:"serviceStartDate"` diff --git a/pkg/api/console/v1/types/vendor.go b/pkg/api/console/v1/types/vendor.go index 3491a321f..47b25c0c5 100644 --- a/pkg/api/console/v1/types/vendor.go +++ b/pkg/api/console/v1/types/vendor.go @@ -43,6 +43,7 @@ func NewVendor(v *coredata.Vendor) *Vendor { return &Vendor{ ID: v.ID, Name: v.Name, + Description: v.Description, CreatedAt: v.CreatedAt, UpdatedAt: v.UpdatedAt, ServiceStartDate: v.ServiceStartDate, diff --git a/pkg/probo/coredata/migrations/20250218T112800Z.sql b/pkg/probo/coredata/migrations/20250218T112800Z.sql new file mode 100644 index 000000000..14e851c71 --- /dev/null +++ b/pkg/probo/coredata/migrations/20250218T112800Z.sql @@ -0,0 +1,2 @@ +ALTER TABLE vendors ADD COLUMN description TEXT NOT NULL DEFAULT ''; +ALTER TABLE vendors ALTER COLUMN description DROP DEFAULT; \ No newline at end of file diff --git a/pkg/probo/coredata/vendor.go b/pkg/probo/coredata/vendor.go index d72a4d7a7..6841e927a 100644 --- a/pkg/probo/coredata/vendor.go +++ b/pkg/probo/coredata/vendor.go @@ -31,6 +31,7 @@ type ( ID gid.GID OrganizationID gid.GID Name string + Description string ServiceStartDate time.Time ServiceTerminationDate *time.Time ServiceCriticality ServiceCriticality @@ -52,6 +53,7 @@ func (v *Vendor) scan(r pgx.Row) error { &v.ID, &v.OrganizationID, &v.Name, + &v.Description, &v.ServiceStartDate, &v.ServiceTerminationDate, &v.ServiceCriticality, @@ -73,6 +75,7 @@ SELECT id, organization_id, name, + description, service_start_date, service_termination_date, service_criticality, @@ -115,6 +118,7 @@ INSERT INTO id, organization_id, name, + description, service_start_date, service_termination_date, service_criticality, @@ -127,6 +131,7 @@ VALUES ( @vendor_id, @organization_id, @name, + @description, @service_start_date, @service_termination_date, @service_criticality, @@ -141,6 +146,7 @@ VALUES ( "vendor_id": v.ID, "organization_id": v.OrganizationID, "name": v.Name, + "description": v.Description, "service_start_date": v.ServiceStartDate, "service_termination_date": v.ServiceTerminationDate, "service_criticality": v.ServiceCriticality, @@ -183,6 +189,7 @@ SELECT id, organization_id, name, + description, service_start_date, service_termination_date, service_criticality,