Commit 2f48dead authored by Marek Veselý's avatar Marek Veselý
Browse files

Merge branch '734-chore-new-version-of-backend-v3-21-0' into 'main'

Resolve "Chore: New version of Backend - v3.21.0"

Closes #734

See merge request inject/frontend!644
parents 23a5bf3b 914d2ca0
Loading
Loading
Loading
Loading
Compare aebac181 to c8449e30
Original line number Diff line number Diff line
Subproject commit aebac181798e5fa1b501784a8d8aaf38a8eba71b
Subproject commit c8449e302163102f761b54f65255200bb9642dac
+1 −1
Original line number Diff line number Diff line
{
  "name": "@inject/codegen",
  "version": "3.20.0",
  "version": "3.21.0",
  "description": "GraphQL API Codegen Setup for the Inject Backend",
  "main": "index.js",
  "license": "MIT",
+1 −1
Original line number Diff line number Diff line
{
  "name": "@inject/frontend",
  "version": "3.20.0",
  "version": "3.21.0",
  "description": "Main wrapper for rendering INJECT Frontend",
  "main": "index.js",
  "license": "MIT",
+37 −2
Original line number Diff line number Diff line
import { Button, ButtonGroup, Classes } from '@blueprintjs/core'
import { css } from '@emotion/css'
import type { Definition } from '@inject/graphql'
import { DeleteDefinition, useTypedMutation } from '@inject/graphql'
import { LinkButton } from '@inject/shared'
import { DeleteDefinition, useHost, useTypedMutation } from '@inject/graphql'
import {
  authenticatedFetch,
  downloadDefinitionUrl,
  LinkButton,
  notify,
} from '@inject/shared'
import type { FC } from 'react'
import { useState } from 'react'
import ConfirmAlert from '../../exercisepanel/ConfirmAlert'
@@ -27,12 +32,35 @@ interface DefinitionButtonsProps {

const DefinitionButtons: FC<DefinitionButtonsProps> = ({ definition }) => {
  const [alertOpen, setAlertOpen] = useState(false)
  const [donwloadLoading, setDonwloadLoading] = useState(false)
  const host = useHost()

  const { id: definitionId } = definition

  const [{ fetching: loading }, deleteDefinition] =
    useTypedMutation(DeleteDefinition)

  const onDownload = () => {
    setDonwloadLoading(true)

    authenticatedFetch(downloadDefinitionUrl(host, definition.id))
      .then(response => response.blob())
      .then(blob => {
        console.log(blob)
        const url = window.URL.createObjectURL(blob)
        const a = document.createElement('a')
        a.href = url
        a.download = `${definition.name}.zip`
        a.click()
      })
      .catch(error =>
        notify(error.message, JSON.stringify(error), { intent: 'danger' })
      )
      .finally(() => {
        setDonwloadLoading(false)
      })
  }

  return (
    <>
      <ButtonGroup className={buttonGroup}>
@@ -43,6 +71,13 @@ const DefinitionButtons: FC<DefinitionButtonsProps> = ({ definition }) => {
          }}
          button={{ icon: 'people', fill: true, title: 'Access' }}
        />
        <Button
          icon='download'
          fill
          title='Download'
          loading={donwloadLoading}
          onClick={onDownload}
        />
        <Button
          type='button'
          active={alertOpen}
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ const DefinitionList: FC<DefinitionListProps> = ({ className }) => {
      {
        id: 'actions',
        name: 'Actions',
        style: { textAlign: 'right', width: '12ch' },
        style: { textAlign: 'right', width: '16ch' },
        renderValue: definition => (
          <span>
            <DefinitionButtons definition={definition} />
Loading