Skip to content

Commit

Permalink
Merge pull request #2623 from glific/feature/flow-error
Browse files Browse the repository at this point in the history
Added flow import error change key change
mdshamoon authored Nov 17, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 57930d5 + bd1ab9e commit de101ca
Showing 3 changed files with 52 additions and 33 deletions.
4 changes: 4 additions & 0 deletions src/containers/Flow/FlowList/FlowList.module.css
Original file line number Diff line number Diff line change
@@ -166,3 +166,7 @@
.RadioLabel {
margin-right: 24px;
}

.ImportDialog {
max-width: 395px;
}
74 changes: 45 additions & 29 deletions src/containers/Flow/FlowList/FlowList.tsx
Original file line number Diff line number Diff line change
@@ -17,10 +17,10 @@ import { ImportButton } from 'components/UI/ImportButton/ImportButton';
import Loading from 'components/UI/Layout/Loading/Loading';
import { DATE_TIME_FORMAT } from 'common/constants';
import { exportFlowMethod, organizationHasDynamicRole } from 'common/utils';
import { setNotification } from 'common/notification';
import styles from './FlowList.module.css';
import { GET_TAGS } from 'graphql/queries/Tags';
import { AutoComplete } from 'components/UI/Form/AutoComplete/AutoComplete';
import { DialogBox } from 'components/UI/DialogBox/DialogBox';

const getName = (text: string, keywordsList: any, roles: any) => {
const keywords = keywordsList.map((keyword: any) => keyword);
@@ -82,6 +82,7 @@ export const FlowList = () => {
const [selectedtag, setSelectedTag] = useState<any>(null);
const [flowName, setFlowName] = useState('');
const [importing, setImporting] = useState(false);
const [importStatus, setImportStatus] = useState([]);

const [releaseFlow] = useLazyQuery(RELEASE_FLOW);

@@ -91,17 +92,8 @@ export const FlowList = () => {

const [importFlow] = useMutation(IMPORT_FLOW, {
onCompleted: (result: any) => {
const { success } = result.importFlow;
if (!success) {
setNotification(
t(
'Sorry! An error occurred! This could happen if the flow is already present or error in the import file.'
),
'error'
);
} else {
setNotification(t('The flow has been imported successfully.'));
}
const { status } = result.importFlow;
setImportStatus(status);
setImporting(false);
},
});
@@ -122,6 +114,27 @@ export const FlowList = () => {
setFlowName(item.name);
exportFlowMutation({ variables: { id } });
};
let dialog;

if (importStatus.length > 0) {
dialog = (
<DialogBox
title="Import flow Status"
buttonOk="Okay"
alignButtons="center"
handleOk={() => setImportStatus([])}
skipCancel
>
<div className={styles.ImportDialog}>
{importStatus.map((status: any) => (
<div key={status.flowName}>
<strong>{status.flowName}:</strong> {status.status}
</div>
))}
</div>
</DialogBox>
);
}

const importButton = (
<ImportButton
@@ -262,23 +275,26 @@ export const FlowList = () => {
}

return (
<List
title={t('Flows')}
listItem="flows"
listItemName="flow"
pageLink="flow"
listIcon={flowIcon}
dialogMessage={dialogMessage}
{...queries}
{...columnAttributes}
searchParameter={['name_or_keyword_or_tags']}
additionalAction={additionalAction}
button={{ show: true, label: t('Create Flow'), symbol: '+' }}
secondaryButton={importButton}
filters={filters}
filterList={activeFilter}
filterDropdowm={tagFilter}
/>
<>
{dialog}
<List
title={t('Flows')}
listItem="flows"
listItemName="flow"
pageLink="flow"
listIcon={flowIcon}
dialogMessage={dialogMessage}
{...queries}
{...columnAttributes}
searchParameter={['name_or_keyword_or_tags']}
additionalAction={additionalAction}
button={{ show: true, label: t('Create Flow'), symbol: '+' }}
secondaryButton={importButton}
filters={filters}
filterList={activeFilter}
filterDropdowm={tagFilter}
/>
</>
);
};

7 changes: 3 additions & 4 deletions src/graphql/mutations/Flow.ts
Original file line number Diff line number Diff line change
@@ -107,10 +107,9 @@ export const CREATE_FLOW_COPY = gql`
export const IMPORT_FLOW = gql`
mutation importFlow($flow: Json!) {
importFlow(flow: $flow) {
success
errors {
key
message
status {
flowName
status
}
}
}

0 comments on commit de101ca

Please sign in to comment.