Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge next into main #2347

Merged
merged 469 commits into from
Jul 29, 2024
Merged

Merge next into main #2347

merged 469 commits into from
Jul 29, 2024

Conversation

thomasdax98
Copy link
Member

thomasdax98 and others added 30 commits April 15, 2024 16:21
…ndencies that get passed through recursivelyLoadBlockData into loader functions (#1936)

Can be extended using module augmentation in application to inject e.g.,
pageTreeNodeId.

Add pageTreeNodeId in demo, although there is no loader that actually
uses it.
Set `clearable` for Form `date` field when it is not required.

---------

Co-authored-by: Ricky James Smith <jamesricky@me.com>
Continues work started in #1807 and add App Router compatible
implementation.

### New APIs

- `previewParams()`: simlar to nextjs's `draftMode()`, returns `scope`
and `previewData` (contains if invisible items should be shown)
- `sitePreviewRoute(req)`: 
- `SitePreviewParams` and `SitePreviewData`: types returned by
`previewParams()`

---------

Co-authored-by: Franz Unger <franz.unger@vivid-planet.com>
Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
#1930)

This allows to use any query, also probably future API-generated
additional queries.

For now the developer needs to make sure gqlType-value and response-type
of query do match. I didn't see a simple solution to enforce this with
typescript types. maybe we should add some warnings/errors in future.
…dded in parent page component (#1937)

And adjust demo Products Future.

This is a major braking change, but we never released a stable version
containing the future generator.

## Alternative

we could add a configuration if the toolbar should be generated. But I
think we usually should not do that as we always want to use the
SaveBoundary.
This is handy to debug or update just a single generated file without
touching the others. This will be rarely needed.
Previously demo site had some "ideas" of i18n support (localized
content) but as there was only a single language configured this was not
tested at all.

New:

- add multiple languages in admin + site (en + de)
- port i18n config from pages router to app router (which is completely
different, this i18n next.config.js doesn't exist anymore, instead it's
a simple dynamic route, see
[docs](https://nextjs.org/docs/app/building-your-application/routing/internationalization))
- all paths are now below a /de or /de with default redirect from / to
/en

---------

Co-authored-by: Thomas Dax <thomas.dax@vivid-planet.com>
Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
This PR adds the hover functionality for the collapsed menu.

---------

Co-authored-by: Ricky James Smith <jamesricky@me.com>
Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
I believe this is a leftover from #1596.
It was added in API (transformToPlain) but not in Admin.

Fixes dirty prompt after save where due to a reload the scope was added.
…ling the list query (#1971)

Sometimes the list query is not needed because special queries are
created in application code.

---------

Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
… prompt dialog (#1961)

Fixes an issue where a form that doesn't unmount doesn't lose its state
even when the user chooses "Discard" in the prompt dialog.
Previously we supported poor man's dependency injection using the
`TransformDependencies` object in `transformToPlain`
This is now replaced by a technique that allows actual dependency
injection.

**Example**

```ts
// news-link.block.ts

class NewsLinkBlockData extends BlockData {
    @BlockField({ nullable: true })
    id?: string;

    transformToPlain() {
        // Return service that does the transformation
        return NewsLinkBlockTransformerService;
    }
}

type TransformResponse = {
    news?: {
        id: string;
        slug: string;
    };
};

@Injectable()
class NewsLinkBlockTransformerService implements BlockTransformerServiceInterface<NewsLinkBlockData, TransformResponse> {
    // Use dependency injection here
    constructor(@InjectRepository(News) private readonly repository: EntityRepository<News>) {}

    async transformToPlain(block: NewsLinkBlockData, context: BlockContext) {
        if (!block.id) {
            return {};
        }

        const news = await this.repository.findOneOrFail(block.id);

        return {
            news: {
                id: news.id,
                slug: news.slug,
            },
        };
    }
}
```

---

TODO

- [x] Convert other library blocks to new technique
- [x] Changeset
- [x] Fix type issues
- [x] Remove transform dependencies
- [x] Refactor complicated `createAsyncTraverse` function
- [x] Naming
- [x] Migration Guide
- [x] Support request-scoped services

---

<!-- Everything below this line will be removed from the commit message
when the PR is merged -->

## PR Checklist

- [x] Verify if the change requires a changeset. See
[CONTRIBUTING.md](https://github.com/vivid-planet/comet/blob/HEAD/CONTRIBUTING.md)
-   [x] Link to the respective task if one exists: COM-403

---------

Co-authored-by: Thomas Dax <thomas.dax@vivid-planet.com>
This fixes Demo site preview.

With App Router i18n changed:
- language is now part of the url also for site preview (before it was
used from scope that passed to site)
- before: resolvePath was only used for the siteLink shown in the Admin
UI
- now: resolvePath is also applied for the preview url opened in site
- because of that we need 2 parameters:
- `path` (called `initialPath` in local variable): the path preview is
initially opened with, only parameter passed from
`openSitePreviewWindow`: resolvePath is not called on this
- `sitePath`: current path, updated from iframe: resolvePath is called
on this

see also inline comments
Allows generating grid with nested fields in grid using dot-notation.
…nu-rework

Merge `next` into `feature/menu-rework`
Remove the  `clearable` prop  from all pickers in `@comet/admin-date-time` and from `ColorPicker`. All pickers are now clearable by default and only not clearable when `required` is set.
Currently, the client also requires the SITE_PREVIEW_SECRET. 
As far as I understand it, however, this should only be required on the
server side.
jamesricky and others added 22 commits July 22, 2024 15:08
Implement updated design to also support usage on content without white
a background.
…props (#2327)

Add back the `multiple` prop and be a single-file select by default.
Only allow selecting multiple files when either the `multiple` prop is
set or when the `maxFiles` prop is set and has a value of more than `1`.

Also simplify stories slightly for more common use cases.
…ManyFilter` (#2238)

This PR adds search filter to OneToMany and ManyToMany relations, that
can be used where a select is impossible to use because of too many
related entities. Doing a poor-mans fulltext search doesn't have this
problem (also has poor performance on the server side though)

The old method (how search was implemented for list queries) didn't
apply here well, so I decided do go a different approach: Instead of
generating code (the service) that lists all fields to query, we find
those fields at runtime now. We are using (1) MikroORM metadata and (2)
our CrudField resolver, the search boolean. Just as before.

And with this new approach it is possible to do that also for related
entities that makes implementing the search possible.

---------

Co-authored-by: Johannes Obermair <johannes.obermair@vivid-planet.com>
This change originally comes from #2151. It is added here in a separate
PR to make it easier to continue working on the file select components
while #2151 is still in the works.
…o initializer (#2324)

Previously, the following property of an entity

```ts
@Property({ type: types.date, nullable: true })
@field({ nullable: true })
availableSince?: Date;
```

resulted in the following input being generated:

```ts
@isnullable()
@isdate()
@field({ nullable: true })
availableSince?: Date;
```

This was problematic for two reasons:

1. The error message would be misleading when trying to create an entity
without providing a value for the property. For example, a valid GraphQL
mutation

    ```graphql
    mutation CreateProduct {
createProduct(input: { title: "A", slug: "A", description: "FOO" }) {
            id
            availableSince
        }
    }
    ```

    would result in the following error:

    ```
    "isDate": "availableSince must be a Date instance"
    ```

2. Relying on the initializer as the default value is not obvious and
appears somewhat magical.

To address this, we now use `null` as the default value for nullable
properties if no initializer is provided. If an initializer is provided,
it is used as the default value.

---------

Co-authored-by: Johannes Obermair <johannes.obermair@vivid-planet.com>
The name "public uploads" was not fitting since the uploads can also be
used for "private" uploads in the Admin. The feature was therefore
renamed to "file uploads".

This requires the following changes:

-   Use `FilesUploadModule` instead of `PublicUploadModule`
-   Use `FileUpload` instead of `PublicUpload`
-   Use `FileUploadsService` instead of `PublicUploadsService`
- Change the upload URL from `/public-upload/files/upload` to
`/files-uploads/upload`

---------

Co-authored-by: Thomas Dax <thomas.dax@vivid-planet.com>
The `/file-uploads/upload` endpoint now requires the `fileUploads`
permission by default. It can be made public by using the
`upload.public` option:

```diff
FileUploadsModule.register({
    /* ... */,
+   upload: {
+       public: true,
+   },
}),
```
- Update migration guide to include changes made since beta.0
- Remove unnecessary changesets that only document changes between beta
versions
The `clearable` prop is removed from `FinalFormSelect` and
`FinalFormAsyncSelect`. They are now clearable by default when
`required` is not set.
@thomasdax98 thomasdax98 changed the title Draft: Merge next into main Merge next into main Jul 29, 2024
@thomasdax98 thomasdax98 marked this pull request as ready for review July 29, 2024 11:35
@auto-assign auto-assign bot requested a review from johnnyomair July 29, 2024 11:35
@thomasdax98 thomasdax98 merged commit c7674b1 into main Jul 29, 2024
8 checks passed
@thomasdax98 thomasdax98 added this to the v7.0.0 milestone Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.