-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) O3-2006 Adds ability to launch workspace from form
- Loading branch information
Showing
7 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
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
15 changes: 15 additions & 0 deletions
15
src/components/inputs/workspace-launcher/workspace-launcher.scss
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,15 @@ | ||
@use '@carbon/colors'; | ||
|
||
.label { | ||
font-weight: 600; | ||
color: colors.$black-100; | ||
} | ||
|
||
.errorLabel label { | ||
color: colors.$red-60; | ||
font-weight: 600; | ||
} | ||
|
||
.workspaceButton { | ||
margin: 1rem 0; | ||
} |
37 changes: 37 additions & 0 deletions
37
src/components/inputs/workspace-launcher/workspace-launcher.tsx
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,37 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { OHRIFormFieldProps } from '../../../api/types'; | ||
import styles from './workspace-launcher.scss'; | ||
import { Button } from '@carbon/react'; | ||
import { useLaunchWorkspaceRequiringVisit } from '@openmrs/esm-patient-common-lib/src/useLaunchWorkspaceRequiringVisit'; | ||
import { showSnackbar } from '@openmrs/esm-framework'; | ||
|
||
const WorkspaceLauncher: React.FC<OHRIFormFieldProps> = ({ question, handler, onChange }) => { | ||
const { t } = useTranslation(); | ||
|
||
const launchWorkspace = useLaunchWorkspaceRequiringVisit(question.questionOptions?.workspaceName); | ||
|
||
const handleLaunchWorkspace = () => { | ||
if (!launchWorkspace) { | ||
showSnackbar({ | ||
title: t('invalidWorkspaceName', 'Invalid worksapce name.'), | ||
subtitle: t('invalidWorkspaceNameSubtitle', 'Please provide a valid workspace name.'), | ||
kind: 'error', | ||
isLowContrast: true, | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div className={styles.label}>{question.label}</div> | ||
<div className={styles.workspaceButton}> | ||
<Button onClick={handleLaunchWorkspace}> | ||
{question.questionOptions?.workspaceName ?? t('launchWorkspace')} | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default WorkspaceLauncher; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
declare module '@carbon/react'; | ||
declare module '*.css'; | ||
declare module '*.scss'; | ||
declare type SideNavProps = {}; |
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