-
Notifications
You must be signed in to change notification settings - Fork 392
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
CB-3703 save product configuration from ui #2334
CB-3703 save product configuration from ui #2334
Conversation
baseFeatures: [] as string[], | ||
}; | ||
const settingsSchema = schema.object({ | ||
baseFeatures: schema.array(schema.string()).default([]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use array of enums? so it is more typescript friendly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
features is extendable entity, so we can't declare all possible values
webapp/packages/core-blocks/src/FormControls/Checkboxes/FieldCheckbox.tsx
Show resolved
Hide resolved
if (typeof result === 'string') { | ||
element.setCustomValidity(result); | ||
return false; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for this else you can just go with
element.setCustomValidity('');
return true;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
const result = validation(value); | ||
|
||
try { | ||
if (typeof result === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is expected behavior in case where result is an empty string? feels like in this case we should go in else statement
so I suggest to add extra check
if (typeof result === 'string' && result)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty string will be treated as invalid field but with no message = no message must be treated as a bug (validation function must not return empty strings)
if (target.value === '') { | ||
return; | ||
} | ||
if (target.validity.valid === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we validate it if it is already valid?
probably, this should be
target.validity.valid === true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- we want to validate on blur
- browser validation focus first invalid field (so if it's invalid it will be impossible to focus other element)
|
||
constructor(readonly name: string, readonly parent?: SettingsGroup) { | ||
this.id = uuid(); | ||
this.subGroups = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is strict order here required? may be we can go with Set (if not) or even create an OrderedSet like you did with OrderedMap (if yes). I just want this staff to be immutable so we don't mess up the settings and it has unique tabs and stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added better types
settings: ScopeSettingsItem[]; | ||
|
||
constructor() { | ||
this.settings = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here for Set
if you think it is a valuable idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added better typing
})), | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should supported languages always be appeared? If so, I suggest to add notification here. so if there are no supported languages, we can find a bug once it appeared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can find it by trying to switch to another language (we will see only english option)
actually we don't want to display any notifications to users because we will try to fall back to english and give users access to application
they will notice that language is not as should be in case they use other langoages than english
|
||
useEffect(() => { | ||
if (ref.current) { | ||
ref.current.addEventListener('scroll', e => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, add removeEventListener
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
list.push({ group, settings: groupSettings || [] }); | ||
} | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see this logic moved to the hook so it is easier to read this component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
also do |
} | ||
|
||
return schema.parse(undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to parse undefined here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to get default value from schema (there no better way to do it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about schema.shape[name].default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's same as schema.string().default('ass')
(shape returns schema object) we can't get default value this way
import type { SettingsGroup } from './SettingsGroup'; | ||
|
||
export interface ISettingOptions { | ||
id: string | number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we want to use one type for "id"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree
const changes = {}; | ||
|
||
for (const [key, value] of this.changes) { | ||
setByPath(changes, key, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we do not want to mutate object from util function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case it's expected, function accepts object
, key
and value
and it will mutate object
we don't need immutable object here
options: this.localizationService.supportedLanguages.map(language => ({ | ||
id: language.isoCode, | ||
name: language.displayName, | ||
})) || [{ id: 'en', name: 'English' }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems supportedLanguages are [] by default so the code will never fallback to the default object
const defaultOptions = [{ id: 'en', name: 'English' }];
const options = this.localizationService.supportedLanguages.length > 0 ? this.localizationService.supportedLanguages.map(language => ({
id: language.isoCode,
name: language.displayName,
})) : defaultOptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in other way, now this.localizationService.supportedLanguages
must never be empty
const changed = serverSettingsService.isChanged; | ||
|
||
return ( | ||
<Form context={form} style={{ height: '100%', display: 'flex', flexDirection: 'column' }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move inline styles to the css module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
type: ESettingsValueType; | ||
|
||
group: SettingsGroup; | ||
name: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TLocalizationToken instead of string for "name" and "description"
} | ||
|
||
function handleClick(id: string) { | ||
document.querySelector('#' + getSettingGroupId(id))?.scrollIntoView(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do it in react way using ref?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can but it will be rocketsciense
|
||
export const SettingsGroups = observer<Props>(function SettingsGroups({ treeData }) { | ||
function getNodeHeight(id: string) { | ||
return 24; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const NODE_HEIGHT= 24;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need (used once, keep simple)
…e-settings-panel
…e-settings-panel
…e-settings-panel
…e-settings-panel
…e-settings-panel
…e-settings-panel
No description provided.