Skip to content

Commit

Permalink
Board rename
Browse files Browse the repository at this point in the history
  • Loading branch information
bioshazard committed Sep 25, 2023
1 parent a759528 commit b5a65ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 38 deletions.
21 changes: 17 additions & 4 deletions src/components/Board.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,16 @@ export default function Board(props) {
.update({ timer }).eq('id', board_id).select().single()
}

const boardTitleUpdate = async (event) => {
event.preventDefault()
const newTitle = event.target.title.value
await supabase.from('boards')
.update({ title: newTitle })
.eq('id', board_id)
event.target.title.blur()
// Let the realtime sub pick up the change...
}

const timerStop = async () => {
const { data, error } = await supabase.from('boards')
.update({ timer: new Date() }).eq('id', board_id)
Expand Down Expand Up @@ -496,13 +506,16 @@ export default function Board(props) {
<FontAwesomeIcon icon={faEraser} /> Clear My Votes
</button>
<button className="px-2 border" onClick={() => setVoteClearModalOpen(true)}>
<FontAwesomeIcon icon={faBomb} /> Clear All Votes
<FontAwesomeIcon icon={faBomb} /> Clear All Votes
</button>
<button className="px-2 border" title="Unsubscribe from board" onClick={unsubBoard}>
<FontAwesomeIcon className="text-yellow-400" icon={faStar} /> Unsub
</button>
</div>
<h1 className='text-2xl'>
<Link to="/"></Link> / <form className="inline">
<input type="text" defaultValue={board.title} size={board.title.length} className="w-fit inline" />
</form> <button title="Unsubscribe from board" onClick={unsubBoard}><FontAwesomeIcon className="text-yellow-400" icon={faStar} /></button>
<Link to="/"></Link> / <form className="inline" onSubmit={boardTitleUpdate}>
<input name="title" type="text" defaultValue={board.title} size={board.title.length} className="w-fit inline" />
</form>
</h1>
<div className="clear-both"></div>
</div>
Expand Down
43 changes: 9 additions & 34 deletions supabase/migrations/20230908132538_psuedonyms.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-- JWT testing
create or replace function get_jwt()
returns text as $$
begin
return auth.jwt();
end;
$$ language plpgsql security definer;
-- -- JWT testing
-- create or replace function get_jwt()
-- returns text as $$
-- begin
-- return auth.jwt();
-- end;
-- $$ language plpgsql security definer;

-- # Tables Definitions

Expand Down Expand Up @@ -117,34 +117,9 @@ on cards for all using (
)
);





-- alter table board_subs enable row level security;

-- create policy "Board Subs: INSERT must match JWT"
-- on board_subs
-- using (
-- auth.jwt() ->> 'psuedonym' in (
-- select persistanon from psuedonyms where profileid = id
-- )
-- );

-- alter table board_subs enable row level security;

-- create policy "Self Manage Board Subs"
-- on board_subs
-- using (
-- current_setting('request.headers')::json ->> 'persistanon' in (
-- select persistanon from profiles where profileid = id
-- )
-- );



-- Add realtime replication
alter publication supabase_realtime
add table boards, cards, votes;

-- TODO: Do I need `with check` on UPDATEs? Yep...
-- TODO: Do I need `with check` on UPDATEs?
-- Otherwise one could do arbitrary updates?

0 comments on commit b5a65ac

Please sign in to comment.