Link cookie policy doc and revamp tracker rows
Expose the generated cookie policy Document on the CookieBanner GraphQL type through a nullable policyDocument field and resolver, and surface a link to it from the banner configuration header next to the origin and ID. The link is hidden until a banner version is published and the document exists. Rework the tracker table rows: drop the Source column in favour of a tracker Type badge, and move each tracker's description inline beneath its name (and into the add/edit row inputs) instead of a separate Description column. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -143,6 +143,32 @@ func (r *cookieBannerResolver) LatestVersion(ctx context.Context, obj *types.Coo
|
||||
}, nil
|
||||
}
|
||||
|
||||
// PolicyDocument is the resolver for the policyDocument field.
|
||||
func (r *cookieBannerResolver) PolicyDocument(ctx context.Context, obj *types.CookieBanner) (*types.Document, error) {
|
||||
if obj.PolicyDocument == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if _, err := r.authorize(ctx, obj.ID, probo.ActionDocumentGet); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
loaders := dataloader.FromContext(ctx)
|
||||
|
||||
document, err := loaders.Document.Load(ctx, obj.PolicyDocument.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get policy document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewDocument(document), nil
|
||||
}
|
||||
|
||||
// ConsentRecords is the resolver for the consentRecords field.
|
||||
func (r *cookieBannerResolver) ConsentRecords(ctx context.Context, obj *types.CookieBanner, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.CookieConsentRecordOrderBy, filter *types.CookieConsentRecordFilter) (*types.CookieConsentRecordConnection, error) {
|
||||
scope, err := r.authorize(ctx, obj.ID, probo.ActionCookieConsentRecordList)
|
||||
|
||||
@@ -153,6 +153,8 @@ type CookieBanner implements Node {
|
||||
|
||||
latestVersion: CookieBannerVersion @goField(forceResolver: true)
|
||||
|
||||
policyDocument: Document @goField(forceResolver: true)
|
||||
|
||||
consentRecords(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
|
||||
@@ -61,7 +61,7 @@ func NewCookieBannerEdge(b *coredata.CookieBanner, orderBy coredata.CookieBanner
|
||||
}
|
||||
|
||||
func NewCookieBanner(b *coredata.CookieBanner) *CookieBanner {
|
||||
return &CookieBanner{
|
||||
banner := &CookieBanner{
|
||||
ID: b.ID,
|
||||
Organization: &Organization{
|
||||
ID: b.OrganizationID,
|
||||
@@ -77,6 +77,12 @@ func NewCookieBanner(b *coredata.CookieBanner) *CookieBanner {
|
||||
CreatedAt: b.CreatedAt,
|
||||
UpdatedAt: b.UpdatedAt,
|
||||
}
|
||||
|
||||
if b.PolicyDocumentID != nil {
|
||||
banner.PolicyDocument = &Document{ID: *b.PolicyDocumentID}
|
||||
}
|
||||
|
||||
return banner
|
||||
}
|
||||
|
||||
func NewCookieBannerTranslation(t *coredata.CookieBannerTranslation) *CookieBannerTranslation {
|
||||
|
||||
Reference in New Issue
Block a user