diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 198f6a07d..b642aede3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/cache@v1 + - uses: actions/cache@v4 with: path: ~/.cache/yarn key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} @@ -31,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/cache@v1 + - uses: actions/cache with: path: ~/.cache/yarn key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 71e3cfb9c..c8a43d221 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -8,7 +8,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/cache@v1 + - uses: actions/cache@v4 # Updated from v1 to v4 with: path: ~/.cache/yarn key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} @@ -42,7 +42,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/cache@v1 + - uses: actions/cache@v4 # Updated from v1 to v4 with: path: ~/.cache/yarn key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/apps/sensenet/src/components/context-menu/use-context-menu-actions.ts b/apps/sensenet/src/components/context-menu/use-context-menu-actions.ts index af986b361..b1fd98c7d 100644 --- a/apps/sensenet/src/components/context-menu/use-context-menu-actions.ts +++ b/apps/sensenet/src/components/context-menu/use-context-menu-actions.ts @@ -196,8 +196,19 @@ export function useContextMenuActions( }, }) break + /*Az az új hozzáállás, hogy ha nem találja meg az action-t akkor jöjjön be az operation kezelő. + Ezt majd le kell!! cserélni úgy, hogy vizsgálva legyen a Type-ja*/ default: - logger.warning({ message: `${actionName} is not implemented yet. Try to use it from command palette.` }) + openDialog({ + name: 'operation', + props: { + content, + OperationName: actionName, + }, + dialogProps: { classes: { paper: globalClasses.pickerDialog } }, + }) + break + // logger.warning({ message: `${actionName} is not implemented yet. Try to use it from command palette.` }) } } diff --git a/apps/sensenet/src/components/dialogs/dialog-provider.tsx b/apps/sensenet/src/components/dialogs/dialog-provider.tsx index f9fe8ecc5..c5419cc20 100644 --- a/apps/sensenet/src/components/dialogs/dialog-provider.tsx +++ b/apps/sensenet/src/components/dialogs/dialog-provider.tsx @@ -13,6 +13,7 @@ import { DateRangePickerProps, DeleteContentDialogProps, ExecuteActionDialogProps, + OperationsDialogProps, PermissionEditorDialogProps, ReferenceContentListProps, RestoreProps, @@ -24,6 +25,7 @@ export type DialogWithProps = ( | { name: 'delete'; props: DeleteContentDialogProps } | { name: 'error'; props: ErrorBoundaryState } | { name: 'copy-move'; props: CopyMoveDialogProps } + | { name: 'operation'; props: OperationsDialogProps } | { name: 'check-in'; props: CheckInProps } | { name: 'are-you-sure'; props: AreYouSureProps } | { name: 'approve'; props: ApproveProps } diff --git a/apps/sensenet/src/components/dialogs/dialogs.tsx b/apps/sensenet/src/components/dialogs/dialogs.tsx index 013d47ed7..9f388c3e5 100644 --- a/apps/sensenet/src/components/dialogs/dialogs.tsx +++ b/apps/sensenet/src/components/dialogs/dialogs.tsx @@ -24,6 +24,7 @@ const ChangePasswordDialog = lazy(() => import('./change-password')) const DateRangePicker = lazy(() => import('./date-range-picker')) const AddDeleteUserGroups = lazy(() => import('./add-delete-user-groups')) const ColumnSettings = lazy(() => import('./column-settings')) +const Operations = lazy(() => import('./operations')) function dialogRenderer(dialog: DialogWithProps) { switch (dialog.name) { @@ -69,6 +70,8 @@ function dialogRenderer(dialog: DialogWithProps) { return case 'column-settings': return + case 'operation': + return default: return null } diff --git a/apps/sensenet/src/components/dialogs/index.ts b/apps/sensenet/src/components/dialogs/index.ts index 45fcd91bb..c4e89b06a 100644 --- a/apps/sensenet/src/components/dialogs/index.ts +++ b/apps/sensenet/src/components/dialogs/index.ts @@ -19,3 +19,4 @@ export * from './restore' export * from './save-query' export * from './add-delete-user-groups' export * from './column-settings' +export * from './operations' diff --git a/apps/sensenet/src/components/dialogs/operations.tsx b/apps/sensenet/src/components/dialogs/operations.tsx new file mode 100644 index 000000000..bc2bbc103 --- /dev/null +++ b/apps/sensenet/src/components/dialogs/operations.tsx @@ -0,0 +1,166 @@ +import { Button, createStyles, DialogActions, DialogContent, makeStyles, TextField } from '@material-ui/core' +import { GenericContent } from '@sensenet/default-content-types' +import { useLogger, useRepository } from '@sensenet/hooks-react' +import React, { useEffect, useRef, useState } from 'react' +import { useCurrentUser } from '../../context' +import { useGlobalStyles } from '../../globalStyles' +import { useLocalization } from '../../hooks' +import { Icon } from '../Icon' +import { DialogTitle, useDialog } from '.' + +export interface OperationsDialogProps { + content: GenericContent + OperationName: string +} +/*Ezt itt jól ki kell dolgozni!!! nem végleges csak demora van egyszerűsítve + Valószínüleg nem is itt lesz a végleges helye hanem ott ahol a GenericContent van +*/ +type UIDescription = { + title?: string + submitTitle?: string + elements: Array<{ + name?: string + description?: string + inputProps: React.HTMLProps + }> +} +const useStyles = makeStyles(() => + createStyles({ + form: { + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + rowGap: '30px', + '& :is(h3,p)': { + margin: '0 0', + fontWeight: 'normal', + }, + '& input': { + padding: '0', + }, + '& .input-container': { + width: '300px', + }, + }, + }), +) + +export function OperationsDialog(props: OperationsDialogProps) { + const { closeLastDialog } = useDialog() + const currentUser = useCurrentUser() + const classes = useStyles() + const logger = useLogger('Operations') + const formRef = useRef(null) + const repository = useRepository() + const localization = useLocalization().operations + const globalClasses = useGlobalStyles() + + const [UIDescription, setUIDescription] = useState() + + useEffect(() => { + console.log(props.OperationName) + const loadOperation = async () => { + try { + const result = await repository.executeAction({ + method: 'GET', + idOrPath: props.content.Path, + name: props.OperationName, + }) + setUIDescription(result) + } catch (error) { + logger.error({ message: error.message }) + } + } + + loadOperation() + }, [logger, props.OperationName, props.content.Path, repository]) + + const submitAction = async (e: React.FormEvent) => { + e.preventDefault() + if (!formRef.current) return + + const formData = new FormData(formRef.current) + const formJson: Record = {} + + formData.forEach((value, key) => { + formJson[key] = value + }) + + try { + await repository.executeAction({ + method: 'POST', + idOrPath: props.content.Path, + name: props.OperationName, + body: formJson, + }) + + logger.information({ message: localization.success }) + + closeLastDialog() + } catch (error) { + logger.error({ message: error.message }) + } + } + + return ( + <> + + + + {UIDescription?.title || localization.title} + + + <> + + { + submitAction(e) + }}> + {UIDescription?.elements.map((field, index) => { + const { inputProps, description, name } = field + + return ( + + {name} + {description} + + + + ) + })} + + + + + {localization.cancel} + + + {UIDescription?.submitTitle || localization.submit} + + + > + > + ) +} + +export default OperationsDialog diff --git a/apps/sensenet/src/localization/default.ts b/apps/sensenet/src/localization/default.ts index c29788a22..4c617d16e 100644 --- a/apps/sensenet/src/localization/default.ts +++ b/apps/sensenet/src/localization/default.ts @@ -685,6 +685,12 @@ const values = { trash: 'Trash', '/Root/ContentTemplates': 'Content Templates', }, + operations: { + title: 'Action Framkework Demo', + submit: 'Upload', + cancel: 'Cancel', + success: 'Succesfull Operation!', + }, } export default values
{description}