diff --git a/client/src/components/Code/CodeFullSelectable/SelectionHint.tsx b/client/src/components/Code/CodeFullSelectable/SelectionHint.tsx new file mode 100644 index 0000000000..d07ce96135 --- /dev/null +++ b/client/src/components/Code/CodeFullSelectable/SelectionHint.tsx @@ -0,0 +1,56 @@ +import React, { memo, useCallback } from 'react'; +import { Trans, useTranslation } from 'react-i18next'; +import { FileIcon, RangeIcon } from '../../../icons'; +import KeyboardHint from '../../KeyboardHint'; + +type Props = { + currentSelection: [number, number][]; + setCurrentSelection: (s: [number, number][]) => void; +}; + +const SelectionHint = ({ currentSelection, setCurrentSelection }: Props) => { + useTranslation(); + + const clearSelection = useCallback(() => { + setCurrentSelection([]); + }, []); + + return ( +
+ {!currentSelection.length ? ( + + ) : ( + + )} +

+ {!currentSelection.length ? ( + The whole file will be used as context. + ) : ( + Selected ranges will be used as context. + )} +

+ {currentSelection?.length > 1 && ( +
+ + + to navigate. + +
+ )} + {!!currentSelection.length && ( + <> +
+ + + )} +
+ ); +}; + +export default memo(SelectionHint); diff --git a/client/src/components/Code/CodeFullSelectable/index.tsx b/client/src/components/Code/CodeFullSelectable/index.tsx index cebfc9ceb1..0de096647a 100644 --- a/client/src/components/Code/CodeFullSelectable/index.tsx +++ b/client/src/components/Code/CodeFullSelectable/index.tsx @@ -23,6 +23,7 @@ import { getSelectionLines } from '../../../utils'; import RefsDefsPopup from '../../RefsDefsPopup'; import SelectionPopup from '../CodeFull/SelectionPopup'; import CodeContainer from './CodeContainer'; +import SelectionHint from './SelectionHint'; type Props = { code: string; @@ -322,6 +323,12 @@ const CodeFullSelectable = ({ selectedLines={selectionPopupData?.selectedLines} /> )} + {isEditingRanges && ( + + )}
); }; diff --git a/client/src/icons/File.tsx b/client/src/icons/File.tsx new file mode 100644 index 0000000000..ed7a3f8850 --- /dev/null +++ b/client/src/icons/File.tsx @@ -0,0 +1,14 @@ +import IconWrapper from './Wrapper'; + +const RawIcon = ( + + + +); + +export default IconWrapper(RawIcon); diff --git a/client/src/icons/Range.tsx b/client/src/icons/Range.tsx new file mode 100644 index 0000000000..69581c2187 --- /dev/null +++ b/client/src/icons/Range.tsx @@ -0,0 +1,18 @@ +import IconWrapper from './Wrapper'; + +const RawIcon = ( + + + + +); + +export default IconWrapper(RawIcon); diff --git a/client/src/icons/index.ts b/client/src/icons/index.ts index 7cb4bee426..7ad4050d51 100644 --- a/client/src/icons/index.ts +++ b/client/src/icons/index.ts @@ -25,6 +25,7 @@ export { default as DocumentsIcon } from './Documents'; export { default as DoorOutIcon } from './DoorOut'; export { default as EyeCutIcon } from './EyeCut'; export { default as FolderIcon } from './Folder'; +export { default as FileIcon } from './File'; export { default as FileWithSparksIcon } from './FileWithSparks'; export { default as GitHubLogo } from './GitHubIcon'; export { default as GlobeIcon } from './Globe'; @@ -42,6 +43,7 @@ export { default as MoreHorizontalIcon } from './MoreHorizontal'; export { default as PencilIcon } from './Pencil'; export { default as PersonIcon } from './Person'; export { default as PlusSignIcon } from './PlusSign'; +export { default as RangeIcon } from './Range'; export { default as RefIcon } from './Ref'; export { default as RefreshIcon } from './Refresh'; export { default as RegexIcon } from './Regex'; diff --git a/client/src/locales/en.json b/client/src/locales/en.json index 264a925ccf..c74bc55532 100644 --- a/client/src/locales/en.json +++ b/client/src/locales/en.json @@ -621,5 +621,7 @@ "Create ranges": "Create ranges", "# tokens_one": "token", "# tokens_other": "tokens", - "Edit ranges": "Edit ranges" + "Edit ranges": "Edit ranges", + "The whole file will be used as context.": "The whole file will be used as context.", + "Selected ranges will be used as context.": "Selected ranges will be used as context." } \ No newline at end of file diff --git a/client/src/locales/es.json b/client/src/locales/es.json index b2390b7f10..704ab3aa63 100644 --- a/client/src/locales/es.json +++ b/client/src/locales/es.json @@ -617,5 +617,7 @@ "Create ranges": "Crear rangos", "# tokens_onw": "ficha", "# tokens_other": "fichas", - "Edit ranges": "Editar rangos" + "Edit ranges": "Editar rangos", + "The whole file will be used as context.": "Todo el archivo se utilizará como contexto.", + "Selected ranges will be used as context.": "Los rangos seleccionados se utilizarán como contexto." } \ No newline at end of file diff --git a/client/src/locales/it.json b/client/src/locales/it.json index a11784083f..ae7911826a 100644 --- a/client/src/locales/it.json +++ b/client/src/locales/it.json @@ -583,5 +583,7 @@ "Create ranges": "Crea gamme", "# tokens_one": "token", "# tokens_other": "token", - "Edit ranges": "Modifica intervalli" + "Edit ranges": "Modifica intervalli", + "The whole file will be used as context.": "L'intero file verrà utilizzato come contesto.", + "Selected ranges will be used as context.": "Gli intervalli selezionati verranno utilizzati come contesto." } \ No newline at end of file diff --git a/client/src/locales/ja.json b/client/src/locales/ja.json index 7d658862d1..16c373c636 100644 --- a/client/src/locales/ja.json +++ b/client/src/locales/ja.json @@ -604,5 +604,7 @@ "Create ranges": "範囲を作成します", "# tokens_one": "トークン", "# tokens_other": "トークン", - "Edit ranges": "編集範囲" + "Edit ranges": "編集範囲", + "The whole file will be used as context.": "ファイル全体がコンテキストとして使用されます。", + "Selected ranges will be used as context.": "選択した範囲はコンテキストとして使用されます。" } \ No newline at end of file diff --git a/client/src/locales/zh-CN.json b/client/src/locales/zh-CN.json index 11cc69ba61..8222554d27 100644 --- a/client/src/locales/zh-CN.json +++ b/client/src/locales/zh-CN.json @@ -613,5 +613,7 @@ "Create ranges": "创建范围", "# tokens_one": "代币", "# tokens_other": "代币", - "Edit ranges": "编辑范围" + "Edit ranges": "编辑范围", + "The whole file will be used as context.": "整个文件将用作上下文。", + "Selected ranges will be used as context.": "选定的范围将用作上下文。" } \ No newline at end of file