Commit 603e51c1 authored by Fran Garcia-Linares's avatar Fran Garcia-Linares Committed by Chris Wells
Browse files

Issue #3279983 by chrisfromredfin, fjgarlin, Libbna: Clean up Unused Svelte Components

parent 6775cc88
Loading
Loading
Loading
Loading
+0 −0

File changed.

Preview suppressed by a .gitattributes entry or the file's encoding is unsupported.

+0 −40
Original line number Diff line number Diff line
<script>
    export let changed;

    function timeDifference(current, previous) {
        var msPerMinute = 60 * 1000;
        var msPerHour = msPerMinute * 60;
        var msPerDay = msPerHour * 24;
        var msPerMonth = msPerDay * 30;
        var msPerYear = msPerDay * 365;

        var elapsed = current - previous;

        if (elapsed < msPerMinute) {
            return Math.round(elapsed/1000) + ' seconds ago';
        }

        else if (elapsed < msPerHour) {
            return Math.round(elapsed/msPerMinute) + ' minutes ago';
        }

        else if (elapsed < msPerDay ) {
            return Math.round(elapsed/msPerHour ) + ' hours ago';
        }

        else if (elapsed < msPerMonth) {
            return 'approximately ' + Math.round(elapsed/msPerDay) + ' days ago';
        }

        else if (elapsed < msPerYear) {
            return 'approximately ' + Math.round(elapsed/msPerMonth) + ' months ago';
        }

        else {
            return 'approximately ' + Math.round(elapsed/msPerYear ) + ' years ago';
        }
    }
</script>
<div class="latest-release">
    Updated {changed}
</div>
+0 −60
Original line number Diff line number Diff line
<script>
    export let project_name;
    let releases = [];
    let project_is_compatible = false;

    function getContent(xmlObj, tagName) {
        return xmlObj.getElementsByTagName(tagName)[0].textContent
    }

    async function fetchReleases(project_name) {
        let releases;
        const response = await fetch(drupalSettings.project_browser.origin_url + "/drupal-org-proxy/project/releases?project=" + project_name);
        if (response.ok) {
            releases = await response.json();
            releases = releases.filter(filterCompatibleReleases);
            console.log(releases);
            return releases;

        } else {
            return [];
        }
    }

    function filterCompatibleReleases(release) {
        if (release.is_compatible && release.hasOwnProperty('version')) {
            project_is_compatible = true;
            return true;
        }
        return false;
    }
</script>
<style>
    .compatible {
        color: green;
    }
    .not-compatible {
        color: red;
    }
    a {
        text-decoration: none;
    }
</style>
<div class="compatibility">
    {#if project_is_compatible}
        <span class="compatible"><span class="check">&#x2714;</span> Compatible with your Drupal installation</span>
    {:else if project_is_compatible === false}
        <span class="not-compatible">Not compatible with your Drupal installation.</span>
    {/if}
</div>
<div class="releases">
    {#await fetchReleases(project_name)}
        <span>Loading...</span>
    {:then releases}
        {#if releases.length}
            <span>Latest release: <a href="{releases[0].release_link}" target="_blank" rel="noreferrer">{releases[0].version}</a> ({releases[0].date_ago})</span>
        {/if}
    {:catch error}
        <span style="color: red">{error.message}</span>
    {/await}
</div>
+0 −32
Original line number Diff line number Diff line
<script>
    import { fetchEntity } from "./project.js";
    export let field_supporting_organizations;
</script>

<style>
    .supporting-organizations {
        font-style: italic;
    }
    .organization a {
        text-decoration: none;
    }
</style>
{#if typeof field_supporting_organizations !== "undefined" && field_supporting_organizations.length}
    <div class="supporting-organizations">
        <span>with support from</span>
        {#each field_supporting_organizations || [] as field_collection}
            {#await fetchEntity(field_collection.uri)}
            {:then item}
                {#await fetchEntity(item.field_supporting_organization.uri)}
                {:then organization}
                    <span class="organization"><a href="{organization.url}" target="_blank" rel="noreferrer">{organization.title}</a>{#if field_supporting_organizations[field_supporting_organizations.length - 1].id !== field_collection.id},{/if}</span>
                {:catch error}
                    <span style="color: red">{error.message}</span>
                {/await}
            {:catch error}
                <span style="color: red">{error.message}</span>
            {/await}
        {/each}
    </div>
{/if}
+0 −22
Original line number Diff line number Diff line
<script>
    import { fetchEntity } from "./project.js";
    export let taxonomy_term_reference;
    export let wrapper_class;
</script>
<style>
    span {
        cursor: pointer;
    }
</style>
{#if taxonomy_term_reference}
    <div class="{wrapper_class}">
        {#await fetchEntity(`https://www.drupal.org/api-d7/taxonomy_term/${taxonomy_term_reference.id}`)}
            <span>Loading...</span>
        {:then term}
            <span title="{term.description.replace(/(<([^>]+)>)/gi, '')}">{term.name}</span>
        {:catch error}
            <span style="color: red">{error.message}</span>
        {/await}
    </div>
{/if}
Loading