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

/explore #55

Draft
wants to merge 924 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
924 commits
Select commit Hold shift + click to select a range
34f9922
Merge branch 'explore' of andirueckel.github.com:medienhaus/medienhau…
andirueckel Feb 28, 2024
5b6fa0b
style: unify text sizes in shadcn components
andirueckel Feb 28, 2024
50b1154
refactor: adapt DataList.js to main
aofn Feb 28, 2024
56c60c0
refactor: use more appropriate icon for kicking users
aofn Feb 28, 2024
072f76e
style: fix Button ghost variant; fix DropdownMenu
andirueckel Feb 28, 2024
7eb19a6
Merge branch 'explore' of andirueckel.github.com:medienhaus/medienhau…
andirueckel Feb 28, 2024
287eb7d
refactor: add icons to dropdown menu
aofn Feb 28, 2024
e01f11d
style: fix DropdownMenuItem grid and colors
andirueckel Feb 28, 2024
8030bca
chore: fix eslint errors
andirueckel Mar 1, 2024
0f6dab6
revert: remove eslint "missing dependencies" from useEffect
andirueckel Mar 1, 2024
9fd0636
fix: copy location.protocol in addition to hostname and path
andirueckel Mar 1, 2024
a9cf1cd
chore: format components/UI/ServiceLink.js
andirueckel Mar 1, 2024
7fd6cf3
style: remove css fill style from Icon.js
andirueckel Mar 1, 2024
2b8559f
chore: wrap svg icons in Icon component for DropdownMenuItem
andirueckel Mar 1, 2024
59c03f4
chore: add/fix/improve/update localized texts
andirueckel Mar 1, 2024
ca10a4f
chore: add localized text
andirueckel Mar 1, 2024
513ff26
refactor: add JSDoc, use Popover to describe chat templates.
aofn Mar 5, 2024
11c033e
add Popover to packages
aofn Mar 5, 2024
daac211
chore: remove unused/unwanted tailwind classes
andirueckel Mar 5, 2024
4c622a0
refactor: add chat templates to presets.js and use them in AddNewChat.js
aofn Mar 5, 2024
4ac94db
style: fix font-weight of KnockCard headline components
andirueckel Mar 5, 2024
77b03d1
chore: remove unused radix package
aofn Mar 5, 2024
a49dc3b
chore: add translations for chat templates
aofn Mar 5, 2024
1355a4b
fix: use correct translation in both useEffects
andirueckel Mar 5, 2024
dbe2cea
merge explore into chat-template
aofn Mar 5, 2024
62b1e3b
Merge remote-tracking branch 'origin/explore' into chat-template
aofn Mar 5, 2024
fef17c1
refactor: move emojis in front of text
aofn Mar 5, 2024
50978cc
Merge pull request #148 from medienhaus/chat-template
aofn Mar 5, 2024
ec3276e
chore: update todos
aofn Mar 5, 2024
eddd6b6
style: make info button square in new chat dialog
andirueckel Mar 5, 2024
c75e802
fix: hydrate room content correctly and improve error handling
aofn Mar 5, 2024
2fcbca1
chore: remove console.log
aofn Mar 5, 2024
25742f4
chore: wrap individual strings in t() function
andirueckel Mar 5, 2024
f876a14
feat: add sonner component
aofn Mar 5, 2024
b48e981
refactor: add sonner to app
aofn Mar 5, 2024
2f29f87
fix: use correct locales file for etherpad
andirueckel Mar 5, 2024
796dc6a
fix: set correct locales namespace for translation strings
andirueckel Mar 5, 2024
883320c
merge main into explore and adapt
aofn Mar 5, 2024
7f5daca
Merge remote-tracking branch 'origin/explore' into explore
aofn Mar 5, 2024
4f253f3
Merge branch 'error-sonner' into explore
aofn Mar 5, 2024
6bfb761
chore: remove trailing whitespaces
andirueckel Mar 5, 2024
895c31e
style: element switches shall be pill-shaped
andirueckel Mar 5, 2024
6abb904
refactor: display error in toast to avoid breaking the layout
aofn Mar 5, 2024
0e68fff
Merge remote-tracking branch 'origin/explore' into explore
aofn Mar 5, 2024
3a2ac6e
style: element invite bar without rounded corners, please
andirueckel Mar 5, 2024
6bbb59c
Merge branch 'main' into explore
andirueckel Mar 5, 2024
dc21fbe
refactor: close modal after successfully adding/creating items/contex…
aofn Mar 5, 2024
f29ef28
chore: add missing locales for new changes in /explore
andirueckel Mar 5, 2024
140e322
Merge pull request #149 from medienhaus/success-sonner
andirueckel Mar 5, 2024
c3b62ec
refactor: use sonner for feedback and error messages
aofn Mar 5, 2024
d161e55
Merge branch 'error-sonner' into explore
aofn Mar 5, 2024
923a27c
chore: fix eslint error (import order)
andirueckel Mar 5, 2024
3287d23
chore: disable eslint for useEffect
aofn Mar 5, 2024
7fc4ba7
Merge remote-tracking branch 'origin/explore' into explore
aofn Mar 5, 2024
1466fcb
refactor: use toast instead of error message
aofn Mar 5, 2024
c93d340
refactor: rename presets.js to matrixPresets.js and move to lib
aofn Mar 5, 2024
99ff217
refactor: display error and success messages in toast when removing i…
aofn Mar 5, 2024
9ef2609
refactor: remove unused variable
aofn Mar 5, 2024
85b9dc5
chore: fix eslint errors
andirueckel Mar 5, 2024
e1599fc
refactor: show individual toasts for each invited user
aofn Mar 5, 2024
c8e1232
Merge branch 'error-sonner' into explore
aofn Mar 5, 2024
fc82ff6
fix: only add success message for actual successes
aofn Mar 5, 2024
2e65e6e
Merge branch 'error-sonner' into explore
aofn Mar 5, 2024
9214ad1
refactor: improve error message
aofn Mar 5, 2024
0b82df1
Merge branch 'error-sonner' into explore
aofn Mar 5, 2024
4a86a82
fix: variable name
aofn Mar 5, 2024
0a19d5f
refactor: use ChatIframeView component in explore
aofn Mar 6, 2024
bb0d231
fix: accidentally deleted spacedeck view
aofn Mar 6, 2024
64399bb
merge main into explore and adapt
aofn Mar 6, 2024
8024f0e
refactor: add empty dependency array to useEffect to avoid unnecessar…
aofn Mar 6, 2024
a2196db
refactor: remove extra component to not rerender after changes inside…
aofn Mar 6, 2024
546bb71
refactor: add custom styles and icons to sonner
aofn Mar 6, 2024
245a296
Merge branch 'error-sonner' into explore
aofn Mar 6, 2024
baa179a
refactor: use shadecn Select in TemplateSelect.js
aofn Mar 6, 2024
ad39a47
merge main into explore
aofn Mar 6, 2024
9c99e90
fix: catch error when trying to hydrate room content for private chat…
aofn Mar 6, 2024
2ca4aae
refactor: add power level content overrider option to room creation a…
aofn Mar 6, 2024
5148559
refactor: make sure iframe header is shown for chat rooms a user is n…
aofn Mar 6, 2024
f38d9e1
fix: iframe selector in chat iframe
aofn Mar 6, 2024
fe2fdc4
style: fixed width for icons in sonner/toast
andirueckel Mar 6, 2024
513cba9
fix: call correct function when experiencing rate limits
aofn Mar 6, 2024
5131654
Merge remote-tracking branch 'origin/error-sonner' into explore
aofn Mar 6, 2024
4b6a867
style: improve vertical spacing
andirueckel Mar 6, 2024
95ece2c
fix: iframe selector
aofn Mar 6, 2024
11802cd
refactor: close menu on success
aofn Mar 6, 2024
5b549e0
Merge branch 'write-workflow' into explore
aofn Mar 6, 2024
e4255f4
fix: iframe has differnet selector in prod and dev environment
aofn Mar 6, 2024
487e096
merge main into explore
aofn Mar 7, 2024
460f9c5
merge main into explore and adapt
aofn Mar 7, 2024
3305365
feat: use shadcn Table for explore and adapt code base and replace em…
aofn Mar 7, 2024
c93ffe7
refactor: create separate cell for icons
aofn Mar 7, 2024
d8a7e70
chore: make eslint happy
aofn Mar 7, 2024
52a4332
style: table colums widths and header icon style
andirueckel Mar 7, 2024
f24984c
refactor: remove unused column
aofn Mar 7, 2024
a2177a5
style: remove type-related classes from Table
andirueckel Mar 11, 2024
b3d964a
style: change border-bottom color of Table rows
andirueckel Mar 11, 2024
4646019
style: apply background-color on hover to tbody tr
andirueckel Mar 11, 2024
65d9e57
style: update/improve size templates in Button
andirueckel Mar 11, 2024
2eb5415
style: adapt to our use-case and clean-up classes of Table
andirueckel Mar 11, 2024
f6dfa73
style: fix column widths in explore content Table
andirueckel Mar 11, 2024
afd4770
style: improve structure and styling of Table elements
andirueckel Mar 11, 2024
6573d71
style: fix icon button width; Table needs implementation
andirueckel Mar 11, 2024
9599bac
style: no bold in Table th element
andirueckel Mar 11, 2024
66dca56
style: border-botton *and* -top for Table thead
andirueckel Mar 11, 2024
5de8766
chore: use TableRow/Cell components in TableFooter
andirueckel Mar 11, 2024
dd83606
style: fix sticky thead and pagination section
andirueckel Mar 11, 2024
cd78f11
refactor: add lock next to password protected pads in explore
aofn Mar 12, 2024
4b92c56
refactor: adapt table in side menu for code changes and display arrow…
aofn Mar 12, 2024
c604f42
draft: only display table and pagination if not empty
andirueckel Mar 11, 2024
6f2e158
style: right-align active icon indicator arrow
andirueckel Mar 12, 2024
819d8d8
fix: internal server error when adding links and display error messag…
aofn Mar 12, 2024
32e7209
Remove dependencies as they're listed in devDependencies already
fnwbr Mar 12, 2024
3ee245c
style: decrease size of password-protected indicator
andirueckel Mar 12, 2024
781276b
chore: remove console.log
aofn Mar 12, 2024
502e567
refactor: remove pagination
aofn Mar 12, 2024
3e13144
style: sticky-bottom "Add more …" button
andirueckel Mar 12, 2024
413225c
style: vertically grow context/item title cell if long
andirueckel Mar 12, 2024
4a28a44
chore: block-comment instead per-line comment
andirueckel Mar 12, 2024
4bcaade
refactor: use shadcn Breadcrumb component for navigation inside explo…
aofn Mar 12, 2024
3ab0181
merge explore-data-table into explore-breadcrumbs
aofn Mar 12, 2024
276403c
WIP: change layout
aofn Mar 12, 2024
9d87528
Merge pull request #150 from medienhaus/explore-data-table
aofn Mar 12, 2024
16b48c0
style: fix scrolling; scroll outer container, not inner
andirueckel Mar 12, 2024
fd28f18
chore: fix eslint errors
andirueckel Mar 12, 2024
acbb9ff
push Breadcrumb file
aofn Mar 12, 2024
5ad10af
chore: improve pencil icon for item type etherpad
andirueckel Mar 12, 2024
b138b28
merge explore into explore-breadcrumb
aofn Mar 12, 2024
d135ab8
fix: truncate pad name for mypads to max 40 characters to avoid errors
aofn Mar 13, 2024
a370848
merge write-workflow into explore
aofn Mar 13, 2024
ee5f43b
Merge branch 'explore' into explore-breadcrumb
aofn Mar 13, 2024
f5f8dc4
style: fix vertical spacing in Drawer/DrawerDialog
andirueckel Mar 13, 2024
ca48a03
wip: inch closer to desired layout
aofn Mar 13, 2024
df8e7a5
fix: make sure links open in target blank
aofn Mar 13, 2024
832a3a1
fix: creating context was broken due to code changes, working again
aofn Mar 13, 2024
447becd
fix: error handling when not in room and not invited
aofn Mar 13, 2024
ea1e463
refactor: implement progress bar for explore instead of displaying lo…
aofn Mar 13, 2024
b21c8ae
draft: restructure header buttons
andirueckel Mar 13, 2024
d4875a7
style: refine progress bar styling
andirueckel Mar 13, 2024
d47d2d3
style: position progress bar very left
andirueckel Mar 13, 2024
f13c8bb
Merge pull request #153 from medienhaus/explore-progressbar
andirueckel Mar 13, 2024
b17bbaa
refactor: extract getSpaceChildren method into own hook
aofn Mar 13, 2024
8619619
merge explore into space-children-hook and adapt to return progress
aofn Mar 13, 2024
9d896a3
Merge pull request #155 from medienhaus/space-children-hook
aofn Mar 13, 2024
ac0711c
chore: remove unused code
aofn Mar 13, 2024
295ccfb
refactor: move fetching state into hook and only display Add more but…
aofn Mar 13, 2024
74f51fe
chore: rename state
andirueckel Mar 13, 2024
e7caf64
style: refine tabs list styling
andirueckel Mar 13, 2024
b432244
chore: formatting
andirueckel Mar 13, 2024
1b6ed07
chore: remove comments and unused code
andirueckel Mar 13, 2024
72d1c40
draft: use Tabs in header
andirueckel Mar 13, 2024
0890787
merge explore into explore-restructure-header-buttons
aofn Mar 13, 2024
9b59502
style: fix TabList inline flex positioning
andirueckel Mar 13, 2024
bcccfd4
draft: change tabs position (and code location)
andirueckel Mar 13, 2024
424e696
chore: remove comments and unused code
andirueckel Mar 13, 2024
547e1f4
fix: parse correct variables to createRoom
aofn Mar 13, 2024
67304cd
style: refine avatar upload grid/sizing
andirueckel Mar 13, 2024
3b9e812
chore: fix eslint error
andirueckel Mar 13, 2024
9e256f2
draft: conditional content; introducing duplicate code
andirueckel Mar 13, 2024
3f16657
style: fix scrolling via `overflow: auto;`
andirueckel Mar 13, 2024
3ff980a
chore: remove comments and unused code
andirueckel Mar 13, 2024
c7558c6
chore: rename first tab in settings to general; add locales
andirueckel Mar 13, 2024
0df129c
chore: format
andirueckel Mar 13, 2024
6ddd15c
style: fix sticky header/footer on mobile
andirueckel Mar 13, 2024
2234ccc
refactor: show members for all users, put settings tab behind condition
aofn Mar 13, 2024
1458410
draft: try to fix/refine breadcrumb header
andirueckel Mar 19, 2024
90fc724
refactor: adapt view when iframe is present and display correct heade…
aofn Mar 19, 2024
e75e3bf
refactor: move sidebar nav out of header and into ExploreIframeViews.js
aofn Mar 19, 2024
65b29fb
fix: display room title if there is only one selected space and popul…
aofn Mar 19, 2024
fd86991
refactor: creating IframeSidebar.js component to display chat view co…
aofn Mar 19, 2024
f67187a
refactor: remove unused variable
aofn Mar 19, 2024
d2f407d
style: fix focus/hover color of a:link in dropdown
andirueckel Mar 19, 2024
0871a92
chore: fix typo(?)
andirueckel Mar 19, 2024
d5addeb
refactor: only show chevron if there are multiple spaces in the array
aofn Mar 19, 2024
3a19e8f
refactor: fix view for items
aofn Mar 19, 2024
122b585
refactor: show breadcrumb navigation above items and add 'add more' icon
aofn Mar 19, 2024
aae5b7a
chore: remove space
andirueckel Mar 19, 2024
620a4da
style: refine iframe header; nowrap and overflow
andirueckel Mar 19, 2024
132df44
style: no muted foreground color in breadcrumb list
andirueckel Mar 19, 2024
f7bb492
style: make last breadcrumb item bold
andirueckel Mar 19, 2024
238c9f7
chore: remove obsolete tailwind font class
andirueckel Mar 19, 2024
864e4e9
style: wrap service iframe header title in h3
andirueckel Mar 19, 2024
7e2aab5
revert: do not wrap title in h3
andirueckel Mar 19, 2024
3d78c41
draft: we might need this after merge for overflow
andirueckel Mar 19, 2024
f6e13fc
style: fix focus color and no underline in dropdown
andirueckel Mar 20, 2024
82396d9
style: change breadcrumb parent directory icon
andirueckel Mar 26, 2024
4b6bbe1
style: change breadcrumb separator icon
andirueckel Mar 26, 2024
72f0f09
Merge pull request #156 from medienhaus/explore-restructure-header-bu…
aofn Mar 26, 2024
8563e2d
merge explore into explore-breadcrumb and adapt
aofn Mar 26, 2024
263b6d7
Merge pull request #157 from medienhaus/explore-breadcrumb
aofn Mar 26, 2024
046ee9b
refactor: simplify cell logic for icons
aofn Mar 26, 2024
b22d327
refactor: Extract the condition for rendering the settings tab and Qu…
aofn Mar 26, 2024
73a565b
Merge branch 'explore-breadcrumb' into explore
aofn Mar 26, 2024
69fcae2
feat: add shadecn Switch
aofn Mar 26, 2024
2f95437
refactor: implement switch to grant users write rights. add condition…
aofn Mar 26, 2024
3f5563b
merge main into explore
aofn Mar 26, 2024
ff74c4b
merge invite-promote into explore
aofn Mar 26, 2024
c6a8c79
refactor: improve error handling
aofn Mar 26, 2024
0a9edc7
style: limit width of settings tabs content
andirueckel Mar 26, 2024
cfd7f3f
refactor: return await function when setting powerlevel
aofn Mar 26, 2024
fea1abd
style: do not flex-wrap breadcrumb line
andirueckel Mar 26, 2024
f1c8a08
chore: fix breadcrumb icon overflow; remove comments
andirueckel Mar 26, 2024
490a05d
refactor: move useGetSpaceChildren.js hook into hooks directory
aofn Mar 26, 2024
079e532
Merge remote-tracking branch 'origin/explore' into explore
aofn Mar 26, 2024
e3a64ca
fix: room name in hint when hovering over knock on space icon
aofn Mar 26, 2024
9877b9b
chore: wrap invitations and knocks in div
andirueckel Mar 26, 2024
fcaf67f
chore: add some vertical spacing to dashboard
andirueckel Mar 26, 2024
a3468c0
chore: format via prettier
andirueckel Mar 26, 2024
4f17de8
style: vertically align lock icon in explore table
andirueckel Mar 27, 2024
e649f30
draft: maybe fix avatar placeholder on ios safari
andirueckel Mar 27, 2024
3bc9f1f
feat: add notification bubble icon to nav toggle
andirueckel Mar 27, 2024
0458f23
chore: use new notification bubble approach in nav
andirueckel Mar 27, 2024
3399474
chore: adapt new notification bubble style/sizing
andirueckel Mar 27, 2024
fb24102
chore: format via prettier
andirueckel Mar 27, 2024
e64a885
fix: close dropdown menu when content was loaded
aofn Mar 27, 2024
308f9b0
chore: remove old comment
andirueckel Mar 27, 2024
48ea80e
style: wrap service table in div for overflow-x
andirueckel Mar 27, 2024
1959e98
style: sticky-bottom invite users button
andirueckel Mar 27, 2024
44646d7
style: wrap favourites table in div for overflow-x
andirueckel Mar 27, 2024
1c74c8b
refactor: ake sure QuickAddExplore is onky displayed after loading is…
aofn Mar 27, 2024
1029915
chore: remove heading in members tab
andirueckel Mar 28, 2024
083e2c7
draft: revert breaking ChatIframeView changes
andirueckel Apr 3, 2024
b64d902
draft: add separate ExploreChatView for /explore
andirueckel Apr 3, 2024
01aa3cf
chore: remove obsolete comments
andirueckel Apr 8, 2024
5284563
fix: display correct icons in context view
andirueckel Apr 8, 2024
5d366e5
chore: comment now unused getIcon() function
andirueckel Apr 8, 2024
d7a6a36
fixing the root of the error: link was created with type context inst…
robertschnuell Apr 8, 2024
8b8be3f
removing unused commented out code
robertschnuell Apr 8, 2024
4a057a9
Merge pull request #161 from medienhaus/explore-fix-icons-in-context-…
robertschnuell Apr 8, 2024
4e340df
style: fix sizing of icon button loading spinner
andirueckel Apr 10, 2024
169af08
chore: format via prettier
andirueckel Apr 10, 2024
bd6cee1
chore: adjust canAddMoreContent to canManageSpace
andirueckel Apr 16, 2024
8739f9b
fix: conditional loading spinner and progress bar
andirueckel Apr 16, 2024
8e675ac
chore: format via prettier
andirueckel Apr 16, 2024
65aeeea
chore: remove canManageSpace condition and const
andirueckel Apr 17, 2024
f9bfbf2
chore: format via prettier
andirueckel Apr 17, 2024
6383554
chore: fix condition for members tab; fix locales
andirueckel Apr 17, 2024
e3b16ba
chore: add more missing locales
andirueckel Apr 17, 2024
45d65af
Merge pull request #164 from medienhaus/explore-conditional-loading
robertschnuell Apr 17, 2024
75ce702
fix: conditionally display table, else no-content notice
andirueckel Apr 17, 2024
02f9ae3
adding default value and remove error
robertschnuell Apr 17, 2024
2e2a882
chore: remove unused locale
andirueckel Apr 17, 2024
e430f3b
chore: return null instead of empty fragment
andirueckel Apr 17, 2024
9dd04e7
Merge pull request #165 from medienhaus/explore-optional-template-wit…
andirueckel Apr 17, 2024
bd015c7
chore: fix eslint errors
andirueckel Apr 17, 2024
cfed0e3
style: fix sizing of icon button loading spinner
andirueckel Apr 17, 2024
23bea27
update config.example.js with localStorage and templates object
andirueckel Apr 18, 2024
309be36
local storage application version control
robertschnuell Apr 18, 2024
f4b7866
chore: try fixing the github eslint runner
andirueckel Apr 18, 2024
07dfd45
chore: fix capitalisation in heading on /dashboard
andirueckel May 28, 2024
af7c7cd
chore: fix spacing between elements on /dashboard
andirueckel May 28, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ yarn-error.log*
# vercel
.vercel

