Skip to content
Merged
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
46 changes: 24 additions & 22 deletions packages/decap-cms-core/src/actions/__tests__/entries.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,32 @@ describe('entries', () => {
fields: [{ name: 'title' }, { name: 'boolean' }],
});

return store.dispatch(createLocalEmptyDraft(collection, '?title=title&boolean=True')).then(() => {
const actions = store.getActions();
expect(actions).toHaveLength(1);
return store
.dispatch(createLocalEmptyDraft(collection, '?title=title&boolean=True'))
.then(() => {
const actions = store.getActions();
expect(actions).toHaveLength(1);

expect(actions[0]).toEqual({
payload: {
author: '',
collection: undefined,
data: { title: 'title', boolean: true },
meta: {},
i18n: {},
isModification: null,
label: null,
mediaFiles: [],
partial: false,
path: '',
raw: '',
slug: '',
status: '',
updatedOn: '',
},
type: 'DRAFT_CREATE_EMPTY',
expect(actions[0]).toEqual({
payload: {
author: '',
collection: undefined,
data: { title: 'title', boolean: true },
meta: {},
i18n: {},
isModification: null,
label: null,
mediaFiles: [],
partial: false,
path: '',
raw: '',
slug: '',
status: '',
updatedOn: '',
},
type: 'DRAFT_CREATE_EMPTY',
});
});
});
});

it('should html escape URL params', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/decap-cms-core/src/components/App/StackToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const StatusButton = styled(DropdownButton)`
css`
background-color: ${colors.processingBackground};
color: ${colors.processingText};
`}
`}

