Skip to content

Commit

Permalink
components retrieval successful
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshmi2506 committed Jan 29, 2024
1 parent f2dfddb commit 490726c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 22 deletions.
6 changes: 0 additions & 6 deletions docs/api/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2591,18 +2591,12 @@ components:
total_unsaved_changes:
type: integer
readOnly: true
total_metadatatype_changes:
type: integer
readOnly: true
has_unsaved_changes:
type: boolean
readOnly: true
has_metadatatype_changes:
type: boolean
readOnly: true
currently_retrieving_nonsource:
type: boolean
readOnly: true
ignored_changes:
type: object
additionalProperties: {}
Expand Down
10 changes: 7 additions & 3 deletions metecho/api/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def get_unsaved_changes(scratch_org, *, originating_user_id):
)()
scratch_org.metadatatype_changes= {}
for types in components:
scratch_org.metadatatype_changes[types]=[types+"alpha"]
scratch_org.metadatatype_changes[types]=[]
except Exception as e:
scratch_org.refresh_from_db()
scratch_org.finalize_get_unsaved_changes(
Expand All @@ -653,15 +653,15 @@ def get_nonsource_components(*,scratch_org,desiredType,originating_user_id):
components=ListComponents(
org_config=org_config,
project_config=project_config,
task_config=TaskConfig({"options":{"metadata_type":desiredType}}),
task_config=TaskConfig({"options":{"metadata_types":desiredType}}),
)()

scratch_org.metadatatype_changes[desiredType]=[cmp["MemberName"] for cmp in components]
except Exception as e:
scratch_org.refresh_from_db()

else:
scratch_org.finalize_get_unsaved_changes(
scratch_org.finalize_get_nonsource_components(
originating_user_id=originating_user_id
)

Expand Down Expand Up @@ -712,6 +712,10 @@ def commit_changes_from_org(
latest_revision_numbers = get_latest_revision_numbers(
scratch_org, originating_user_id=originating_user_id
)
member_types= list(desired_changes.keys())
for member_type in member_types:
if member_type in scratch_org.metadatatype_changes:
del desired_changes[member_type]
for member_type in desired_changes.keys():
for member_name in desired_changes[member_type]:
try:
Expand Down
1 change: 0 additions & 1 deletion metecho/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,6 @@ class ScratchOrg(
latest_revision_numbers = models.JSONField(
default=dict, encoder=DjangoJSONEncoder, blank=True
)
currently_retrieving_nonsource= models.BooleanField(default=False)
currently_refreshing_changes = models.BooleanField(default=False)
currently_retrieving_metadata = models.BooleanField(default=False)
currently_parsing_datasets = models.BooleanField(default=False)
Expand Down
7 changes: 0 additions & 7 deletions metecho/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,6 @@ class ScratchOrgSerializer(HashIdModelSerializer):
has_unsaved_changes = serializers.SerializerMethodField()
metadatatype_changes = serializers.SerializerMethodField()
has_metadatatype_changes = serializers.SerializerMethodField()
total_metadatatype_changes = serializers.SerializerMethodField()
total_unsaved_changes = serializers.SerializerMethodField()
ignored_changes = serializers.SerializerMethodField()
has_ignored_changes = serializers.SerializerMethodField()
Expand Down Expand Up @@ -1054,8 +1053,6 @@ class Meta:
"is_omnistudio_installed",
"metadatatype_changes",
"has_metadatatype_changes",
"total_metadatatype_changes",
"currently_retrieving_nonsource"
)
extra_kwargs = {
"last_modified_at": {"read_only": True},
Expand All @@ -1066,7 +1063,6 @@ class Meta:
"last_checked_unsaved_changes_at": {"read_only": True},
"url": {"read_only": True},
"currently_refreshing_changes": {"read_only": True},
"currently_retrieving_nonsource": {"read_only": True},
"currently_retrieving_metadata": {"read_only": True},
"currently_refreshing_org": {"read_only": True},
"currently_reassigning_user": {"read_only": True},
Expand Down Expand Up @@ -1100,9 +1096,6 @@ def get_unsaved_changes(self, obj) -> dict:
def get_metadatatype_changes(self,obj) -> dict:
return self._X_changes(obj, "metadatatype")

def get_total_metadatatype_changes(self,obj) ->int:
return self._total_X_changes(obj, "metadatatype")

def get_has_unsaved_changes(self, obj) -> bool:
return self._has_X_changes(obj, "unsaved")

Expand Down
2 changes: 1 addition & 1 deletion src/js/components/tasks/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const TaskDetail = (
orgHasChanges =
(devOrg?.total_unsaved_changes || 0) -
(devOrg?.total_ignored_changes || 0) >
0;
0 || (devOrg?.has_metadatatype_changes)==true;
userIsDevOwner = Boolean(
userIsAssignedDev && devOrg?.is_created && devOrg?.owner === user.id,
);
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/tasks/retrieveMetadata/changes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const ChangesForm = ({

// Check if there is a match and get the group name
const alpha = match ? match[1] : null;
if (expandedPanels[groupName]) {
if (expandedPanels[groupName]=== undefined) {
await apiFetch({
url: window.api_urls.scratch_org_listmetadata(id),
dispatch,
Expand Down
6 changes: 3 additions & 3 deletions src/js/components/tasks/retrieveMetadata/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ const RetrieveMetadataModal = ({ org, isOpen, closeModal }: Props) => {
label={t('Go Back')}
variant="outline-brand"
onClick={prevPage}
disabled={ignoringChanges}
disabled={ignoringChanges || org.currently_refreshing_changes==true}
/>,
<Button
key="page-2-button-2"
label={ignoreLabel}
variant={onlyIgnoredChecked ? 'brand' : 'outline-brand'}
onClick={saveIgnored}
disabled={
!(numberChangesChecked || numberIgnoredChecked) || ignoringChanges
!(numberChangesChecked || numberIgnoredChecked) || ignoringChanges || org.currently_refreshing_changes==true
}
/>,
<Button
Expand All @@ -282,7 +282,7 @@ const RetrieveMetadataModal = ({ org, isOpen, closeModal }: Props) => {
variant={onlyIgnoredChecked ? 'outline-brand' : 'brand'}
onClick={nextPage}
disabled={
!(numberChangesChecked || numberIgnoredChecked) || ignoringChanges
!(numberChangesChecked || numberIgnoredChecked) || ignoringChanges || org.currently_refreshing_changes==true
}
/>,
],
Expand Down

0 comments on commit 490726c

Please sign in to comment.