diff --git a/package.json b/package.json index d884ea4..243ad66 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "typescript": "~4.5.5" }, "dependencies": { - "@atlassian/forge-graphql": "13.0.6", + "@atlassian/forge-graphql": "13.3.0", "@forge/api": "^2.8.1", "@forge/bridge": "^2.3.0", "@forge/events": "^0.5.3", diff --git a/src/utils/format-custom-fields-to-yaml.ts b/src/utils/format-custom-fields-to-yaml.ts index 8da8639..81e1796 100644 --- a/src/utils/format-custom-fields-to-yaml.ts +++ b/src/utils/format-custom-fields-to-yaml.ts @@ -3,6 +3,8 @@ import { CompassCustomNumberField, CompassCustomTextField, CompassCustomUserField, + CompassCustomSingleSelectField, + CompassCustomMultiSelectField, CustomField, CustomFieldFromYAML, CustomFieldType, @@ -20,6 +22,15 @@ export const isCompassCustomBooleanField = (customField: CustomField): customFie export const isCompassCustomUserField = (customField: CustomField): customField is CompassCustomUserField => (customField as CompassCustomUserField).userIdValue !== undefined; +export const isCompassCustomSingleSelectField = ( + customField: CustomField, +): customField is CompassCustomSingleSelectField => + (customField as CompassCustomSingleSelectField).option !== undefined; + +export const isCompassCustomMultiSelectField = ( + customField: CustomField, +): customField is CompassCustomMultiSelectField => (customField as CompassCustomMultiSelectField).options !== undefined; + export const formatCustomFieldsToYamlFormat = ( customFieldsInComponent: CustomField[], ): CustomFieldFromYAML[] | null => { @@ -58,6 +69,18 @@ export const formatCustomFieldsToYamlFormat = ( return [mappedCustomFieldToYamlFormat]; } + if (isCompassCustomSingleSelectField(customField)) { + mappedCustomFieldToYamlFormat.type = CustomFieldType.SINGLE_SELECT; + mappedCustomFieldToYamlFormat.value = customField?.option?.id || null; + return [mappedCustomFieldToYamlFormat]; + } + + if (isCompassCustomMultiSelectField(customField)) { + mappedCustomFieldToYamlFormat.type = CustomFieldType.MULTI_SELECT; + mappedCustomFieldToYamlFormat.value = customField?.options?.map((option) => option.id) || null; + return [mappedCustomFieldToYamlFormat]; + } + // Future types added here will return an empty array which the flatmap // will remove resulting in no code being shown in the yaml file and no // errors being thrown diff --git a/yarn.lock b/yarn.lock index 41224da..3baaa64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20,15 +20,16 @@ call-me-maybe "^1.0.1" js-yaml "^4.1.0" -"@atlassian/forge-graphql@13.0.6": - version "13.0.6" - resolved "https://packages.atlassian.com/api/npm/atlassian-npm/@atlassian/forge-graphql/-/forge-graphql-13.0.6.tgz#0f0d69dfaf513f8451558362223d6f00985e57f9" - integrity sha512-yZjEdOY0DTXuXx/XwM64SEvZLiVdqhQTprWUFYMwksmn4L/xPFoclggoxo5o3n3xkJtfzVogxqxITUMt0kDtPw== +"@atlassian/forge-graphql@13.3.0": + version "13.3.0" + resolved "https://packages.atlassian.com/api/npm/atlassian-npm/@atlassian/forge-graphql/-/forge-graphql-13.3.0.tgz#4711ec64e86739eb31ddb6b7472fb9a3dc449b41" + integrity sha512-Z9ZFD/PAfCexEfSYEMAM+Z9X0kocp5sgHcvvcrKcxf7uCMXwFPzagWcWt0q0PF2xoqprq/PQ2TIPSI0oDugXbA== dependencies: "@forge/api" "^2.3.0" axios "^0.21.1" fs "^0.0.1-security" js-yaml "^4.1.0" + lodash "^4.17.21" path "^0.12.7" url-parse "^1.5.10"