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 feature/menu-rework #1998

Merged
merged 547 commits into from
Apr 25, 2024

Conversation

jamesricky
Copy link
Contributor

@jamesricky jamesricky commented Apr 25, 2024

No description provided.

andrearutrecht and others added 30 commits February 19, 2024 10:49
…1689)

Support `helperText` `Field` prop in Forms
<details><summary>Screenshot of Demo:</summary>
<p>

<img width="685" alt="Screenshot 2024-02-15 at 09 06 28"
src="https://github.com/vivid-planet/comet/assets/122883866/ca0a1c5b-fc10-4940-83a8-6788e6b4ab18">

</p>
</details> 

- [ ] Add changeset (if necessary)

---------

Co-authored-by: Niko Sams <niko.sams@gmail.com>
Use new field components to simplify forms. 

New available field components: 

-   TextField
-   TextAreaField
-   SearchField
-   SelectField
-   CheckboxField
-   SwitchField
-   ColorField
-   DateField
-   DateRangeField
-   TimeField
-   TimeRangeField
-   DateTimeField

---------

Co-authored-by: Julia Wegmayr <julia.wegmayr@vivid-planet.com>
### Description
In this PR IconButtons in the BlocksBlock header are exchanged to
RowActionsItems to add tooltips. Also, slight spacing adjustments were
made.

### Screenshots/ Screen Recordings
#### Before

https://github.com/vivid-planet/comet/assets/56400587/bae9bec3-829e-449e-b7dc-155edca4dcf9

#### After

https://github.com/vivid-planet/comet/assets/56400587/df7e2bb1-6f7b-46e5-8a8a-426933e35688

---------

Co-authored-by: Thomas Dax <thomas.dax@vivid-planet.com>
Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
Add loading state for edit `StackPage` in `PagesPage`

Prevents flash of "Document not found" error message when reloading the
page editor

---

Previously:



https://github.com/vivid-planet/comet/assets/13380047/8f401034-f5a3-40df-a52e-7039a936cef7


Now:



https://github.com/vivid-planet/comet/assets/13380047/ac68b2ca-71b3-4c9e-9a9f-676dfb189b2b


---

