Add description to vendor

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-02-18 11:31:02 +01:00
parent 6da223ed36
commit 88e6aae09a
9 changed files with 119 additions and 19 deletions

View File

@@ -22,6 +22,7 @@ const vendorOverviewPageQuery = graphql`
... on Vendor { ... on Vendor {
id id
name name
description
serviceStartDate serviceStartDate
serviceTerminationDate serviceTerminationDate
serviceCriticality serviceCriticality
@@ -55,9 +56,9 @@ function VendorOverviewPageContent({
<div className="mx-auto max-w-4xl space-y-6"> <div className="mx-auto max-w-4xl space-y-6">
<div className="space-y-2"> <div className="space-y-2">
<h1 className="text-xl font-semibold text-gray-900"> <h1 className="text-xl font-semibold text-gray-900">
{data.node?.name} {data.node.name}
</h1> </h1>
<p className="text-gray-600">View and manage vendor details</p> <p className="text-gray-600">{data.node.description}</p>
</div> </div>
<Card className="p-6"> <Card className="p-6">
@@ -76,7 +77,7 @@ function VendorOverviewPageContent({
<Label className="text-sm">Service Start Date</Label> <Label className="text-sm">Service Start Date</Label>
</div> </div>
<p className="text-sm text-gray-600"> <p className="text-sm text-gray-600">
{new Date(data.node?.serviceStartDate).toLocaleDateString()} {new Date(data.node.serviceStartDate).toLocaleDateString()}
</p> </p>
</div> </div>
@@ -87,7 +88,7 @@ function VendorOverviewPageContent({
<Label className="text-sm">Service Termination Date</Label> <Label className="text-sm">Service Termination Date</Label>
</div> </div>
<p className="text-sm text-gray-600"> <p className="text-sm text-gray-600">
{new Date(data.node?.serviceTerminationDate).toLocaleDateString()} {new Date(data.node.serviceTerminationDate).toLocaleDateString()}
</p> </p>
</div> </div>
)} )}

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<c905d68569a5158d7e5a0ee5eb600a2b>> * @generated SignedSource<<055f5292e2ca7bfecd0d701ce34c8d34>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -10,6 +10,7 @@
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type CreateVendorInput = { export type CreateVendorInput = {
description: string;
name: string; name: string;
organizationId: string; organizationId: string;
}; };

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<939b83dd396154844197ee10514be613>> * @generated SignedSource<<5e9e499f91b8d971375b191b9ce35f5d>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -17,6 +17,7 @@ export type VendorOverviewPageQuery$variables = {
export type VendorOverviewPageQuery$data = { export type VendorOverviewPageQuery$data = {
readonly node: { readonly node: {
readonly createdAt?: any; readonly createdAt?: any;
readonly description?: string;
readonly id?: string; readonly id?: string;
readonly name?: string; readonly name?: string;
readonly riskTier?: RiskTier; readonly riskTier?: RiskTier;
@@ -65,45 +66,52 @@ v4 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "serviceStartDate", "name": "description",
"storageKey": null "storageKey": null
}, },
v5 = { v5 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "serviceTerminationDate", "name": "serviceStartDate",
"storageKey": null "storageKey": null
}, },
v6 = { v6 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "serviceCriticality", "name": "serviceTerminationDate",
"storageKey": null "storageKey": null
}, },
v7 = { v7 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "riskTier", "name": "serviceCriticality",
"storageKey": null "storageKey": null
}, },
v8 = { v8 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "statusPageUrl", "name": "riskTier",
"storageKey": null "storageKey": null
}, },
v9 = { v9 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "createdAt", "name": "statusPageUrl",
"storageKey": null "storageKey": null
}, },
v10 = { v10 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
v11 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
@@ -136,7 +144,8 @@ return {
(v7/*: any*/), (v7/*: any*/),
(v8/*: any*/), (v8/*: any*/),
(v9/*: any*/), (v9/*: any*/),
(v10/*: any*/) (v10/*: any*/),
(v11/*: any*/)
], ],
"type": "Vendor", "type": "Vendor",
"abstractKey": null "abstractKey": null
@@ -180,7 +189,8 @@ return {
(v7/*: any*/), (v7/*: any*/),
(v8/*: any*/), (v8/*: any*/),
(v9/*: any*/), (v9/*: any*/),
(v10/*: any*/) (v10/*: any*/),
(v11/*: any*/)
], ],
"type": "Vendor", "type": "Vendor",
"abstractKey": null "abstractKey": null
@@ -191,16 +201,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "c9d7bade02d1802838f6ac3b02ef7c9a", "cacheID": "04e4ae3f0c7613bf50b59368d02ba937",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "VendorOverviewPageQuery", "name": "VendorOverviewPageQuery",
"operationKind": "query", "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; export default node;

View File

@@ -115,6 +115,7 @@ type VendorEdge {
type Vendor implements Node { type Vendor implements Node {
id: ID! id: ID!
name: String! name: String!
description: String!
createdAt: Datetime! createdAt: Datetime!
updatedAt: Datetime! updatedAt: Datetime!
serviceStartDate: Datetime! serviceStartDate: Datetime!
@@ -318,6 +319,7 @@ type Mutation {
input CreateVendorInput { input CreateVendorInput {
organizationId: ID! organizationId: ID!
name: String! name: String!
description: String!
} }
input DeleteVendorInput { input DeleteVendorInput {
@@ -350,6 +352,7 @@ enum RiskTier @goModel(model: "github.com/getprobo/probo/pkg/probo/coredata.Risk
input UpdateVendorInput { input UpdateVendorInput {
id: ID! id: ID!
name: String name: String
description: String
serviceStartDate: Datetime serviceStartDate: Datetime
serviceTerminationDate: Datetime serviceTerminationDate: Datetime
serviceCriticality: ServiceCriticality serviceCriticality: ServiceCriticality

View File

@@ -246,6 +246,7 @@ type ComplexityRoot struct {
Vendor struct { Vendor struct {
CreatedAt func(childComplexity int) int CreatedAt func(childComplexity int) int
Description func(childComplexity int) int
ID func(childComplexity int) int ID func(childComplexity int) int
Name func(childComplexity int) int Name func(childComplexity int) int
RiskTier 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 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": case "Vendor.id":
if e.complexity.Vendor.ID == nil { if e.complexity.Vendor.ID == nil {
break break
@@ -1438,6 +1446,7 @@ type VendorEdge {
type Vendor implements Node { type Vendor implements Node {
id: ID! id: ID!
name: String! name: String!
description: String!
createdAt: Datetime! createdAt: Datetime!
updatedAt: Datetime! updatedAt: Datetime!
serviceStartDate: Datetime! serviceStartDate: Datetime!
@@ -1641,6 +1650,7 @@ type Mutation {
input CreateVendorInput { input CreateVendorInput {
organizationId: ID! organizationId: ID!
name: String! name: String!
description: String!
} }
input DeleteVendorInput { input DeleteVendorInput {
@@ -1673,6 +1683,7 @@ enum RiskTier @goModel(model: "github.com/getprobo/probo/pkg/probo/coredata.Risk
input UpdateVendorInput { input UpdateVendorInput {
id: ID! id: ID!
name: String name: String
description: String
serviceStartDate: Datetime serviceStartDate: Datetime
serviceTerminationDate: Datetime serviceTerminationDate: Datetime
serviceCriticality: ServiceCriticality serviceCriticality: ServiceCriticality
@@ -4890,6 +4901,8 @@ func (ec *executionContext) fieldContext_Mutation_createVendor(ctx context.Conte
return ec.fieldContext_Vendor_id(ctx, field) return ec.fieldContext_Vendor_id(ctx, field)
case "name": case "name":
return ec.fieldContext_Vendor_name(ctx, field) return ec.fieldContext_Vendor_name(ctx, field)
case "description":
return ec.fieldContext_Vendor_description(ctx, field)
case "createdAt": case "createdAt":
return ec.fieldContext_Vendor_createdAt(ctx, field) return ec.fieldContext_Vendor_createdAt(ctx, field)
case "updatedAt": case "updatedAt":
@@ -7140,6 +7153,44 @@ func (ec *executionContext) fieldContext_Vendor_name(_ context.Context, field gr
return fc, nil 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) { 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) fc, err := ec.fieldContext_Vendor_createdAt(ctx, field)
if err != nil { if err != nil {
@@ -7567,6 +7618,8 @@ func (ec *executionContext) fieldContext_VendorEdge_node(_ context.Context, fiel
return ec.fieldContext_Vendor_id(ctx, field) return ec.fieldContext_Vendor_id(ctx, field)
case "name": case "name":
return ec.fieldContext_Vendor_name(ctx, field) return ec.fieldContext_Vendor_name(ctx, field)
case "description":
return ec.fieldContext_Vendor_description(ctx, field)
case "createdAt": case "createdAt":
return ec.fieldContext_Vendor_createdAt(ctx, field) return ec.fieldContext_Vendor_createdAt(ctx, field)
case "updatedAt": case "updatedAt":
@@ -9194,7 +9247,7 @@ func (ec *executionContext) unmarshalInputCreateVendorInput(ctx context.Context,
asMap[k] = v asMap[k] = v
} }
fieldsInOrder := [...]string{"organizationId", "name"} fieldsInOrder := [...]string{"organizationId", "name", "description"}
for _, k := range fieldsInOrder { for _, k := range fieldsInOrder {
v, ok := asMap[k] v, ok := asMap[k]
if !ok { if !ok {
@@ -9215,6 +9268,13 @@ func (ec *executionContext) unmarshalInputCreateVendorInput(ctx context.Context,
return it, err return it, err
} }
it.Name = data 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 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 { for _, k := range fieldsInOrder {
v, ok := asMap[k] v, ok := asMap[k]
if !ok { if !ok {
@@ -9303,6 +9363,13 @@ func (ec *executionContext) unmarshalInputUpdateVendorInput(ctx context.Context,
return it, err return it, err
} }
it.Name = data 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": case "serviceStartDate":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceStartDate")) ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("serviceStartDate"))
data, err := ec.unmarshalODatetime2ᚖtimeᚐTime(ctx, v) 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 { if out.Values[i] == graphql.Null {
out.Invalids++ out.Invalids++
} }
case "description":
out.Values[i] = ec._Vendor_description(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "createdAt": case "createdAt":
out.Values[i] = ec._Vendor_createdAt(ctx, field, obj) out.Values[i] = ec._Vendor_createdAt(ctx, field, obj)
if out.Values[i] == graphql.Null { if out.Values[i] == graphql.Null {

View File

@@ -69,6 +69,7 @@ type CreatePeopleInput struct {
type CreateVendorInput struct { type CreateVendorInput struct {
OrganizationID gid.GID `json:"organizationId"` OrganizationID gid.GID `json:"organizationId"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"`
} }
type DeletePeopleInput struct { type DeletePeopleInput struct {
@@ -240,6 +241,7 @@ type TaskStateTransitionEdge struct {
type UpdateVendorInput struct { type UpdateVendorInput struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
ServiceStartDate *time.Time `json:"serviceStartDate,omitempty"` ServiceStartDate *time.Time `json:"serviceStartDate,omitempty"`
ServiceTerminationDate *time.Time `json:"serviceTerminationDate,omitempty"` ServiceTerminationDate *time.Time `json:"serviceTerminationDate,omitempty"`
ServiceCriticality *coredata.ServiceCriticality `json:"serviceCriticality,omitempty"` ServiceCriticality *coredata.ServiceCriticality `json:"serviceCriticality,omitempty"`
@@ -250,6 +252,7 @@ type UpdateVendorInput struct {
type Vendor struct { type Vendor struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
ServiceStartDate time.Time `json:"serviceStartDate"` ServiceStartDate time.Time `json:"serviceStartDate"`

View File

@@ -43,6 +43,7 @@ func NewVendor(v *coredata.Vendor) *Vendor {
return &Vendor{ return &Vendor{
ID: v.ID, ID: v.ID,
Name: v.Name, Name: v.Name,
Description: v.Description,
CreatedAt: v.CreatedAt, CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt, UpdatedAt: v.UpdatedAt,
ServiceStartDate: v.ServiceStartDate, ServiceStartDate: v.ServiceStartDate,

View File

@@ -0,0 +1,2 @@
ALTER TABLE vendors ADD COLUMN description TEXT NOT NULL DEFAULT '';
ALTER TABLE vendors ALTER COLUMN description DROP DEFAULT;

View File

@@ -31,6 +31,7 @@ type (
ID gid.GID ID gid.GID
OrganizationID gid.GID OrganizationID gid.GID
Name string Name string
Description string
ServiceStartDate time.Time ServiceStartDate time.Time
ServiceTerminationDate *time.Time ServiceTerminationDate *time.Time
ServiceCriticality ServiceCriticality ServiceCriticality ServiceCriticality
@@ -52,6 +53,7 @@ func (v *Vendor) scan(r pgx.Row) error {
&v.ID, &v.ID,
&v.OrganizationID, &v.OrganizationID,
&v.Name, &v.Name,
&v.Description,
&v.ServiceStartDate, &v.ServiceStartDate,
&v.ServiceTerminationDate, &v.ServiceTerminationDate,
&v.ServiceCriticality, &v.ServiceCriticality,
@@ -73,6 +75,7 @@ SELECT
id, id,
organization_id, organization_id,
name, name,
description,
service_start_date, service_start_date,
service_termination_date, service_termination_date,
service_criticality, service_criticality,
@@ -115,6 +118,7 @@ INSERT INTO
id, id,
organization_id, organization_id,
name, name,
description,
service_start_date, service_start_date,
service_termination_date, service_termination_date,
service_criticality, service_criticality,
@@ -127,6 +131,7 @@ VALUES (
@vendor_id, @vendor_id,
@organization_id, @organization_id,
@name, @name,
@description,
@service_start_date, @service_start_date,
@service_termination_date, @service_termination_date,
@service_criticality, @service_criticality,
@@ -141,6 +146,7 @@ VALUES (
"vendor_id": v.ID, "vendor_id": v.ID,
"organization_id": v.OrganizationID, "organization_id": v.OrganizationID,
"name": v.Name, "name": v.Name,
"description": v.Description,
"service_start_date": v.ServiceStartDate, "service_start_date": v.ServiceStartDate,
"service_termination_date": v.ServiceTerminationDate, "service_termination_date": v.ServiceTerminationDate,
"service_criticality": v.ServiceCriticality, "service_criticality": v.ServiceCriticality,
@@ -183,6 +189,7 @@ SELECT
id, id,
organization_id, organization_id,
name, name,
description,
service_start_date, service_start_date,
service_termination_date, service_termination_date,
service_criticality, service_criticality,