Skip to content

Commit

Permalink
automatic chores (27d5d76) 📝 [skip-ci]
Browse files Browse the repository at this point in the history
This is a commit done by the GitHub action https://github.com/Puzzlepart/did/blob/dev/.github/workflows/automatic_chores.yml. This way we avoid having to generate documentation, run eslint etc. locally before commiting to the repo. See #903 for more details.
  • Loading branch information
github-automatic-chores committed Apr 29, 2024
1 parent 27d5d76 commit c350fb1
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<br />


[![version](https://img.shields.io/badge/version-0.13.3-12-green.svg)](https://semver.org)
[![version](https://img.shields.io/badge/version-0.13.3-13-green.svg)](https://semver.org)

<details>
<summary>📖 Table of Contents</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import _ from 'lodash'
export const ProjectResources: StyledComponent = () => {
const { projectOwner, resources, isDataLoaded } = useProjectResources()
const { t } = useTranslation()
if(!projectOwner && _.isEmpty(resources)) {
if (!projectOwner && _.isEmpty(resources)) {
return null
}
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { useExtension } from 'hooks'
import { Project } from 'types'
import { Resources } from '../../../ProjectForm'
import { ResourcesExtension, ResourcesExtensionDefault } from '../../../ProjectForm/Resources/types'
import {
ResourcesExtension,
ResourcesExtensionDefault
} from '../../../ProjectForm/Resources/types'
import { useProjectsContext } from '../../../context'
import { useUsersQuery } from './useUsersQuery'

Expand Down
2 changes: 1 addition & 1 deletion client/pages/Projects/ProjectForm/Resources/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ export type ResourcesExtension = {
export const ResourcesExtensionDefault: ResourcesExtension = {
projectOwner: null,
resources: []
}
}
34 changes: 20 additions & 14 deletions server/services/mongo/document/MongoDocumentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class MongoDocumentService<T> {
const isFalse = query[key] === false
q[key] = isFalse
? {
$in: [false, null]
}
$in: [false, null]
}
: query[key]
return q
}, {})
Expand All @@ -64,7 +64,7 @@ export class MongoDocumentService<T> {
/**
* Parses JSON string to object before inserting into the mongo collection.
* Also merges the extensions metadata with the extensions object.
*
*
* @param document Document to parse
* @param key Key of the field
*/
Expand All @@ -74,15 +74,18 @@ export class MongoDocumentService<T> {
if (!json) return null
switch (key) {
case 'extensions': {
return [...this._extensions.entries()].reduce((extensions, [key, metadata]) => {
return {
...extensions,
[key]: {
...metadata,
...extensions[key],
return [...this._extensions.entries()].reduce(
(extensions, [key, metadata]) => {
return {
...extensions,
[key]: {
...metadata,
...extensions[key]
}
}
}
}, json)
},
json
)
}
default: {
return json
Expand Down Expand Up @@ -113,7 +116,7 @@ export class MongoDocumentService<T> {
document[key as string] =
action === 'get'
? JSON.stringify(document[key])
: this._parseJson(document, key)
: this._parseJson(document, key)
}
}
}
Expand Down Expand Up @@ -214,11 +217,14 @@ export class MongoDocumentService<T> {
* If the extension ID is an instance of `Extension`, the metadata parameter is ignored.
* If the extension ID is a string or a number, the metadata parameter is used.
* If the `extensions` field type is not registered, it will be registered as `JSON`.
*
*
* @param extensionId - The ID of the extension to register, either a string, number, or an instance of `Extension`.
* @param metadata - Optional metadata for the extension.
*/
public registerExtension(extensionId: string | Extension, metadata?: ExtensionMetadata) {
public registerExtension(
extensionId: string | Extension,
metadata?: ExtensionMetadata
) {
if (extensionId instanceof Extension) {
this._extensions.set(extensionId.id, extensionId.metadata)
} else {
Expand Down
10 changes: 5 additions & 5 deletions server/services/mongo/document/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export type FieldType = 'JSON'

export type ExtensionMetadata = {
status: 'Available' | 'Unavailable'
description: string
status: 'Available' | 'Unavailable'
description: string
}
export type Extensions = Map<string, ExtensionMetadata>

export abstract class Extension {
public abstract id: string
public abstract metadata: ExtensionMetadata
}
public abstract id: string
public abstract metadata: ExtensionMetadata
}
2 changes: 1 addition & 1 deletion server/services/mongo/project/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ export class BudgetTrackingExtension extends Extension {
status: 'Available',
description: 'Budget tracking'
}
}
}

0 comments on commit c350fb1

Please sign in to comment.