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

New Changes Comparison View #6770

Merged
merged 34 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
15a6b3c
First draft for a new comparison view
bastianallgeier Oct 9, 2024
97568ca
Open in new window buttons
bastianallgeier Oct 9, 2024
3a79ce4
Rename view to k-page-changes-view
bastianallgeier Oct 22, 2024
08ae8ec
Move view logic to ModelView component instead of the content module
bastianallgeier Oct 22, 2024
fd5d4a8
Make iframes responsive
bastianallgeier Oct 22, 2024
99a781c
Set a default background for the iframes
bastianallgeier Oct 22, 2024
5484c1a
Fix CS issues
bastianallgeier Oct 22, 2024
a5c5799
Add a unit test for the changes route
bastianallgeier Oct 22, 2024
0760036
Translated labels
bastianallgeier Oct 22, 2024
57927a8
Responsive header buttons
bastianallgeier Oct 22, 2024
83c37a4
Responsive form controls
bastianallgeier Oct 22, 2024
c3b273a
Better wording
bastianallgeier Oct 22, 2024
4378bce
Remove repeating code
bastianallgeier Oct 22, 2024
d3eefd0
Flip the menu order
bastianallgeier Oct 22, 2024
5e8513d
New expand and collapse icons
bastianallgeier Nov 4, 2024
99662e3
Various UX changes
bastianallgeier Nov 4, 2024
b76419d
Improve the wording in the discard dialog
bastianallgeier Nov 5, 2024
16b93c7
New asterisk and window icons
bastianallgeier Nov 6, 2024
541aed2
Slightly better wording
bastianallgeier Nov 6, 2024
b407d6b
Rename View and implement for the site
bastianallgeier Nov 6, 2024
9677b7a
Fix the options in the page dropdown
bastianallgeier Nov 6, 2024
029a8b5
Fix / add unit tests
bastianallgeier Nov 6, 2024
3914f1b
New PreviewDropdownButton to handle the open/preview/copy dropdowns
bastianallgeier Nov 6, 2024
9f00a64
Fix outdated toggle method
bastianallgeier Nov 9, 2024
78ccaf7
Improve copy language strings
bastianallgeier Nov 9, 2024
1b98a11
Use existing clipboard helper
bastianallgeier Nov 9, 2024
1b3a5a5
New VersionId option for preview URLs
bastianallgeier Nov 9, 2024
23aba26
Add use statement
bastianallgeier Nov 9, 2024
05d31fa
Remove unnecessary fallback
bastianallgeier Nov 11, 2024
4c268d7
Throw a permission exception if the preview view cannot be visited
bastianallgeier Nov 11, 2024
43b0070
Remove outdated prop
bastianallgeier Nov 11, 2024
b6a041a
Check for permissions for the preview button in the dropdown
bastianallgeier Nov 11, 2024
bb96335
Leave the preview view on esc
bastianallgeier Nov 11, 2024
f9ce581
Rename clipboard event
bastianallgeier Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions config/areas/site/buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@
use Kirby\Cms\Site;
use Kirby\Panel\Ui\Buttons\LanguagesDropdown;
use Kirby\Panel\Ui\Buttons\PageStatusButton;
use Kirby\Panel\Ui\Buttons\PreviewButton;
use Kirby\Panel\Ui\Buttons\PreviewDropdownButton;
use Kirby\Panel\Ui\Buttons\SettingsButton;

