Skip to content

Commit

Permalink
Merge branch 'master' into listing-query
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleybl authored Nov 16, 2022
2 parents 83e455a + f66ab8a commit a9ecfe6
Show file tree
Hide file tree
Showing 70 changed files with 3,351 additions and 345 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ public/critical.css
# Sphinx and MyST
docs/_build/
/.python-version
/.tool-versions
18 changes: 10 additions & 8 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ CNAME
entrypoint.sh
Jenkinsfile
Makefile
.husky

# Logs
logs
Expand Down Expand Up @@ -91,14 +92,6 @@ typings/
# Volto logos
./logos

# yarn 3
.yarn
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Razzle cache
cache/

Expand All @@ -116,3 +109,12 @@ styleguide.config
packages/*
!packages/volto-slate
.tx

# yarn 3
.yarn
.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
1 change: 1 addition & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const defaultRazzleOptions = {
module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
staticDirs: ['./static'],
webpackFinal: async (config, { configType }) => {
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
// You can change the configuration based on that.
Expand Down
Binary file added .storybook/static/previewImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 48 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,55 @@

### Breaking

### Feature

### Bugfix

### Internal

- Ignore `.tool-versions` file

### Documentation

- Add `@plone/scripts` as a mandatory devDependency for projects to the upgrade guide @sneridagh

## 16.0.0-alpha.50 (2022-11-15)

### Feature

- Brazilian Portuguese translation updated @ericof

### Bugfix

- Fix condition in `applySchemaDefaults` @tiberiuichim @sneridagh
- Load core add-ons configuration as any other add-on. @sneridagh
- Fix `FormValidation` error object, use field `id` instead of field `title` @sneridagh
- Revert #2828 PR change of the default `showSearchButton` Search block behavior (see [#3883](https://github.com/plone/volto/issues/3883)) @sneridagh
- Fix `package.json` `postinstall` in core @sneridagh

### Documentation

- Add missing pieces of the upgrade to use yarn 3 for projects @sneridagh
- Complete docs about the yarn 3 upgrade @sneridagh
- Add additional components to storybook @danalvrz

## 16.0.0-alpha.49 (2022-11-11)

### Breaking

- Restrict css selector for error message (volto-slate) #3838 @mamico
- Upgrade `husky` to latest version @sneridagh
- Enable the use of yarn 3 in the build by default @sneridagh

See https://6.dev-docs.plone.org/volto/upgrade-guide/index.html for more information.


### Feature

- Japanese translation updated @terapyon
- Improve the `AlignWidget`, add `narrow` fix default support @sneridagh
- Add support for loading core add-ons from the `packages` folder defined in Volto's `package.json` @sneridagh
- Implement the Upgrade Control Panel @ericof
- Allow addons to customize modules from the project root, via the `@root` namespace and folder @tiberiuichim

### Bugfix

Expand All @@ -21,14 +61,19 @@ See https://6.dev-docs.plone.org/volto/upgrade-guide/index.html for more informa
- Remove slate's builtin undo support, as it conflicts with Volto's undo manager. This fixes crashes when undoing in text blocks and slate's undo stack is empty and "crosses" into Volto's undo stack. This is a temporary workaround, ideally the two undo managers would be delimited so they each work together. @tiberiuichim
- Fix highlighting of selection when the Slate editor is not DOM-focused. @tiberiuichim
- Improve the algorithm that calculates the position of the Slate Toolbar @tiberiuichim
- The `_unwrapElement` of the volto-slate `ElementEditor` will return an updated range (selection) of the unwrapped element.
- The `_unwrapElement` of the volto-slate `ElementEditor` will return an updated range (selection) of the unwrapped element. @tiberiuichim
- Replace the main client entry point in `start-client.jsx` anonymous function for a named one. @sneridagh
- Fix `currentPath` option for `openObjectBrowser`. @iFlameing
- Fix updating the listing block when the variation is changed while editing @tiberiuichim
- fix(warning): StyleMenu dropdown item to use data-attr instead of custom @nileshgulia1
- Added --canary flag in plone/install.sh. @MdSahil-oss

### Internal

- Upgrade dependencies to latest released slate libraries. Make sure to pass down `ref` to rendered slate elements, as ref is now a function @tiberiuichim
- Add `editableProps` prop to the `SlateEditor` component, to pass down props to the base Slate `Editable` component. @tiberiuichim
- Clean, re-enable block-slate-format-link Cypress tests @tiberiuichim
- Rewrite some anonymous functions as named functions, to remove warning about Hot Reloading. @tiberiuichim
- Add translation for objectlist `Add` text @iFlameing
- Add translations for facet widget value @iFlameing

Expand Down Expand Up @@ -180,7 +225,6 @@ See https://6.dev-docs.plone.org/volto/upgrade-guide/index.html for more informa
### Breaking

- Sentry integration is now lazy-loaded. The `sentryOptions` key from the `settings` registry becomes a callable that passes resolved sentry libraries. @tiberiuichim
- Enable the use of yarn 3 in the build by default @sneridagh

See https://6.dev-docs.plone.org/volto/upgrade-guide/index.html for more information.

Expand Down Expand Up @@ -414,6 +458,7 @@ Undo html_static_path configuration in `plone/documentation`, and restore image
### Internal

### Documentation

- Fix copy / paste text in list @robgietema

## 16.0.0-alpha.27 (2022-08-29)
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ MAKEFLAGS+=--no-builtin-rules

INSTANCE_PORT=8080
DOCKER_IMAGE=plone/plone-backend:6.0.0b3
KGS=plone.restapi==8.31.0 plone.volto==4.0.0a14
KGS=plone.restapi==8.32.0 plone.volto==4.0.0a14
TESTING_ADDONS=plone.app.robotframework==2.0.0b2 plone.app.testing==7.0.0a3
NODEBIN = ./node_modules/.bin

# Plone 5 legacy
DOCKER_IMAGE5=plone/plone-backend:5.2.9
KGS5=plone.restapi==8.31.0 plone.volto==4.0.0a14 plone.rest==2.0.0
KGS5=plone.restapi==8.32.0 plone.volto==4.0.0a14 plone.rest==2.0.0

# Sphinx variables
# You can set these variables from the command line.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ const {
getAddonsLoaderChain,
} = AddonConfigurationRegistry;

describe('AddonConfigurationRegistry', () => {
it('works in Volto', () => {
const base = path.join(__dirname, '..');
const reg = new AddonConfigurationRegistry(base);
expect(reg.projectRootPath).toStrictEqual(base);
expect(reg.addonNames).toStrictEqual(['@plone/volto-slate']);
});
describe('AddonConfigurationRegistry - Project', () => {
jest.mock(
`${path.join(
__dirname,
'fixtures',
'test-volto-project',
)}/node_modules/@plone/volto/package.json`,
() => ({
// TODO: mock the packages folder inside the mocked @plone/volto to work with resolves
packagesFolderAddons: {},
}),
{ virtual: true },
);

it('works in a mock project directory', () => {
const base = path.join(__dirname, 'fixtures', 'test-volto-project');
Expand Down Expand Up @@ -149,6 +155,7 @@ describe('AddonConfigurationRegistry', () => {
expect(reg.getAddonCustomizationPaths()).toStrictEqual({
'@plone/volto/client': `${base}/node_modules/test-released-source-addon/src/customizations/client.js`,
'@plone/volto/server': `${base}/addons/test-addon/src/custom-addons/volto/server.jsx`,
'@root/marker': `${base}/node_modules/test-released-source-addon/src/customizations/@root/marker.js`,
'test-released-source-addon/index': `${base}/addons/test-addon/src/custom-addons/test-released-source-addon/index.js`,
});
});
Expand Down
11 changes: 11 additions & 0 deletions __tests__/addon-registry-volto.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path');
const AddonConfigurationRegistry = require('../addon-registry');

describe('AddonConfigurationRegistry - Volto', () => {
it('works in Volto', () => {
const base = path.join(__dirname, '..');
const reg = new AddonConfigurationRegistry(base);
expect(reg.projectRootPath).toStrictEqual(base);
expect(reg.addonNames).toStrictEqual(['@plone/volto-slate']);
});
});
Empty file.
95 changes: 63 additions & 32 deletions addon-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ function fromEntries(pairs) {
function buildDependencyGraph(addons, extractDependency) {
// getAddonsLoaderChain
const graph = new DepGraph({ circular: true });
graph.addNode('@package');
graph.addNode('@root');

const seen = ['@package'];
const stack = [['@package', addons]];
const seen = ['@root'];
const stack = [['@root', addons]];

while (stack.length > 0) {
const [pkgName, addons] = stack.shift();
Expand Down Expand Up @@ -70,7 +70,7 @@ function buildDependencyGraph(addons, extractDependency) {
* a resolved chain of dependencies
*/
function getAddonsLoaderChain(graph) {
return graph.dependenciesOf('@package').map((name) => {
return graph.dependenciesOf('@root').map((name) => {
const extras = graph.getNodeData(name) || [].join(',');
return extras.length ? `${name}:${extras}` : name;
});
Expand Down Expand Up @@ -108,16 +108,24 @@ class AddonConfigurationRegistry {
} else {
this.voltoConfigJS = [];
}
this.resultantMergedAddons = [
...(packageJson.addons || []),
...(this.voltoConfigJS.addons || []),
];

this.projectRootPath = projectRootPath;
this.voltoPath =
packageJson.name === '@plone/volto'
? `${projectRootPath}`
: `${projectRootPath}/node_modules/@plone/volto`;

this.packagesFolderAddons =
packageJson.name === '@plone/volto'
? packageJson.packagesFolderAddons || {}
: require(`${getPackageBasePath(this.voltoPath)}/package.json`)
.packagesFolderAddons || {};

this.resultantMergedAddons = [
...(packageJson.addons || []),
...(this.voltoConfigJS.addons || []),
];

this.addonNames = this.resultantMergedAddons.map((s) => s.split(':')[0]);
this.packages = {};
this.customizations = new Map();
Expand All @@ -128,6 +136,9 @@ class AddonConfigurationRegistry {

this.dependencyGraph = buildDependencyGraph(
[
...(Object.keys(this.packagesFolderAddons).map(
(key) => this.packagesFolderAddons[key].package,
) || []),
...this.resultantMergedAddons,
...(process.env.ADDONS ? process.env.ADDONS.split(';') : []),
],
Expand Down Expand Up @@ -184,32 +195,42 @@ class AddonConfigurationRegistry {
this.packages[name] = Object.assign(this.packages[name] || {}, pkg);
});
}
this.initSlate();
this.initPackagesFolder();
}

initSlate() {
if (this.packages['@plone/volto-slate']) return;
initPackagesFolder() {
const registerPackageFolder = (packageFolderName, packageInfo) => {
const packageName = packageInfo.package;
if (this.packages[packageName]) return;

const slatePath = path.normalize(
`${this.voltoPath}/packages/volto-slate/src`,
);
const slatePackageJsonPath = path.normalize(
`${this.voltoPath}/packages/volto-slate/package.json`,
);
const packagePath = path.normalize(
`${this.voltoPath}/packages/${packageFolderName}/src`,
);
const packageJsonPath = path.normalize(
`${this.voltoPath}/packages/${packageFolderName}/package.json`,
);

// some tests set the root in a location that doesn't have the packages
if (!fs.existsSync(packagePath)) return;

// some tests set the root in a location that doesn't have the packages
if (!fs.existsSync(slatePath)) return;

this.packages['@plone/volto-slate'] = {
modulePath: slatePath,
packageJson: slatePackageJsonPath,
version: require(slatePackageJsonPath).version,
isPublishedPackage: false,
isRegisteredAddon: false,
name: '@plone/volto-slate',
addons: [],
this.packages[packageName] = {
modulePath: packagePath,
packageJson: packageJsonPath,
version: require(packageJsonPath).version,
isPublishedPackage: false,
isRegisteredAddon: false,
name: packageName,
addons: [],
};
this.addonNames.push(packageName);
};
this.addonNames.push('@plone/volto-slate');

Object.keys(this.packagesFolderAddons).forEach((packageFolderName) => {
registerPackageFolder(
packageFolderName,
this.packagesFolderAddons[packageFolderName],
);
});
}

/**
Expand Down Expand Up @@ -309,7 +330,7 @@ class AddonConfigurationRegistry {
*/
getAddons() {
return this.dependencyGraph
.dependenciesOf('@package')
.dependenciesOf('@root')
.map((name) => this.packages[name]);
}

Expand Down Expand Up @@ -374,6 +395,16 @@ class AddonConfigurationRegistry {
}
});

// allow customization of modules in the `@root` namespace from addons,
// by creating a folder called `@root`.
const rootBase = path.join(base, '@root');
if (fs.existsSync(rootBase))
reg.push({
customPath: rootBase,
sourcePath: `${this.projectRootPath}/src`,
name: '@root',
});

reg.push(
fs.existsSync(path.join(base, 'volto'))
? {
Expand Down Expand Up @@ -481,9 +512,9 @@ class AddonConfigurationRegistry {
sep="+10"
splines=curved
"@package" [color = red fillcolor=yellow style=filled]
"@root" [color = red fillcolor=yellow style=filled]
`;
let queue = ['@package'];
let queue = ['@root'];
let name;

while (queue.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion api/versions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async-generator = 1.10
collective.folderishtypes = 3.0.0
collective.recipe.plonesite = 1.12.0
h11 = 0.12.0
plone.restapi = 8.30.0
plone.restapi = 8.32.0
plone.volto = 4.0.0a13
prompt-toolkit = 2.0.10
pyOpenSSL = 21.0.0
Expand Down
Loading

0 comments on commit a9ecfe6

Please sign in to comment.