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

FE bug fix #1235

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/CommandBar/steps/AddToStudio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const AddToStudio = (props: Props) => {
const newSectionsToShow: CommandBarSectionType[] = [];
initialSections.forEach((s) => {
const items = (s.items as CommandBarItemGeneralType[]).filter((item) => {
return item.label.toLowerCase().includes(inputValue.toLowerCase());
return item.label?.toLowerCase().includes(inputValue?.toLowerCase());
});

if (items.length) {
Expand Down
9 changes: 5 additions & 4 deletions client/src/CommandBar/steps/Documentation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ const Documentation = ({}: Props) => {
}
const newSections: CommandBarSectionType[] = [];
sections.forEach((s) => {
const newItems = s.items.filter((i) =>
('label' in i ? i.label : i.componentProps.doc.name)
.toLowerCase()
.includes(inputValue.toLowerCase()),
const newItems = s.items.filter(
(i) =>
('label' in i ? i.label : i.componentProps.doc.name)
?.toLowerCase()
.includes(inputValue?.toLowerCase()),
);
if (newItems.length) {
newSections.push({ ...s, items: newItems });
Expand Down
4 changes: 2 additions & 2 deletions client/src/CommandBar/steps/Initial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ const InitialCommandBar = ({ shouldShowTutorial }: Props) => {
}
const newSections: CommandBarSectionType[] = [];
initialSections.forEach((s) => {
const newItems = (s.items as CommandBarItemGeneralType[]).filter((i) =>
i.label.toLowerCase().includes(inputValue.toLowerCase()),
const newItems = (s.items as CommandBarItemGeneralType[]).filter(
(i) => i.label?.toLowerCase().includes(inputValue?.toLowerCase()),
);
if (newItems.length) {
newSections.push({
Expand Down
9 changes: 5 additions & 4 deletions client/src/CommandBar/steps/LocalRepos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ const LocalRepos = ({}: Props) => {
}
const newSections: CommandBarSectionType[] = [];
sections.forEach((s) => {
const newItems = s.items.filter((i) =>
('label' in i ? i.label : i.componentProps.repo.shortName)
.toLowerCase()
.includes(inputValue.toLowerCase()),
const newItems = s.items.filter(
(i) =>
('label' in i ? i.label : i.componentProps.repo.shortName)
?.toLowerCase()
.includes(inputValue?.toLowerCase()),
);
if (newItems.length) {
newSections.push({ ...s, items: newItems });
Expand Down
6 changes: 3 additions & 3 deletions client/src/CommandBar/steps/ManageRepos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ const ManageRepos = ({ shouldShowTutorial }: Props) => {
) => {
return 'componentProps' in item
? item.componentProps.repo.shortName
.toLowerCase()
.includes(inputValue.toLowerCase())
: item.label.toLowerCase().includes(inputValue.toLowerCase());
?.toLowerCase()
.includes(inputValue?.toLowerCase())
: item.label?.toLowerCase().includes(inputValue?.toLowerCase());
};

sections.forEach((s) => {
Expand Down
4 changes: 2 additions & 2 deletions client/src/CommandBar/steps/PrivateRepos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ const PrivateReposStep = ({ shouldShowTutorial }: Props) => {
sections.forEach((s) => {
const items = (s.items as CommandBarItemCustomType[]).filter((item) => {
return item.componentProps.repo.shortName
.toLowerCase()
.includes(inputValue.toLowerCase());
?.toLowerCase()
.includes(inputValue?.toLowerCase());
});

if (items.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const ConversationInput = ({
.filter(
(t): t is FileTabType =>
t.type === TabTypesEnum.FILE &&
(!search || t.path.toLowerCase().includes(search.toLowerCase())),
(!search || t.path?.toLowerCase().includes(search?.toLowerCase())),
)
.map((t) => ({ path: t.path, repo: t.repoRef }));
filesResults.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const TemplatesDropdown = ({ templates, onTemplateSelected }: Props) => {
setTemplatesToShow(templates);
} else {
setTemplatesToShow(
templates.filter((t) =>
t.name.toLowerCase().includes(inputValue.toLowerCase()),
templates.filter(
(t) => t.name?.toLowerCase().includes(inputValue?.toLowerCase()),
),
);
}
Expand Down
33 changes: 18 additions & 15 deletions client/src/Project/LeftSidebar/NavPanel/Repo/RepoDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,38 @@ const RepoDropdown = ({
if (!search) {
return indexedBranches;
}
return indexedBranches.filter((b) =>
b
.replace(/^origin\//, '')
.toLowerCase()
.includes(search.toLowerCase()),
return indexedBranches.filter(
(b) =>
b
.replace(/^origin\//, '')
?.toLowerCase()
.includes(search?.toLowerCase()),
);
}, [indexedBranches, search]);

const indexingBranchesToShow = useMemo(() => {
if (!search) {
return branchesToSync;
}
return branchesToSync.filter((b) =>
b
.replace(/^origin\//, '')
.toLowerCase()
.includes(search.toLowerCase()),
return branchesToSync.filter(
(b) =>
b
.replace(/^origin\//, '')
?.toLowerCase()
.includes(search?.toLowerCase()),
);
}, [branchesToSync, search]);

const notIndexedBranchesToShow = useMemo(() => {
if (!search) {
return notSyncedBranches;
}
return notSyncedBranches.filter((b) =>
b
.replace(/^origin\//, '')
.toLowerCase()
.includes(search.toLowerCase()),
return notSyncedBranches.filter(
(b) =>
b
.replace(/^origin\//, '')
?.toLowerCase()
.includes(search?.toLowerCase()),
);
}, [notSyncedBranches, search]);

Expand Down
2 changes: 1 addition & 1 deletion client/src/Project/LeftSidebar/NavPanel/Repo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const RepoNav = ({
}
return resp?.entries.sort((a, b) => {
if ((a.entry_data === 'Directory') === (b.entry_data === 'Directory')) {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
return a.name?.toLowerCase() < b.name?.toLowerCase() ? -1 : 1;
} else {
return a.entry_data === 'Directory' ? -1 : 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const FileResult = ({
}
return resp?.entries.sort((a, b) => {
if ((a.entry_data === 'Directory') === (b.entry_data === 'Directory')) {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
return a.name?.toLowerCase() < b.name?.toLowerCase() ? -1 : 1;
} else {
return a.entry_data === 'Directory' ? -1 : 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const RepoResult = ({ repoRef, isExpandable, index }: Props) => {
}
return resp?.entries.sort((a, b) => {
if ((a.entry_data === 'Directory') === (b.entry_data === 'Directory')) {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
return a.name?.toLowerCase() < b.name?.toLowerCase() ? -1 : 1;
} else {
return a.entry_data === 'Directory' ? -1 : 1;
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/MarkdownWithCode/FolderChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const FolderChip = ({ onClick, path, repoRef }: Props) => {
}
return resp?.entries.sort((a, b) => {
if ((a.entry_data === 'Directory') === (b.entry_data === 'Directory')) {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
return a.name?.toLowerCase() < b.name?.toLowerCase() ? -1 : 1;
} else {
return a.entry_data === 'Directory' ? -1 : 1;
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/useCodeSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const useCodeSearch = ({
}
const lines = code.split('\n');
const results = lines.reduce(function (prev: number[], cur, i) {
if (cur.toLowerCase().includes(deferredSearchTerm.toLowerCase())) {
if (cur?.toLowerCase().includes(deferredSearchTerm?.toLowerCase())) {
prev.push(i);
}
return prev;
Expand Down
4 changes: 2 additions & 2 deletions client/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const getFileExtensionForLang = (lang: string, lowercased?: boolean) => {
// @ts-ignore
let ext = langs[lang]?.[0];
if (lowercased) {
const key = Object.keys(langs).find((key) => key.toLowerCase() === lang);
const key = Object.keys(langs).find((key) => key?.toLowerCase() === lang);
if (key) {
// @ts-ignore
ext = langs[key]?.[0];
Expand All @@ -97,7 +97,7 @@ export const getPrettyLangName = (lang: string) => {
case 'tsx':
return 'TypeScript';
default:
return Object.keys(langs).find((key) => key.toLowerCase() === lang);
return Object.keys(langs).find((key) => key?.toLowerCase() === lang);
}
};

Expand Down
6 changes: 3 additions & 3 deletions client/src/utils/keyboardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const checkEventKeys = (e: KeyboardEvent, shortcut?: string[]) => {
if (!shortcut) {
return false;
}
const keys = shortcut.map((k) => k.toLowerCase());
const keys = shortcut.map((k) => k?.toLowerCase());
if (
(keys.includes('cmd') && !(e.metaKey || e.ctrlKey)) ||
(!keys.includes('cmd') && (e.metaKey || e.ctrlKey))
Expand Down Expand Up @@ -53,9 +53,9 @@ export const checkEventKeys = (e: KeyboardEvent, shortcut?: string[]) => {
if (
(e.altKey &&
keys.includes(
e.code.replace('Key', '').replace('Digit', '').toLowerCase(),
e.code.replace('Key', '').replace('Digit', '')?.toLowerCase(),
)) ||
(e.shiftKey && keys.includes(e.code.replace('Digit', '').toLowerCase()))
(e.shiftKey && keys.includes(e.code.replace('Digit', '')?.toLowerCase()))
) {
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/utils/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ export const mapReposBySections = (githubRepos: RepoType[]) => {
? 1
: b === 'Local'
? -1
: a.toLowerCase() < b.toLowerCase()
: a?.toLowerCase() < b?.toLowerCase()
? -1
: 1,
)
.forEach((k) => {
result.push({
org: k,
items: byOrg[k].sort((a, b) =>
a.folderName.toLowerCase() < b.folderName.toLowerCase()
a.folderName?.toLowerCase() < b.folderName?.toLowerCase()
? -1
: a.folderName.toLowerCase() > b.folderName.toLowerCase()
: a.folderName?.toLowerCase() > b.folderName?.toLowerCase()
? 1
: a.shortName.toLowerCase() < b.shortName.toLowerCase()
: a.shortName?.toLowerCase() < b.shortName?.toLowerCase()
? -1
: 1,
),
Expand Down
Loading