-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bootstrap document preview element
- Loading branch information
Showing
36 changed files
with
563 additions
and
28 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
packages/form-js-editor/src/features/properties-panel/entries/DocumentsDataSource.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { get } from 'min-dash'; | ||
|
||
import { useService, useVariables } from '../hooks'; | ||
|
||
import { FeelTemplatingEntry, isFeelEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
export function DocumentsDataSourceEntry(props) { | ||
const { editField, field } = props; | ||
|
||
const entries = []; | ||
|
||
entries.push({ | ||
id: 'dataSource', | ||
component: DocumentsDataSource, | ||
editField: editField, | ||
field: field, | ||
isEdited: isFeelEntryEdited, | ||
isDefaultVisible: (field) => field.type === 'documentPreview', | ||
}); | ||
|
||
return entries; | ||
} | ||
|
||
function DocumentsDataSource(props) { | ||
const { editField, field, id } = props; | ||
|
||
const debounce = useService('debounce'); | ||
|
||
const variables = useVariables().map((name) => ({ name })); | ||
|
||
const path = ['dataSource']; | ||
|
||
const getValue = () => { | ||
return get(field, path, ''); | ||
}; | ||
|
||
const setValue = (value) => { | ||
return editField(field, path, value); | ||
}; | ||
|
||
const schema = `[ | ||
{ | ||
"documentId": "u123", | ||
"metadata": { | ||
"filename": "Document.pdf", | ||
"mimeType": "application/pdf" | ||
} | ||
} | ||
]`; | ||
|
||
const tooltip = ( | ||
<div> | ||
<p>A source is a JSON object containing metadata for a document or an array of documents.</p> | ||
<p>Each entry must include a document ID, name, and MIME type.</p> | ||
<p>Additional details are optional. The expected format is as follows:</p> | ||
<pre> | ||
<code>{schema}</code> | ||
</pre> | ||
</div> | ||
); | ||
|
||
return FeelTemplatingEntry({ | ||
debounce, | ||
element: field, | ||
getValue, | ||
id, | ||
label: 'Documents metadata source', | ||
feel: 'required', | ||
singleLine: true, | ||
setValue, | ||
variables, | ||
tooltip, | ||
}); | ||
} |
79 changes: 79 additions & 0 deletions
79
packages/form-js-editor/src/features/properties-panel/entries/EndpointKey.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { get } from 'min-dash'; | ||
|
||
import { useService, useVariables } from '../hooks'; | ||
|
||
import { FeelTemplatingEntry, isFeelEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
export function EndpointKeyEntry(props) { | ||
const { editField, field } = props; | ||
|
||
const entries = []; | ||
|
||
entries.push({ | ||
id: 'endpointKey', | ||
component: EndpointKey, | ||
editField: editField, | ||
field: field, | ||
isEdited: isFeelEntryEdited, | ||
isDefaultVisible: (field) => field.type === 'documentPreview', | ||
}); | ||
|
||
return entries; | ||
} | ||
|
||
function EndpointKey(props) { | ||
const { editField, field, id } = props; | ||
|
||
const debounce = useService('debounce'); | ||
|
||
const variables = useVariables().map((name) => ({ name })); | ||
|
||
const path = ['endpointKey']; | ||
|
||
const getValue = () => { | ||
return get(field, path, ''); | ||
}; | ||
|
||
const setValue = (value) => { | ||
return editField(field, path, value); | ||
}; | ||
|
||
const tooltip = ( | ||
<div> | ||
<p>A context key that will be evaluated to a string containing the API endpoint for downloading a document.</p> | ||
<p> | ||
This string must contain <br /> | ||
the <code>{'{ documentId }'}</code> placeholder which will be replaced with the document ID from the documents | ||
metadata. | ||
</p> | ||
<p> | ||
If you're using the Camunda Tasklist UI this variable will be automatically injected in the context for you. | ||
</p> | ||
<p> | ||
Find more details in the{' '} | ||
<a href="https://docs.camunda.io" rel="noopener noreferrer" target="_blank"> | ||
Camunda documentation | ||
</a> | ||
. | ||
</p> | ||
</div> | ||
); | ||
|
||
return FeelTemplatingEntry({ | ||
debounce, | ||
element: field, | ||
getValue, | ||
id, | ||
label: 'Document API endpoint key', | ||
feel: 'required', | ||
singleLine: true, | ||
setValue, | ||
variables, | ||
description, | ||
tooltip, | ||
}); | ||
} | ||
|
||
// helpers ////////// | ||
|
||
const description = <>An API endpoint for downloading a document</>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/form-js-editor/src/features/properties-panel/entries/MaxHeightEntry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { get } from 'min-dash'; | ||
|
||
import { useService } from '../hooks'; | ||
|
||
import { NumberFieldEntry, isNumberFieldEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
export function MaxHeightEntry(props) { | ||
const { editField, field } = props; | ||
|
||
const entries = []; | ||
|
||
entries.push({ | ||
id: 'maxHeight', | ||
component: MaxHeight, | ||
editField: editField, | ||
field: field, | ||
isEdited: isNumberFieldEntryEdited, | ||
isDefaultVisible: (field) => field.type === 'documentPreview', | ||
}); | ||
|
||
return entries; | ||
} | ||
|
||
function MaxHeight(props) { | ||
const { editField, field, id } = props; | ||
|
||
const debounce = useService('debounce'); | ||
|
||
const path = ['maxHeight']; | ||
|
||
const getValue = () => { | ||
return get(field, path, ''); | ||
}; | ||
|
||
const setValue = (value) => { | ||
return editField(field, path, value); | ||
}; | ||
|
||
return NumberFieldEntry({ | ||
debounce, | ||
label: 'Max height', | ||
element: field, | ||
id, | ||
getValue, | ||
setValue, | ||
validate, | ||
}); | ||
} | ||
|
||
// helpers ////////// | ||
|
||
/** | ||
* @param {string|number|undefined} value | ||
* @returns {string|null} | ||
*/ | ||
const validate = (value) => { | ||
if (value === undefined || value === '') { | ||
return null; | ||
} | ||
|
||
if (typeof value === 'string') { | ||
return 'Value must be a number.'; | ||
} | ||
|
||
if (!Number.isInteger(value)) { | ||
return 'Should be an integer.'; | ||
} | ||
|
||
if (value < 1) { | ||
return 'Should be greater than zero.'; | ||
} | ||
}; |
51 changes: 51 additions & 0 deletions
51
packages/form-js-editor/src/features/properties-panel/entries/TitleEntry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { get } from 'min-dash'; | ||
|
||
import { useService, useVariables } from '../hooks'; | ||
|
||
import { FeelTemplatingEntry, isFeelEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
export function TitleEntry(props) { | ||
const { editField, field } = props; | ||
|
||
const entries = []; | ||
|
||
entries.push({ | ||
id: 'title', | ||
component: Title, | ||
editField: editField, | ||
field: field, | ||
isEdited: isFeelEntryEdited, | ||
isDefaultVisible: (field) => field.type === 'documentPreview', | ||
}); | ||
|
||
return entries; | ||
} | ||
|
||
function Title(props) { | ||
const { editField, field, id } = props; | ||
|
||
const debounce = useService('debounce'); | ||
|
||
const variables = useVariables().map((name) => ({ name })); | ||
|
||
const path = ['title']; | ||
|
||
const getValue = () => { | ||
return get(field, path, ''); | ||
}; | ||
|
||
const setValue = (value) => { | ||
return editField(field, path, value); | ||
}; | ||
|
||
return FeelTemplatingEntry({ | ||
debounce, | ||
element: field, | ||
getValue, | ||
id, | ||
label: 'Title', | ||
singleLine: true, | ||
setValue, | ||
variables, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/form-js-editor/src/features/properties-panel/groups/AppearanceGroup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.