diff --git a/gradle/changelog/rework_branch_overview.yaml b/gradle/changelog/rework_branch_overview.yaml new file mode 100644 index 0000000000..dd6ecc52d8 --- /dev/null +++ b/gradle/changelog/rework_branch_overview.yaml @@ -0,0 +1,2 @@ +- type: changed + description: Rework branch overview diff --git a/scm-ui/ui-extensions/src/extensionPoints.ts b/scm-ui/ui-extensions/src/extensionPoints.ts index 2d89a575b7..5e4c901e0f 100644 --- a/scm-ui/ui-extensions/src/extensionPoints.ts +++ b/scm-ui/ui-extensions/src/extensionPoints.ts @@ -26,6 +26,7 @@ import React, { ComponentType, ReactNode } from "react"; import { Branch, Changeset, + ContentType, File, Group, HalRepresentation, @@ -44,7 +45,6 @@ import { RepositoryTypeCollection, Tag, User, - ContentType, } from "@scm-manager/ui-types"; import { ExtensionPointDefinition } from "./binder"; import { RenderableExtensionPointDefinition, SimpleRenderableDynamicExtensionPointDefinition } from "./ExtensionPoint"; @@ -680,3 +680,21 @@ export type GroupInformationTableBottom = RenderableExtensionPointDefinition< "group.information.table.bottom", { group: Group } >; + +type BranchListDetailProps = { + repository: Repository; + branch: Branch; + labelId: string; +}; + +/** + * @since 2.46.0 + */ +export type BranchListDetail = ExtensionPointDefinition< + "branches.list.detail", + { + name: string; + render: (props: BranchListDetailProps) => ReactNode | null; + }, + Omit +>; diff --git a/scm-ui/ui-layout/package.json b/scm-ui/ui-layout/package.json index 3a31954995..22a712ee27 100644 --- a/scm-ui/ui-layout/package.json +++ b/scm-ui/ui-layout/package.json @@ -20,6 +20,7 @@ "@scm-manager/ui-overlays": "2.45.3-SNAPSHOT", "@scm-manager/ui-buttons": "2.45.3-SNAPSHOT", "@storybook/addon-actions": "^6.5.10", + "@storybook/addon-docs": "^6.5.14", "@storybook/addon-essentials": "^6.5.10", "@storybook/addon-interactions": "^6.5.10", "@storybook/addon-links": "^6.5.10", @@ -27,17 +28,18 @@ "@storybook/manager-webpack5": "^6.5.10", "@storybook/react": "^6.5.10", "@storybook/testing-library": "^0.0.13", - "@storybook/addon-docs": "^6.5.14", "babel-loader": "^8.2.5", "storybook-addon-mock": "^3.2.0", "storybook-addon-themes": "^6.1.0", "tsup": "^6.2.3" }, "peerDependencies": { + "classnames": "2", "react": "17", "react-dom": "17", - "classnames": "2", - "styled-components": "5" + "styled-components": "5", + "@scm-manager/ui-buttons": "2.45.3-SNAPSHOT", + "@scm-manager/ui-overlays": "2.45.3-SNAPSHOT" }, "prettier": "@scm-manager/prettier-config", "eslintConfig": { @@ -45,5 +47,9 @@ }, "publishConfig": { "access": "public" + }, + "dependencies": { + "@radix-ui/react-collapsible": "^1.0.3" } -} \ No newline at end of file +} + diff --git a/scm-ui/ui-layout/src/card/Card.tsx b/scm-ui/ui-layout/src/card/Card.tsx index d11fbb8593..ab6cdcd45a 100644 --- a/scm-ui/ui-layout/src/card/Card.tsx +++ b/scm-ui/ui-layout/src/card/Card.tsx @@ -25,6 +25,7 @@ import React, { ComponentType, HTMLAttributes, ReactHTML, Ref } from "react"; import styled from "styled-components"; import classNames from "classnames"; +import CSS from "csstype"; const CardRowsContainer = styled.div` overflow: hidden; @@ -33,28 +34,38 @@ const CardRowsContainer = styled.div` type Props = HTMLAttributes & { action?: React.ReactElement; /** - * @default 'div' + * @default "div" */ as?: keyof ReactHTML | ComponentType & { ref?: Ref }>; + + /** + * @default "0.5rem" + * @since 2.46.0 + */ + rowGap?: CSS.Properties["gap"]; }; /** * @beta * @since 2.44.0 */ -const Card = React.forwardRef(({ className, children, as: Comp = "div", action, ...props }, ref) => - React.createElement( - Comp, - { - className: classNames(className, "is-relative", "is-flex", "scmm-card"), - ref, - ...props, - }, - - {children} - , - action ? {action} : null - ) +const Card = React.forwardRef( + ({ className, rowGap = "0.5rem", children, as: Comp = "div", action, ...props }, ref) => + React.createElement( + Comp, + { + className: classNames(className, "is-relative", "is-flex", "scmm-card"), + ref, + ...props, + }, + + {children} + , + action ? {action} : null + ) ); export default Card; diff --git a/scm-ui/ui-layout/src/card/CardRow.tsx b/scm-ui/ui-layout/src/card/CardRow.tsx index 0e78882339..d7009e5f70 100644 --- a/scm-ui/ui-layout/src/card/CardRow.tsx +++ b/scm-ui/ui-layout/src/card/CardRow.tsx @@ -26,6 +26,6 @@ * @beta * @since 2.44.0 */ -const CardRow = "div"; +const CardRow = "div" as const; export default CardRow; diff --git a/scm-ui/ui-layout/src/collapsible/Collapsible.stories.tsx b/scm-ui/ui-layout/src/collapsible/Collapsible.stories.tsx new file mode 100644 index 0000000000..a5fa71dd0a --- /dev/null +++ b/scm-ui/ui-layout/src/collapsible/Collapsible.stories.tsx @@ -0,0 +1,50 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import StoryRouter from "storybook-react-router"; +import { ComponentMeta, StoryFn } from "@storybook/react"; +import React, { ComponentProps } from "react"; +import { ExtractProps } from "@scm-manager/ui-extensions"; +import { Link } from "react-router-dom"; +import { Menu } from "@scm-manager/ui-overlays"; +import { Icon } from "@scm-manager/ui-buttons"; +import CardRow from "../card/CardRow"; +import Collapsible from "./Collapsible"; + +export default { + title: "Collapsible", + component: Collapsible, + decorators: [StoryRouter()], +} as ComponentMeta; + +const Template: StoryFn> = (args) => ; + +export const Default = Template.bind({}); +// More on args: https://storybook.js.org/docs/react/writing-stories/args +Default.args = { + children: [ + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", + ], + header: "This is a collapsible", +} as ComponentProps; diff --git a/scm-ui/ui-layout/src/collapsible/Collapsible.tsx b/scm-ui/ui-layout/src/collapsible/Collapsible.tsx new file mode 100644 index 0000000000..eb0a0951dc --- /dev/null +++ b/scm-ui/ui-layout/src/collapsible/Collapsible.tsx @@ -0,0 +1,61 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import React, { ComponentProps, ReactNode, useState } from "react"; +import * as RadixCollapsible from "@radix-ui/react-collapsible"; +import { Icon } from "@scm-manager/ui-buttons"; +import styled from "styled-components"; + +const StyledTrigger = styled(RadixCollapsible.Trigger)` + margin-right: 0.5rem; +`; + +const StyledCollapsibleHeader = styled.div` + background-color: var(--scm-secondary-less-color); +`; + +type Props = { + header: ReactNode; +} & Pick, "defaultOpen">; + +/** + * @beta; + * @since 2.46.0 + */ +const Collapsible = React.forwardRef(({ children, header, defaultOpen }, ref) => { + const [open, setOpen] = useState(defaultOpen); + return ( + + + {header} + + {open ? "angle-up" : "angle-down"} + + + {children} + + ); +}); + +export default Collapsible; diff --git a/scm-ui/ui-layout/src/index.ts b/scm-ui/ui-layout/src/index.ts index 7acf771d2d..04dc36aa86 100644 --- a/scm-ui/ui-layout/src/index.ts +++ b/scm-ui/ui-layout/src/index.ts @@ -26,6 +26,8 @@ import CardListComponent, { CardListBox as CardListBoxComponent, CardListCard } import CardTitle from "./card/CardTitle"; import CardRow from "./card/CardRow"; +export { default as Collapsible } from "./collapsible/Collapsible"; + const CardListExport = { Card: Object.assign(CardListCard, { Row: CardRow, diff --git a/scm-ui/ui-overlays/package.json b/scm-ui/ui-overlays/package.json index 35b8f21af4..8db01be1b0 100644 --- a/scm-ui/ui-overlays/package.json +++ b/scm-ui/ui-overlays/package.json @@ -41,7 +41,8 @@ }, "dependencies": { "@radix-ui/react-tooltip": "1.0.2", - "@radix-ui/react-dropdown-menu": "2.0.4", + "@radix-ui/react-dialog": "1.0.2", + "@radix-ui/react-dropdown-menu": "2.0.1", "@scm-manager/ui-buttons": "2.45.3-SNAPSHOT" }, "prettier": "@scm-manager/prettier-config", @@ -51,4 +52,5 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} + diff --git a/scm-ui/ui-overlays/src/dialog/Dialog.stories.tsx b/scm-ui/ui-overlays/src/dialog/Dialog.stories.tsx new file mode 100644 index 0000000000..cf3ea947ed --- /dev/null +++ b/scm-ui/ui-overlays/src/dialog/Dialog.stories.tsx @@ -0,0 +1,65 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import StoryRouter from "storybook-react-router"; +import { ComponentMeta, StoryFn } from "@storybook/react"; +import React, { ComponentProps } from "react"; +import { ExtractProps } from "@scm-manager/ui-extensions"; +import { Button } from "@scm-manager/ui-buttons"; +import Dialog from "./Dialog"; + +export default { + title: "Dialog", + component: Dialog, + decorators: [StoryRouter()], + render: (story) =>
{story}
, +} as ComponentMeta; + +const Template: StoryFn> = (args) => ; + +export const Default = Template.bind({}); +// More on args: https://storybook.js.org/docs/react/writing-stories/args +Default.args = { + title: "My Dialog", + trigger: , + description: "Do you really want to do this ?", + children: ( + + + + + + + + + +
YesNo
4212
+ ), + footer: [ + , + , + ], +} as ComponentProps; diff --git a/scm-ui/ui-overlays/src/dialog/Dialog.tsx b/scm-ui/ui-overlays/src/dialog/Dialog.tsx new file mode 100644 index 0000000000..b2156c94cf --- /dev/null +++ b/scm-ui/ui-overlays/src/dialog/Dialog.tsx @@ -0,0 +1,85 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import * as RadixDialog from "@radix-ui/react-dialog"; +import { DialogProps } from "@radix-ui/react-dialog"; +import React, { ComponentProps, ReactComponentElement, ReactElement, ReactNode, useCallback } from "react"; +import { Button } from "@scm-manager/ui-buttons"; +import { useTranslation } from "react-i18next"; + +export const CloseButton = React.forwardRef>( + ({ children, ...props }, ref) => ( + + + + ) +); + +type Props = { + trigger: ReactComponentElement; + title: ReactNode; + description?: ReactNode; + footer?: ReactElement[] | ((close: () => void) => ReactElement[]); +} & Pick; + +/** + * @beta + * @since 2.46.0 + */ +const Dialog = React.forwardRef( + ({ children, onOpenChange, open, footer, title, trigger, description }, ref) => { + const contentProps = description ? {} : { "aria-describedby": undefined }; + const close = useCallback(() => onOpenChange && onOpenChange(false), [onOpenChange]); + const [t] = useTranslation("commons"); + return ( + + {trigger} + + + +
+
+ {title} + +
+
+ {description ? {description} : null} + {children} +
+ {footer ? ( +
{typeof footer === "function" ? footer(close) : footer}
+ ) : null} +
+
+
+
+ ); + } +); + +export default Dialog; diff --git a/scm-ui/ui-overlays/src/index.ts b/scm-ui/ui-overlays/src/index.ts index 67a53270f4..be8119d1bc 100644 --- a/scm-ui/ui-overlays/src/index.ts +++ b/scm-ui/ui-overlays/src/index.ts @@ -22,8 +22,9 @@ * SOFTWARE. */ -import MenuComponent, { MenuButton, MenuExternalLink, MenuLink } from "./menu/Menu"; +import MenuComponent, { MenuButton, MenuDialog, MenuExternalLink, MenuLink } from "./menu/Menu"; import MenuTrigger, { DefaultMenuTrigger } from "./menu/MenuTrigger"; +import DialogComponent, { CloseButton } from "./dialog/Dialog"; export { default as Tooltip } from "./tooltip/Tooltip"; @@ -31,6 +32,11 @@ export const Menu = Object.assign(MenuComponent, { Button: MenuButton, Link: MenuLink, ExternalLink: MenuExternalLink, + DialogButton: MenuDialog, Trigger: MenuTrigger, DefaultTrigger: DefaultMenuTrigger, }); + +export const Dialog = Object.assign(DialogComponent, { + CloseButton, +}); diff --git a/scm-ui/ui-overlays/src/menu/Menu.stories.tsx b/scm-ui/ui-overlays/src/menu/Menu.stories.tsx index a510b97f5a..e7972b965e 100644 --- a/scm-ui/ui-overlays/src/menu/Menu.stories.tsx +++ b/scm-ui/ui-overlays/src/menu/Menu.stories.tsx @@ -26,8 +26,9 @@ import StoryRouter from "storybook-react-router"; import { ComponentMeta, StoryFn } from "@storybook/react"; import React, { ComponentProps } from "react"; import { ExtractProps } from "@scm-manager/ui-extensions"; -import Menu, { MenuButton, MenuExternalLink, MenuLink } from "./Menu"; -import { Icon } from "@scm-manager/ui-buttons"; +import Menu, { MenuButton, MenuDialog, MenuExternalLink, MenuLink } from "./Menu"; +import { Button, Icon } from "@scm-manager/ui-buttons"; +import { CloseButton } from "../dialog/Dialog"; export default { title: "Menu", @@ -54,5 +55,25 @@ Default.args = { trashA disabled button , + Do it, Cancel]} + dialogContent={ + + + + + + + + + +
YesNo
4212
+ } + > + + Open Dialog +
, ], } as ComponentProps; diff --git a/scm-ui/ui-overlays/src/menu/Menu.tsx b/scm-ui/ui-overlays/src/menu/Menu.tsx index a714c49151..ec8b7847d6 100644 --- a/scm-ui/ui-overlays/src/menu/Menu.tsx +++ b/scm-ui/ui-overlays/src/menu/Menu.tsx @@ -22,17 +22,28 @@ * SOFTWARE. */ -import React, { AnchorHTMLAttributes, ButtonHTMLAttributes, FC } from "react"; +import React, { + AnchorHTMLAttributes, + ButtonHTMLAttributes, + ComponentProps, + createContext, + FC, + ReactNode, + useCallback, + useContext, + useMemo, + useState, +} from "react"; import * as RadixMenu from "@radix-ui/react-dropdown-menu"; import styled from "styled-components"; import { DefaultMenuTrigger } from "./MenuTrigger"; import classNames from "classnames"; import { Link as ReactRouterLink, LinkProps as ReactRouterLinkProps } from "react-router-dom"; +import Dialog from "../dialog/Dialog"; const MenuContent = styled(RadixMenu.Content)` border: var(--scm-border); background-color: var(--scm-secondary-background); - z-index: 400; position: relative; `; @@ -105,6 +116,53 @@ export const MenuButton = React.forwardRef( ) ); +type MenuContextType = { + handleDialogItemOpenChange: (open: boolean) => void; +}; +const MenuContext = createContext(null as unknown as MenuContextType); + +type MenuDialogProps = Omit & + Omit, "trigger"> & { + dialogContent?: ReactNode; + }; + +/** + * @beta + * @since 2.46.0 + * @see {@link Dialog} + */ +export const MenuDialog = React.forwardRef( + ({ children, dialogContent, title, description, footer }, ref) => { + const { handleDialogItemOpenChange } = useContext(MenuContext); + const [open, setOpen] = useState(false); + const handleSelect = useCallback((event: Event) => event.preventDefault(), []); + const changeOpen = useCallback( + (newValue: boolean) => { + setOpen(newValue); + handleDialogItemOpenChange(newValue); + }, + [handleDialogItemOpenChange] + ); + + return ( + + {children} + + } + title={title} + description={description} + footer={footer} + onOpenChange={changeOpen} + open={open} + > + {dialogContent} + + ); + } +); + type Props = { className?: string; trigger?: React.ReactElement; @@ -119,8 +177,23 @@ type Props = { * @see https://www.w3.org/WAI/ARIA/apg/patterns/menubar/ */ const Menu: FC = ({ children, side, className, trigger = }) => { + const [dropdownOpen, setDropdownOpen] = useState(false); + const [hasOpenDialog, setHasOpenDialog] = useState(false); + const handleDialogItemOpenChange = useCallback((open: boolean) => { + setHasOpenDialog(open); + if (!open) { + setDropdownOpen(false); + } + }, []); + const menuContextValue = useMemo( + () => ({ + handleDialogItemOpenChange, + }), + [handleDialogItemOpenChange] + ); + return ( - + {trigger} = ({ children, side, className, trigger = diff --git a/scm-ui/ui-styles/src/components/_main.scss b/scm-ui/ui-styles/src/components/_main.scss index ca995aef30..351b4bfa63 100644 --- a/scm-ui/ui-styles/src/components/_main.scss +++ b/scm-ui/ui-styles/src/components/_main.scss @@ -67,6 +67,10 @@ border: none; } +.is-white-space-pre { + white-space: pre; +} + .has-background-transparent { background-color: transparent; } diff --git a/scm-ui/ui-webapp/public/locales/de/commons.json b/scm-ui/ui-webapp/public/locales/de/commons.json index f7f9b84f55..d771efc0d0 100644 --- a/scm-ui/ui-webapp/public/locales/de/commons.json +++ b/scm-ui/ui-webapp/public/locales/de/commons.json @@ -1,4 +1,9 @@ { + "dialog": { + "closeButton": { + "ariaLabel": "Dialog schließen" + } + }, "menu": { "defaultTriggerLabel": "Menü" }, diff --git a/scm-ui/ui-webapp/public/locales/de/repos.json b/scm-ui/ui-webapp/public/locales/de/repos.json index 6d38dff24c..c9fc08b05e 100644 --- a/scm-ui/ui-webapp/public/locales/de/repos.json +++ b/scm-ui/ui-webapp/public/locales/de/repos.json @@ -121,15 +121,24 @@ }, "branches": { "overview": { - "title": "Übersicht aller verfügbaren Branches", + "title": "Branches", "noBranches": "Keine Branches gefunden.", "createButton": "Branch erstellen", - "lastCommit": "Letzter Commit" + "lastCommit": "Letzter Commit", + "sort": { + "label": "Sortierung nach", + "option": { + "default": "Standard", + "name_asc": "Name A-Z", + "name_desc": "Name Z-A" + } + } }, "table": { "branches": { "active": "Aktive Branches", - "stale": "Stale Branches" + "stale": "Stale Branches", + "subtitle": "Letzter Commit von {{author}}" }, "lastCommit": "Letzter Commit", "lastCommitter": "von {{name}}" @@ -153,7 +162,7 @@ "behindLabel": "{{count}} hinterher" }, "delete": { - "button": "Branch löschen", + "button": "Löschen", "subtitle": "Branch löschen", "description": "Gelöschte Branches können nicht wiederhergestellt werden.", "confirmAlert": { diff --git a/scm-ui/ui-webapp/public/locales/en/commons.json b/scm-ui/ui-webapp/public/locales/en/commons.json index 8b7577f3d2..5740fe3a0e 100644 --- a/scm-ui/ui-webapp/public/locales/en/commons.json +++ b/scm-ui/ui-webapp/public/locales/en/commons.json @@ -1,4 +1,9 @@ { + "dialog": { + "closeButton": { + "ariaLabel": "Close Dialog" + } + }, "menu": { "defaultTriggerLabel": "Menu" }, diff --git a/scm-ui/ui-webapp/public/locales/en/repos.json b/scm-ui/ui-webapp/public/locales/en/repos.json index cf809768e9..5b8d9afdb4 100644 --- a/scm-ui/ui-webapp/public/locales/en/repos.json +++ b/scm-ui/ui-webapp/public/locales/en/repos.json @@ -121,15 +121,24 @@ }, "branches": { "overview": { - "title": "Overview of All Branches", + "title": "Branches", "noBranches": "No branches found.", "createButton": "Create Branch", - "lastCommit": "Last commit" + "lastCommit": "Last commit", + "sort": { + "label": "Sort by", + "option": { + "default": "Default", + "name_asc": "Name A-Z", + "name_desc": "Name Z-A" + } + } }, "table": { "branches": { "active": "Active Branches", - "stale": "Stale Branches" + "stale": "Stale Branches", + "subtitle": "Last commit by {{author}}" }, "lastCommit": "Last commit", "lastCommitter": "by {{name}}" @@ -153,7 +162,7 @@ "behindLabel": "{{count}} behind" }, "delete": { - "button": "Delete Branch", + "button": "Delete", "subtitle": "Delete Branch", "description": "Deleted branches cannot be restored.", "confirmAlert": { diff --git a/scm-ui/ui-webapp/src/repos/branches/components/BranchList.tsx b/scm-ui/ui-webapp/src/repos/branches/components/BranchList.tsx new file mode 100644 index 0000000000..18707e399e --- /dev/null +++ b/scm-ui/ui-webapp/src/repos/branches/components/BranchList.tsx @@ -0,0 +1,64 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import { Branch, BranchDetails, Repository } from "@scm-manager/ui-types"; +import React, { FC, useMemo } from "react"; +import { extensionPoints } from "@scm-manager/ui-extensions"; +import { CardList } from "@scm-manager/ui-layout"; +import { ErrorNotification } from "@scm-manager/ui-components"; +import { useDeleteBranch } from "@scm-manager/ui-api"; +import BranchListItem from "./BranchListItem"; + +type Props = { + baseUrl: string; + repository: Repository; + branches: Branch[]; + branchesDetails?: BranchDetails[]; +}; + +const BranchList: FC = ({ repository, baseUrl, branches, branchesDetails }) => { + const { isLoading, error, remove } = useDeleteBranch(repository); + const defaultBranchDetails = useMemo(() => [], []); + + return ( + <> + + + {branches.map((branch) => ( + branchName === branch.name)} + /> + ))} + + + ); +}; +export default BranchList; diff --git a/scm-ui/ui-webapp/src/repos/branches/components/BranchListItem.tsx b/scm-ui/ui-webapp/src/repos/branches/components/BranchListItem.tsx new file mode 100644 index 0000000000..d743521228 --- /dev/null +++ b/scm-ui/ui-webapp/src/repos/branches/components/BranchListItem.tsx @@ -0,0 +1,136 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import { Dialog, Menu } from "@scm-manager/ui-overlays"; +import { Icon } from "@scm-manager/ui-buttons"; +import { CardList } from "@scm-manager/ui-layout"; +import { Link } from "react-router-dom"; +import { encodePart } from "../../sources/components/content/FileLink"; +import { useKeyboardIteratorTarget } from "@scm-manager/ui-shortcuts"; +import { Trans, useTranslation } from "react-i18next"; +import { DateFromNow, useGeneratedId } from "@scm-manager/ui-components"; +import { extensionPoints, useBinder } from "@scm-manager/ui-extensions"; +import React, { FC } from "react"; +import { Branch, BranchDetails, Repository } from "@scm-manager/ui-types"; +import styled from "styled-components"; + +const DetailsContainer = styled(CardList.Card.Row)` + gap: 0.5rem 1rem; +`; + +const BranchDetail: FC<{ + branch: Branch; + repository: Repository; + detail: extensionPoints.BranchListDetail["type"]; +}> = ({ repository, detail, branch }) => { + const labelId = useGeneratedId(); + const renderedDetail = detail.render({ branch, repository, labelId }); + if (!renderedDetail) { + return null; + } + return ( + + + {detail.name} + + {renderedDetail} + + ); +}; + +type Props = { + branch: Branch; + defaultBranchDetails: extensionPoints.BranchListDetail["type"][]; + remove: (branch: Branch) => void; + isLoading: boolean; + baseUrl: string; + repository: Repository; + branchDetails?: BranchDetails; +}; + +const BranchListItem: FC = ({ branch, defaultBranchDetails, remove, isLoading, baseUrl, repository }) => { + const binder = useBinder(); + const [t] = useTranslation("repos"); + + return ( + + remove(branch)} isLoading={isLoading}> + {t("branch.delete.confirmAlert.submit")} + , + + {t("branch.delete.confirmAlert.cancel")} + , + ]} + > + trash + {t("branch.delete.button")} + + + ) : undefined + } + > + + + + {branch.name} + + + + + , + space: , + }} + /> + + + {[ + ...defaultBranchDetails, + ...binder.getExtensions("branches.list.detail", { + branch, + repository, + }), + ].map((detail) => ( + + ))} + + + ); +}; + +export default BranchListItem; diff --git a/scm-ui/ui-webapp/src/repos/branches/components/BranchRow.tsx b/scm-ui/ui-webapp/src/repos/branches/components/BranchRow.tsx deleted file mode 100644 index 2cd70a979d..0000000000 --- a/scm-ui/ui-webapp/src/repos/branches/components/BranchRow.tsx +++ /dev/null @@ -1,120 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2020-present Cloudogu GmbH and Contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import React, { FC } from "react"; -import { Link as ReactLink } from "react-router-dom"; -import { useTranslation } from "react-i18next"; -import classNames from "classnames"; -import styled from "styled-components"; -import { Branch, BranchDetails, Link, Repository } from "@scm-manager/ui-types"; -import { Button, devices, SmallLoadingSpinner } from "@scm-manager/ui-components"; -import { binder } from "@scm-manager/ui-extensions"; -import DefaultBranchTag from "./DefaultBranchTag"; -import AheadBehindTag from "./AheadBehindTag"; -import BranchCommitDateCommitter from "./BranchCommitDateCommitter"; -import { useKeyboardIteratorTarget } from "@scm-manager/ui-shortcuts"; -import { encodePart } from "../../sources/components/content/FileLink"; - -type Props = { - repository: Repository; - baseUrl: string; - branch: Branch; - onDelete: (branch: Branch) => void; - details?: BranchDetails; -}; - -const AdaptTableFlow = styled.tr` - @media screen and (max-width: ${devices.mobile.width}px) { - td { - display: block; - border-left-width: 3px !important; - } - } -`; - -const MobileFlowSpan = styled.span` - @media screen and (min-width: ${devices.tablet.width}px) { - margin-left: 1rem; - } - @media screen and (max-width: ${devices.mobile.width}px) { - display: block; - white-space: break-spaces; - word-break: break-word; - } -`; - -const BranchRow: FC = ({ repository, baseUrl, branch, onDelete, details }) => { - const to = `${baseUrl}/${encodePart(branch.name)}/info`; - const [t] = useTranslation("repos"); - const ref = useKeyboardIteratorTarget(); - - let deleteButton; - if ((branch?._links?.delete as Link)?.href) { - deleteButton = ( -