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

Soft deprecate config labels #1300

Merged
merged 4 commits into from
Oct 14, 2024
Merged

Soft deprecate config labels #1300

merged 4 commits into from
Oct 14, 2024

Conversation

Skaiir
Copy link
Contributor

@Skaiir Skaiir commented Oct 10, 2024

Closes #1291

I ended up trying to keep it minimal. Still keeping the isNew flag, but there's only one place where it HAD to be used. We are safe to default the labels now because in any case, if it's not new, the label should be '' (not undefined).

@Skaiir Skaiir requested a review from vsgoulart October 10, 2024 10:45
@bpmn-io-tasks bpmn-io-tasks bot added the needs review Review pending label Oct 10, 2024
});
const field = config.create(
{
...(config.label ? { label: config.label } : {}),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applyDefaults removed here as some long time ago, we made the change to serialize empty labels to '' instead of undefined (so that they would persist across loads). Hence this wasn't doing anything to properly formatted schemas.

const defaults = {};
set(defaults, DATETIME_SUBTYPE_PATH, DATETIME_SUBTYPES.DATE);
set(defaults, DATE_LABEL_PATH, 'Date');

if (isNew) {
Copy link
Contributor Author

@Skaiir Skaiir Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we need isNew so that date label doesn't get created for time components. It's the only place where this is required.

group: 'basic-input',
emptyValue: null,
sanitizeValue: sanitizeDateTimePickerValue,
create: (options = {}) => {
create: (options = {}, isNew) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just think we should give a more descriptive name

Suggested change
create: (options = {}, isNew) => {
create: (options = {}, is NewLabel) => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll rename it all to isNewField (the fact that the label is new is only an implementation detail of the fact that the field is new).

@@ -13,7 +13,7 @@ export class FieldFactory {
this._formFields = formFields;
}

create(attrs, applyDefaults = true) {
create(attrs, isNew = true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
create(attrs, isNew = true) {
create(attrs, isNewLabel = true) {

@@ -302,12 +310,12 @@ describe('core/FieldFactory', function () {

// helpers //////////////

function testCreate(options, applyDefaults = true) {
const { type, label, keyed = false, defaults = {} } = options;
function testCreate(options, isNew = true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function testCreate(options, isNew = true) {
function testCreate(options, isNewLabel = true) {

@Skaiir Skaiir merged commit 05738d9 into main Oct 14, 2024
12 checks passed
@Skaiir Skaiir deleted the 1291-soft-deprecate-config-labels branch October 14, 2024 07:26
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants