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

Show warning for old entity spec version #1059

Merged
merged 3 commits into from
Nov 25, 2024
Merged

Conversation

ktuite
Copy link
Member

@ktuite ktuite commented Nov 20, 2024

Frontend of getodk/central-backend#1272

Issue getodk/central#730

Screenshot 2024-11-19 at 4 31 23 PM

What has been done to verify that this works as intended?

Why is this the best possible solution? Were any other approaches considered?

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Does this change require updates to user documentation? If so, please file an issue here and include the link below.

Before submitting this PR, please make sure you have:

  • run npm run test and npm run lint and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code or assets from external sources are properly credited in comments or that everything is internally sourced

Comment on lines 44 to 50
{{ $t('warningsText[3].' + warning.type, { value: warning.details.xmlFormId }) }}
<doc-link :to="documentLinks[warning.type]">{{ $t('moreInfo.learnMore') }}</doc-link>
{{ $t('warningsText[3].' + warning.type, { value: getWarningValue(warning) }) }}
<template v-if="warning.type === 'oldEntityVersion'">
<a :href="externalLinks.oldEntityVersion" target="_blank">{{ $t('moreInfo.learnMore') }}</a>
</template>
<template v-else>
<doc-link :to="documentLinks[warning.type]">{{ $t('moreInfo.learnMore') }}</doc-link>
</template>
Copy link
Member

Choose a reason for hiding this comment

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

I think this predated your changes, but I feel like we're trying to impose a structure on these warnings that doesn't necessarily exist. We have three warnings, and we render each differently. Instead of trying to use computed properties and methods, could we use v-if/v-else? I think that'd be clearer overall. I'm thinking of something like:

<template v-if="warning.type === 'deletedFormExists'">
  {{ $t('warningsText[3].deletedFormExists, { value: warning.details.xmlFormId }) }}
  <doc-link to="central-forms/#deleting-a-form">{{ $t('moreInfo.learnMore') }}</doc-link>
</template>
<template v-else-if="warning.type === 'structureChanged'">
  {{ $t('warningsText[3].structuredChanged') }}
  <doc-link to="central-forms/#central-forms-updates">{{ $t('moreInfo.learnMore') }}</doc-link>
  <span>
    <br>
    <strong>{{ $t('fields') }}</strong> {{ warning.details.join(', ') }}
  </span>
</template>
<template v-else-if="warning.type === 'oldEntityVersion'">
  {{ $t('warningsText[3].oldEntityVersion, { value: warning.details.version }) }}
  <a href="https://getodk.github.io/xforms-spec/entities" target="_blank">{{ $t('moreInfo.learnMore') }}</a>
</template>

For example, I think it's easier to see here that while each warning shows an i18n message, they all work a little differently. deletedFormExists shows details.xmlFormId, oldEntityVersion shows details.version, and structureChanged only shows static text. Its details is actually an array of fields, which are shown in a separate <span>.

Copy link
Member Author

Choose a reason for hiding this comment

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

I like this a lot better, I was struggling with how to manage these different, yet in some ways similar, cases.

@@ -318,7 +330,8 @@ export default {
"Workflow warnings:",
{
"deletedFormExists": "There is a form with ID \"{value}\" in the Trash. If you upload this Form, you won’t be able to undelete the other one with the matching ID.",
"structureChanged": "The following fields have been deleted, renamed or are now in different groups or repeats. These fields will not be visible in the Submission table or included in exports by default."
"structureChanged": "The following fields have been deleted, renamed or are now in different groups or repeats. These fields will not be visible in the Submission table or included in exports by default.",
"oldEntityVersion": "Entities specification version \"{value}\" is not compatible with Offline Entities. Please use version 2024.1.0 or later."
Copy link
Member

Choose a reason for hiding this comment

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

I think curly quotes are usually a nice touch:

Suggested change
"oldEntityVersion": "Entities specification version \"{value}\" is not compatible with Offline Entities. Please use version 2024.1.0 or later."
"oldEntityVersion": "Entities specification version {value} is not compatible with Offline Entities. Please use version 2024.1.0 or later."

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I change it for the deletedFormExists string above, too, or would that require it to get re-translated (so maybe I should just leave it as is)?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think it's not worth it getting re-translated. It'll be nice to have curly quotes in the new warning though.

</span>
</template>
<template v-else-if="warning.type === 'oldEntityVersion'">
{{ $t('warningsText[3].oldEntityVersion', { value: warning.details.version }) }}
Copy link
Member Author

Choose a reason for hiding this comment

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

could call value version in the translation message

@@ -318,7 +324,8 @@ export default {
"Workflow warnings:",
{
"deletedFormExists": "There is a form with ID \"{value}\" in the Trash. If you upload this Form, you won’t be able to undelete the other one with the matching ID.",
"structureChanged": "The following fields have been deleted, renamed or are now in different groups or repeats. These fields will not be visible in the Submission table or included in exports by default."
"structureChanged": "The following fields have been deleted, renamed or are now in different groups or repeats. These fields will not be visible in the Submission table or included in exports by default.",
"oldEntityVersion": "Entities specification version “{value}” is not compatible with Offline Entities. Please use version 2024.1.0 or later."
Copy link
Member Author

Choose a reason for hiding this comment

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

Could possibly say "We recommend using version 2024.1.0 or later..." to leave it more open ended?

@ktuite ktuite merged commit 42c9277 into master Nov 25, 2024
1 check passed
@ktuite ktuite deleted the ktuite/warnEntitySpec branch November 25, 2024 21:11
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