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

treaty: add desk permissions check #215

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 17 additions & 1 deletion desk/app/treaty.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
=/ =treaty (treaty-from-docket:cc desk docket)
=. sovereign (~(put by sovereign) desk treaty)
:_ this
?^ vips.treaty
[warp give]:so
[publish warp give]:so
::
%del
Expand Down Expand Up @@ -271,7 +273,21 @@
|= [=desk =docket:docket]
=+ .^(=cass:clay %cw (scry:io desk /desk/docket))
=+ .^(hash=@uv %cz (scry:io desk ~))
[our.bowl desk da+da.cass hash docket]
=- [our.bowl desk - da+da.cass hash docket]
=, clay
=/ perms .^([r=dict w=dict] %cp (scry:io desk /))
=/ =_who:*real who.rul.r.perms
=+ mod=mod.rul.r.perms
?: ?=(%black mod) ~
=- ?~ - (sy ~[our.bowl]) -
^- crew
=; crews
?~ ships=p.who crews
(~(uni in `crew`ships) crews)
^- crew
%+ roll ~(val by q.who)
|= [=crew all=crew]
(~(uni in all) crew)
:: +al: Side effects for allies
++ al
|_ =ship
Expand Down
8 changes: 8 additions & 0 deletions desk/lib/treaty.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@
%- pairs
:~ ship+s+(scot %p ship.t)
desk+s+desk.t
vips+(vips `crew:clay`vips.t)
cass+(case case.t)
hash+s+(scot %uv hash.t)
==
++ vips
|= v=crew:clay
:- %a
%+ turn ~(tap in v)
|= =^ship
^- json
s+(scot %p ship)
::
++ case
|= c=^case
Expand Down
2 changes: 1 addition & 1 deletion desk/sur/treaty.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:: Includes the docket itself, plus provenance generated by clay
::
+$ treaty
[=ship =desk =case hash=@uv =docket:docket]
[=ship =desk vips=crew:clay =case hash=@uv =docket:docket]
ryjm marked this conversation as resolved.
Show resolved Hide resolved
::
:: $update:treaty: Diff of treaty state
::
Expand Down
20 changes: 14 additions & 6 deletions ui/src/components/AppInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const AppInfo: FC<AppInfoProps> = ({
}, [publisher, desk]);

const installing = installStatus === 'installing';
const buttonText = treaty?.vips && treaty.vips.includes(window.ship) ? 'VIP' : 'Get App';

if (!docket) {
// TODO: maybe replace spinner with skeletons
Expand All @@ -103,12 +104,21 @@ export const AppInfo: FC<AppInfoProps> = ({
href={getAppHref(docket.href)}
target="_blank"
rel="noreferrer"
onClick={() => addRecentApp(docket.desk)}
>
onClick={() => addRecentApp(docket.desk)}>
Open App
</PillButton>
)}
{installStatus !== 'installed' && (
{(treaty?.vips && treaty?.vips.length > 0) && (
<PillButton
variant="secondary"
as="a"
href={getAppHref(docket.href)}
target="_blank"
rel="noreferrer">
Not Listed
</PillButton>
) ||
installStatus !== 'installed' && (
<Dialog.Root>
<DialogTrigger asChild>
<PillButton variant="alt-primary" disabled={installing}>
Expand All @@ -117,9 +127,7 @@ export const AppInfo: FC<AppInfoProps> = ({
<Spinner />
<span className="sr-only">Installing...</span>
</>
) : (
'Get App'
)}
) : buttonText}
</PillButton>
</DialogTrigger>
<Dialog.Portal>
Expand Down
1 change: 1 addition & 0 deletions ui/src/gear/docket/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface SuspendChad {
export interface Treaty extends Docket {
ship: string;
desk: string;
vips: [ship: string];
cass: Cass;
hash: string;
}
Expand Down