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

Feature: Use uui invalid color (Awaiting new UUI version) #18273

Draft
wants to merge 1 commit into
base: v15/dev
Choose a base branch
from
Draft
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
@@ -1,4 +1,4 @@
import type { UmbContentDetailModel, UmbElementValueModel } from '../types.js';

Check notice on line 1 in src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/content-detail-workspace-base.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

✅ No longer an issue: Large Method

constructor is no longer above the threshold for lines of code
import { UmbContentWorkspaceDataManager } from '../manager/index.js';
import { UmbMergeContentVariantDataController } from '../controller/merge-content-variant-data.controller.js';
import type { UmbContentVariantPickerData, UmbContentVariantPickerValue } from '../variant-picker/index.js';
Expand Down Expand Up @@ -59,6 +59,7 @@
contentTypeDetailRepository: UmbDetailRepositoryConstructor<ContentTypeDetailModelType>;
contentValidationRepository?: ClassConstructor<UmbContentValidationRepository<DetailModelType>>;
skipValidationOnSubmit?: boolean;
ignorerValidationOnSubmit?: boolean;
contentVariantScaffold: VariantModelType;
saveModalToken?: UmbModalToken<UmbContentVariantPickerData<VariantOptionModelType>, UmbContentVariantPickerValue>;
}
Expand Down Expand Up @@ -140,6 +141,7 @@
public readonly variantOptions;

#validateOnSubmit: boolean;
#ignorerValidationOnSubmit: boolean;
#serverValidation = new UmbServerModelValidatorContext(this);
#validationRepositoryClass?: ClassConstructor<UmbContentValidationRepository<DetailModelType>>;
#validationRepository?: UmbContentValidationRepository<DetailModelType>;
Expand All @@ -163,6 +165,7 @@
const contentTypeDetailRepository = new args.contentTypeDetailRepository(this);
this.#validationRepositoryClass = args.contentValidationRepository;
this.#validateOnSubmit = args.skipValidationOnSubmit ? !args.skipValidationOnSubmit : true;
this.#ignorerValidationOnSubmit = args.ignorerValidationOnSubmit ? !args.ignorerValidationOnSubmit : true;

Check warning on line 168 in src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/content-detail-workspace-base.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ New issue: Complex Method

