Skip to content

Commit

Permalink
Hide non textual entries from analysis module
Browse files Browse the repository at this point in the history
  • Loading branch information
subinasr committed Jun 26, 2024
1 parent 5fa40dd commit 6c02e6c
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 55 deletions.
2 changes: 0 additions & 2 deletions app/components/LeftPaneEntries/AssistItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,6 @@ function AssistItem(props: Props) {
}
predictionsErrored={!!fetchErrors || !!createErrors || isErrored}
messageText={messageText}
// NOTE: Setting this as undefined as this
// component is only used for textual entries
footerActions={(
<>
<QuickActionButton
Expand Down
7 changes: 4 additions & 3 deletions app/components/LeftPaneEntries/EntryItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function ExcerptModal(props: ExcerptModalProps) {

export interface EntryItemProps extends Pick<
EntryInput,
'droppedExcerpt' | 'excerpt' | 'entryType' | 'deleted' | 'stale'
'droppedExcerpt' | 'excerpt' | 'entryType' | 'deleted' | 'stale' | 'imageRaw'
> {
entryId: string;
isActive?: boolean;
Expand Down Expand Up @@ -135,6 +135,7 @@ function EntryItem(props: EntryItemProps) {
stale,
leadAttachment,
entryAttachment,
imageRaw,
} = props;

const editExcerptDropdownRef: QuickActionDropdownMenuProps['componentRef'] = React.useRef(null);
Expand Down Expand Up @@ -186,7 +187,7 @@ function EntryItem(props: EntryItemProps) {
<ExcerptInput
value={excerpt}
image={entryImage}
imageRaw={leadAttachment?.filePreview?.url ?? ''}
imageRaw={imageRaw ?? leadAttachment?.filePreview?.url ?? undefined}
entryAttachment={entryAttachment}
entryType={entryType}
readOnly
Expand Down Expand Up @@ -322,7 +323,7 @@ function EntryItem(props: EntryItemProps) {
value={excerpt}
// droppedExcerpt={droppedExcerpt}
image={entryImage}
imageRaw={leadAttachment?.filePreview?.url ?? undefined}
imageRaw={imageRaw ?? leadAttachment?.filePreview?.url ?? undefined}
entryType={entryType}
entryAttachment={entryAttachment}
leadAttachment={leadAttachment}
Expand Down
34 changes: 22 additions & 12 deletions app/components/LeftPaneEntries/TableAndVisualItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';
import React, { useCallback } from 'react';
import { BsDownload } from 'react-icons/bs';
import {
IoAdd,
} from 'react-icons/io5';

import {
isDefined,
} from '@togglecorp/fujs';
import {
Container,
QuickActionButton,
Expand Down Expand Up @@ -31,6 +33,20 @@ interface VisualProps {
export type Props = EntryProps | VisualProps;

function TableAndVisualItem(props: Props) {
const handleEntryAddFromAttachment = useCallback(() => {
// eslint-disable-next-line react/destructuring-assignment
if (props.type === 'entry-item') {
return;
}
// eslint-disable-next-line react/destructuring-assignment
if (props.onClick) {
// eslint-disable-next-line react/destructuring-assignment
props.onClick(props.attachment);
}
}, [
props,
]);

// eslint-disable-next-line react/destructuring-assignment
if (props.type === 'entry-item') {
return (
Expand All @@ -42,7 +58,6 @@ function TableAndVisualItem(props: Props) {

const {
attachment,
onClick,
disableClick,
} = props;

Expand All @@ -51,22 +66,17 @@ function TableAndVisualItem(props: Props) {
headerActions={(
<>
<QuickActionButton
// FIXME:
name={undefined}
title="Add Entry"
onClick={() => {
if (onClick) {
onClick(attachment);
}
}}
onClick={handleEntryAddFromAttachment}
disabled={disableClick}
>
<IoAdd />
</QuickActionButton>
{attachment.type === 'XLSX' && (
{attachment.type === 'XLSX' && isDefined(attachment.file.url) && (
<QuickActionLink
title="Open external"
to={attachment.file?.url || ''}
to={attachment.file.url}
>
<BsDownload />
</QuickActionLink>
Expand All @@ -77,7 +87,7 @@ function TableAndVisualItem(props: Props) {
>
<ImagePreview
alt="Preview Image"
src={attachment.filePreview?.url ?? ''}
src={attachment.filePreview?.url ?? undefined}
/>
</Container>
);
Expand Down
25 changes: 12 additions & 13 deletions app/components/LeftPaneEntries/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ interface Props {
} | null>;
}

const defaultMaxItemsPerPage = 10;
const MAX_ITEMS_PER_PAGE = 10;

function LeftPane(props: Props) {
const {
Expand Down Expand Up @@ -268,7 +268,6 @@ function LeftPane(props: Props) {
// FIXME: rename the following variables to indicate that these are for
// lead attachments
const [activePage, setActivePage] = useState<number>(1);
const [maxItemsPerPage, setMaxItemsPerPage] = useState(defaultMaxItemsPerPage);

const [
attachmentsWithEntriesHidden,
Expand All @@ -288,7 +287,7 @@ function LeftPane(props: Props) {
leadId,
projectId,
page: activePage,
pageSize: maxItemsPerPage,
pageSize: MAX_ITEMS_PER_PAGE,
excludeAttachmentIds: attachmentsWithEntriesHidden
? leadAttachmentIdsWithEntries
: [],
Expand All @@ -297,7 +296,6 @@ function LeftPane(props: Props) {
leadId,
projectId,
activePage,
maxItemsPerPage,
attachmentsWithEntriesHidden,
leadAttachmentIdsWithEntries,
],
Expand Down Expand Up @@ -944,15 +942,16 @@ function LeftPane(props: Props) {
messageShown
messageIconShown
/>
<Pager
className={styles.pager}
activePage={activePage}
itemsCount={leadPreviewCount ?? 0}
maxItemsPerPage={maxItemsPerPage}
onActivePageChange={setActivePage}
onItemsPerPageChange={setMaxItemsPerPage}
itemsPerPageControlHidden
/>
{isDefined(leadPreviewCount) && (
<Pager
className={styles.pager}
activePage={activePage}
itemsCount={leadPreviewCount}
maxItemsPerPage={MAX_ITEMS_PER_PAGE}
onActivePageChange={setActivePage}
itemsPerPageControlHidden
/>
)}
</TabPanel>
{!hideOriginalPreview && (
<TabPanel
Expand Down
11 changes: 7 additions & 4 deletions app/components/entry/ExcerptInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React from 'react';
import { BsDownload } from 'react-icons/bs';
import { _cs } from '@togglecorp/fujs';
import {
_cs,
isDefined,
} from '@togglecorp/fujs';
import {
Container,
ImagePreview,
Expand Down Expand Up @@ -111,14 +114,14 @@ function ExcerptInput<N extends string>(props: Props<N>) {
return (
<Container
className={_cs(className, styles.excerptInput, styles.imageExcerptContainer)}
headerActions={fileType === 'XLSX' ? (
headerActions={fileType === 'XLSX' && isDefined(file) && isDefined(file.url) && (
<QuickActionLink
title="Open external"
to={file?.url || ''}
to={file.url}
>
<BsDownload />
</QuickActionLink>
) : undefined}
)}
>
{attachmentSrc ? (
<ImagePreview
Expand Down
36 changes: 20 additions & 16 deletions app/components/leadFilters/SourcesFilter/EntryFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ interface Props<K extends string> {
entryTypeOptions?: EnumEntity<string>[] | null;
frameworkFilters?: FrameworkFilterType[] | null;
disabled?: boolean;
hideEntryTypeFilter?: boolean;
}

function EntryFilter<K extends string>(props: Props<K>) {
Expand All @@ -86,6 +87,7 @@ function EntryFilter<K extends string>(props: Props<K>) {
optionsDisabled,
entryTypeOptions,
frameworkFilters,
hideEntryTypeFilter,
} = props;

const setFieldValue = useFormObject(name, onChange, defaultValue);
Expand Down Expand Up @@ -207,22 +209,24 @@ function EntryFilter<K extends string>(props: Props<K>) {
label="Has Comment"
disabled={disabled}
/>
<MultiSelectInput
variant="general"
className={_cs(
styles.input,
(doesObjectHaveNoData(value?.entryTypes) && !allFiltersVisible)
&& styles.hidden,
)}
name="entryTypes"
value={value?.entryTypes}
onChange={setFieldValue}
keySelector={enumKeySelector}
labelSelector={enumLabelSelector}
options={entryTypeOptions}
disabled={disabled || optionsDisabled}
label="Entry Type"
/>
{!hideEntryTypeFilter && (
<MultiSelectInput
variant="general"
className={_cs(
styles.input,
(doesObjectHaveNoData(value?.entryTypes) && !allFiltersVisible)
&& styles.hidden,
)}
name="entryTypes"
value={value?.entryTypes}
onChange={setFieldValue}
keySelector={enumKeySelector}
labelSelector={enumLabelSelector}
options={entryTypeOptions}
disabled={disabled || optionsDisabled}
label="Entry Type"
/>
)}
{frameworkFilters?.map((filter) => {
const filterValue = filterValuesMap[filter.key];
return (
Expand Down
4 changes: 4 additions & 0 deletions app/components/leadFilters/SourcesFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ interface Props {

optionsLoading: boolean;
optionsErrored: boolean;

hideEntryTypeFilter?: boolean;
}

function SourcesFilter(props: Props) {
Expand All @@ -182,6 +184,7 @@ function SourcesFilter(props: Props) {
onChange: setFieldValue,
optionsLoading,
optionsErrored,
hideEntryTypeFilter,
} = props;

const error = getErrorObject(formError);
Expand Down Expand Up @@ -412,6 +415,7 @@ function SourcesFilter(props: Props) {
optionsDisabled={optionsLoading || optionsErrored}
allFiltersVisible
disabled={disabled}
hideEntryTypeFilter={hideEntryTypeFilter}
/>
</TabPanel>
)}
Expand Down
2 changes: 1 addition & 1 deletion app/views/EntryEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ function EntryEdit(props: Props) {
secondaryTagging: frameworkDetails?.secondaryTagging,
onAddButtonClick: handleAddButtonClick,
primaryTagging: frameworkDetails?.primaryTagging,
entryAttachment: datum.id ? entryAttachmentsMap?.[datum.id] : undefined,
entryAttachment: isDefined(datum.id) ? entryAttachmentsMap?.[datum.id] : undefined,
excerptHeaderActions: datum.id && projectId && (
<>
<EntryVerification
Expand Down
2 changes: 0 additions & 2 deletions app/views/PillarAnalysis/AnalyticalStatementInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,6 @@ function AnalyticalStatementInput(props: AnalyticalStatementInputProps) {
tags,
]);

console.log('all tags', allWidgetTagNames);

const [selectedField, setSelectedField] = useState<Field | undefined>('statement');
const [selectedContent, setSelectedContent] = useState<Content | undefined>('entries');

Expand Down
4 changes: 2 additions & 2 deletions app/views/PillarAnalysis/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ export const PROJECT_ENTRIES_FOR_ANALYSIS = gql`
$createdAtLte: DateTime,
$createdBy: [ID!],
$usedEntries: [ID!],
$entryTypes: [EntryTagTypeEnum!],
$filterableData: [EntryFilterDataInputType!]
$leadAssignees: [ID!],
$leadCreatedBy: [ID!],
Expand Down Expand Up @@ -411,7 +410,7 @@ export const PROJECT_ENTRIES_FOR_ANALYSIS = gql`
createdAtGte: $createdAtGte,
createdAtLte: $createdAtLte,
createdBy: $createdBy,
entryTypes: $entryTypes,
entryTypes: EXCERPT,
filterableData: $filterableData,
leadAssignees: $leadAssignees,
leadConfidentialities: $leadConfidentialities,
Expand Down Expand Up @@ -1483,6 +1482,7 @@ function PillarAnalysis() {
isEntriesOnlyFilter
optionsLoading={false}
optionsErrored={false}
hideEntryTypeFilter
/>
)}
<Tabs
Expand Down

0 comments on commit 6c02e6c

Please sign in to comment.