Skip to content

Commit

Permalink
WIP, prevent client crash when ix extractor has no templates
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Jul 18, 2024
1 parent 0f96181 commit c50e777
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/api/services/informationextraction/ixextractors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const Extractors = {
await createBlankSuggestionsForExtractor(saved);
return saved;
},

update: async (id: string, name: string, property: string, templateIds: string[]) => {
const [extractor] = await model.get({ _id: new ObjectId(id) });
if (!extractor) throw Error('Missing extractor.');
Expand Down
2 changes: 1 addition & 1 deletion app/api/suggestions/specs/eventListeners.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ describe(`On ${TemplateDeletedEvent.name}`, () => {
expect(suggestions).toEqual([]);
});

it('should not act if the feature is not enabld', async () => {
it('should not act if the feature is not enabled', async () => {
await disableFeatures();

const suggestions = await testingDB.mongodb?.collection('ixsuggestions').find({}).toArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const SuggestionsTitle = ({
onFiltersButtonClicked: () => void;
activeFilters: number;
}) => {
const allProperties = [...(templates[0].commonProperties || []), ...templates[0].properties];
const allProperties = [
...(templates[0]?.commonProperties || []),
...(templates[0]?.properties || []),
];
const template = allProperties.find(prop => prop.name === property);

let propGraphics: string | React.ReactNode = '_';
Expand Down
5 changes: 4 additions & 1 deletion app/react/V2/Routes/Settings/IX/components/TableElements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ const suggestionsTableColumnsBuilder: Function = (
acceptSuggestions: (suggestions: TableSuggestion[]) => void,
openPdfSidepanel: (suggestion: TableSuggestion) => void
) => {
const allProperties = [...(templates[0].commonProperties || []), ...templates[0].properties];
const allProperties = [
...(templates[0]?.commonProperties || []),
...(templates[0]?.properties || []),
];

return [
suggestionColumnHelper.accessor('entityTitle', {
Expand Down

0 comments on commit c50e777

Please sign in to comment.