mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-11 19:56:44 +00:00
fix workflow
This commit is contained in:
parent
e0f59e4754
commit
2808db2683
12 changed files with 123 additions and 116 deletions
|
|
@ -10,7 +10,7 @@ import { VeryLightGrey } from 'Common/Types/BrandColors';
|
|||
|
||||
export enum ModalWidth {
|
||||
Normal,
|
||||
Large
|
||||
Large,
|
||||
}
|
||||
|
||||
export interface ComponentProps {
|
||||
|
|
@ -28,7 +28,7 @@ export interface ComponentProps {
|
|||
isBodyLoading?: boolean | undefined;
|
||||
icon?: IconProp | undefined;
|
||||
iconType?: IconType | undefined;
|
||||
modalWidth?: ModalWidth | undefined
|
||||
modalWidth?: ModalWidth | undefined;
|
||||
}
|
||||
|
||||
const Modal: FunctionComponent<ComponentProps> = (
|
||||
|
|
@ -57,7 +57,14 @@ const Modal: FunctionComponent<ComponentProps> = (
|
|||
|
||||
<div className="fixed inset-0 z-10 overflow-y-auto">
|
||||
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
|
||||
<div className={`relative transform rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full ${props.modalWidth && props.modalWidth === ModalWidth.Large ? "sm:max-w-7xl" : "sm:max-w-lg"} `}>
|
||||
<div
|
||||
className={`relative transform rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full ${
|
||||
props.modalWidth &&
|
||||
props.modalWidth === ModalWidth.Large
|
||||
? 'sm:max-w-7xl'
|
||||
: 'sm:max-w-lg'
|
||||
} `}
|
||||
>
|
||||
{props.onClose && (
|
||||
<div className="absolute top-0 right-0 hidden pt-4 pr-4 sm:block">
|
||||
<Button
|
||||
|
|
@ -91,8 +98,9 @@ const Modal: FunctionComponent<ComponentProps> = (
|
|||
)}
|
||||
<div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:mr-4 sm:text-left">
|
||||
<h3
|
||||
className={`text-lg font-medium leading-6 text-gray-900 ${props.icon ? 'ml-10 -mt-8 mb-5' : ''
|
||||
}`}
|
||||
className={`text-lg font-medium leading-6 text-gray-900 ${
|
||||
props.icon ? 'ml-10 -mt-8 mb-5' : ''
|
||||
}`}
|
||||
id="modal-title"
|
||||
>
|
||||
{props.title}
|
||||
|
|
|
|||
|
|
@ -64,14 +64,14 @@ export enum ShowTableAs {
|
|||
}
|
||||
|
||||
export interface ComponentProps<TBaseModel extends BaseModel> {
|
||||
modelType: { new(): TBaseModel };
|
||||
modelType: { new (): TBaseModel };
|
||||
id: string;
|
||||
onFetchInit?:
|
||||
| undefined
|
||||
| ((pageNumber: number, itemsOnPage: number) => void);
|
||||
| undefined
|
||||
| ((pageNumber: number, itemsOnPage: number) => void);
|
||||
onFetchSuccess?:
|
||||
| undefined
|
||||
| ((data: Array<TBaseModel>, totalCount: number) => void);
|
||||
| undefined
|
||||
| ((data: Array<TBaseModel>, totalCount: number) => void);
|
||||
cardProps?: CardComponentProps | undefined;
|
||||
columns: Columns<TBaseModel>;
|
||||
selectMoreFields?: Select<TBaseModel>;
|
||||
|
|
@ -203,8 +203,8 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
alignItem: column.alignItem,
|
||||
getElement: column.getElement
|
||||
? (item: JSONObject): ReactElement => {
|
||||
return column.getElement!(item, onBeforeFetchData);
|
||||
}
|
||||
return column.getElement!(item, onBeforeFetchData);
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
try {
|
||||
setErrorModalText(
|
||||
(err as HTTPErrorResponse).message ||
|
||||
'Server Error. Please try again'
|
||||
'Server Error. Please try again'
|
||||
);
|
||||
} catch (e) {
|
||||
setErrorModalText('Server Error. Please try again');
|
||||
|
|
@ -349,7 +349,7 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
try {
|
||||
setTableFilterError(
|
||||
(err as HTTPErrorResponse).message ||
|
||||
'Server Error. Please try again'
|
||||
'Server Error. Please try again'
|
||||
);
|
||||
} catch (e) {
|
||||
setTableFilterError('Server Error. Please try again');
|
||||
|
|
@ -385,8 +385,8 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
getSelect(),
|
||||
sortBy
|
||||
? {
|
||||
[sortBy as any]: sortOrder,
|
||||
}
|
||||
[sortBy as any]: sortOrder,
|
||||
}
|
||||
: {},
|
||||
getPopulate(),
|
||||
props.fetchRequestOptions
|
||||
|
|
@ -398,7 +398,7 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
try {
|
||||
setError(
|
||||
(err as HTTPErrorResponse).message ||
|
||||
'Server Error. Please try again'
|
||||
'Server Error. Please try again'
|
||||
);
|
||||
} catch (e) {
|
||||
setError('Server Error. Please try again');
|
||||
|
|
@ -511,8 +511,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
showTableAs !== ShowTableAs.OrderedStatesList
|
||||
) {
|
||||
headerbuttons.push({
|
||||
title: `${props.createVerb || 'Create'} ${props.singularName || model.singularName
|
||||
}`,
|
||||
title: `${props.createVerb || 'Create'} ${
|
||||
props.singularName || model.singularName
|
||||
}`,
|
||||
buttonStyle: ButtonStyleType.NORMAL,
|
||||
className:
|
||||
props.showFilterButton || props.showRefreshButton
|
||||
|
|
@ -730,9 +731,13 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
|
||||
if (
|
||||
(permissions &&
|
||||
((props.isDeleteable && model.hasDeletePermissions(permissions)) ||
|
||||
(props.isEditable && model.hasUpdatePermissions(permissions)) ||
|
||||
(props.isViewable && model.hasReadPermissions(permissions)))) || (props.actionButtons && props.actionButtons.length > 0)
|
||||
((props.isDeleteable &&
|
||||
model.hasDeletePermissions(permissions)) ||
|
||||
(props.isEditable &&
|
||||
model.hasUpdatePermissions(permissions)) ||
|
||||
(props.isViewable &&
|
||||
model.hasReadPermissions(permissions)))) ||
|
||||
(props.actionButtons && props.actionButtons.length > 0)
|
||||
) {
|
||||
columns.push({
|
||||
title: 'Actions',
|
||||
|
|
@ -999,9 +1004,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
|
||||
let getTitleElement:
|
||||
| ((
|
||||
item: JSONObject,
|
||||
onBeforeFetchData?: JSONObject | undefined
|
||||
) => ReactElement)
|
||||
item: JSONObject,
|
||||
onBeforeFetchData?: JSONObject | undefined
|
||||
) => ReactElement)
|
||||
| undefined = undefined;
|
||||
let getDescriptionElement:
|
||||
| ((item: JSONObject) => ReactElement)
|
||||
|
|
@ -1045,10 +1050,10 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
onCreateNewItem={
|
||||
props.isCreateable
|
||||
? (order: number) => {
|
||||
setOrderedStatesListNewItemOrder(order);
|
||||
setModalType(ModalType.Create);
|
||||
setShowModal(true);
|
||||
}
|
||||
setOrderedStatesListNewItemOrder(order);
|
||||
setModalType(ModalType.Create);
|
||||
setShowModal(true);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
singularLabel={
|
||||
|
|
@ -1113,8 +1118,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
}}
|
||||
>
|
||||
<Pill
|
||||
text={`${new props.modelType().readBillingPlan
|
||||
} Plan`}
|
||||
text={`${
|
||||
new props.modelType().readBillingPlan
|
||||
} Plan`}
|
||||
color={Yellow}
|
||||
/>
|
||||
</span>
|
||||
|
|
@ -1188,16 +1194,19 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
<ModelFormModal<TBaseModel>
|
||||
title={
|
||||
modalType === ModalType.Create
|
||||
? `${props.createVerb || 'Create'} New ${props.singularName || model.singularName
|
||||
}`
|
||||
? `${props.createVerb || 'Create'} New ${
|
||||
props.singularName || model.singularName
|
||||
}`
|
||||
: `Edit ${props.singularName || model.singularName}`
|
||||
}
|
||||
name={
|
||||
modalType === ModalType.Create
|
||||
? `${props.name} > ${props.createVerb || 'Create'
|
||||
} New ${props.singularName || model.singularName}`
|
||||
: `${props.name} > Edit ${props.singularName || model.singularName
|
||||
}`
|
||||
? `${props.name} > ${
|
||||
props.createVerb || 'Create'
|
||||
} New ${props.singularName || model.singularName}`
|
||||
: `${props.name} > Edit ${
|
||||
props.singularName || model.singularName
|
||||
}`
|
||||
}
|
||||
initialValues={
|
||||
modalType === ModalType.Create
|
||||
|
|
@ -1209,8 +1218,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
|||
}}
|
||||
submitButtonText={
|
||||
modalType === ModalType.Create
|
||||
? `${props.createVerb || 'Create'} ${props.singularName || model.singularName
|
||||
}`
|
||||
? `${props.createVerb || 'Create'} ${
|
||||
props.singularName || model.singularName
|
||||
}`
|
||||
: `Save Changes`
|
||||
}
|
||||
onSuccess={async (item: TBaseModel) => {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ const TableRow: FunctionComponent<ComponentProps> = (
|
|||
props.item[column.key] ? (
|
||||
OneUptimeDate.getDateAsLocalFormattedString(
|
||||
props.item[
|
||||
column.key
|
||||
column.key
|
||||
] as string,
|
||||
true
|
||||
)
|
||||
|
|
@ -90,11 +90,11 @@ const TableRow: FunctionComponent<ComponentProps> = (
|
|||
''
|
||||
)
|
||||
) : column.type ===
|
||||
FieldType.DateTime ? (
|
||||
FieldType.DateTime ? (
|
||||
props.item[column.key] ? (
|
||||
OneUptimeDate.getDateAsLocalFormattedString(
|
||||
props.item[
|
||||
column.key
|
||||
column.key
|
||||
] as string,
|
||||
false
|
||||
)
|
||||
|
|
@ -102,7 +102,7 @@ const TableRow: FunctionComponent<ComponentProps> = (
|
|||
''
|
||||
)
|
||||
) : column.type ===
|
||||
FieldType.Boolean ? (
|
||||
FieldType.Boolean ? (
|
||||
props.item[column.key] ? (
|
||||
<Icon
|
||||
icon={IconProp.Check}
|
||||
|
|
@ -183,7 +183,7 @@ const TableRow: FunctionComponent<ComponentProps> = (
|
|||
}
|
||||
isLoading={
|
||||
isButtonLoading[
|
||||
i
|
||||
i
|
||||
]
|
||||
}
|
||||
onClick={() => {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ const WorkflowElement: FunctionComponent<ComponentProps> = (
|
|||
const projectId: string | undefined = props.workflow.projectId
|
||||
? props.workflow.projectId.toString()
|
||||
: props.workflow.project
|
||||
? props.workflow.project._id
|
||||
: '';
|
||||
? props.workflow.project._id
|
||||
: '';
|
||||
return (
|
||||
<Link
|
||||
onNavigateComplete={props.onNavigateComplete}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@ import Modal, { ModalWidth } from 'CommonUI/src/Components/Modal/Modal';
|
|||
const Workflows: FunctionComponent<PageComponentProps> = (
|
||||
_props: PageComponentProps
|
||||
): ReactElement => {
|
||||
|
||||
|
||||
|
||||
const [showViewLogsModal, setShowViewLogsModal] = useState<boolean>(false);
|
||||
const [logs, setLogs] = useState<string>('');
|
||||
|
||||
|
|
@ -65,8 +62,7 @@ const Workflows: FunctionComponent<PageComponentProps> = (
|
|||
item: JSONObject,
|
||||
onCompleteAction: Function
|
||||
) => {
|
||||
|
||||
setLogs((item['logs'] as string));
|
||||
setLogs(item['logs'] as string);
|
||||
setShowViewLogsModal(true);
|
||||
|
||||
onCompleteAction();
|
||||
|
|
@ -78,7 +74,7 @@ const Workflows: FunctionComponent<PageComponentProps> = (
|
|||
name="Workflow Logs"
|
||||
isViewable={false}
|
||||
selectMoreFields={{
|
||||
logs: true
|
||||
logs: true,
|
||||
}}
|
||||
cardProps={{
|
||||
icon: IconProp.Logs,
|
||||
|
|
@ -107,7 +103,9 @@ const Workflows: FunctionComponent<PageComponentProps> = (
|
|||
<WorkflowElement
|
||||
workflow={
|
||||
JSONFunctions.fromJSON(
|
||||
(item['workflow'] as JSONObject) || [],
|
||||
(item[
|
||||
'workflow'
|
||||
] as JSONObject) || [],
|
||||
Workflow
|
||||
) as Workflow
|
||||
}
|
||||
|
|
@ -126,29 +124,25 @@ const Workflows: FunctionComponent<PageComponentProps> = (
|
|||
]}
|
||||
/>
|
||||
|
||||
{showViewLogsModal && <Modal
|
||||
title={'Workflow Logs'}
|
||||
description="Here are the logs for this workflow"
|
||||
isLoading={false}
|
||||
modalWidth={ModalWidth.Large}
|
||||
onSubmit={() => {
|
||||
setShowViewLogsModal(false);
|
||||
}}
|
||||
|
||||
submitButtonText={
|
||||
'Close'
|
||||
}
|
||||
submitButtonStyleType={
|
||||
ButtonStyleType.NORMAL
|
||||
}
|
||||
>
|
||||
<div className="text-gray-500 mt-5 text-sm h-96 overflow-scroll overflow-x-hidden p-5 border-gray-50 border border-2 bg-gray-100 rounded">
|
||||
{logs}
|
||||
</div>
|
||||
</Modal>}
|
||||
|
||||
{showViewLogsModal && (
|
||||
<Modal
|
||||
title={'Workflow Logs'}
|
||||
description="Here are the logs for this workflow"
|
||||
isLoading={false}
|
||||
modalWidth={ModalWidth.Large}
|
||||
onSubmit={() => {
|
||||
setShowViewLogsModal(false);
|
||||
}}
|
||||
submitButtonText={'Close'}
|
||||
submitButtonStyleType={ButtonStyleType.NORMAL}
|
||||
>
|
||||
<div className="text-gray-500 mt-5 text-sm h-96 overflow-scroll overflow-x-hidden p-5 border-gray-50 border border-2 bg-gray-100 rounded">
|
||||
{logs}
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
</>
|
||||
</Page >
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -96,8 +96,7 @@ const Workflows: FunctionComponent<PageComponentProps> = (
|
|||
content: true,
|
||||
},
|
||||
title: 'Content',
|
||||
description:
|
||||
'Enter the content of the variable',
|
||||
description: 'Enter the content of the variable',
|
||||
fieldType: FormFieldSchemaType.LongText,
|
||||
required: true,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ const Delete: FunctionComponent<PageComponentProps> = (
|
|||
isEnabled: true,
|
||||
},
|
||||
title: 'Enabled',
|
||||
fieldType: FormFieldSchemaType.Checkbox
|
||||
fieldType: FormFieldSchemaType.Checkbox,
|
||||
},
|
||||
]}
|
||||
modelDetailProps={{
|
||||
|
|
@ -120,7 +120,7 @@ const Delete: FunctionComponent<PageComponentProps> = (
|
|||
isEnabled: true,
|
||||
},
|
||||
title: 'Enabled',
|
||||
fieldType: FieldType.Boolean
|
||||
fieldType: FieldType.Boolean,
|
||||
},
|
||||
],
|
||||
modelId: modelId,
|
||||
|
|
|
|||
|
|
@ -24,12 +24,9 @@ const Delete: FunctionComponent<PageComponentProps> = (
|
|||
): ReactElement => {
|
||||
const modelId: ObjectID = Navigation.getLastParamAsObjectID(1);
|
||||
|
||||
|
||||
|
||||
const [showViewLogsModal, setShowViewLogsModal] = useState<boolean>(false);
|
||||
const [logs, setLogs] = useState<string>('');
|
||||
|
||||
|
||||
return (
|
||||
<Page
|
||||
title={'Workflow'}
|
||||
|
|
@ -75,10 +72,11 @@ const Delete: FunctionComponent<PageComponentProps> = (
|
|||
name="Workflow Logs"
|
||||
query={{
|
||||
workflowId: modelId,
|
||||
projectId: DashboardNavigation.getProjectId()?.toString(),
|
||||
projectId:
|
||||
DashboardNavigation.getProjectId()?.toString(),
|
||||
}}
|
||||
selectMoreFields={{
|
||||
logs: true
|
||||
logs: true,
|
||||
}}
|
||||
actionButtons={[
|
||||
{
|
||||
|
|
@ -89,8 +87,7 @@ const Delete: FunctionComponent<PageComponentProps> = (
|
|||
item: JSONObject,
|
||||
onCompleteAction: Function
|
||||
) => {
|
||||
|
||||
setLogs((item['logs'] as string));
|
||||
setLogs(item['logs'] as string);
|
||||
setShowViewLogsModal(true);
|
||||
|
||||
onCompleteAction();
|
||||
|
|
@ -125,7 +122,9 @@ const Delete: FunctionComponent<PageComponentProps> = (
|
|||
<WorkflowElement
|
||||
workflow={
|
||||
JSONFunctions.fromJSON(
|
||||
(item['workflow'] as JSONObject) || [],
|
||||
(item[
|
||||
'workflow'
|
||||
] as JSONObject) || [],
|
||||
Workflow
|
||||
) as Workflow
|
||||
}
|
||||
|
|
@ -144,28 +143,24 @@ const Delete: FunctionComponent<PageComponentProps> = (
|
|||
]}
|
||||
/>
|
||||
|
||||
{showViewLogsModal && <Modal
|
||||
title={'Workflow Logs'}
|
||||
description="Here are the logs for this workflow"
|
||||
isLoading={false}
|
||||
modalWidth={ModalWidth.Large}
|
||||
onSubmit={() => {
|
||||
setShowViewLogsModal(false);
|
||||
}}
|
||||
|
||||
submitButtonText={
|
||||
'Close'
|
||||
}
|
||||
submitButtonStyleType={
|
||||
ButtonStyleType.NORMAL
|
||||
}
|
||||
>
|
||||
<div className="text-gray-500 mt-5 text-sm h-96 overflow-scroll overflow-x-hidden p-5 border-gray-50 border border-2 bg-gray-100 rounded">
|
||||
{logs}
|
||||
</div>
|
||||
</Modal>}
|
||||
{showViewLogsModal && (
|
||||
<Modal
|
||||
title={'Workflow Logs'}
|
||||
description="Here are the logs for this workflow"
|
||||
isLoading={false}
|
||||
modalWidth={ModalWidth.Large}
|
||||
onSubmit={() => {
|
||||
setShowViewLogsModal(false);
|
||||
}}
|
||||
submitButtonText={'Close'}
|
||||
submitButtonStyleType={ButtonStyleType.NORMAL}
|
||||
>
|
||||
<div className="text-gray-500 mt-5 text-sm h-96 overflow-scroll overflow-x-hidden p-5 border-gray-50 border border-2 bg-gray-100 rounded">
|
||||
{logs}
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
</>
|
||||
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -114,8 +114,7 @@ const Workflows: FunctionComponent<PageComponentProps> = (
|
|||
content: true,
|
||||
},
|
||||
title: 'Content',
|
||||
description:
|
||||
'Enter the content of the variable',
|
||||
description: 'Enter the content of the variable',
|
||||
fieldType: FormFieldSchemaType.LongText,
|
||||
required: true,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ const Workflows: FunctionComponent<PageComponentProps> = (
|
|||
isEnabled: true,
|
||||
},
|
||||
title: 'Enabled',
|
||||
fieldType: FormFieldSchemaType.Checkbox
|
||||
fieldType: FormFieldSchemaType.Checkbox,
|
||||
},
|
||||
]}
|
||||
showRefreshButton={true}
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ export class RouteUtil {
|
|||
if (
|
||||
route.toString() === RouteMap[PageMap.USER_PROFILE]?.toString() ||
|
||||
route.toString() ===
|
||||
RouteMap[PageMap.PROJECT_INVITATIONS]?.toString() ||
|
||||
RouteMap[PageMap.PROJECT_INVITATIONS]?.toString() ||
|
||||
route.toString() === RouteMap[PageMap.ACTIVE_INCIDENTS]?.toString()
|
||||
) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -246,10 +246,12 @@ export default class WorkflowVariable extends BaseModel {
|
|||
Permission.ProjectAdmin,
|
||||
Permission.CanCreateWorkflowVariable,
|
||||
],
|
||||
read: [Permission.ProjectOwner,
|
||||
Permission.ProjectAdmin,
|
||||
Permission.ProjectMember,
|
||||
Permission.CanReadWorkflowVariable],
|
||||
read: [
|
||||
Permission.ProjectOwner,
|
||||
Permission.ProjectAdmin,
|
||||
Permission.ProjectMember,
|
||||
Permission.CanReadWorkflowVariable,
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({ required: true, type: TableColumnType.Boolean })
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue