@@ -94,29 +94,71 @@ export function isDefaultOrganizationProject(project: Project) {
94
94
}
95
95
96
96
export function getDefaultProjectStorageType ( storageRules : StorageRules , project ?: Project ) : 'local' | 'remote' | 'git' {
97
- if ( storageRules . enableCloudSync && ! storageRules . enableLocalVault && ! storageRules . enableGitSync ) {
98
- return 'remote' ;
99
- }
97
+ // When the project exist. That means the user open the settings modal
98
+ if ( project ) {
99
+ if ( isGitProject ( project ) ) {
100
+ if ( storageRules . enableGitSync ) {
101
+ return 'git' ;
102
+ }
103
+ if ( storageRules . enableLocalVault ) {
104
+ return 'local' ;
105
+ }
106
+ return 'remote' ;
107
+ }
100
108
101
- if ( storageRules . enableCloudSync && storageRules . enableLocalVault ) {
102
- if ( project && isGitProject ( project ) ) {
109
+ if ( isRemoteProject ( project ) ) {
110
+ if ( storageRules . enableCloudSync ) {
111
+ return 'remote' ;
112
+ }
113
+ if ( storageRules . enableLocalVault ) {
114
+ return 'local' ;
115
+ }
103
116
return 'git' ;
104
117
}
105
118
106
- if ( project && isRemoteProject ( project ) ) {
119
+ if ( storageRules . enableLocalVault ) {
120
+ return 'local' ;
121
+ }
122
+
123
+ if ( storageRules . enableCloudSync ) {
107
124
return 'remote' ;
108
125
}
109
126
127
+ return 'git' ;
128
+ }
129
+
130
+ // When the project doesn't exist. That means the user create a new project
131
+ if ( storageRules . enableLocalVault ) {
110
132
return 'local' ;
111
133
}
112
134
113
- if ( project && isGitProject ( project ) ) {
135
+ if ( storageRules . enableCloudSync ) {
136
+ return 'remote' ;
137
+ }
138
+
139
+ if ( storageRules . enableGitSync ) {
114
140
return 'git' ;
115
141
}
116
142
117
143
return 'local' ;
118
144
}
119
145
146
+ export function isSwitchingStorageType ( project : Project , storageType : 'local' | 'remote' | 'git' ) {
147
+ if ( storageType === 'git' && ! isGitProject ( project ) ) {
148
+ return true ;
149
+ }
150
+
151
+ if ( storageType === 'local' && ( isRemoteProject ( project ) || isGitProject ( project ) ) ) {
152
+ return true ;
153
+ }
154
+
155
+ if ( storageType === 'remote' && ! isRemoteProject ( project ) ) {
156
+ return true ;
157
+ }
158
+
159
+ return false ;
160
+ }
161
+
120
162
export function getProjectStorageTypeLabel ( storageRules : StorageRules ) : string {
121
163
const storageTypes = {
122
164
'Cloud Sync' : storageRules . enableCloudSync ,
0 commit comments