Closes COM-469
![Screenshot 2024-02-19 at 17 59
03](https://github.com/vivid-planet/comet/assets/109900447/47e20aca-189b-4a10-84d6-5265f8f1ddf6)

---------

Co-authored-by: Julia Wegmayr <julia.wegmayr@vivid-planet.com>
Co-authored-by: Ricky James Smith <jamesricky@me.com>
COM-202 , COM-203


https://github.com/vivid-planet/comet/assets/118435139/c230b360-c8ea-42d0-af0e-901e53ec172e

## Test custom inline styles: 

<details>
    <summary>Used customInlineStyles for RichTextBlock</summary>

```tsc
export const RichTextBlock = createRichTextBlock({
    link: LinkBlock,
    rte: {
        customInlineStyles: {
            HIGHLIGHT: {
                label: "Highlight!",
                icon: Highlight,
                style: {
                    backgroundColor: "yellow",
                },
            },
        },
    },
});
```

</details>


https://github.com/vivid-planet/comet/assets/118435139/bea488ec-99f7-448b-a9e0-c2d1e67580c3

## ⚠️ Note: The translation tool has to be smart enough to ignore the
html tags!

![Screenshot 2024-02-01 at 09 08
30](https://github.com/vivid-planet/comet/assets/118435139/26660266-990b-434e-9c50-b7eb387a54b4)

<details>
    <summary>External+News Link FinalFormInput disable Button</summary>

# dbe8ae3


https://github.com/vivid-planet/comet/assets/118435139/b85f5753-1619-4ccb-9634-4dc201221799
    
</details>
Merge main into feature/translation-module
…gn (#1716)

Also remove dialog sizes above MD from story. 
Sizes above 1024px (other than `fullWidth`) should not be used,
according to the design guidelines.
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @comet/admin@6.1.0

### Minor Changes

-   b35bb8d: Add basis for content translation

Wrap a component with a `ContentTranslationServiceProvider` to add
support for content translation to all underlying `FinalFormInput`
inputs.

    ```tsx
    <ContentTranslationServiceProvider
        enabled={true}
        translate={async function (text: string): Promise<string> {
            return yourTranslationFnc(text);
        }}
    >
        ...
    </ContentTranslationServiceProvider>
    ```

You can disable translation for a specific `FinalFormInput` by using the
`disableContentTranslation` prop.

    ```diff
    <Field
        required
        fullWidth
        name="myField"
        component={FinalFormInput}
label={<FormattedMessage id="myField" defaultMessage="My Field" />}
    +   disableContentTranslation
    />
    ```

- 8eb1375: Add `SaveBoundary` and `SaveBoundarySaveButton` that helps
implementing multiple forms with a centralized save button

Render a `Savable` Component anywhere below a `SaveBoundary`. For
`FinalForm` this hasn't to be done manually.

-   a4fac91: Rework `Alert` component

    -   Use theme wherever possible
    -   Move styles where they're more fitting
    -   Fix some paddings

### Patch Changes

- dcfa03c: Fix a crash when using the `Alert` component inside a MUI
`Snackbar`
-   Updated dependencies [08e0da0]
    -   @comet/admin-icons@6.1.0

## @comet/admin-rte@6.1.0

### Minor Changes

-   f1fc9e2: Add support for content translation

### Patch Changes

-   Updated dependencies [dcfa03c]
-   Updated dependencies [08e0da0]
-   Updated dependencies [b35bb8d]
-   Updated dependencies [8eb1375]
-   Updated dependencies [a4fac91]
    -   @comet/admin@6.1.0
    -   @comet/admin-icons@6.1.0

## @comet/admin-theme@6.1.0

### Minor Changes

-   a4fac91: Rework `Alert` component

    -   Use theme wherever possible
    -   Move styles where they're more fitting
    -   Fix some paddings

### Patch Changes

-   Updated dependencies [08e0da0]
    -   @comet/admin-icons@6.1.0

## @comet/cms-api@6.1.0

### Minor Changes

- 7ea43eb: Make the `UserService`-option of the `UserPermissionsModule`
optional.

    The service is still necessary though for the Administration-Panel.

- 86cd5c6: Allow a callback for the `availableContentScopes`-option of
the `UserPermissionsModule`

Please be aware that when using this possibility to make sure to cache
the
    response properly as this is called for every request to the API.

- 737ab3b: Allow returning multiple content scopes in
`ScopedEntity`-decorator

-   f416510: Remove `CurrentUserLoader` and `CurrentUserInterface`

Overriding the the current user in the application isn't supported
anymore when using the new `UserPermissionsModule`, which provides the
current user DTO itself.

### Patch Changes

- ef84331: Fix type of @RequiredPermission to accept a non-array string
for a single permission
- 8e158f8: Add missing `@RequiredPermission()` decorator to
`FileLicensesResolver`
- 5018441: API Generator: Add missing `scope` argument and filter to
`<entity>BySlug` query
- 1f6c58e: API Generator: support GraphQLJSONObject input for fields
that are not a InputType class
    -   @comet/blocks-api@6.1.0

## @comet/admin-color-picker@6.1.0

### Patch Changes

-   Updated dependencies [dcfa03c]
-   Updated dependencies [08e0da0]
-   Updated dependencies [b35bb8d]
-   Updated dependencies [8eb1375]
-   Updated dependencies [a4fac91]
    -   @comet/admin@6.1.0
    -   @comet/admin-icons@6.1.0

## @comet/admin-date-time@6.1.0

### Patch Changes

-   Updated dependencies [dcfa03c]
-   Updated dependencies [08e0da0]
-   Updated dependencies [b35bb8d]
-   Updated dependencies [8eb1375]
-   Updated dependencies [a4fac91]
    -   @comet/admin@6.1.0
    -   @comet/admin-icons@6.1.0

## @comet/admin-icons@6.1.0

### Patch Changes

-   08e0da0: Fix icons inside tooltips by forwarding the ref

## @comet/admin-react-select@6.1.0

### Patch Changes

-   Updated dependencies [dcfa03c]
-   Updated dependencies [b35bb8d]
-   Updated dependencies [8eb1375]
-   Updated dependencies [a4fac91]
    -   @comet/admin@6.1.0

## @comet/blocks-admin@6.1.0

### Patch Changes

-   Updated dependencies [dcfa03c]
-   Updated dependencies [08e0da0]
-   Updated dependencies [b35bb8d]
-   Updated dependencies [8eb1375]
-   Updated dependencies [a4fac91]
    -   @comet/admin@6.1.0
    -   @comet/admin-icons@6.1.0

## @comet/cms-admin@6.1.0

### Patch Changes

-   7ea5f61: Use `useCurrentUser` hook where possible

-   693cbdb: Add loading state for edit `StackPage` in `PagesPage`

Prevents flash of "Document not found" error message when reloading the
page editor

-   Updated dependencies [dcfa03c]

-   Updated dependencies [08e0da0]

-   Updated dependencies [b35bb8d]

-   Updated dependencies [f1fc9e2]

-   Updated dependencies [8eb1375]

-   Updated dependencies [a4fac91]
    -   @comet/admin@6.1.0
    -   @comet/admin-icons@6.1.0
    -   @comet/admin-rte@6.1.0
    -   @comet/admin-theme@6.1.0
    -   @comet/admin-date-time@6.1.0
    -   @comet/blocks-admin@6.1.0

## @comet/eslint-config@6.1.0

### Patch Changes

-   @comet/eslint-plugin@6.1.0

## @comet/admin-babel-preset@6.1.0



## @comet/blocks-api@6.1.0



## @comet/cli@6.1.0



## @comet/eslint-plugin@6.1.0



## @comet/cms-site@6.1.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
<img width="336" alt="Screenshot 2024-01-22 at 14 19 12"
src="https://github.com/vivid-planet/comet/assets/109900447/d1322d17-723b-469d-9021-23cd23a4e7b3">

---------

Co-authored-by: Julia Wegmayr <julia.wegmayr@vivid-planet.com>
<details>
    <summary>CopyToClipboardButton</summary>


https://github.com/vivid-planet/comet/assets/71731085/049cccc2-4c97-4d43-a426-9fef891da0c3

</details>

<details>
    <summary>Themed CopyToClipboardButton</summary>


![comet-copyToClipboardButton-themed](https://github.com/vivid-planet/comet/assets/71731085/3a29f7c5-ab59-4109-b661-39be0f3ca0fe)

</details>

---------

Co-authored-by: Stefanie Kaltenhauser <stefanie.kaltenhauser@vivid-planet.com>
<img width="675" alt="Screenshot 2024-02-20 at 11 03 52"
src="https://github.com/vivid-planet/comet/assets/109900447/6ef65283-10de-4736-bbd2-5d24fc365a27">



<img width="681" alt="Screenshot 2024-02-20 at 11 03 59"
src="https://github.com/vivid-planet/comet/assets/109900447/a0663357-328d-4850-88df-bb9685c9865d">

---------

Co-authored-by: Julia Wegmayr <julia.wegmayr@vivid-planet.com>
Co-authored-by: Ricky James Smith <jamesricky@me.com>
Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
<img width="553" alt="Screenshot 2024-02-01 at 14 12 05"
src="https://github.com/vivid-planet/comet/assets/109900447/388cb711-d910-431c-a238-958126e73420">

---------

Co-authored-by: Julia Wegmayr <julia.wegmayr@vivid-planet.com>
Co-authored-by: Ricky James Smith <jamesricky@me.com>
<details>
    <summary>CopyToClipboardButton</summary>


https://github.com/vivid-planet/comet/assets/71731085/431f432b-4ac0-42b4-8b4d-e2e005f8c9a9


</details>

<details>
    <summary>Themed CopyToClipboardButton</summary>


https://github.com/vivid-planet/comet/assets/71731085/c1d4b458-8670-4501-bb83-a519f558fffc


</details>

Co-authored-by: Stefanie Kaltenhauser <stefanie.kaltenhauser@vivid-planet.com>
Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
The name `isHref` is too specific for a link target, because we can't
always expect a HTML anchor element, since Comet DXP is headless. This
PR renames the `isHref` validator, the `IsHref` decorator and the
`IsHrefConstraint` respectively to `isLinkTarget`, `IsLinkTarget` and
`IsLinkTargetConstraint`.

---------

Co-authored-by: Thomas Dax <thomas.dax@vivid-planet.com>
- `packageDimensions` was nullable, although the database fields aren't
nullable (caused an DB error if null was saved)
- Admin Generator (present and future) doesn't support nested fields
(for future it is WIP, present will never get it)
- Easy solution: remove it
- #1729 will showcase nested fields and everything (as replacement for
packageDimensions)
- add "price" input field as it is required by the api
- add missing toolbar including save button in add form

---

Closes COM-460

---------

Co-authored-by: Phillip Lechenauer <phillip.lechenauer@vivid-planet.com>
Co-authored-by: Niko Sams <ns@vivid-planet.com>
Co-authored-by: Niko Sams <niko.sams@gmail.com>
… of SVGs (#1732)

COM-366  
Change the icon generator to accept icons with more than one path, as
well as circles etc. and more complex structures like:
```
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
  <g clip-path="url(#a)">
    <path fill="#242424" fill-rule="evenodd" d="M7.529.401a.5.5 0 0 1 .275.082l.076.06 3.647 3.574a.5.5 0 0 1-.63.772l-.07-.058-3.501-3.43-5.99.015.003 5.968 7.474 7.475 5.994-5.994-1.578-1.681a.5.5 0 0 1-.038-.64l.06-.067a.5.5 0 0 1 .64-.038l.067.06 1.91 2.034a.5.5 0 0 1 .046.628l-.056.068-6.69 6.69a.5.5 0 0 1-.639.058l-.069-.057L.486 7.945a.5.5 0 0 1-.14-.274l-.007-.08L.335.918a.5.5 0 0 1 .41-.492l.09-.008L7.528.4ZM5 4a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z" clip-rule="evenodd"/>
  </g>
  <defs>
    <clipPath id="a">
      <path fill="#fff" d="M0 0h16v16H0z"/>
    </clipPath>
  </defs>
</svg>
```
The new icons have the same structure as the input svg files but without
the `fill` prop. All other props are kept.
I tested resizing and coloring, both work.

---------

Co-authored-by: Phillip Lechenauer <phillip.lechenauer@vivid-planet.com>
Adds dependency
https://github.com/golevelup/nestjs/tree/master/packages/discovery

We lose code completion in RequiredPermission-decorator and
getPermissionsForUser as there are only strings but that's not a huge
deal as the system gets much more flexible.

---------

Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
Co-authored-by: Ben-Ho <bh@vivid-planet.com>
`demo/site/src/blocks/seo` was moved to the `@comet/cms-site` package.
Additionally, an open graph image resolver function
(`resolveOpenGraphImageUrlTemplate`) was added as prop. It ensures that
if the open graph image block is custom, a function also has to be
passed that can resolve object and return the url template as string.

---------

Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
thomasdax98 and others added 23 commits April 17, 2024 08:25
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>
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @comet/admin@6.6.1

### Patch Changes

-   @comet/admin-icons@6.6.1

## @comet/admin-color-picker@6.6.1

### Patch Changes

-   @comet/admin@6.6.1
-   @comet/admin-icons@6.6.1

## @comet/admin-date-time@6.6.1

### Patch Changes

-   @comet/admin@6.6.1
-   @comet/admin-icons@6.6.1

## @comet/admin-react-select@6.6.1

### Patch Changes

-   @comet/admin@6.6.1

## @comet/admin-rte@6.6.1

### Patch Changes

-   @comet/admin@6.6.1
-   @comet/admin-icons@6.6.1

## @comet/admin-theme@6.6.1

### Patch Changes

-   @comet/admin-icons@6.6.1

## @comet/blocks-admin@6.6.1

### Patch Changes

-   @comet/admin@6.6.1
-   @comet/admin-icons@6.6.1

## @comet/cms-admin@6.6.1

### Patch Changes

-   @comet/admin@6.6.1
-   @comet/admin-date-time@6.6.1
-   @comet/admin-icons@6.6.1
-   @comet/admin-rte@6.6.1
-   @comet/admin-theme@6.6.1
-   @comet/blocks-admin@6.6.1

## @comet/cms-api@6.6.1

### Patch Changes

- 890795f: Fix calculation of `totalCount` in
`DependenciesService#getDependents`
    -   @comet/blocks-api@6.6.1

## @comet/eslint-config@6.6.1

### Patch Changes

-   @comet/eslint-plugin@6.6.1

## @comet/admin-babel-preset@6.6.1



## @comet/admin-icons@6.6.1



## @comet/blocks-api@6.6.1



## @comet/cli@6.6.1



## @comet/eslint-plugin@6.6.1



## @comet/cms-site@6.6.1

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Found this while changing a dependency in `next`.
#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>
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.
@jamesricky jamesricky self-assigned this Apr 25, 2024
@johnnyomair
Copy link
Collaborator

@jamesricky the test workflow fails

@johnnyomair
Copy link
Collaborator

We discussed this internally, @jamesricky will fix the tests in the feature branch.

@johnnyomair johnnyomair merged commit 75ab6aa into feature/menu-rework Apr 25, 2024
2 of 3 checks passed
@johnnyomair johnnyomair deleted the merge-next-into-feature-menu-rework branch April 25, 2024 12:16
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.