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 2 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 @@ -31,12 +31,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="left">
oidacra marked this conversation as resolved.
Show resolved Hide resolved
{{
contentlet?.creationDate
? (contentlet?.ownerName | dotNameFormat) ||
Expand All @@ -59,11 +55,7 @@
<span
class="sidebar-card__subtitle"
[tooltipPosition]="'left'"
[pTooltip]="
!contentlet?.modDate
? ('edit.content.sidebar.information.moddate.tooltip' | dm)
: null
">
[pTooltip]="contentlet?.modUserName">
{{ contentlet?.modDate ? (contentlet?.modUserName | dotNameFormat) : '-' }}
</span>
@if (contentlet?.modDate) {
Expand All @@ -81,11 +73,7 @@
<span
class="sidebar-card__subtitle"
[tooltipPosition]="'left'"
[pTooltip]="
!contentlet?.publishDate
? ('edit.content.sidebar.information.publishdate.tooltip' | dm)
: null
">
[pTooltip]="contentlet?.publishUserName">
{{
contentlet?.publishDate
? (contentlet?.publishUserName | dotNameFormat)
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' }}</span>
oidacra marked this conversation as resolved.
Show resolved Hide resolved
</ng-template>
</p-tabPanel>
<p-tabPanel [header]="'Settings' | dm">
<ng-template pTemplate="content">
<span class="temporal-content">{{ 'Coming soon' }}</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 @@ -285,17 +285,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