🏡 index : ~doyle/chartered.git

author Jordan Doyle <jordan@doyle.la> 2022-09-17 3:56:25.0 +01:00:00
committer Jordan Doyle <jordan@doyle.la> 2022-09-17 3:56:25.0 +01:00:00
commit
94633dbc97ab9597b77a4db7f10a15cbde7a0c9d [patch]
tree
ace55f5573044897291298a44cb4aa2c819971f7
parent
927620d7e9031e272e94ad113aaddc73dd1e3f16
download
94633dbc97ab9597b77a4db7f10a15cbde7a0c9d.tar.gz

Add visual indicator that an organisation is public



Diff

 chartered-frontend/src/types/organisations.ts                             |  2 ++
 chartered-web/src/endpoints/web_api/organisations/info.rs                 |  2 ++
 chartered-web/src/endpoints/web_api/organisations/list.rs                 |  2 ++
 chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.svelte | 11 +++++++++++
 chartered-frontend/src/routes/(authed)/organisations/list/+page.svelte    | 10 ++++++++++
 5 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/chartered-frontend/src/types/organisations.ts b/chartered-frontend/src/types/organisations.ts
index 2c9ff78..9a3bc91 100644
--- a/chartered-frontend/src/types/organisations.ts
+++ a/chartered-frontend/src/types/organisations.ts
@@ -5,11 +5,13 @@
export interface OrganisationListItem {
    name: string;
    description: string;
    public: boolean;
}

export interface OrganisationDetail {
    description: string;
    crates: OrganisationCrate[];
    public: boolean;
}

export interface OrganisationCrate {
diff --git a/chartered-web/src/endpoints/web_api/organisations/info.rs b/chartered-web/src/endpoints/web_api/organisations/info.rs
index 828557f..af2fdac 100644
--- a/chartered-web/src/endpoints/web_api/organisations/info.rs
+++ a/chartered-web/src/endpoints/web_api/organisations/info.rs
@@ -51,6 +51,7 @@
                permissions: can_manage_users.then(|| perms),
            })
            .collect(),
        public: organisation.organisation().public,
    }))
}

@@ -61,6 +62,7 @@
    implied_permissions: Option<&'static [[UserPermission; 2]]>,
    crates: Vec<ResponseCrate>,
    members: Vec<ResponseUser>,
    public: bool,
}

#[derive(Serialize)]
diff --git a/chartered-web/src/endpoints/web_api/organisations/list.rs b/chartered-web/src/endpoints/web_api/organisations/list.rs
index ddc0922..df3f54d 100644
--- a/chartered-web/src/endpoints/web_api/organisations/list.rs
+++ a/chartered-web/src/endpoints/web_api/organisations/list.rs
@@ -19,6 +19,7 @@
            .map(|v| ResponseOrganisation {
                name: v.name,
                description: v.description,
                public: v.public,
            })
            .collect(),
    }))
@@ -33,6 +34,7 @@
pub struct ResponseOrganisation {
    name: String,
    description: String,
    public: bool,
}

#[derive(Error, Debug)]
diff --git a/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.svelte b/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.svelte
index 9ae9ab6..8882946 100644
--- a/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.svelte
+++ a/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.svelte
@@ -91,8 +91,15 @@
<header>
    <div class="container flex flex-col md:flex-row items-center md:items-start mx-auto p-10 mb-3">
        <div class="flex-grow text-center md:text-left">
            <h1 class="text-5xl text-highlight font-bold tracking-tight">
                {$page.params.organisation}
            <h1 class="text-5xl text-highlight font-bold tracking-tight inline-flex">
                <span class="mr-2">{$page.params.organisation}</span>
                {#await organisationPromise then organisation}
                    {#if organisation.public}
                        <span title="Public organisation">
                            <Icon name="users" />
                        </span>
                    {/if}
                {/await}
            </h1>

            <h2>
diff --git a/chartered-frontend/src/routes/(authed)/organisations/list/+page.svelte b/chartered-frontend/src/routes/(authed)/organisations/list/+page.svelte
index 41484f9..98e058b 100644
--- a/chartered-frontend/src/routes/(authed)/organisations/list/+page.svelte
+++ a/chartered-frontend/src/routes/(authed)/organisations/list/+page.svelte
@@ -1,7 +1,8 @@
<script type="typescript">
    import { request } from '../../../../stores/auth';
    import type { OrganisationList } from '../../../../types/organisations';
    import ErrorAlert from '../../../../components/ErrorAlert.svelte';
    import Icon from '../../../../components/Icon.svelte';

    // fetch a list of all the current user's organisations from the backend
    const organisationsPromise = request<OrganisationList>('/web/v1/organisations');
@@ -57,7 +58,14 @@
            {#each organisations.organisations as organisation}
                <a class="card flex space-x-2 items-center" href={`/crates/${organisation.name}`}>
                    <div class="flex-grow h-full">
                        <h5 class="text-highlight card-header">{organisation.name}</h5>
                        <h5 class="text-highlight card-header inline-flex items-center">
                            <span class="mr-2">{organisation.name}</span>
                            {#if organisation.public}
                                <span title="Public organisation">
                                    <Icon name="users" />
                                </span>
                            {/if}
                        </h5>
                        <p class="card-body">
                            {#if organisation.description}
                                {organisation.description}