Skip to content

Commit

Permalink
Address PR Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xenown authored and selinali2010 committed Feb 3, 2023
1 parent cef76b2 commit 413e559
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/unit_tests/PresetListItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('PresetListItem', () => {
it('should handle change with format change', async () => {
const testValue = 'Standard';
const newValue = 'tO p$RoPeR /cAsInG -_';
const expectedNewValue = 'To proper casing -_';
const expectedNewValue = 'tO pRoPeR cAsInG -_';
const { user } = setup(
<PresetListItem
value={testValue}
Expand Down
8 changes: 0 additions & 8 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,3 @@ export const computeAvgFreq = (filters: IFilter[], index: number) => {
// have manually confirmed this.
export const isRestrictedPresetName = (newName: string) =>
RESERVED_FILE_NAMES_SET.has(newName.toUpperCase());

export const isDuplicatePresetName = (
newName: string,
existingNames: string[]
) =>
existingNames.some(
(oldValue) => newName.toLowerCase() === oldValue.toLowerCase()
);
1 change: 1 addition & 0 deletions src/renderer/PresetsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ const PresetsBar = () => {
isDisabled={!!globalError}
errorMessage={newPresetNameError}
handleChange={handleChangeNewPresetName}
formatInput={formatPresetName}
/>
</div>
<Button
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/PresetListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const PresetListItem = ({
errorMessage={errorMessage}
handleChange={handleInputChange}
handleEscape={handleEscape}
formatInput={formatPresetName}
updateOnSubmitOnly
/>
) : (
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export const range = (start: number, stop: number, step: number) =>
Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + i * step);

export const formatPresetName = (s: string) => {
const filteredS = s.replace(/[^a-zA-Z0-9|_|\-| ]+/, '');
return filteredS.slice(0, 1).toUpperCase() + filteredS.slice(1).toLowerCase();
return s.replace(/[^a-zA-Z0-9|_|\-| ]+/, '');
};

// *** CUSTOM HOOKS ***
Expand Down

0 comments on commit 413e559

Please sign in to comment.