mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-23 08:18:41 +03:00
58d8e864e0
* feat: add ability to hide collections #211 (#213) * feat: add ability to hide collections #211 * fix: hide/unhide collection label is swapped * fix: missing useCallback dependency * fix: add selected tabs to existing collection adds all tabs in current window #215 (#216) * fix: add selected tabs to existing collection adds all tabs in current window #215 * fix: force selected tabs only for adding tabs to groups * feat: compact collection view (#214) * feat: compact collection view #201 * loc: compact view localization * fix(loc): missing "color" translation in edit dialog * feat: add ability to edit saved tabs (#218) * feat: adds option to edit saved tabs #217 * loc: translations for #217 * build(deps): Bump the react group with 2 updates (#221) Bumps the react group with 2 updates: [react](https://github.com/facebook/react/tree/HEAD/packages/react) and [react-dom](https://github.com/facebook/react/tree/HEAD/packages/react-dom). Updates `react` from 19.2.1 to 19.2.3 - [Release notes](https://github.com/facebook/react/releases) - [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/facebook/react/commits/v19.2.3/packages/react) Updates `react-dom` from 19.2.1 to 19.2.3 - [Release notes](https://github.com/facebook/react/releases) - [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/facebook/react/commits/v19.2.3/packages/react-dom) --- updated-dependencies: - dependency-name: react dependency-version: 19.2.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: react - dependency-name: react-dom dependency-version: 19.2.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: react ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): Bump the deps group with 4 updates (#220) Bumps the deps group with 4 updates: [@fluentui/react-components](https://github.com/microsoft/fluentui), [@eslint/js](https://github.com/eslint/eslint/tree/HEAD/packages/js), [eslint](https://github.com/eslint/eslint) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint). Updates `@fluentui/react-components` from 9.72.8 to 9.72.9 - [Release notes](https://github.com/microsoft/fluentui/releases) - [Commits](https://github.com/microsoft/fluentui/compare/@fluentui/react-components_v9.72.8...@fluentui/react-components_v9.72.9) Updates `@eslint/js` from 9.39.1 to 9.39.2 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](https://github.com/eslint/eslint/commits/v9.39.2/packages/js) Updates `eslint` from 9.39.1 to 9.39.2 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](https://github.com/eslint/eslint/compare/v9.39.1...v9.39.2) Updates `typescript-eslint` from 8.49.0 to 8.51.0 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.51.0/packages/typescript-eslint) --- updated-dependencies: - dependency-name: "@fluentui/react-components" dependency-version: 9.72.9 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: deps - dependency-name: "@eslint/js" dependency-version: 9.39.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: deps - dependency-name: eslint dependency-version: 9.39.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: deps - dependency-name: typescript-eslint dependency-version: 8.51.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: deps ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: Bump version from 3.2.3 to 3.3.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
122 lines
4.3 KiB
TypeScript
122 lines
4.3 KiB
TypeScript
import { useDialog } from "@/contexts/DialogProvider";
|
|
import EditDialog from "@/entrypoints/sidepanel/components/EditDialog";
|
|
import CollectionContext, { CollectionContextType } from "@/entrypoints/sidepanel/contexts/CollectionContext";
|
|
import { useCollections } from "@/entrypoints/sidepanel/contexts/CollectionsProvider";
|
|
import GroupContext, { GroupContextType } from "@/entrypoints/sidepanel/contexts/GroupContext";
|
|
import { useDangerStyles } from "@/hooks/useDangerStyles";
|
|
import useSettings from "@/hooks/useSettings";
|
|
import { TabItem } from "@/models/CollectionModels";
|
|
import { sendMessage } from "@/utils/messaging";
|
|
import { Button, Menu, MenuItem, MenuList, MenuPopover, MenuTrigger, Tooltip } from "@fluentui/react-components";
|
|
import * as ic from "@fluentui/react-icons";
|
|
import { ReactElement } from "react";
|
|
import { openGroup } from "../../utils/opener";
|
|
import { getTabsToSaveAsync } from "@/utils/getTabsToSaveAsync";
|
|
import sendPartialSaveNotification from "@/utils/sendPartialSaveNotification";
|
|
|
|
export default function GroupMoreMenu(): ReactElement
|
|
{
|
|
const [listLocation] = useSettings("listLocation");
|
|
const isTabView: boolean = listLocation === "tab" || listLocation === "pinned";
|
|
const { group, indices } = useContext<GroupContextType>(GroupContext);
|
|
const { hasPinnedGroup, collection } = useContext<CollectionContextType>(CollectionContext);
|
|
const [deletePrompt] = useSettings("deletePrompt");
|
|
const dialog = useDialog();
|
|
const { updateGroup, removeItem, ungroup } = useCollections();
|
|
|
|
const dangerCls = useDangerStyles();
|
|
|
|
const AddIcon = ic.bundleIcon(ic.Add20Filled, ic.Add20Regular);
|
|
const UngroupIcon = ic.bundleIcon(ic.FullScreenMaximize20Filled, ic.FullScreenMaximize20Regular);
|
|
const EditIcon = ic.bundleIcon(ic.Edit20Filled, ic.Edit20Regular);
|
|
const NewWindowIcon = ic.bundleIcon(ic.WindowNew20Filled, ic.WindowNew20Regular);
|
|
const DeleteIcon = ic.bundleIcon(ic.Delete20Filled, ic.Delete20Regular);
|
|
|
|
const handleDelete = () =>
|
|
{
|
|
const removeIndex: number[] = [collection.timestamp, ...indices.slice(1)];
|
|
|
|
if (deletePrompt)
|
|
dialog.pushPrompt({
|
|
title: i18n.t("groups.menu.delete"),
|
|
content: i18n.t("common.delete_prompt"),
|
|
confirmText: i18n.t("common.actions.delete"),
|
|
destructive: true,
|
|
onConfirm: () => removeItem(...removeIndex)
|
|
});
|
|
else
|
|
removeItem(...removeIndex);
|
|
};
|
|
|
|
const handleEdit = () =>
|
|
dialog.pushCustom(
|
|
<EditDialog
|
|
type="group"
|
|
group={ group }
|
|
hidePinned={ hasPinnedGroup }
|
|
onSave={ item => updateGroup(item, collection.timestamp, indices[1]) } />
|
|
);
|
|
|
|
const openGroupInNewWindow = () =>
|
|
{
|
|
if (import.meta.env.FIREFOX && listLocation === "popup")
|
|
sendMessage("openGroup", { group, newWindow: true });
|
|
else
|
|
openGroup(group, true);
|
|
};
|
|
|
|
const handleAddSelected = async () =>
|
|
{
|
|
const [newTabs, skipCount] = await getTabsToSaveAsync(true);
|
|
|
|
if (newTabs.length > 0)
|
|
await updateGroup({
|
|
...group,
|
|
items: [...group.items, ...newTabs.map<TabItem>(i => ({ type: "tab", url: i.url!, title: i.title }))]
|
|
}, collection.timestamp, indices[1]);
|
|
|
|
if (skipCount > 0)
|
|
await sendPartialSaveNotification();
|
|
};
|
|
|
|
return (
|
|
<Menu>
|
|
<Tooltip relationship="label" content={ i18n.t("common.tooltips.more") }>
|
|
<MenuTrigger>
|
|
<Button size="small" appearance="subtle" icon={ <ic.MoreVertical20Regular /> } />
|
|
</MenuTrigger>
|
|
</Tooltip>
|
|
|
|
<MenuPopover>
|
|
<MenuList>
|
|
{ group.items.length > 0 &&
|
|
<MenuItem icon={ <NewWindowIcon /> } onClick={ openGroupInNewWindow }>
|
|
{ i18n.t("groups.menu.new_window") }
|
|
</MenuItem>
|
|
}
|
|
|
|
<MenuItem icon={ <AddIcon /> } onClick={ handleAddSelected }>
|
|
{ isTabView ? i18n.t("groups.menu.add_all") : i18n.t("groups.menu.add_selected") }
|
|
</MenuItem>
|
|
|
|
<MenuItem icon={ <EditIcon /> } onClick={ handleEdit }>
|
|
{ i18n.t("groups.menu.edit") }
|
|
</MenuItem>
|
|
{ group.items.length > 0 &&
|
|
<MenuItem
|
|
className={ dangerCls.menuItem }
|
|
icon={ <UngroupIcon /> }
|
|
onClick={ () => ungroup(collection.timestamp, indices[1]) }
|
|
>
|
|
{ i18n.t("groups.menu.ungroup") }
|
|
</MenuItem>
|
|
}
|
|
<MenuItem className={ dangerCls.menuItem } icon={ <DeleteIcon /> } onClick={ handleDelete }>
|
|
{ i18n.t("groups.menu.delete") }
|
|
</MenuItem>
|
|
</MenuList>
|
|
</MenuPopover>
|
|
</Menu>
|
|
);
|
|
}
|