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

fix(edit-content) fix minors bugs Edit Content #31065

Merged
merged 4 commits into from
Jan 6, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<a
data-testid="content-type-link"
[pTooltip]="'edit.content.sidebar.information.go.to.content.type' | dm"
tooltipPosition="bottom"
class="sidebar-card sidebar-card__content-type"
[routerLink]="'/content-types-angular/edit/' + contentType.variable"
target="_blank">
Expand All @@ -31,12 +32,8 @@
<span class="sidebar-card__title">{{ 'Created' | dm }}</span>
<span
class="sidebar-card__subtitle"
[tooltipPosition]="'left'"
[pTooltip]="
!contentlet?.creationDate
? ('edit.content.sidebar.information.no.created.yet' | dm)
: null
">
[pTooltip]="contentlet?.ownerName"
tooltipPosition="bottom">
{{
contentlet?.creationDate
? (contentlet?.ownerName | dotNameFormat) ||
Expand All @@ -48,7 +45,8 @@
<span
class="sidebar-card__date"
data-testid="created-date"
[pTooltip]="contentlet?.creationDate | date: 'MM/dd/yyyy HH:mm:ss'">
[pTooltip]="contentlet?.creationDate | date: 'MM/dd/yyyy HH:mm:ss'"
tooltipPosition="bottom">
{{ contentlet?.creationDate | dotRelativeDate: 'MM/dd/yyyy' : null }}
</span>
}
Expand All @@ -58,19 +56,16 @@
<span class="sidebar-card__title">{{ 'Modified' | dm }}</span>
<span
class="sidebar-card__subtitle"
[tooltipPosition]="'left'"
[pTooltip]="
!contentlet?.modDate
? ('edit.content.sidebar.information.moddate.tooltip' | dm)
: null
">
[tooltipPosition]="'bottom'"
[pTooltip]="contentlet?.modUserName">
{{ contentlet?.modDate ? (contentlet?.modUserName | dotNameFormat) : '-' }}
</span>
@if (contentlet?.modDate) {
<span
class="sidebar-card__date"
data-testid="modified-date"
[pTooltip]="contentlet?.modDate | date: 'MM/dd/yyyy HH:mm:ss'">
[pTooltip]="contentlet?.modDate | date: 'MM/dd/yyyy HH:mm:ss'"
tooltipPosition="bottom">
{{ contentlet?.modDate | dotRelativeDate: 'MM/dd/yyyy' : null }}
</span>
}
Expand All @@ -80,12 +75,8 @@
<span class="sidebar-card__title">{{ 'Published' | dm }}</span>
<span
class="sidebar-card__subtitle"
[tooltipPosition]="'left'"
[pTooltip]="
!contentlet?.publishDate
? ('edit.content.sidebar.information.publishdate.tooltip' | dm)
: null
">
[tooltipPosition]="'bottom'"
[pTooltip]="contentlet?.publishUserName">
{{
contentlet?.publishDate
? (contentlet?.publishUserName | dotNameFormat)
Expand All @@ -96,7 +87,8 @@
<span
class="sidebar-card__date"
data-testid="published-date"
[pTooltip]="contentlet?.publishDate | date: 'MM/dd/yyyy HH:mm:ss'">
[pTooltip]="contentlet?.publishDate | date: 'MM/dd/yyyy HH:mm:ss'"
tooltipPosition="bottom">
{{ contentlet?.publishDate | dotRelativeDate: 'MM/dd/yyyy' : null }}
</span>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@
data-testId="workflow" />
</dot-edit-content-sidebar-section>
</p-tabPanel>

<p-tabPanel [header]="'History' | dm">
<ng-template pTemplate="content">
<span class="temporal-content">{{ 'coming.soon' | dm }}</span>
</ng-template>
</p-tabPanel>
<p-tabPanel [header]="'Settings' | dm">
<ng-template pTemplate="content">
<span class="temporal-content">{{ 'coming.soon' | dm }}</span>
</ng-template>
</p-tabPanel>
</p-tabView>
</aside>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@
}
}

.temporal-content {
padding-top: $spacing-3;
padding-left: $spacing-3;
display: flex;
width: 100%;
}

.content-sidebar {
overflow: auto;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ describe('ContentletStatusPipe', () => {
expect(result.classes).toBe('p-chip-gray');
});

it('should transform contentlet status to "Changed"', () => {
it('should transform contentlet status to "Published"', () => {
const contentlet = { live: true, working: true, archived: false } as DotCMSContentlet;

const result = pipe.transform(contentlet);

expect(result.label).toBe('Changed');
expect(result.classes).toBe('p-chip-pink');
expect(result.label).toBe('Published');
expect(result.classes).toBe('p-chip-success');
});

it('should transform contentlet status to empty label and default classes', () => {
Expand All @@ -62,4 +62,11 @@ describe('ContentletStatusPipe', () => {
expect(result.label).toBe('');
expect(result.classes).toBe('');
});

it('should transform undefined contentlet to "New" status', () => {
const result = pipe.transform(undefined);

expect(result.label).toBe('New');
expect(result.classes).toBe('p-chip-blue');
});
});
24 changes: 16 additions & 8 deletions core-web/libs/edit-content/src/lib/pipes/contentlet-status.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,24 @@ export class ContentletStatusPipe implements PipeTransform {

private getContentletStatus(contentlet: DotCMSContentlet): DotEditContentStatus {
// Archived: Content has been archived
if (contentlet.archived) return DotEditContentStatus.ARCHIVED;

// Changed: Has both live and working versions (unpublished changes exist)
if (contentlet.live && contentlet.working) return DotEditContentStatus.CHANGED;
if (contentlet.archived) {
return DotEditContentStatus.ARCHIVED;
}

// Published: Has live version but no working version (no unpublished changes)
if (contentlet.live && !contentlet.working) return DotEditContentStatus.PUBLISHED;
// Live content handling
if (contentlet.live) {
// Compare working and live inodes to determine if content has changed
if (contentlet.workingInode === contentlet.liveInode) {
return DotEditContentStatus.PUBLISHED;
} else {
return DotEditContentStatus.CHANGED;
}
}

// Draft: Has working version but no live version (never published)
if (contentlet.working && !contentlet.live) return DotEditContentStatus.DRAFT;
// Draft: Not live and has working version
if (contentlet.working) {
return DotEditContentStatus.DRAFT;
}

// Unknown: None of the above conditions match
return DotEditContentStatus.UNKNOWN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,14 @@ export function withContent() {
const initialContentletState =
!scheme || !step ? 'reset' : 'existing';

// The current step is the first step of the selected scheme
const currentScheme = parsedSchemes[currentSchemeId];

patchState(store, {
contentType,
currentSchemeId,
schemes: parsedSchemes,
currentContentActions: parsedCurrentActions,
contentlet,
state: ComponentStatus.LOADED,
currentStep: currentScheme?.firstStep,
currentStep: step,
lastTask: task,
initialContentletState
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
DotHttpErrorManagerService,
DotMessageService,
DotWorkflowActionsFireService,
DotWorkflowsActionsService
DotWorkflowsActionsService,
DotWorkflowService
} from '@dotcms/data-access';
import { ComponentStatus, DotCMSContentlet } from '@dotcms/dotcms-models';

Expand All @@ -23,7 +24,8 @@ import { withWorkflow } from './workflow.feature';
import {
MOCK_CONTENTLET_1_TAB,
MOCK_WORKFLOW_ACTIONS_NEW_ITEMNTTYPE_1_TAB,
MOCK_WORKFLOW_DATA
MOCK_WORKFLOW_DATA,
MOCK_WORKFLOW_STATUS
} from '../../utils/edit-content.mock';
import { CONTENT_TYPE_MOCK } from '../../utils/mocks';
import { parseCurrentActions, parseWorkflows } from '../../utils/workflows.utils';
Expand All @@ -44,7 +46,7 @@ describe('WorkflowFeature', () => {
let router: SpyObject<Router>;
let messageService: SpyObject<MessageService>;
let dotMessageService: SpyObject<DotMessageService>;

let dotWorkflowService: SpyObject<DotWorkflowService>;
const createStore = createServiceFactory({
service: signalStore(
withState({ ...initialRootState, ...mockInitialStateWithContent }),
Expand All @@ -56,7 +58,8 @@ describe('WorkflowFeature', () => {
DotHttpErrorManagerService,
DotMessageService,
MessageService,
Router
Router,
DotWorkflowService
]
});

Expand All @@ -68,7 +71,7 @@ describe('WorkflowFeature', () => {
router = spectator.inject(Router);
messageService = spectator.inject(MessageService);
dotMessageService = spectator.inject(DotMessageService);

dotWorkflowService = spectator.inject(DotWorkflowService);
dotMessageService.get.mockReturnValue('Success Message');
});

Expand All @@ -86,6 +89,7 @@ describe('WorkflowFeature', () => {
workflowActionService.getByInode.mockReturnValue(
of(MOCK_WORKFLOW_ACTIONS_NEW_ITEMNTTYPE_1_TAB)
);
dotWorkflowService.getWorkflowStatus.mockReturnValue(of(MOCK_WORKFLOW_STATUS));

store.fireWorkflowAction(mockOptions);
tick();
Expand Down Expand Up @@ -156,7 +160,10 @@ describe('WorkflowFeature', () => {
expect(store.getCurrentStep()).toBeNull();
expect(messageService.add).toHaveBeenCalledWith(
expect.objectContaining({
severity: 'success'
detail: 'Success Message',
icon: 'pi pi-spin pi-spinner',
severity: 'info',
summary: 'Success Message'
})
);
}));
Expand All @@ -165,6 +172,7 @@ describe('WorkflowFeature', () => {
workflowActionsFireService.fireTo.mockReturnValue(of(MOCK_CONTENTLET_1_TAB));

store.fireWorkflowAction(mockOptions);
tick();

expect(messageService.add).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
DotMessageService,
DotRenderMode,
DotWorkflowActionsFireService,
DotWorkflowsActionsService
DotWorkflowsActionsService,
DotWorkflowService
} from '@dotcms/data-access';
import {
ComponentStatus,
Expand Down Expand Up @@ -200,6 +201,7 @@ export function withWorkflow() {
dotHttpErrorManagerService = inject(DotHttpErrorManagerService),
messageService = inject(MessageService),
dotMessageService = inject(DotMessageService),
dotWorkflowService = inject(DotWorkflowService),
router = inject(Router)
) => ({
/**
Expand Down Expand Up @@ -282,11 +284,18 @@ export function withWorkflow() {
DotRenderMode.EDITING
),
contentlet: of(contentlet),
isReset: of(isReset)
isReset: of(isReset),
// Workflow status for this inode
workflowStatus: dotWorkflowService.getWorkflowStatus(inode)
});
}),
tapResponse({
next: ({ contentlet, currentContentActions, isReset }) => {
next: ({
contentlet,
currentContentActions,
isReset,
workflowStatus
}) => {
// Always navigate if the inode has changed
if (contentlet.inode !== currentContentlet?.inode) {
router.navigate(['/content', contentlet.inode], {
Expand All @@ -298,6 +307,8 @@ export function withWorkflow() {
const parsedCurrentActions =
parseCurrentActions(currentContentActions);

const { step } = workflowStatus;

if (isReset) {
patchState(store, {
contentlet,
Expand All @@ -317,6 +328,7 @@ export function withWorkflow() {
currentContentActions: parsedCurrentActions,
currentSchemeId: store.currentSchemeId(),
state: ComponentStatus.LOADED,
currentStep: step,
error: null
});
}
Expand Down
10 changes: 6 additions & 4 deletions dotCMS/src/main/webapp/WEB-INF/messages/Language.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5851,9 +5851,9 @@ edit.content.success.workflow.message=Your changes have been applied.
edit.content.processing.workflow.message=Your changes are being applied.
edit.content.processing.workflow.message.title=Processing

edit.content.layout.back.to.old.edit.content=Try out the new Edit Content experience, which makes it easier than ever to edit and manage content. You can easily
edit.content.layout.back.to.old.edit.content.switch=switch back
edit.content.layout.back.to.old.edit.content.subtitle=any time.
edit.content.layout.back.to.old.edit.content=You are currently viewing the new Edit Content experience. You can easily revert to the
edit.content.layout.back.to.old.edit.content.switch=previous version
edit.content.layout.back.to.old.edit.content.subtitle=at any time.

edit.content.layout.select.workflow.warning=You haven't selected a Workflow yet.
edit.content.layout.select.workflow.warning.switch=Select a Workflow
Expand Down Expand Up @@ -5909,4 +5909,6 @@ analytics.search.query.by.daily.sessions=Daily Sessions and Requests by Host

uve.device.selector.mobile=Mobile
uve.device.selector.tablet=Tablet
uve.device.selector.default=Desktop
uve.device.selector.default=Desktop

coming.soon=Coming Soon
Loading