Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Personal View #391

Merged
merged 8 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions frontend/src/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from "./pulldasher/pulls-context";
import { Pull } from "./pull";
import {
chakra,
useColorMode,
Button,
HStack,
Expand All @@ -20,6 +19,7 @@ import {
MenuButton,
MenuItemOption,
MenuList,
Text
} from "@chakra-ui/react";
import { useRef, useEffect, useCallback } from "react";
import { useBoolUrlState } from "./use-url-state";
Expand All @@ -34,6 +34,8 @@ import {
faCircleNotch,
faXmark,
faCircleExclamation,
faUser,
faUsers
} from "@fortawesome/free-solid-svg-icons";

// Default width of the left and right sections of the nav bar
Expand All @@ -56,6 +58,7 @@ export function Navbar(props: NavBarProps) {
true
);
const [showDrafts, toggleShowDrafts] = useBoolUrlState("drafts", true);
const [showPersonalView , togglePersonalView] = useBoolUrlState("personal", false);
const hideBelowMedium = ["none", "none", "block"];
const hideBelowLarge = ["none", "none", "none", "block"];

Expand All @@ -75,6 +78,10 @@ export function Navbar(props: NavBarProps) {
() => setPullFilter("drafts", showDrafts ? null : isNotDraft),
[showDrafts]
);
useEffect(
() => setPullFilter("personal", showPersonalView ? isMineViaAffiliation : null),
[showPersonalView]
);
// Set the page title
const title = getTitle();
useEffect(() => { document.title = title || ''; }, [title]);
Expand All @@ -99,15 +106,6 @@ export function Navbar(props: NavBarProps) {
flexBasis={sideWidth}
spacing="2"
>
<Box display={hideBelowLarge} p="1 15px 0 0" fontSize="16px">
<ConnectionStateIndicator />
</Box>
<chakra.span
display={hideBelowLarge}
title={`Shown: ${pulls.size} Total: ${allOpenPulls.length}`}
>
open: {pulls.size}
</chakra.span>
<Button
display={hideBelowMedium}
size="sm"
Expand All @@ -129,6 +127,16 @@ export function Navbar(props: NavBarProps) {
<FontAwesomeIcon icon={faCodeMerge} />
</Button>
<NotificationRequest />
<Button
display={hideBelowMedium}
size="sm"
title={showPersonalView ? "Show All" : "Show Personal View"}
colorScheme="blue"
variant="ghost"
onClick={togglePersonalView}
>
<FontAwesomeIcon icon={showPersonalView ? faUsers : faUser} />
</Button>
<Menu closeOnSelect={false}>
<MenuButton
as={Button}
Expand Down Expand Up @@ -187,6 +195,21 @@ export function Navbar(props: NavBarProps) {
display="flex"
justifyContent="flex-end"
>
<HStack marginRight="12px" >
<Box display={hideBelowLarge} p="1 15px 0 0" fontSize="16px">
<ConnectionStateIndicator />
</Box>
<Box display={hideBelowLarge} title={`Shown: ${pulls.size} Total: ${allOpenPulls.length}`}>
<HStack>
<Text>
open:
</Text>
<Text w="1.25em" textAlign="center">
{pulls.size}
</Text>
</HStack>
</Box>
</HStack>
<SearchInput />
</Box>
</Flex>
Expand All @@ -206,6 +229,10 @@ function isNotDraft(pull: Pull): boolean {
return !pull.isDraft();
}

function isMineViaAffiliation(pull: Pull): boolean {
return pull.isMineViaAffiliation();
}

function SearchInput() {
const setPullFilter = useSetFilter();
const searchInputRef = useRef<HTMLInputElement>(null);
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ export class Pull extends PullData {
return this.user.login == getUser();
}

isMineViaAffiliation(): boolean {
return (
this.isMine() ||
this.hasCurrentSig(getUser()) ||
this.hasOutdatedSig(getUser()) ||
this.hasMyDevBlock() ||
this.hasMyDeployBlock()
);
}

isCrDone(): boolean {
return this.cr_signatures.current.length >= this.status.cr_req;
}
Expand All @@ -69,6 +79,14 @@ export class Pull extends PullData {
);
}

hasMyDevBlock(): boolean {
return this.getDevBlock()?.data.user.login == getUser();
}

hasMyDeployBlock(): boolean {
return this.getDeployBlock()?.data.user.login == getUser();
}

getDevBlock(): Signature | null {
return this.status.dev_block[0];
}
Expand Down
Loading