constructor has a cyclomatic complexity of 9, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
this.structure = new UmbContentTypeStructureManager<ContentTypeDetailModelType>(this, contentTypeDetailRepository);
this.variesByCulture = this.structure.ownerContentTypeObservablePart((x) => x?.variesByCulture);
this.variesBySegment = this.structure.ownerContentTypeObservablePart((x) => x?.variesBySegment);
Expand Down Expand Up @@ -616,7 +619,11 @@
return this.performCreateOrUpdate(variantIds, saveData);
},
async () => {
return this.invalidSubmit();
if (this.#ignorerValidationOnSubmit) {
return this.performCreateOrUpdate(variantIds, saveData);
} else {
return this.invalidSubmit();
}

Check warning on line 626 in src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/content-detail-workspace-base.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ Getting worse: Complex Method

_handleSubmit increases in cyclomatic complexity from 13 to 14, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check warning on line 626 in src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/content-detail-workspace-base.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ New issue: Bumpy Road Ahead

_handleSubmit has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
},
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class UmbPropertyLayoutElement extends UmbLitElement {
<div id="headerColumn">
<uui-label id="label" title=${this.alias} ?required=${this.mandatory}>
${this.localize.string(this.label)}
${when(this.invalid, () => html`<uui-badge color="danger" attention>!</uui-badge>`)}
${when(this.invalid, () => html`<uui-badge color="invalid" attention>!</uui-badge>`)}
</uui-label>
<slot name="action-menu"></slot>
${this.#renderDescription()}
Expand Down Expand Up @@ -134,10 +134,17 @@ export class UmbPropertyLayoutElement extends UmbLitElement {
word-break: break-word;
}
:host([invalid]) #label {
color: var(--uui-color-danger);
color: var(--umb-validation-look-danger, var(--uui-color-danger))
var(--umb-validation-look-warning, var(--uui-color-warning-standalone));
}
uui-badge {
right: -30px;

background-color: var(--umb-validation-look-danger, var(--uui-color-danger))
var(--umb-validation-look-warning, var(--uui-color-warning));

color: var(--umb-validation-look-danger, var(--uui-color-danger-contrast))
var(--umb-validation-look-warning, var(--uui-color-warning-contrast));
}

#description {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class UmbFormValidationMessageElement extends UmbLitElement {
static override styles = [
css`
#messages {
color: var(--uui-color-danger-standalone);
color: var(--uui-color-invalid-standalone);
}
`,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
@customElement('umb-workspace-modal')
export class UmbWorkspaceModalElement extends UmbLitElement {
@property({ attribute: false })
data?: UmbWorkspaceModalData;
public get data(): UmbWorkspaceModalData | undefined {
return this._data;
}
public set data(value: UmbWorkspaceModalData | undefined) {
this._data = value;
if (value?.inheritValidationLook) {
// Do nothing.
} else {
const elementStyle = this.style;
elementStyle.setProperty('--uui-color-invalid', 'var(--uui-color-danger)');
elementStyle.setProperty('--uui-color-invalid-emphasis', 'var(--uui-color-danger-emphasis)');
elementStyle.setProperty('--uui-color-invalid-standalone', 'var(--uui-color-danger-standalone)');
elementStyle.setProperty('--uui-color-invalid-contrast', 'var(--uui-color-danger-contrast)');
}
}
private _data?: UmbWorkspaceModalData | undefined;

/**
* TODO: Consider if this binding and events integration is the right for communicating back the modal handler. Or if we should go with some Context API. like a Modal Context API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface UmbWorkspaceModalData<DataModelType = unknown> {
entityType: string;
preset: Partial<DataModelType>;
baseDataPath?: string;
inheritValidationLook?: boolean;
}

export type UmbWorkspaceModalValue =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export class UmbDocumentPublishingWorkspaceContext extends UmbContextBase<UmbDoc
* @memberof UmbDocumentPublishingWorkspaceContext
*/
public async saveAndPublish(): Promise<void> {
const elementStyle = (this.getHostElement() as HTMLElement).style;
elementStyle.removeProperty('--uui-color-invalid');
elementStyle.removeProperty('--uui-color-invalid-emphasis');
elementStyle.removeProperty('--uui-color-invalid-standalone');
elementStyle.removeProperty('--uui-color-invalid-contrast');
return this.#handleSaveAndPublish();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
detailRepositoryAlias: UMB_DOCUMENT_DETAIL_REPOSITORY_ALIAS,
contentTypeDetailRepository: UmbDocumentTypeDetailRepository,
contentValidationRepository: UmbDocumentValidationRepository,
skipValidationOnSubmit: true,
skipValidationOnSubmit: false,
ignorerValidationOnSubmit: true,

Check warning on line 84 in src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ Getting worse: Large Method

UmbDocumentWorkspaceContext.constructor increases from 93 to 94 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
contentVariantScaffold: UMB_DOCUMENT_DETAIL_MODEL_VARIANT_SCAFFOLD,
saveModalToken: UMB_DOCUMENT_SAVE_MODAL,
});
Expand Down Expand Up @@ -250,11 +251,11 @@
* @returns {Promise<void>} a promise which resolves once it has been completed.
*/
public override requestSubmit() {
return this._handleSubmit();
}

// Because we do not make validation prevent submission this also submits the workspace. [NL]
public override invalidSubmit() {
const elementStyle = (this.getHostElement() as HTMLElement).style;
elementStyle.setProperty('--uui-color-invalid', 'var(--uui-color-warning)');
elementStyle.setProperty('--uui-color-invalid-emphasis', 'var(--uui-color-warning-emphasis)');
elementStyle.setProperty('--uui-color-invalid-standalone', 'var(--uui-color-warning-standalone)');
elementStyle.setProperty('--uui-color-invalid-contrast', 'var(--uui-color-warning-contrast)');
return this._handleSubmit();
}

Expand Down
Loading