Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ynput/ayon-frontend into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
martastain committed Dec 13, 2023
2 parents cb619a6 + 1b45159 commit 877ad02
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/components/ApiKeyManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useUpdateUserAPIKeyMutation } from '../services/user/updateUser'
import { toast } from 'react-toastify'
import styled from 'styled-components'
import confirmDelete from '../helpers/confirmDelete'
import copyToClipboard from '../helpers/copyToClipboard'

const PanelStyled = styled(Panel)`
flex-direction: row;
Expand Down Expand Up @@ -76,8 +77,7 @@ const ApiKeyManager = ({ preview, name }) => {
}

const handleCopyKey = () => {
navigator.clipboard.writeText(newKey.key)
toast.success('API Key Copied')
copyToClipboard(newKey.key)
}

if (preview || newKey?.key)
Expand Down
4 changes: 1 addition & 3 deletions src/components/ShareDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { closeShare } from '../features/context'
import { Button } from '@ynput/ayon-react-components'
import copyToClipboard from '../helpers/copyToClipboard'
import { TabView, TabPanel } from 'primereact/tabview'
import { toast } from 'react-toastify'
import { Dialog } from 'primereact/dialog'

const ShareStyled = styled.div`
Expand Down Expand Up @@ -73,8 +72,7 @@ const ShareDialog = () => {
const copyImage = async (img) => {
const blob = await convertToBlob(img)
// copies image to clipboard
navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })])
toast.info('Image copied to clipboard')
copyToClipboard([new ClipboardItem({ [blob.type]: blob })])
}

const string = JSON.stringify(data, null, 2).replace(/"/g, '').replace(/{|}/g, '').slice(1, -1)
Expand Down
8 changes: 3 additions & 5 deletions src/containers/AddonSettings/AddonSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,13 @@ const AddonSettings = ({ projectName, showSites = false }) => {
}

const onPasteValue = async (addon, siteId, path) => {
const text = await navigator.clipboard.readText()
let value
try {
value = JSON.parse(text)
const text = await navigator.clipboard.readText()
const value = JSON.parse(text)
pushValueToPath(addon, siteId, path, value)
} catch (e) {
toast.error('Cannot paste, invalid clipboard contents')
return
}
pushValueToPath(addon, siteId, path, value)
} // paste

const onPushToProduction = async () => {
Expand Down
5 changes: 2 additions & 3 deletions src/containers/Breadcrumbs/Breadcrumbs.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useEffect, useState, useRef } from 'react'
import { useSelector } from 'react-redux'
import { useLocation } from 'react-router-dom'
import { toast } from 'react-toastify'
import { Button, InputText } from '@ynput/ayon-react-components'
import * as Styled from './Breadcrumbs.styled'

import { upperFirst } from 'lodash'
import useUriNavigate from '/src/hooks/useUriNavigate'
import copyToClipboard from '/src/helpers/copyToClipboard'

const uri2crumbs = (uri = '', pathname) => {
// parse uri to path and query params
Expand Down Expand Up @@ -104,8 +104,7 @@ const Breadcrumbs = () => {
}

const onCopy = () => {
navigator.clipboard.writeText(localUri)
toast.success('Copied to clipboard')
copyToClipboard(localUri)
}

const handleKeyDown = (e) => {
Expand Down
10 changes: 2 additions & 8 deletions src/containers/RawSettingsDialog/RawSettingsDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
useSetRawAddonSettingsOverridesMutation,
useLazyGetRawAddonSettingsOverridesQuery,
} from '/src/services/addonSettings'
import copyToClipboard from '/src/helpers/copyToClipboard'

const EditorWrapper = styled.div`
position: relative;
Expand Down Expand Up @@ -124,14 +125,7 @@ const RawSettingsDialog = ({

const footer = (
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'flex-end' }}>
<Button
label="Copy"
icon="content_copy"
onClick={() => {
navigator.clipboard.writeText(code)
toast.success('Copied to clipboard')
}}
/>
<Button label="Copy" icon="content_copy" onClick={() => copyToClipboard(code)} />
<SaveButton label="Save" icon="save" active={!warn} onClick={onSave} />
</div>
)
Expand Down
12 changes: 3 additions & 9 deletions src/containers/SettingsEditor/fields.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMemo } from 'react'
import { toast } from 'react-toastify'
import { Button, Divider } from '@ynput/ayon-react-components'
import ReactMarkdown from 'react-markdown'
import SettingsPanel from './SettingsPanel'
Expand All @@ -8,6 +7,7 @@ import useCreateContext from '/src/hooks/useCreateContext'

import { isEqual } from 'lodash'
import { Badge, BadgeWrapper } from '/src/components/Badge'
import copyToClipboard from '/src/helpers/copyToClipboard'

const FormArrayField = styled.div`
flex-grow: 1;
Expand Down Expand Up @@ -177,10 +177,7 @@ function ObjectFieldTemplate(props) {
const contextMenuItems = [
{
label: 'Copy',
command: () => {
navigator.clipboard.writeText(JSON.stringify(props.formData, null, 2))
toast.success('Copied to clipboard')
},
command: () => copyToClipboard(JSON.stringify(props.formData, null, 2)),
},
{
label: 'Paste',
Expand Down Expand Up @@ -336,10 +333,7 @@ function FieldTemplate(props) {
{
label: 'Copy value',
disabled: !props.formContext.onCopyValue,
command: () => {
navigator.clipboard.writeText(JSON.stringify(props.formData, null, 2))
toast.success('Copied to clipboard')
},
command: () => copyToClipboard(JSON.stringify(props.formData, null, 2)),
},
{
label: 'Paste value',
Expand Down

0 comments on commit 877ad02

Please sign in to comment.