Skip to content

Commit

Permalink
Backlog 21612 backport (#176)
Browse files Browse the repository at this point in the history
* QA-14839: Alternate tag should not exist for single language site (#146)

* QA-14839: Alternate tag should not exist for single language site

* QA-14839: Add cypress test to cover the new case

* QA-14839: Fix PR feedback

* Qa 14820 fix ce display (#152)

* QA-14820 : use nodeByPath instead of nodesByQuery

* QA-14820 : add cypress + small clean

* QA-14916: Fix Toolbar of vanityURLs not properly closed (#165)

* QA-14916: Add cypress to test Toolbar comportment (#167)

* QA-14916: Add cypress to test Toolbar comportment

* QA-14916: Fix PR feedbacks

* BACKLOG-21278 : display vanity url as read only when user have not wr… (#168)

* BACKLOG-21278 : display vanity url as read only when user have not write permissions

* add read only badge

* add missing labels

* remove unecessary code

* update dependencies

* BACKLOG-21278 : add automatically vanity url permission to editor role

* rework infoButton

* BACKLOG-21278 : display read only badge in content editor ui

* add cypress tests

* upgrade @jahia/cypress

* add cyclone

* update node version

* BACKLOG-21272 : add new tests  (#148)

* BACKLOG-21272 : rewrite tests

* format

* add test of case second vanity url of the page

* fix after comments

* fix after comments part 2

* fix after comment"

* BACKLOG-21272 : add test case url rewrite in live (#151)

* BACKLOG-21272 : add test case url rewrite in live

* BACKLOG-21272 : add url rewrite test

* upgrade jahia-cypress

* set the servername at test level only

* fix after comments

* remove duplicate

* fix uiPermission test

---------

Co-authored-by: jahia-carp <[email protected]>
Co-authored-by: ksagnard <[email protected]>
  • Loading branch information
3 people authored Oct 19, 2023
1 parent aec5b5c commit d7c5dec
Show file tree
Hide file tree
Showing 49 changed files with 2,041 additions and 600 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/on-code-change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: Jahia/jahia-modules-action/static-analysis@v2
with:
skip_lint_modules: true
node_version: 14
node_version: 18
auditci_level: critical

build:
Expand Down Expand Up @@ -106,4 +106,4 @@ jobs:
name: Tests Report (Cluster)
path: tests/artifacts/results/xml_reports/**/*.xml
reporter: java-junit
fail-on-error: 'false'
fail-on-error: 'false'
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@
}
},
"dependencies": {
"@apollo/client": "^3.7.14",
"@apollo/client": "^3.8.4",
"@apollo/react-components": "^4.0.0",
"@apollo/react-hoc": "^4.0.0",
"@jahia/data-helper": "^1.1.4",
"@jahia/design-system-kit": "^1.1.12",
"@jahia/icons": "^1.1.2",
"@jahia/moonstone": "^2.5.1",
"@jahia/react-material": "^3.0.1",
"@jahia/react-material": "^3.0.5",
"@jahia/ui-extender": "^1.0.0",
"@material-ui/core": "^3.6.2",
"@material-ui/core": "^3.9.3",
"@material-ui/icons": "^3.0.1",
"graphql": "^15.4.0",
"graphql-tag": "^2.11.0",
"i18next": "^19.0.3",
Expand All @@ -50,7 +53,6 @@
"react-redux": "^7.2.0"
},
"resolutions": {
"@apollo/client": "3.5.10",
"graphql": "15.4.0",
"@jahia/data-helper/graphql": "^15.4.0"
},
Expand All @@ -66,9 +68,11 @@
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.6",
"@babel/preset-react": "^7.0.0",
"@cyclonedx/webpack-plugin": "^3.8.2",
"@jahia/eslint-config": "^1.1.0",
"@jahia/stylelint-config": "^0.0.3",
"@jahia/test-framework": "^1.2.0",
"@jahia/webpack-config": "^1.1.0",
"@types/jest": "^24.0.11",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.4",
Expand Down
5 changes: 3 additions & 2 deletions src/javascript/components/AddVanityUrl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,15 @@ class AddVanityUrlComponent extends React.Component {
};

render() {
const {t, classes} = this.props;
const {t, classes, hasWritePermission} = this.props;
const {errors, mappings} = this.state;

if (!this.state.showInputField) {
return (
<>
{this.props.children && this.props.children(this.state.showInputField)}
<Button className={classes.addVanityButton}
<Button isDisabled={!hasWritePermission}
className={classes.addVanityButton}
aria-label="add"
label={t('label.buttons.addVanity')}
icon={<Add/>}
Expand Down
60 changes: 0 additions & 60 deletions src/javascript/components/InfoButton.jsx

This file was deleted.

Empty file.
39 changes: 2 additions & 37 deletions src/javascript/components/SiteSettingsSeoApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LanguageSelector from './LanguageSelector';
import {withTranslation} from 'react-i18next';
import {Information, SwapHoriz, Publish, Dropdown, Header} from '@jahia/moonstone';
import * as _ from 'lodash';
import InfoButton from './InfoButton';
import {InfoDialog} from './VanityList/live/InfoDialog';
import Publication from './Publication';
import Move from './Move';
import {withVanityMutationContext} from './VanityMutationsProvider';
Expand Down Expand Up @@ -79,10 +79,6 @@ class SiteSettingsSeoApp extends React.Component {
open: false,
urlPairs: []
},
infoButton: {
open: false,
message: ''
},
workspace: {
key: SiteSettingsSeoConstants.VANITY_URL_WORKSPACE_DROPDOWN_DATA[0].key,
value: SiteSettingsSeoConstants.VANITY_URL_WORKSPACE_DROPDOWN_DATA[0].value
Expand All @@ -97,9 +93,6 @@ class SiteSettingsSeoApp extends React.Component {
this.onSearchBlur = this.onSearchBlur.bind(this);
this.onSelectedLanguagesChanged = this.onSelectedLanguagesChanged.bind(this);

this.openInfoButton = this.openInfoButton.bind(this);
this.closeInfoButton = this.closeInfoButton.bind(this);

this.openMove = this.openMove.bind(this);
this.closeMove = this.closeMove.bind(this);

Expand All @@ -123,11 +116,6 @@ class SiteSettingsSeoApp extends React.Component {
key: 'moveAction',
call: this.openMove
},
infoButton: {
buttonIcon: <Information/>,
className: 'move',
call: this.openInfoButton
},
updateVanity: {
call: (data, onSuccess, onError) => {
try {
Expand Down Expand Up @@ -175,24 +163,6 @@ class SiteSettingsSeoApp extends React.Component {
onError(err, mess);
}

openInfoButton = message => {
this.setState({
infoButton: {
open: true,
message: message
}
});
};

closeInfoButton() {
this.setState({
infoButton: {
open: false,
message: ''
}
});
}

openMove = urlPairs => {
this.setState({
move: {
Expand Down Expand Up @@ -325,7 +295,7 @@ class SiteSettingsSeoApp extends React.Component {

render() {
let {siteInfo, t, classes, lang, polling: globalPolling} = this.props;
let polling = !(this.state.publication.open || this.state.move.open || this.state.infoButton.open);
let polling = !(this.state.publication.open || this.state.move.open);
let variables = buildTableQueryVariablesAllVanity({selectedLanguageCodes: this.state.loadParams.selectedLanguageCodes, path: siteInfo.path, lang: lang, ...this.state.loadParams});

return (
Expand Down Expand Up @@ -393,11 +363,6 @@ class SiteSettingsSeoApp extends React.Component {
onClose={this.closeMove}
/>}

{this.state.infoButton.open && <InfoButton
{...this.state.infoButton}
onClose={this.closeInfoButton}
/>}

{this.state.publication.open && <Publication
{...this.state.publication}
onClose={this.closePublication}
Expand Down
1 change: 1 addition & 0 deletions src/javascript/components/Toolbar/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const Toolbar = ({selection, onChangeSelection, actions}) => {
return action.key !== 'updateVanity';
}}
onChangeSelection={onChangeSelection}
onDeleted={onChangeSelection}
/>
</div>
</Paper>
Expand Down
25 changes: 2 additions & 23 deletions src/javascript/components/Utils/Utils.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
import {keyBy, merge, values, sortBy, map} from 'lodash';

export const hasMixin = (node, mixin) => {
if (node.mixinTypes) {
return node.mixinTypes.find(mixinType => mixinType.name === mixin) !== undefined;
}

let mixinTypesProperty = node.properties.find(property => property.name === 'jcr:mixinTypes');
if (mixinTypesProperty) {
return mixinTypesProperty.values.includes(mixin);
}

return false;
};

export const isMarkedForDeletion = url => {
return hasMixin(url, 'jmix:markedForDeletion');
};

export const atLeastOneMarkedForDeletion = urls => {
return urls.some(url => url.default.publicationInfo.publicationStatus === 'MARKED_FOR_DELETION' || url.default.mixinTypes.find(mixin => mixin.name === 'jmix:markedForDeletion'));
};
Expand All @@ -34,7 +17,7 @@ export const atLeastOneNotPublished = urls => {
};

export const buildTableQueryVariablesOneNode = props => {
return buildTableQueryVariables({query: `/jcr:root${encodePathForJCR(props.path)}`, ...props});
return buildTableQueryVariables(props);
};

export const buildTableQueryVariablesAllVanity = props => {
Expand Down Expand Up @@ -62,12 +45,8 @@ export const gqlContentNodeToVanityUrlPairs = (gqlContentNode, vanityUrlsFieldNa
return values(urlPairs);
};

// See https://stackoverflow.com/questions/23388485/xpath-whitespace-encoding for details
const encodePathForJCR = path => path
.replaceAll(' ', '_x0020_')
.replaceAll(/\/(\d)/g, (_, s) => '/_x00' + s.charCodeAt(0).toString(16).slice(-4) + '_');

const buildTableQueryVariables = props => ({
path: props.path,
lang: props.lang,
languages: props.selectedLanguageCodes,
offset: (props.currentPage * props.pageSize),
Expand Down
27 changes: 14 additions & 13 deletions src/javascript/components/VanityList/DefaultRow.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import * as _ from 'lodash';
import {Checkbox, Switch, TableCell, TableRow} from '@material-ui/core';
import {Switch, TableCell, TableRow} from '@material-ui/core';
import {Editable} from '../Editable';
import classes from './DefaultRow.scss';
import {Chip, Loader, Lock, Typography} from '@jahia/moonstone';
import {Chip, Loader, Lock, Typography, Checkbox} from '@jahia/moonstone';
import {LanguageMenu} from '../LanguageMenu';
import {DisplayAction} from '@jahia/ui-extender';

Expand All @@ -17,6 +17,7 @@ import * as PropTypes from 'prop-types';
import clsx from 'clsx';

export const DefaultRow = ({
hasWritePermission,
urlPair,
isCheckboxesDisplayed,
onChangeSelection,
Expand Down Expand Up @@ -58,31 +59,29 @@ export const DefaultRow = ({
className={(isCheckboxesDisplayed ? (isExpanded ? '' : classes.hidden) : (classes.hiddenOnHover)) + ' ' + classes.checkboxLeft}
width="3%"
>
{!isOpenCardMode && <Checkbox checked={selected}
onClick={event => {
event.stopPropagation();
}}
onChange={(event, checked) => onChangeSelection(checked, [urlPair])}/>}
{!isOpenCardMode && <Checkbox isDisabled={!hasWritePermission}
checked={selected}
onChange={event => onChangeSelection(event.currentTarget.checked, [urlPair])}/>}
</TableCell>
<TableCell width="55px">
<Switch classes={{switchBase: classes.switchBase, checked: classes.switchChecked}}
checked={url.active}
disabled={Boolean(isMarkedForDeletion)}
disabled={Boolean(isMarkedForDeletion) || Boolean(!hasWritePermission)}
data-vud-role="action-active"
onClick={event => {
event.stopPropagation();
}}
onChange={event => actions.updateVanity.call({urlPair: urlPair, active: event.target.checked}, event)}/>
</TableCell>
<TableCell className={clsx(classes.tableCellTextInput, {[classes.inactive]: !url.active})} width="100%">
{isMarkedForDeletion &&
{(isMarkedForDeletion || !hasWritePermission) &&
<Typography data-vud-role="url"
className={classes.deletedUrl}
className={isMarkedForDeletion ? classes.deletedUrl : ''}
>
{url.url}
</Typography>}
{!isMarkedForDeletion && <Editable value={url.url}
onChange={onMappingChanged}/>}
{!isMarkedForDeletion && hasWritePermission && <Editable value={url.url}
onChange={onMappingChanged}/>}
</TableCell>
<TableCell width="120px">
<div className={classes.chipContainer}>
Expand All @@ -91,7 +90,7 @@ export const DefaultRow = ({
</div>
</TableCell>
<TableCell className={clsx(classes.languageContainer, {[classes.inactive]: !url.active})} width="90px">
<LanguageMenu isDisabled={Boolean(isMarkedForDeletion)}
<LanguageMenu isDisabled={Boolean(isMarkedForDeletion) || Boolean(!hasWritePermission)}
languageCode={urlPair.default.language}
onLanguageSelected={languageCode => actions.updateVanity.call({
urlPair: urlPair,
Expand All @@ -101,6 +100,7 @@ export const DefaultRow = ({
<TableCell width="40px" align="center" padding="none">
<span>
<DisplayAction
disabled={!hasWritePermission}
path={urlPair.default.path}
urlPair={urlPair}
urlPairs={[urlPair]}
Expand Down Expand Up @@ -130,6 +130,7 @@ export const DefaultRow = ({
};

DefaultRow.propTypes = {
hasWritePermission: PropTypes.bool.isRequired,
urlPair: PropTypes.object.isRequired,
actions: PropTypes.object.isRequired,
isCheckboxesDisplayed: PropTypes.bool.isRequired,
Expand Down
Loading

0 comments on commit d7c5dec

Please sign in to comment.