Skip to content

Commit ed1e0fa

Browse files
committed
Merge branch 'develop'
2 parents 6fe400f + fdd5182 commit ed1e0fa

File tree

6 files changed

+40
-10
lines changed

6 files changed

+40
-10
lines changed

.yarn/releases/yarn-3.6.2.cjs renamed to .yarn/releases/yarn-3.6.3.cjs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins:
66
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
77
spec: "@yarnpkg/plugin-interactive-tools"
88

9-
yarnPath: .yarn/releases/yarn-3.6.2.cjs
9+
yarnPath: .yarn/releases/yarn-3.6.3.cjs
1010

1111
logFilters:
1212
# discard these messages that flood the build log

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cord-api-v3",
33
"version": "3.0.0",
44
"license": "MIT",
5-
"packageManager": "[email protected].2",
5+
"packageManager": "[email protected].3",
66
"engines": {
77
"node": ">= 18.9"
88
},

src/components/progress-report/media/dto/media-list.dto.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { InputType, ObjectType } from '@nestjs/graphql';
1+
import { Field, InputType, ObjectType } from '@nestjs/graphql';
22
import {
33
PaginatedList,
44
SortablePaginationInput,
@@ -28,3 +28,14 @@ export class ProgressReportMediaList extends PaginatedList(
2828
) {
2929
readonly report: ProgressReport;
3030
}
31+
32+
@ObjectType()
33+
export class AvailableProgressReportMediaVariant {
34+
@Field(() => Variant)
35+
readonly variant: Variant<MediaVariant>;
36+
37+
@Field({
38+
description: 'Whether the user can upload/create media for this variant',
39+
})
40+
readonly canCreate: boolean;
41+
}

src/components/progress-report/media/resolvers/list.resolver.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Parent, ResolveField, Resolver } from '@nestjs/graphql';
22
import { AnonSession, Session, Variant } from '~/common';
33
import { Privileges, withVariant } from '../../../authorization';
44
import {
5+
AvailableProgressReportMediaVariant as AvailableVariant,
56
ProgressReportMedia as ReportMedia,
67
ProgressReportMediaList as ReportMediaList,
78
} from '../dto';
@@ -12,6 +13,7 @@ export class ProgressReportMediaListResolver {
1213

1314
@ResolveField(() => [Variant], {
1415
description: 'The variants the requester has access to upload',
16+
deprecationReason: 'Use `availableVariants` instead',
1517
})
1618
uploadableVariants(
1719
@Parent() { report }: ReportMediaList,
@@ -23,4 +25,25 @@ export class ProgressReportMediaListResolver {
2325
privileges.forContext(withVariant(context, variant)).can('create'),
2426
);
2527
}
28+
29+
@ResolveField(() => [AvailableVariant], {
30+
description: 'The variants available to the requester',
31+
})
32+
availableVariants(
33+
@Parent() { report }: ReportMediaList,
34+
@AnonSession() session: Session,
35+
): readonly AvailableVariant[] {
36+
const context = report as any; // the report is fine for condition context
37+
const privileges = this.privileges.for(session, ReportMedia);
38+
return ReportMedia.Variants.filter((variant) =>
39+
privileges.forContext(withVariant(context, variant)).can('read'),
40+
).map(
41+
(variant): AvailableVariant => ({
42+
variant,
43+
canCreate: privileges
44+
.forContext(withVariant(context, variant))
45+
.can('create'),
46+
}),
47+
);
48+
}
2649
}

src/core/database/query/deletes.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ export const deleteBaseNode = (nodeVar: string) => (query: Query) =>
1717
node('propertyNode', 'Property'),
1818
])
1919
// Mark any parent base node relationships (pointing to the base node) as active = false.
20-
.optionalMatch([
21-
node(nodeVar),
22-
relation('in', 'baseNodeRel'),
23-
node('', 'BaseNode'),
24-
])
20+
.optionalMatch([node(nodeVar), relation('in', 'baseNodeRel'), node()])
2521
.setValues({
2622
[`${nodeVar}.deletedAt`]: DateTime.local(),
2723
'baseNodeRel.active': false,

0 commit comments

Comments
 (0)