diff --git a/frontend/components/basic/EventFilter.tsx b/frontend/components/basic/EventFilter.tsx new file mode 100644 index 000000000..5a9506f0e --- /dev/null +++ b/frontend/components/basic/EventFilter.tsx @@ -0,0 +1,112 @@ +import React from 'react'; +import { Fragment } from 'react'; +import { + faAngleDown, + faCheck, + faDownload, + faPlus, + faUpload, + faX +} from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { Listbox, Transition } from '@headlessui/react'; + +import guidGenerator from '../utilities/randomId'; +import Button from './buttons/Button'; + +interface ListBoxProps { + selected: string; + select: (event: string) => void; + data: string[]; + text?: string; + buttonAction?: () => void; + isFull?: boolean; +} + +const eventOptions = [ + { + name: 'Secrets Pushed', + icon: faUpload + }, + { + name: 'Secrets Pulled', + icon: faDownload + } +]; + +/** + * This is the component that we use for drop down lists. + * @param {object} obj + * @param {string} obj.selected - the item that is currently selected + * @param {function} obj.select - what happends if you select the item inside a list + * @param {string[]} obj.data - all the options available + * @param {string} obj.text - the text that shows us in front of the select option + * @param {function} obj.buttonAction - if there is a button at the bottom of the list, this is the action that happens when you click the button + * @param {string} obj.width - button width + * @returns + */ +export default function EventFilter({ + selected, + select, + data, + text, + buttonAction, + isFull +}: ListBoxProps): JSX.Element { + return ( + +
+ + {selected != '' ? ( +

{selected}

+ ) : ( +

Select an event

+ )} + {selected != '' ? ( + select('')} + /> + ) : ( + + )} +
+ + + {eventOptions.map((event, id) => { + return ( + + {({ selected }) => ( + <> + + {' '} + {event.name} + + + )} + {/* {event.name} */} + + ); + })} + + +
+
+ ); +} diff --git a/frontend/components/basic/Layout.tsx b/frontend/components/basic/Layout.tsx index 91f257ff9..bf3b8bf51 100644 --- a/frontend/components/basic/Layout.tsx +++ b/frontend/components/basic/Layout.tsx @@ -4,12 +4,12 @@ import { useEffect, useState } from 'react'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { - faBook, faBookOpen, faGear, faKey, faMobile, faPlug, + faTimeline, faUser } from '@fortawesome/free-solid-svg-icons'; import { faPlus } from '@fortawesome/free-solid-svg-icons'; @@ -153,8 +153,8 @@ export default function Layout({ children }: LayoutProps) { }, { href: '/activity/' + workspaceMapping[workspaceSelected as any], - title: 'Activity', - emoji: + title: 'Activity Logs', + emoji: }, { href: '/settings/project/' + workspaceMapping[workspaceSelected as any], diff --git a/frontend/components/basic/Listbox.tsx b/frontend/components/basic/Listbox.tsx index aa8c41f85..e87bab208 100644 --- a/frontend/components/basic/Listbox.tsx +++ b/frontend/components/basic/Listbox.tsx @@ -1,19 +1,19 @@ -import React from "react"; -import { Fragment } from "react"; +import React from 'react'; +import { Fragment } from 'react'; import { faAngleDown, faCheck, - faPlus, -} from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { Listbox, Transition } from "@headlessui/react"; + faPlus +} from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { Listbox, Transition } from '@headlessui/react'; interface ListBoxProps { selected: string; onChange: () => void; data: string[]; - text: string; - buttonAction: () => void; + text?: string; + buttonAction?: () => void; isFull?: boolean; } @@ -34,20 +34,20 @@ export default function ListBox({ data, text, buttonAction, - isFull, + isFull }: ListBoxProps): JSX.Element { return (
{text} - {" "} + {' '} {selected}
@@ -70,11 +70,11 @@ export default function ListBox({ key={personIdx} className={({ active, selected }) => `my-0.5 relative cursor-default select-none py-2 pl-10 pr-4 rounded-md ${ - selected ? "bg-white/10 text-gray-400 font-bold" : "" + selected ? 'bg-white/10 text-gray-400 font-bold' : '' } ${ active && !selected - ? "bg-white/5 text-mineshaft-200 cursor-pointer" - : "text-gray-400" + ? 'bg-white/5 text-mineshaft-200 cursor-pointer' + : 'text-gray-400' } ` } value={person} @@ -83,7 +83,7 @@ export default function ListBox({ <> {person} diff --git a/frontend/components/basic/table/ActivityTable.tsx b/frontend/components/basic/table/ActivityTable.tsx index fe98277e7..0f5f3eb6b 100644 --- a/frontend/components/basic/table/ActivityTable.tsx +++ b/frontend/components/basic/table/ActivityTable.tsx @@ -49,17 +49,14 @@ const ActivityLogsRow = ({ row }: { row: ActivityTableProps }): JSX.Element => { const [payloadOpened, setPayloadOpened] = useState(false); return ( <> - +
setPayloadOpened(!payloadOpened)} - className="border-mineshaft-700 border-t text-gray-300 flex items-center" + className="border-mineshaft-700 border-t text-gray-300 flex items-center cursor-pointer" > diff --git a/frontend/pages/activity/[id].tsx b/frontend/pages/activity/[id].tsx index 3dc55799f..9b51d7f74 100644 --- a/frontend/pages/activity/[id].tsx +++ b/frontend/pages/activity/[id].tsx @@ -1,11 +1,96 @@ import React, { useEffect, useState } from 'react'; import { useRouter } from 'next/router'; +import EventFilter from '~/components/basic/EventFilter'; import ActivityTable from '~/components/basic/table/ActivityTable'; import NavHeader from '~/components/navigation/NavHeader'; import onboardingCheck from '~/components/utilities/checks/OnboardingCheck'; const data = [ + { + eventName: 'Secrets Pulled', + user: 'matsiiako@gmail.com', + source: 'CLI', + time: new Date() + }, + { + eventName: 'Secrets Pushed', + user: 'matsiiako@gmail.com', + source: 'Web', + time: new Date() + }, + { + eventName: 'Secrets Pulled', + user: 'matsiiako@gmail.com', + source: 'CLI', + time: new Date() + }, + { + eventName: 'Secrets Pushed', + user: 'matsiiako@gmail.com', + source: 'Web', + time: new Date() + }, + { + eventName: 'Secrets Pulled', + user: 'matsiiako@gmail.com', + source: 'CLI', + time: new Date() + }, + { + eventName: 'Secrets Pushed', + user: 'matsiiako@gmail.com', + source: 'Web', + time: new Date() + }, + { + eventName: 'Secrets Pulled', + user: 'matsiiako@gmail.com', + source: 'CLI', + time: new Date() + }, + { + eventName: 'Secrets Pushed', + user: 'matsiiako@gmail.com', + source: 'Web', + time: new Date() + }, + { + eventName: 'Secrets Pulled', + user: 'matsiiako@gmail.com', + source: 'CLI', + time: new Date() + }, + { + eventName: 'Secrets Pushed', + user: 'matsiiako@gmail.com', + source: 'Web', + time: new Date() + }, + { + eventName: 'Secrets Pulled', + user: 'matsiiako@gmail.com', + source: 'CLI', + time: new Date() + }, + { + eventName: 'Secrets Pushed', + user: 'matsiiako@gmail.com', + source: 'Web', + time: new Date() + }, + { + eventName: 'Secrets Pulled', + user: 'matsiiako@gmail.com', + source: 'CLI', + time: new Date() + }, + { + eventName: 'Secrets Pushed', + user: 'matsiiako@gmail.com', + source: 'Web', + time: new Date() + }, { eventName: 'Secrets Pulled', user: 'matsiiako@gmail.com', @@ -32,6 +117,7 @@ export default function Activity() { const [hasUserStarred, setHasUserStarred] = useState(false); const [hasUserPushedSecrets, setHasUserPushedSecrets] = useState(false); const [usersInOrg, setUsersInOrg] = useState(false); + const [eventChosen, setEventChosen] = useState(''); useEffect(() => { onboardingCheck({ @@ -54,7 +140,20 @@ export default function Activity() { Event history limited to the last 12 months.

- + {/* Licence Required +
+ +
*/} + + eventChosen != '' ? event.eventName == eventChosen : event + )} + />
); }