#vs code workspace files
*.code-workspace

# JetBrains IDE related things
Expand Down
2 changes: 1 addition & 1 deletion assets/_globalCss.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
--destructive: 348 78% 50%;
--destructive-foreground: 348 98% 70%;
--border: 0 0% 90%;
--input: 0 0% 90%;
--input: 0 0% 50%;
--ring: 0 0% 0%;

/* color definitions (legacy support) */
Expand Down
185 changes: 185 additions & 0 deletions components/CachedContextMultiLevelSelect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
import React, { useCallback, useEffect, useState } from 'react';
import _ from 'lodash';
import { useTranslation } from 'react-i18next';

import { useAuth } from '@/lib/Auth';
import { useMatrix } from '@/lib/Matrix';
import LoadingSpinnerInline from './UI/LoadingSpinnerInline';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/UI/shadcn/Select';

const CachedContextMultiLevelSelectSingleLevel = ({
parentSpaceRoomId,
selectedContextRoomId,
onSelect,
onFetchedChildren,
templatePlaceholderMapping,
templatePrefixFilter,
sortAlphabetically,
showTopics,
rootId,
}) => {
const auth = useAuth();
const matrixClient = auth.getAuthenticationProvider('matrix').getMatrixClient();
const matrix = useMatrix(auth.getAuthenticationProvider('matrix'));
const [isLoading, setIsLoading] = useState(true);
const [parentSpaceMetaEvent, setParentSpaceMetaEvent] = useState();
const [childContexts, setChildContexts] = useState();
const { t } = useTranslation();

useEffect(() => {
let isSubscribed = true;

// Fetch all child contexts from our storage
const fetchChildContexts = async () => {
let newChildContexts = [];
const spaceCache = (await matrix.spaces.get(parentSpaceRoomId)) || (await matrix.rooms.get(parentSpaceRoomId));
if (!spaceCache) return;
setParentSpaceMetaEvent(spaceCache.meta);

for (const room of spaceCache.children) {
const roomObject = matrix.spaces.get(room) || matrix.rooms.get(room);
// // If this is not a context, ignore this space child
// if (metaEvent && metaEvent.type !== 'context') continue;
// // If we only want to show specific contexts, ignore this space child if its template doesn't have the given prefix
if (templatePrefixFilter && roomObject.meta && !_.startsWith(roomObject.meta.template, templatePrefixFilter)) continue;
// // ... otherwise show this space child:
newChildContexts.push(roomObject);
}

if (sortAlphabetically) {
newChildContexts = _.sortBy(newChildContexts, 'name');
}

if (!isSubscribed) return;
onFetchedChildren(newChildContexts.length > 0);
setChildContexts(newChildContexts);
};

const fetch = async () => {
setIsLoading(true);
await fetchChildContexts();
setIsLoading(false);
};

fetch();

return () => {
isSubscribed = false;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [matrixClient, parentSpaceRoomId, sortAlphabetically, templatePlaceholderMapping, templatePrefixFilter]);

Check failure

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Error

React Hook useEffect has missing dependencies: 'matrix.rooms', 'matrix.spaces', and 'onFetchedChildren'. Either include them or remove the dependency array. If 'onFetchedChildren' changes too often, find the parent component that defines it and wrap that definition in useCallback.

if (isLoading) {
return (
<Select key="loading" disabled>
<SelectTrigger>
<SelectValue placeholder={<LoadingSpinnerInline />} />
</SelectTrigger>
</Select>
);
}

if (!childContexts || childContexts.length < 1) {
return null;
}

return (
<Select
defaultValue={selectedContextRoomId}
onValueChange={(value) => {
onSelect(parentSpaceRoomId, value);
}}
>
<SelectTrigger>
{templatePlaceholderMapping && parentSpaceMetaEvent && templatePlaceholderMapping[parentSpaceMetaEvent.template] ? (
// If we have a template-specific placeholder, show that...
<SelectValue placeholder={templatePlaceholderMapping[parentSpaceMetaEvent.template]} />
) : (
// ... otherwise just show an empty placeholder
<SelectValue placeholder={`-- ${t('select option')} --`} />
)}
</SelectTrigger>
<SelectContent>
{Object.entries(childContexts).map(([key, room]) => {
// if room is undefined we jump to the next one
// this can happen when for example a room was not removed as a space child from its parent but is already deleted
if (!room) return;
const disabled = matrix.spaces.get(rootId).children?.includes(room.roomId);

return (
<SelectItem key={key} disabled={disabled} value={room.roomId}>
{room.name}
{showTopics && room.topic && ` (${room.topic})`}
</SelectItem>
);
})}
</SelectContent>
</Select>
);
};

/**
* This component renders a multi-level <select> UI for an arbitrary set of contexts in the sense of Matrix spaces.
* `activeContexts` is the array of room IDs for the currently set context spaces.
*
* @param {Array} activeContexts
* @param {function} onChange (newActiveContexts, isLeaf)
* @param {boolean} showTopics - If the contents of m.room.topic should be displayed in parentheses next to the name
* @param {boolean} sortAlphabetically - If entries should be ordered alphabetically
* @param {Object} templatePlaceholderMapping - Optional object containing placeholders for each <select> based on the `dev.medienhaus.meta.template` of the parent context
* @param {string} templatePrefixFilter - Optional prefix to filter contexts by their templates
* @param {string} rootId - The root context from where to start fetching room hierarchies
*
* @return {React.ReactElement}
*/
const CachedContextMultiLevelSelect = ({
activeContexts,
onChange,
showTopics,
sortAlphabetically,
templatePlaceholderMapping,
templatePrefixFilter,
rootId,
}) => {
const onSelect = useCallback(
(parentContextRoomId, selectedChildContextRoomId) => {
const newActiveContexts = [
...activeContexts.splice(0, activeContexts.findIndex((contextRoomId) => contextRoomId === parentContextRoomId) + 1),
];
if (selectedChildContextRoomId) newActiveContexts.push(selectedChildContextRoomId);
onChange(newActiveContexts, undefined);
},
[activeContexts, onChange],
);

const onFinishedFetchingChildren = useCallback(
(hasChildren) => {
if (onChange.length > 1) {
onChange(activeContexts, !hasChildren);
}
},
[activeContexts, onChange],
);

return (
<>
{activeContexts &&
activeContexts.map((contextRoomId, i) => (
<CachedContextMultiLevelSelectSingleLevel
key={contextRoomId}
onSelect={onSelect}
onFetchedChildren={onFinishedFetchingChildren}
parentSpaceRoomId={contextRoomId}
selectedContextRoomId={activeContexts[i + 1] ?? ''}
showTopics={showTopics}
sortAlphabetically={sortAlphabetically}
templatePlaceholderMapping={templatePlaceholderMapping}
templatePrefixFilter={templatePrefixFilter}
rootId={rootId}
/>
))}
</>
);
};

export default CachedContextMultiLevelSelect;
18 changes: 13 additions & 5 deletions components/ContextMultiLevelSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';

import { useAuth } from '@/lib/Auth';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/UI/shadcn/Select';
import LoadingSpinnerInline from '@/components/UI/LoadingSpinnerInline';

const ContextMultiLevelSelectSingleLevel = ({
parentSpaceRoomId,
Expand All @@ -14,15 +15,15 @@ const ContextMultiLevelSelectSingleLevel = ({
templatePrefixFilter,
sortAlphabetically,
showTopics,
setSelectedContextName,
}) => {
const { t } = useTranslation();

const auth = useAuth();
const matrix = auth.getAuthenticationProvider('matrix');
const matrixClient = matrix.getMatrixClient();
const [isLoading, setIsLoading] = useState(true);
const [parentSpaceMetaEvent, setParentSpaceMetaEvent] = useState();
const [childContexts, setChildContexts] = useState();
const { t } = useTranslation();

useEffect(() => {
let isSubscribed = true;
Expand All @@ -45,7 +46,10 @@ const ContextMultiLevelSelectSingleLevel = ({
);
if (!roomHierarchy) roomHierarchy = { rooms: [] };

// return name of selected context
setSelectedContextName && setSelectedContextName(roomHierarchy.rooms[0].name);
// Remove the first entry, which is the context we retrieved the children for

roomHierarchy.rooms.shift();

// Ensure we're looking at contexts, and not spaces/rooms of other types
Expand All @@ -54,7 +58,7 @@ const ContextMultiLevelSelectSingleLevel = ({
// If this space/room does not have a meta event we do not care about it
if (!metaEvent) continue;
// If this is not a context, ignore this space child
if (metaEvent && metaEvent.type !== 'context') continue;
// if (metaEvent && metaEvent.type !== 'context') continue;
// If we only want to show specific contexts, ignore this space child if its template doesn't have the given prefix
if (templatePrefixFilter && metaEvent && !_.startsWith(metaEvent.template, templatePrefixFilter)) continue;
// ... otherwise show this space child:
Expand Down Expand Up @@ -90,7 +94,7 @@ const ContextMultiLevelSelectSingleLevel = ({
return (
<Select key="loading" disabled>
<SelectTrigger>
<SelectValue placeholder={t('loading...')} />
<SelectValue placeholder={<LoadingSpinnerInline />} />
</SelectTrigger>
</Select>
);
Expand All @@ -113,7 +117,7 @@ const ContextMultiLevelSelectSingleLevel = ({
<SelectValue placeholder={templatePlaceholderMapping[parentSpaceMetaEvent.template]} />
) : (
// ... otherwise just show an empty placeholder
<SelectValue />
<SelectValue placeholder={`-- ${t('select option')} --`} />
)}
</SelectTrigger>
<SelectContent>
Expand All @@ -138,6 +142,7 @@ const ContextMultiLevelSelectSingleLevel = ({
* @param {boolean} sortAlphabetically - If entries should be ordered alphabetically
* @param {Object} templatePlaceholderMapping - Optional object containing placeholders for each <select> based on the `dev.medienhaus.meta.template` of the parent context
* @param {string} templatePrefixFilter - Optional prefix to filter contexts by their templates
* @param {React.setState} setSelectedContextName- Oprional setter function for parent name
*
* @return {React.ReactNode}
*/
Expand All @@ -148,12 +153,14 @@ const ContextMultiLevelSelect = ({
sortAlphabetically,
templatePlaceholderMapping,
templatePrefixFilter,
setSelectedContextName,
}) => {
const onSelect = useCallback(
(parentContextRoomId, selectedChildContextRoomId) => {
const newActiveContexts = [
...activeContexts.splice(0, activeContexts.findIndex((contextRoomId) => contextRoomId === parentContextRoomId) + 1),
];

if (selectedChildContextRoomId) newActiveContexts.push(selectedChildContextRoomId);
onChange(newActiveContexts, undefined);
},
Expand Down Expand Up @@ -183,6 +190,7 @@ const ContextMultiLevelSelect = ({
sortAlphabetically={sortAlphabetically}
templatePlaceholderMapping={templatePlaceholderMapping}
templatePrefixFilter={templatePrefixFilter}
setSelectedContextName={setSelectedContextName}
/>
))}
</>
Expand Down
22 changes: 4 additions & 18 deletions components/UI/ConfirmCancelButtons.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
import { styled } from 'styled-components';
import { useTranslation } from 'react-i18next';

import { Button } from '@/components/UI/shadcn/Button';

const ConfirmCancelButtonsWrapper = styled.div`
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: var(--margin);
`;

const SmallConfirmCancelButtonsWrapper = styled(ConfirmCancelButtonsWrapper)`
width: fit-content;
`;

const ConfirmCancelButtons = ({ disabled, confirmLabel, cancelLabel, small }) => {
const ConfirmCancelButtons = ({ disabled, confirmLabel, cancelLabel, destructive, disableConfirm }) => {
const { t } = useTranslation();

// We might want to use a special wrapper if we want to use a small version of this component
const Wrapper = small ? SmallConfirmCancelButtonsWrapper : ConfirmCancelButtonsWrapper;

return (
<Wrapper>
<div className="grid grid-cols-2 gap-4">
<Button variant="outline" type="reset" disabled={disabled}>
{cancelLabel || t('Cancel')}
</Button>
<Button type="submit" disabled={disabled}>
<Button type="submit" variant={destructive ? 'destructive' : 'default'} disabled={disabled || disableConfirm}>
{confirmLabel || t('Confirm')}
</Button>
</Wrapper>
</div>
);
};

Expand Down
4 changes: 2 additions & 2 deletions components/UI/CopyToClipboard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { RiCheckLine, RiClipboardLine } from '@remixicon/react';
import _ from 'lodash';

import Icon from './Icon';
import TextButton from './TextButton';
Expand All @@ -12,8 +13,7 @@ const CopyToClipboard = ({ content, title }) => {
const copyToClipboard = async () => {
navigator.clipboard.writeText(content);
setWasContentCopied(true);
await new Promise((r) => setTimeout(r, 2000));
setWasContentCopied(false);
_.delay(() => setWasContentCopied(false), 2500);
};

return (
Expand Down
13 changes: 9 additions & 4 deletions components/UI/DataList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import _ from 'lodash';
import { ServiceTable } from './ServiceTable';
import Form from './Form';
import { Input } from '@/components/UI/shadcn/Input';
import { Button } from '@/components/UI/shadcn/Button';
import ConfirmCancelButtons from '@/components/UI/ConfirmCancelButtons';

/**
* Datalist component that functions as an input with a datalist and supports keyboard navigation and mouse interaction.
Expand Down Expand Up @@ -44,7 +44,7 @@ const TableWrapper = styled.section`
overflow-x: auto;
`;

export default function DataList({ options, onInputChange, keysToDisplay, onSubmit }) {
export default function DataList({ options, onInputChange, keysToDisplay, onSubmit, onCancel }) {
const [value, setValue] = useState('');
const [isOpen, setIsOpen] = useState(false);
const [selectedIndex, setSelectedIndex] = useState(-1);
Expand Down Expand Up @@ -144,7 +144,7 @@ export default function DataList({ options, onInputChange, keysToDisplay, onSubm
};

return (
<InviteUserForm onSubmit={handleSubmit}>
<InviteUserForm onSubmit={handleSubmit} onReset={onCancel}>
<Input
type="text"
value={value}
Expand Down Expand Up @@ -188,7 +188,12 @@ export default function DataList({ options, onInputChange, keysToDisplay, onSubm
</ServiceTable.Body>
</ServiceTable>
</TableWrapper>
<Button disabled={selected.length === 0 && checked.length === 0}>{t('Invite')}</Button>
<ConfirmCancelButtons
onCancel={onCancel}
disableConfirm={selected.length === 0 && checked.length === 0}
cancelLabel="Close"
confirmLabel="Invite"
/>
</InviteUserForm>
);
}
Expand Down
Loading
Loading