fix(ui): sort services on create page (#7745)

* fix(ui): sort services on create page

* address review comments
This commit is contained in:
Chirag Madlani 2022-09-27 18:14:06 +05:30 committed by GitHub
parent 92aea1c179
commit bcbe1ec8e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 8 deletions

View File

@ -117,7 +117,9 @@ const SelectServiceType = ({
)}
</div>
</div>
<p className="break-word text-center">{type}</p>
<p className="break-word text-center">
{type.includes('Custom') ? startCase(type) : type}
</p>
</div>
))}
</div>

View File

@ -66,7 +66,8 @@ const TeamsSelectable = ({
return (
<TreeNode disabled={disabled} key={value} title={teamName} value={value}>
{team.children && team.children.map((n) => getTreeNodes(n))}
{team.children &&
team.children.map((n: TeamHierarchy) => getTreeNodes(n))}
</TreeNode>
);
};

View File

@ -70,6 +70,7 @@ import { DatabaseServiceType } from '../generated/entity/services/databaseServic
import { MessagingServiceType } from '../generated/entity/services/messagingService';
import { MlModelServiceType } from '../generated/entity/services/mlmodelService';
import { PipelineServiceType } from '../generated/entity/services/pipelineService';
import { customServiceComparator } from '../utils/StringsUtils';
export const NoDataFoundPlaceHolder = noDataFound;
export const AddPlaceHolder = addPlaceHolder;
@ -126,12 +127,23 @@ export const PIPELINE_DEFAULT = pipelineDefault;
export const PLUS = plus;
export const NOSERVICE = noService;
export const excludedService = [MlModelServiceType.Sklearn];
export const serviceTypes: Record<ServiceTypes, Array<string>> = {
databaseServices: Object.values(DatabaseServiceType),
messagingServices: Object.values(MessagingServiceType),
dashboardServices: Object.values(DashboardServiceType),
pipelineServices: Object.values(PipelineServiceType),
mlmodelServices: Object.values(MlModelServiceType),
databaseServices: (Object.values(DatabaseServiceType) as string[]).sort(
customServiceComparator
),
messagingServices: (Object.values(MessagingServiceType) as string[]).sort(
customServiceComparator
),
dashboardServices: (Object.values(DashboardServiceType) as string[]).sort(
customServiceComparator
),
pipelineServices: (Object.values(PipelineServiceType) as string[]).sort(
customServiceComparator
),
mlmodelServices: (Object.values(MlModelServiceType) as string[]).sort(
customServiceComparator
),
};
export const arrServiceTypes: Array<ServiceTypes> = [

View File

@ -35,7 +35,7 @@
justify-content: space-between;
}
.break-word {
word-break: break-all;
word-break: break-word;
}
.justify-center {
justify-content: center;

View File

@ -161,3 +161,17 @@ export const getDecodedFqn = (fqn: string, plusAsSpace = false) => {
export const isExternalUrl = (url = '') => {
return /^https?:\/\//.test(url);
};
/**
*
* @param a compare value one
* @param b compare value two
* @returns sorted array (A-Z) which will have custom value at last
*/
export const customServiceComparator = (a: string, b: string): number => {
if (a.includes('Custom') || b.includes('Custom')) {
return a.includes('Custom') ? 1 : -1;
} else {
return a.localeCompare(b);
}
};