${props =>
props.label === 'stale' &&
Expand Down
10 changes: 7 additions & 3 deletions packages/decap-cms-core/src/components/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class Editor extends React.Component {
// deleteLocalBackup(collection, !newEntry && slug);
// }

createHookContext = (context) => {
createHookContext = context => {
const defaultContext = {
editor: {
props: this.props,
Expand All @@ -253,7 +253,12 @@ export class Editor extends React.Component {
persistUnpublishedEntry: async (collection, existingUnpublishedEntry, entry, opts = {}) => {
const context = this.createHookContext(opts);
const entryDraft = entry || this.props.createEmptyDraft(collection);
return this.props.persistUnpublishedEntry(collection, existingUnpublishedEntry, context, entryDraft);
return this.props.persistUnpublishedEntry(
collection,
existingUnpublishedEntry,
context,
entryDraft,
);
},
publishUnpublishedEntry: async (collection, slug, entry, opts = {}) => {
const context = this.createHookContext(opts);
Expand Down Expand Up @@ -417,7 +422,6 @@ export class Editor extends React.Component {
}
}


await deleteUnpublishedEntry(collection.get('name'), slug);

// this.deleteBackup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const styleStrings = {
`,
flat: `
margin-top: 0 !important;
`
`,
};

const ControlContainer = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ export default class Widget extends Component {

setInactiveStyle = () => {
this.props.setInactiveStyle();
if ((this.props.field.has('pattern') || this.props.field.has('negative_pattern')) && !isEmpty(this.getValidateValue())) {
if (
(this.props.field.has('pattern') || this.props.field.has('negative_pattern')) &&
!isEmpty(this.getValidateValue())
) {
this.validate();
}
};
Expand Down
66 changes: 29 additions & 37 deletions packages/decap-cms-core/src/components/Editor/EditorToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const StatusButton = styled(DropdownButton)`
css`
background-color: ${colors.processingBackground};
color: ${colors.processingText};
`}
`}

${props =>
props.label === 'stale' &&
Expand Down Expand Up @@ -390,34 +390,29 @@ export class EditorToolbar extends React.Component {
);
};

handleStatusChange = (newStatusName) => {
const {
currentStatus,
onChangeStatus,
t
} = this.props;
handleStatusChange = newStatusName => {
const { currentStatus, onChangeStatus, t } = this.props;

if (currentStatus === status.get('PROCESSING')) {
const newStatusLabel = t(`editor.editorToolbar.${newStatusName.toLowerCase()}`);

if (!window.confirm(t('editor.editor.onProcessingStatusChange', {
newStatus: newStatusLabel
}))) {
if (
!window.confirm(
t('editor.editor.onProcessingStatusChange', {
newStatus: newStatusLabel,
}),
)
) {
return;
}
}

onChangeStatus(newStatusName);
}
};

handleDelete = () => {
const {
currentStatus,
hasUnpublishedChanges,
onDeleteUnpublishedChanges,
onDelete,
t
} = this.props;
const { currentStatus, hasUnpublishedChanges, onDeleteUnpublishedChanges, onDelete, t } =
this.props;
if (currentStatus === status.get('PROCESSING')) {
const translationKey = hasUnpublishedChanges
? 'editor.editor.onProcessingDeleteUnpublishedChanges'
Expand All @@ -427,7 +422,7 @@ export class EditorToolbar extends React.Component {
}
}
return hasUnpublishedChanges ? onDeleteUnpublishedChanges() : onDelete();
}
};

renderWorkflowStatusControls = () => {
const { isUpdatingStatus, currentStatus, t, useOpenAuthoring } = this.props;
Expand Down Expand Up @@ -681,26 +676,23 @@ export class EditorToolbar extends React.Component {
</SaveButton>,
currentStatus
? [
<React.Fragment key="workflow-status-controls">
{this.renderWorkflowStatusControls()}
{currentStatus === status.get('PENDING_PUBLISH') &&
this.renderNewEntryWorkflowPublishControls({ canCreate, canPublish })}
</React.Fragment>,
]
<React.Fragment key="workflow-status-controls">
{this.renderWorkflowStatusControls()}
{currentStatus === status.get('PENDING_PUBLISH') &&
this.renderNewEntryWorkflowPublishControls({ canCreate, canPublish })}
</React.Fragment>,
]
: !isNewEntry && (
<React.Fragment key="existing-entry-workflow-publish-controls">
{this.renderExistingEntryWorkflowPublishControls({
canCreate,
canPublish,
canDelete,
})}
</React.Fragment>
),
<React.Fragment key="existing-entry-workflow-publish-controls">
{this.renderExistingEntryWorkflowPublishControls({
canCreate,
canPublish,
canDelete,
})}
</React.Fragment>
),
!hasUnpublishedChanges && !isModification ? null : (
<DeleteButton
key="delete-button"
onClick={this.handleDelete}
>
<DeleteButton key="delete-button" onClick={this.handleDelete}>
{isDeleting ? t('editor.editorToolbar.discarding') : deleteLabel}
</DeleteButton>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
returnObj.persistEntry = (collection, context, entryDraft) => {
const { unpublished = stateProps.unpublishedEntry } = context;
return dispatch(persistUnpublishedEntry(collection, unpublished, context, entryDraft));
}
};
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const ColumnHeader = styled.h2`
css`
background-color: ${colors.processingBackground};
color: ${colors.processingText};
`}
`}

${props =>
props.name === 'stale' &&
Expand Down Expand Up @@ -162,7 +162,7 @@ class WorkflowList extends React.Component {
const collection = dragProps.collection;
const oldStatus = dragProps.ownStatus;
if (oldStatus === 'processing') {
window.alert(this.props.t('workflow.workflowList.onProcessingUpdate'))
window.alert(this.props.t('workflow.workflowList.onProcessingUpdate'));
return;
}
if (newStatus === 'stale') {
Expand All @@ -174,7 +174,7 @@ class WorkflowList extends React.Component {

requestDelete = (collection, slug, ownStatus) => {
if (ownStatus === 'processing') {
window.alert(this.props.t('workflow.workflowList.onProcessingUpdate'))
window.alert(this.props.t('workflow.workflowList.onProcessingUpdate'));
return;
}
if (window.confirm(this.props.t('workflow.workflowList.onDeleteEntry'))) {
Expand Down
3 changes: 1 addition & 2 deletions packages/decap-cms-core/src/lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ allowedEvents.forEach(e => {

const lib = {
immutable,
}
};

/**
* Global Registry Object
Expand Down Expand Up @@ -321,4 +321,3 @@ export function getCustomFormatsFormatters() {
export function getFormatter(name) {
return registry.formats[name]?.formatter;
}

10 changes: 6 additions & 4 deletions packages/decap-cms-locales/src/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const en = {
widget: {
required: '%{fieldLabel} is required.',
regexPattern: "%{fieldLabel} didn't match the pattern: %{pattern}.",
regexNegativePattern: "%{fieldLabel} should not contain pattern: %{pattern}.",
regexNegativePattern: '%{fieldLabel} should not contain pattern: %{pattern}.',
processing: '%{fieldLabel} is processing.',
range: '%{fieldLabel} must be between %{minValue} and %{maxValue}.',
min: '%{fieldLabel} must be at least %{minValue}.',
Expand Down Expand Up @@ -115,9 +115,11 @@ const en = {
'All changes to this entry will be deleted.\n\n Do you still want to delete?',
loadingEntry: 'Loading entry...',
confirmLoadBackup: 'A local backup was recovered for this entry, would you like to use it?',
onProcessingStatusChange: "Are you sure you want to change the status to %{newStatus} while the entry is processing?",
onProcessingDeleteUnpublishedChanges: "Are you sure you want to delete unpublished changes while the entry is processing?",
onProcessingDeleteEntry: "Are you sure you want to delete this entry while it is processing?",
onProcessingStatusChange:
'Are you sure you want to change the status to %{newStatus} while the entry is processing?',
onProcessingDeleteUnpublishedChanges:
'Are you sure you want to delete unpublished changes while the entry is processing?',
onProcessingDeleteEntry: 'Are you sure you want to delete this entry while it is processing?',
onStackPublishing: 'Are you sure you want to publish all changes?',
onStackClosing: 'Are you sure you want to discard all changes?',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('DateTimeControl', () => {
});

test('sets value in custom format (local timezone) when input value changes', () => {
const { input, props } = setup({ field: new Map() })
const { input, props } = setup({ field: new Map() });

const testDate = '2024-03-15T10:30:00';

Expand Down
6 changes: 3 additions & 3 deletions packages/decap-cms-widget-list/src/ListControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export default class ListControl extends React.Component {
const { value, onChange } = this.props;

const listValue = value.get(index);
if (!listValue) return
if (!listValue) return;

const { itemsCollapsed } = this.state;

Expand All @@ -459,7 +459,7 @@ export default class ListControl extends React.Component {

this.setState({
itemsCollapsed: newItemsCollapsed,
keys: newKeys
keys: newKeys,
});

onChange(value.insert(index + 1, listValue));
Expand Down Expand Up @@ -690,7 +690,7 @@ export default class ListControl extends React.Component {
}
}

const ObjectControl = (this.props.getWidget('object')).control;
const ObjectControl = this.props.getWidget('object').control;

return (
<SortableListItem
Expand Down
4 changes: 2 additions & 2 deletions packages/decap-cms-widget-string/src/StringControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export default class StringControl extends React.Component {
shouldComponentUpdate(nextProps, nextState = {}) {
return Boolean(
this.props.classNameWrapper !== nextProps.classNameWrapper ||
this.state.value !== nextState.value ||
nextProps.value !== nextState.value
this.state.value !== nextState.value ||
nextProps.value !== nextState.value,
);
}

Expand Down
Loading