Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMPASS-14931 bumping forge version for single/multi select #59

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 23 additions & 0 deletions src/utils/format-custom-fields-to-yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
CompassCustomNumberField,
CompassCustomTextField,
CompassCustomUserField,
CompassCustomSingleSelectField,
CompassCustomMultiSelectField,
CustomField,
CustomFieldFromYAML,
CustomFieldType,
Expand All @@ -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 => {
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Loading