Skip to content
3 changes: 2 additions & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,8 @@ export default {
editor: {
nameInputLabel: 'Name',
nameInputHelpText: 'This is the name you will see on your workspace.',
nameIsRequiredError: 'You need to define a name for your workspace',
nameIsRequiredError: 'You need to define a name for your workspace.',
nameHasHtml: 'HTML tags are not allowed in workspace names.',
Comment thread
ctkochan22 marked this conversation as resolved.
currencyInputLabel: 'Default currency',
currencyInputHelpText: 'All expenses on this workspace will be converted to this currency.',
save: 'Save',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ export default {
nameInputLabel: 'Nombre',
nameInputHelpText: 'Este es el nombre que verás en tu espacio de trabajo.',
nameIsRequiredError: 'Debes definir un nombre para tu espacio de trabajo.',
nameHasHtml: 'Las etiquetas HTML no están permitidas en los nombres de los espacios de trabajo.',
currencyInputLabel: 'Moneda por defecto',
currencyInputHelpText: 'Todas los gastos en este espacio de trabajo serán convertidos a esta moneda.',
save: 'Guardar',
Expand Down
15 changes: 11 additions & 4 deletions src/pages/workspace/WorkspaceSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class WorkspaceSettingsPage extends React.Component {
constructor(props) {
super(props);

this.submit = this.submit.bind(this);
this.getCurrencyItems = this.getCurrencyItems.bind(this);
this.submit = this.submit.bind(this);
this.validate = this.validate.bind(this);
}

Expand All @@ -55,17 +55,24 @@ class WorkspaceSettingsPage extends React.Component {
if (this.props.policy.isPolicyUpdating) {
return;
}
const name = values.name.trim();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👋 Leaving a note that this has caused a regression in #18006.
In short, we removed .trim() on the front end, while it is present on the back end. This was causing name to change position temporarily if you add spaces before/after the workspace name.
We resolved this by trimming the workspace name before passing it to Policy.updateGeneralSettings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Damn! 😕 thanks

const outputCurrency = values.currency;
Policy.updateGeneralSettings(this.props.policy.id, name, outputCurrency);
Policy.updateGeneralSettings(this.props.policy.id, values.name, outputCurrency);
Keyboard.dismiss();
}

validate(values) {
const errors = {};
if (!values.name || !values.name.trim().length) {
Comment thread
ctkochan22 marked this conversation as resolved.
const name = values.name.trim();

// Searches for anything that looks like an html tag "< >""
if (name.search(/<(.|\n)*?>/g) !== -1) {
errors.name = this.props.translate('workspace.editor.nameHasHtml');
}

if (!name || !name.length) {
errors.name = this.props.translate('workspace.editor.nameIsRequiredError');
}

return errors;
}

Expand Down