Skip to content

Commit

Permalink
[ENG-1699] Pin Job manager (#2264)
Browse files Browse the repository at this point in the history
* wip

* minor cleanup

* Update Popover.tsx

* remove prop
  • Loading branch information
ameer2468 committed Mar 29, 2024
1 parent 5a7d15d commit 21a0ec0
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 24 deletions.
26 changes: 21 additions & 5 deletions interface/app/$libraryId/Layout/Sidebar/JobManager/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Check, Trash, X } from '@phosphor-icons/react';
import { Check, PushPin, Trash, X } from '@phosphor-icons/react';
import { useQueryClient } from '@tanstack/react-query';
import dayjs from 'dayjs';
import { useState } from 'react';
Expand All @@ -11,6 +11,7 @@ import {
import { Button, PopoverClose, toast, Tooltip } from '@sd/ui';
import { useIsDark, useLocale } from '~/hooks';

import { getSidebarStore, useSidebarStore } from '../store';
import IsRunningJob from './IsRunningJob';
import JobGroup from './JobGroup';

Expand Down Expand Up @@ -46,6 +47,7 @@ function sortJobData(jobs: IJobGroup[]) {
export function JobManager() {
const queryClient = useQueryClient();
const [toggleConfirmation, setToggleConfirmation] = useState(false);
const store = useSidebarStore();

const jobGroups = useLibraryQuery(['jobs.reports']);

Expand Down Expand Up @@ -79,7 +81,17 @@ export function JobManager() {
return (
<div className="h-full overflow-hidden pb-10">
<div className="z-20 flex h-9 w-full items-center rounded-t-md border-b border-app-line/50 bg-app-button/30 px-2">
<span className=" ml-1.5 font-medium">{t('recent_jobs')}</span>
<Tooltip label={t('pin')}>
<Button
onClick={() => {
getSidebarStore().pinJobManager = !store.pinJobManager;
}}
size="icon"
>
<PushPin weight={store.pinJobManager ? 'fill' : 'regular'} size={16} />
</Button>
</Tooltip>
<span className="ml-1 font-medium ">{t('recent_jobs')}</span>
<div className="grow" />
{toggleConfirmation ? (
<div className="flex h-[85%] w-fit items-center justify-center gap-2 rounded-md border border-app-line bg-app/40 px-2">
Expand All @@ -103,14 +115,18 @@ export function JobManager() {
size="icon"
>
<Tooltip label={t('clear_finished_jobs')}>
<Trash className="size-4" />
<Trash size={16} />
</Tooltip>
</Button>
)}
<PopoverClose asChild>
<Button className="opacity-70" size="icon">
<Button
onClick={() => (getSidebarStore().pinJobManager = false)}
className="opacity-70"
size="icon"
>
<Tooltip label={t('close')}>
<X className="size-4" />
<X size={16} />
</Tooltip>
</Button>
</PopoverClose>
Expand Down
12 changes: 9 additions & 3 deletions interface/app/$libraryId/Layout/Sidebar/SidebarLayout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ import {
} from '@sd/client';
import { Button, ButtonLink, Popover, Tooltip, usePopover } from '@sd/ui';
import { useKeysMatcher, useLocale, useShortcut } from '~/hooks';
import { useRoutingContext } from '~/RoutingContext';
import { usePlatform } from '~/util/Platform';

import DebugPopover from '../DebugPopover';
import { IsRunningJob, JobManager } from '../JobManager';
import { useSidebarStore } from '../store';
import FeedbackButton from './FeedbackButton';

export default () => {
const { library } = useClientContext();
const { visible } = useRoutingContext();
const { t } = useLocale();
const debugState = useDebugState();
const navigate = useNavigate();
const symbols = useKeysMatcher(['Meta', 'Shift']);

const { t } = useLocale();
const store = useSidebarStore();

useShortcut('navToSettings', (e) => {
e.stopPropagation();
Expand Down Expand Up @@ -74,7 +77,10 @@ export default () => {
</ButtonLink>
<JobManagerContextProvider>
<Popover
popover={jobManagerPopover}
popover={{
...jobManagerPopover,
open: jobManagerPopover.open || (store.pinJobManager && visible)
}}
trigger={
<Button
id="job-manager-button"
Expand Down
11 changes: 11 additions & 0 deletions interface/app/$libraryId/Layout/Sidebar/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { proxy, useSnapshot } from "valtio";

//This store is being used
//to record the state of the sidebar for specific behaviours i.e pinning

const store = proxy({
pinJobManager: false as boolean,
});

export const useSidebarStore = () => useSnapshot(store);
export const getSidebarStore = () => store;
2 changes: 0 additions & 2 deletions interface/app/$libraryId/TopBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ function useTabKeybinds(props: { addTab(): void; removeTab(index: number): void

useShortcut('newTab', (e) => {
if (!visible) return;

e.stopPropagation();

props.addTab();
});

Expand Down
3 changes: 2 additions & 1 deletion interface/locales/by/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"go_to_tag": "Ir para marcação",
"no_labels": "Sem etiquetas",
"search_for_files_and_actions": "Pesquisar por arquivos e ações...",
"toggle_command_palette": "Alternar paleta de comandos"
"toggle_command_palette": "Alternar paleta de comandos",
"pin": "шпілька"
}
3 changes: 2 additions & 1 deletion interface/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"go_to_tag": "Gehe zum Markieren",
"no_labels": "Keine Etiketten",
"search_for_files_and_actions": "Nach Dateien und Aktionen suchen...",
"toggle_command_palette": "Befehlspalette umschalten"
"toggle_command_palette": "Befehlspalette umschalten",
"pin": "Stift"
}
3 changes: 2 additions & 1 deletion interface/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"your_account": "Your account",
"your_account_description": "Spacedrive account and information.",
"your_local_network": "Your Local Network",
"your_privacy": "Your Privacy"
"your_privacy": "Your Privacy",
"pin": "Pin"
}
3 changes: 2 additions & 1 deletion interface/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"go_to_tag": "Ir a la etiqueta",
"no_labels": "Sin etiquetas",
"search_for_files_and_actions": "Buscar archivos y acciones...",
"toggle_command_palette": "Alternar paleta de comandos"
"toggle_command_palette": "Alternar paleta de comandos",
"pin": "Alfiler"
}
3 changes: 2 additions & 1 deletion interface/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"go_to_tag": "Aller au tag",
"no_labels": "Pas d'étiquettes",
"search_for_files_and_actions": "Rechercher des fichiers et des actions...",
"toggle_command_palette": "Basculer la palette de commandes"
"toggle_command_palette": "Basculer la palette de commandes",
"pin": "Épingle"
}
3 changes: 2 additions & 1 deletion interface/locales/it/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"update_downloaded": "Aggiornamento scaricato. Riavvia Spacedrive per eseguire l'installazione",
"updated_successfully": "Aggiornato con successo, sei sulla versione {{version}}",
"version": "Versione {{versione}}",
"view_changes": "Visualizza modifiche"
"view_changes": "Visualizza modifiche",
"pin": "Spillo"
}
3 changes: 2 additions & 1 deletion interface/locales/ja/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"go_to_tag": "タグに移動",
"no_labels": "ラベルなし",
"search_for_files_and_actions": "ファイルとアクションを検索します...",
"toggle_command_palette": "コマンドパレットの切り替え"
"toggle_command_palette": "コマンドパレットの切り替え",
"pin": "ピン"
}
3 changes: 2 additions & 1 deletion interface/locales/nl/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"go_to_tag": "Ga naar taggen",
"no_labels": "Geen etiketten",
"search_for_files_and_actions": "Zoeken naar bestanden en acties...",
"toggle_command_palette": "Schakel het opdrachtpalet in of uit"
"toggle_command_palette": "Schakel het opdrachtpalet in of uit",
"pin": "Pin"
}
3 changes: 2 additions & 1 deletion interface/locales/ru/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"go_to_tag": "Перейти к тегу",
"no_labels": "Нет ярлыков",
"search_for_files_and_actions": "Поиск файлов и действий...",
"toggle_command_palette": "Переключить палитру команд"
"toggle_command_palette": "Переключить палитру команд",
"pin": "приколоть"
}
3 changes: 2 additions & 1 deletion interface/locales/tr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"go_to_tag": "Etikete git",
"no_labels": "Etiket yok",
"search_for_files_and_actions": "Dosyaları ve eylemleri arayın...",
"toggle_command_palette": "Komut paletini değiştir"
"toggle_command_palette": "Komut paletini değiştir",
"pin": "Toplu iğne"
}
3 changes: 2 additions & 1 deletion interface/locales/zh-CN/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"go_to_tag": "转到标签",
"no_labels": "无标签",
"search_for_files_and_actions": "搜索文件和操作...",
"toggle_command_palette": "切换命令面板"
"toggle_command_palette": "切换命令面板",
"pin": "别针"
}
3 changes: 2 additions & 1 deletion interface/locales/zh-TW/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
"go_to_tag": "轉到標籤",
"no_labels": "無標籤",
"search_for_files_and_actions": "搜尋文件和操作...",
"toggle_command_palette": "切換命令面板"
"toggle_command_palette": "切換命令面板",
"pin": "別針"
}
4 changes: 2 additions & 2 deletions packages/ui/src/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const Popover = ({ popover, trigger, children, disabled, className, ...pr
}, [setOpen]);

return (
<Radix.Root open={popover.open} onOpenChange={popover.setOpen}>
<Radix.Root open={popover.open} onOpenChange={setOpen}>
<Radix.Trigger ref={triggerRef} disabled={disabled} asChild>
{trigger}
</Radix.Trigger>
Expand All @@ -64,7 +64,7 @@ export const Popover = ({ popover, trigger, children, disabled, className, ...pr
'bg-app-overlay',
'border border-app-line',
'shadow-2xl',
'animate-in fade-in',
'radix-state-closed:animate-out radix-state-closed:fade-out-0',
className
)}
{...props}
Expand Down

0 comments on commit 21a0ec0

Please sign in to comment.