Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
- The “View Mode” (Matrix, relation, Addresses, and Content Block fields), “Thumb Style”, “Section Type”, and image transforms’ “Mode” settings now show their options as joined, illustrated buttons, with each option’s label inside the button, below its illustration, and the selected option’s illustration drawn in blue. When there isn’t room for them in one row, they wrap as separate buttons. ([#20233](https://github.com/craftcms/cms/pull/20233), [#20285](https://github.com/craftcms/cms/pull/20285))
- Dashboard widgets, such as Recent Entries and My Drafts, now update when elements are saved, in the same browser tab or another one. ([#20485](https://github.com/craftcms/cms/pull/20485))
- Dashboard widgets can now be given a color, like entry types, from the dashboard’s Widget Settings menu. Widgets are gray unless given another color, now drawn like gray cards elsewhere in the control panel, with a filled header bar, and “No color” draws a widget with no fill of its own, like an uncolored element card.
- Added the “About Craft CMS” dashboard widget, which shows Craft’s version and edition, any trials of Craft or plugins that are installed with a link to buy them, and, for users who can update Craft, whether updates are available. It replaces the Updates widget, including on existing dashboards, and admins get it at the end of theirs. The command palette’s new “About Craft CMS” action shows the same.
- Dashboard widget titles now line up with the widgets’ content.
- Dashboard widgets’ titles now sit above a hairline at the top of each widget, and widget settings have their Save and Cancel buttons in a footer.
- Recent Entries widgets now have an “Entry Criteria” setting, like custom entry sources, in place of their “Site” and “Section” settings. Existing widgets’ site and section selections carry over as criteria rules.
Expand All @@ -64,7 +65,6 @@
- New Users widgets now show the total number of new users in their date range, above a sparkline of new users per day, which gets taller as the widget gets wider.
- Craft Support widgets are now a list of links to the documentation, Knowledge Base, Craft Support, GitHub bug reports and feature requests, Discord, and Craft Partners, plus an “Ask AI” button when the AI assistant is available. Support requests are now sent from craftcms.com/contact, rather than a form in the widget.
- Quick Post widgets now show a large button in their entry type’s icon and color, and are titled “New {Section} Entry” by default.
- Updates widgets now say when they last checked for updates.
- Fields in slideouts, the details pane, and dashboard widget settings are now 16px apart, rather than 24px. Fields in the main content pane of full-page forms are still 24px apart.
- Fixed a bug where Dashboard widgets spanning multiple columns ended a few pixels before the right edge of the last column they spanned.
- Fixed a bug where date pickers within slideouts could open far away from their inputs at some browser zoom and display scaling levels. ([#20399](https://github.com/craftcms/cms/issues/20399))
Expand Down Expand Up @@ -705,7 +705,7 @@ Craft's Mutex classes have been deprecated. [Laravel's atomic locking](https://l
- Deprecated `craft\widgets\NewUsers`. `CraftCms\Cms\Dashboard\Widgets\NewUsers` should be used instead.
- Deprecated `craft\widgets\QuickPost`. `CraftCms\Cms\Dashboard\Widgets\QuickPost` should be used instead.
- Deprecated `craft\widgets\RecentEntries`. `CraftCms\Cms\Dashboard\Widgets\RecentEntries` should be used instead.
- Deprecated `craft\widgets\Updates`. `CraftCms\Cms\Dashboard\Widgets\Updates` should be used instead.
- Deprecated `craft\widgets\Updates`. `CraftCms\Cms\Dashboard\Widgets\AboutCraft`, which replaced the Updates widget, should be used instead.
- Deprecated `craft\records\Widget`. `CraftCms\Cms\Dashboard\Models\Widget` should be used instead.

##### Events
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Added the “About Craft CMS” dashboard widget, which shows Craft’s version and edition, any trials of Craft or plugins that are installed with a link to buy them, and, for users who can update Craft, whether updates are available. It replaces the Updates widget, including on existing dashboards, and admins get it at the end of theirs. The command palette’s new “About Craft CMS” action shows the same.
- Config settings that hold config objects, such as `mcp` and `anchors`, can now have their individual settings set with `CRAFT_{SETTING}_{NESTED_SETTING}` environment variables, such as `CRAFT_MCP_INSTRUCTIONS`. They override the same settings from whole-object variables such as `CRAFT_MCP`. ([#20783](https://github.com/craftcms/cms/pull/20783))
- Entry type and volume settings pages now have “Settings”, “Content”, and “Appearance” tabs, so the field layout and card appearance no longer sit below the general settings. ([#20214](https://github.com/craftcms/cms/discussions/20214), [#20658](https://github.com/craftcms/cms/pull/20658))
- Added `CraftCms\Cms\Ui\Nodes\Outlet` and `CraftCms\Cms\Ui\Controls\FieldLayoutDesigner::cardViewDesignerOutlet()`. ([#20658](https://github.com/craftcms/cms/pull/20658))
Expand Down Expand Up @@ -63,7 +64,6 @@
- New Users widgets now show the total number of new users in their date range, above a sparkline of new users per day in the widget’s color, which gets taller as the widget gets wider.
- Craft Support widgets are now a list of links to the documentation, Knowledge Base, Craft Support, GitHub bug reports and feature requests, Discord, and Craft Partners, plus an “Ask AI” button when the AI assistant is available. Support requests are now sent from craftcms.com/contact, rather than a form in the widget.
- Quick Post widgets now show a large button in their entry type’s icon and color, and are titled “New {Section} Entry” by default.
- Updates widgets now show whether updates are available with an icon, say when they last checked, and check again from a button beside their title.
- Dashboard widgets’ settings now load when they’re opened, rather than with the dashboard.
- Saved element conditions, such as custom sources’ and Recent Entries widgets’ criteria, now load faster on sites with many custom fields. Their rules are checked without loading every field layout, unless they’re rules for fields.
- Added the `cpIconPath` and `cpLogoPath` config settings, which set the control panel’s icon and the login page’s logo from files on the server. SVG files are rendered inline, so they can adapt to the selected light or dark theme, such as with the `light-dark()` CSS function. ([#20647](https://github.com/craftcms/cms/issues/20647))
Expand Down
14 changes: 14 additions & 0 deletions resources/css/cp.css
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,20 @@ Temporary holding for cp-pane styles until craft-pane is a thing
}
}

/* An icon leading an item in a list, such as a widget's links or statuses: in the
color of the tinted card or other colorable it's in, or the link color
outside one. Layered so a component's own color for it still applies. */
@layer components {
.cp-item-icon {
color: var(--c-color-fill-loud, var(--c-text-link));
}

/* White's loud fill is white, which would vanish on its card. */
[data-color='white'] .cp-item-icon {
color: var(--c-text-link);
}
}

.markdown-field > .markdown-field-editor {
display: block;
min-height: 0;
Expand Down
118 changes: 118 additions & 0 deletions resources/js/common/components/AboutCraft.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import {afterEach, expect, it, vi} from 'vite-plus/test';
import {createApp, defineComponent, h, type App} from 'vue';
import type {AboutCraftInfo} from './about-craft';
import AboutCraft from './AboutCraft.vue';

const state = vi.hoisted(() => ({get: vi.fn()}));
vi.mock('@craftcms/ui', async () => ({
...(await vi.importActual('@craftcms/ui')),
actionClient: {get: state.get},
}));
vi.mock('@actions/App/AboutCraftController', () => ({
default: {url: () => '/about-craft'},
}));
// Stands in for the updates row, with a button that finishes a check.
vi.mock('./AboutCraftUpdates.vue', () => ({
default: defineComponent({
emits: ['checked'],
setup:
(_, {emit}) =>
() =>
h('button', {class: 'finish-check', onClick: () => emit('checked')}),
}),
}));

let app: App | undefined;

afterEach(() => {
app?.unmount();
document.body.innerHTML = '';
vi.resetAllMocks();
});

function mount(info: AboutCraftInfo): HTMLElement {
const host = document.createElement('div');
document.body.append(host);
app = createApp({render: () => h(AboutCraft, {info})});
app.mount(host);

return host;
}

it('shows Craft’s edition and version', () => {
const host = mount({
version: '6.0.0',
edition: 'Pro',
trial: null,
updates: null,
});

expect(
host
.querySelector('.about-craft__app')!
.textContent!.replace(/\s+/g, ' ')
.trim()
).toBe('Craft CMS Pro Pro edition');
expect(
host.querySelector('.about-craft__edition [aria-hidden="true"]')!
.textContent
).toBe('Pro');
expect(host.querySelector('.about-craft__version')!.textContent).toBe(
'6.0.0'
);
// Nothing to report below them
expect(host.querySelector('.about-craft__section')).toBeNull();
});

it('offers to buy the trials that are installed', () => {
const host = mount({
version: '6.0.0',
edition: 'Pro',
trial: {
message: 'Craft Pro is installed as a trial.',
cartUrl: 'https://console.craftcms.com/cart/new',
},
updates: null,
});

const trial = host.querySelector('.about-craft__trial')!;
// Set as the button's property, which it links with
const button = trial.querySelector('craft-button') as HTMLElement & {
href?: string;
};

expect(trial.textContent).toContain('Craft Pro is installed as a trial.');
expect(button.textContent!.trim()).toBe('Buy now');
expect(button.href).toBe('https://console.craftcms.com/cart/new');
});

it('fetches the trials again once the updates are checked, as they’re only known with the license info', async () => {
// The license info had expired with the updates, so no trials were known.
state.get.mockResolvedValue({
data: {
version: '6.0.0',
edition: 'Pro',
trial: {
message: 'Craft Pro is installed as a trial.',
cartUrl: 'https://console.craftcms.com/cart/new',
},
updates: {cached: true, total: 0, dateFetched: '2026-11-16T12:00:00Z'},
},
});
const host = mount({
version: '6.0.0',
edition: 'Pro',
trial: null,
updates: {cached: false, total: 0, dateFetched: null},
});
expect(host.querySelector('.about-craft__trial')).toBeNull();

host.querySelector<HTMLElement>('.finish-check')!.click();

await vi.waitFor(() =>
expect(host.querySelector('.about-craft__trial')?.textContent).toContain(
'Craft Pro is installed as a trial.'
)
);
expect(state.get).toHaveBeenCalledWith('/about-craft');
});
191 changes: 191 additions & 0 deletions resources/js/common/components/AboutCraft.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<script setup lang="ts">
/**
* Craft’s version and edition, any trials of Craft or plugins that are
* installed, and, for users who can update Craft, whether updates are
* available, as the “About Craft CMS” dashboard widget and command palette
* view show them.
*/
import {actionClient, t} from '@craftcms/ui';
import {ref, watch} from 'vue';
import AboutCraftController from '@actions/App/AboutCraftController';
import type {AboutCraftInfo} from './about-craft';
import AboutCraftRow from './AboutCraftRow.vue';
import AboutCraftUpdates from './AboutCraftUpdates.vue';
import CraftCmsMark from './CraftCmsMark.vue';

const props = defineProps<{
info: AboutCraftInfo;
}>();

/**
* The trials, which are only known while Craft's license info is cached.
* That's fetched along with the updates, so they're fetched again after
* the updates are checked.
*/
const trial = ref(props.info.trial);

watch(
() => props.info.trial,
(value) => (trial.value = value)
);

async function refreshTrial() {
try {
const {data} = await actionClient.get<AboutCraftInfo>(
AboutCraftController.url()
);
trial.value = data.trial;
} catch {
// The trials stay as they were.
}
}
</script>

<template>
<div class="about-craft">
<div class="about-craft__identity">
<CraftCmsMark class="about-craft__mark" />
<div>
<p class="about-craft__app cp-h3">
<span lang="en">Craft CMS</span>{{ ' ' }}
<span class="about-craft__edition">
<span aria-hidden="true">{{ info.edition }}</span
>{{ ' ' }}
<span class="sr-only">{{
t('{edition} edition', {edition: info.edition})
}}</span>
</span>
</p>
<p class="about-craft__version">{{ info.version }}</p>
</div>
</div>
<div v-if="info.updates" class="about-craft__section">
<AboutCraftUpdates :updates="info.updates" @checked="refreshTrial" />
</div>
<div v-if="trial" class="about-craft__section">
<AboutCraftRow class="about-craft__trial">
<template #icon><craft-icon name="flask"></craft-icon></template>
<span class="about-craft-row__title">{{ trial.message }}</span>
<template #action>
<!-- Leads off-site, so it opens in a new tab, and says so -->
<craft-button
variant="plain"
inherit
flush="inline block"
icon="circle-right"
icon-position="suffix"
:href="trial.cartUrl"
class="about-craft-row__link about-craft__buy"
>{{ t('Buy now') }}</craft-button
>
</template>
</AboutCraftRow>
</div>
</div>
</template>

<style scoped>
/* Its content can be kept to --about-craft-max-inline-size, centered, while
the lines between sections still reach its edges. */
.about-craft {
display: flex;
flex-direction: column;
/* Resolved against this element's width, where it's used */
--_inset: max(0px, (100% - var(--about-craft-max-inline-size, 100%)) / 2);
}

.about-craft__identity {
display: flex;
align-items: center;
gap: var(--c-spacing-md);
padding-inline: var(--_inset);
}

.about-craft__mark {
flex: none;
inline-size: calc(44rem / 16);
block-size: calc(44rem / 16);
}

/* Styled like widget titles (.cp-h3). Centered as flex items: in a taller
line, vertical-align leaves the badge low. */
.about-craft__app {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--c-spacing-xs) calc(var(--c-spacing-sm) + 2px);
}

.about-craft__version {
margin: 0;
color: var(--c-text-quiet);
font-size: var(--c-text-sm);
}

.about-craft__edition {
display: inline-flex;
padding-block: 3px;
padding-inline: 5px 3px;
border: 1.5px solid color-mix(in srgb, currentColor 40%, transparent);
border-radius: var(--c-radius-sm);
font-size: 11px;
font-weight: 800;
line-height: 1;
letter-spacing: 1.7px;
text-transform: uppercase;
user-select: none;
}

/* Each section has a line above it, with even space on either side. */
.about-craft__section {
margin-block-start: var(--c-spacing-lg);
/* With its row's own padding, it matches the space above the line. */
padding-block-start: calc(var(--c-spacing-lg) - var(--c-spacing-sm));
/* The line reaches past the container's padding, given as --about-craft-bleed, to its edges. */
margin-inline: calc(var(--about-craft-bleed, 0px) * -1);
padding-inline: calc(var(--about-craft-bleed, 0px) + var(--_inset));
/* Softer than the card's and palette's own dividers, as it only groups */
border-block-start: 1px solid
color-mix(in srgb, var(--c-color-neutral-border-quiet) 50%, transparent);
}

/* The section above ends with its row's padding, which counts toward the space. */
.about-craft__section + .about-craft__section {
margin-block-start: calc(var(--c-spacing-lg) - var(--c-spacing-sm));
}

/* Its row's padding would add to the container's below it. */
.about-craft__section:last-child {
margin-block-end: calc(var(--c-spacing-sm) * -1);
}

/* Available updates fill their section, from line to line and edge to edge,
rather than just their row. */
.about-craft__section:has(.about-craft-row[data-tone='accent']) {
/* Below the line above it, rather than tinting it */
background-clip: padding-box;
background-color: var(
--about-craft-tint-fill,
var(--c-color-accent-fill-quiet)
);
/* The space below it, which the next section would otherwise leave above its line */
padding-block-end: calc(var(--c-spacing-lg) - var(--c-spacing-sm));

& + .about-craft__section {
margin-block-start: 0;
}

/* Last, it reaches the container's bottom edge too. */
&:last-child {
margin-block-end: calc(var(--about-craft-bleed, 0px) * -1);
padding-block-end: calc(
var(--about-craft-bleed, 0px) - var(--c-spacing-sm)
);
}

/* The section's fill stands in for the row's own. */
& :deep(.about-craft-row) {
background: none;
}
}
</style>
Loading
Loading