return [
'site.preview' => function (Site $site) {
return new PreviewButton(link: $site->url());
return new PreviewDropdownButton(
open: $site->url(),
preview: $site->panel()->url(true) . '/preview/compare',
copy: $site->url(),
);
},
'page.preview' => function (Page $page) {
if ($page->permissions()->can('preview') === true) {
return new PreviewButton(link: $page->previewUrl());
return new PreviewDropdownButton(
open: $page->previewUrl(),
preview: $page->panel()->url(true) . '/preview/compare',
copy: $page->previewUrl(),
);
}
},
'page.settings' => function (Page $page) {
Expand Down
44 changes: 44 additions & 0 deletions config/areas/site/views.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@
return Find::file('pages/' . $id, $filename)->panel()->view();
}
],
'page.preview' => [
'pattern' => 'pages/(:any)/preview/(changes|latest|compare)',
'action' => function (string $path, string $mode) {
$page = Find::page($path);
$view = $page->panel()->view();
$preview = $page->previewUrl();

return [
'component' => 'k-preview-view',
'props' => [
...$view['props'],
'back' => $view['props']['link'],
'mode' => $mode,
'src' => [
'changes' => $preview . '?_version=changes',
bastianallgeier marked this conversation as resolved.
Show resolved Hide resolved
'latest' => $preview,
]
],
'title' => $view['props']['title'] . ' | ' . I18n::translate('changes'),
bastianallgeier marked this conversation as resolved.
Show resolved Hide resolved
];
}
],
'site' => [
'pattern' => 'site',
'action' => fn () => App::instance()->site()->panel()->view()
Expand All @@ -24,4 +46,26 @@
return Find::file('site', $filename)->panel()->view();
}
],
'site.preview' => [
'pattern' => 'site/preview/(changes|latest|compare)',
'action' => function (string $mode) {
$site = App::instance()->site();
$view = $site->panel()->view();
$preview = $site->previewUrl();

return [
'component' => 'k-preview-view',
'props' => [
...$view['props'],
'back' => $view['props']['link'],
'mode' => $mode,
'src' => [
'changes' => $preview . '?_version=changes',
bastianallgeier marked this conversation as resolved.
Show resolved Hide resolved
'latest' => $preview,
]
],
'title' => I18n::translate('view.site') . ' | ' . I18n::translate('changes'),
];
}
],
];
7 changes: 6 additions & 1 deletion i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
"collapse.all": "Collapse All",
"color": "Color",
"coordinates": "Coordinates",
"copied": "Copied",
distantnative marked this conversation as resolved.
Show resolved Hide resolved
"copy": "Copy",
"copy.all": "Copy all",
"copy.success": "{count} copied!",
"copy.url": "Copy URL",
"create": "Create",
"custom": "Custom",

Expand Down Expand Up @@ -378,7 +380,7 @@
"filter": "Filter",

"form.discard": "Discard changes",
"form.discard.confirm": "Do you really want to <strong>delete all unpublished changes</strong>?",
"form.discard.confirm": "Do you really want to <strong>discard all your changes</strong>?",
"form.locked": "This content is disabled for you as it is currently edited by another user",
"form.unsaved": "The current changes have not yet been saved",
"form.preview": "Preview changes",
Expand Down Expand Up @@ -748,10 +750,13 @@
"users": "Users",

"version": "Version",
"version.changes": "Changed version",
"version.compare": "Compare versions",
bastianallgeier marked this conversation as resolved.
Show resolved Hide resolved
"version.current": "Current version",
"version.latest": "Latest version",
"versionInformation": "Version information",

"view": "View",
"view.account": "Your account",
"view.installation": "Installation",
"view.languages": "Languages",
Expand Down
21 changes: 21 additions & 0 deletions panel/public/img/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion panel/src/components/Forms/FormControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<k-button
v-for="button in buttons"
:key="button.text"
:responsive="true"
v-bind="button"
size="sm"
variant="filled"
Expand Down Expand Up @@ -41,7 +42,7 @@
</template>
<template v-if="preview">
<hr />
<k-dropdown-item :link="preview" icon="preview" target="_blank">
<k-dropdown-item :link="preview" icon="window">
{{ $t("form.preview") }}
</k-dropdown-item>
</template>
Expand Down
6 changes: 4 additions & 2 deletions panel/src/components/Views/ModelView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default {
}

await this.$panel.content.discard();
this.$panel.view.reload();
},
onInput(values) {
if (this.isLocked === true) {
Expand All @@ -105,13 +106,14 @@ export default {
e?.preventDefault?.();
this.onSubmit();
},
onSubmit(values = {}) {
async onSubmit(values = {}) {
if (this.isLocked === true) {
return false;
}

this.$panel.content.update(values);
this.$panel.content.publish();
await this.$panel.content.publish();
await this.$panel.view.refresh();
},
toPrev(e) {
if (this.prev && e.target.localName === "body") {
Expand Down
2 changes: 1 addition & 1 deletion panel/src/components/Views/Pages/PageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
:is-locked="isLocked"
:is-unsaved="isUnsaved"
:modified="modified"
:preview="changesUrl"
:preview="api + '/preview/compare'"
@discard="onDiscard"
@submit="onSubmit"
/>
Expand Down
2 changes: 1 addition & 1 deletion panel/src/components/Views/Pages/SiteView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
:is-locked="isLocked"
:is-unsaved="isUnsaved"
:modified="modified"
:preview="changesUrl"
:preview="api + '/preview/compare'"
@discard="onDiscard"
@submit="onSubmit"
/>
Expand Down
Loading
Loading