* Updating homepage body color * WIP: Fixing scrolls and adding anchors * Removing divider from bottom of the page. * Adding hover background color to app card * Changing edit and launch icons. * Fixing app name paddding in card. * Fixing workspaces overflow * Adding right padding to applications view * Adding share icon to share btn * Fixing Application card styles. * Fixing text decoration in button. * Adding new workspace button * Fixing new workspace and new app styles. * Adding icon sizes. * Fixing Org Name and Org settings menu. * Application menu working * Fixing overlay visibility on app card * Fixing settings page content width. * Fixing workspace icon * Changing app card colors. * Removing debugger * Adding app icon. * Fixing the spaces in application card * Adding storybook-static folder to gitignore. * Adding other storybook files. * Adding menu items for app * Removing cypress selector from text. * Menu width issue fixed * Default app icon color added * Removing hardcoded colors * Removing hardcoded colors. * Light Mode on! * Showing correct icon and color in menu * Update color working properly. * Updating appIcon * Editable text working. * Adding validator * Adding edit permissions to menu * Removing box shadow on app card. * Fixing context menu fill color * Fixing Menu hover issues. * Fixing menu open close hover issues. * Fixing settings pages * Changed Workspace to org. * Fix: State management in EditableText Component (#540) * Error state height is fixed as per design * savingState prop condition fixed * Fixing createnew. * Fixing saving state for application card. * Fixed application card editable text error. * Fixing issue caused during merge. * Fixing tests in create org. * Removing commented code. * Removing unwanted vars. * Fixing delete duplicate tests. * Latest color palette. * Fixing form and table widget. * Removing switcher from header * Removing unused files * Fixing app card context dropdown * Show overlay fix * Adding localStorage support to theme. * Making dark mode the default. Co-authored-by: Rohit Kumawat <rohit.kumawat@primathon.in>
137 lines
4.1 KiB
TypeScript
137 lines
4.1 KiB
TypeScript
import { createSelector } from "reselect";
|
|
import { AppState } from "reducers";
|
|
import { ApplicationsReduxState } from "reducers/uiReducers/applicationsReducer";
|
|
import {
|
|
ApplicationPayload,
|
|
OrganizationDetails,
|
|
} from "constants/ReduxActionConstants";
|
|
import Fuse from "fuse.js";
|
|
import { UserApplication } from "constants/userConstants";
|
|
|
|
const fuzzySearchOptions = {
|
|
keys: ["applications.name", "organization.name"],
|
|
shouldSort: true,
|
|
threshold: 0.5,
|
|
location: 0,
|
|
distance: 100,
|
|
};
|
|
|
|
const getApplicationsState = (state: AppState) => state.ui.applications;
|
|
const getApplications = (state: AppState) =>
|
|
state.ui.applications.applicationList;
|
|
export const getCurrentApplication = (state: AppState): UserApplication => {
|
|
const appId = state.entities.pageList.applicationId;
|
|
const apps = state.ui.users.current
|
|
? state.ui.users.current.applications
|
|
: [];
|
|
const app = apps.find(app => app.id === appId);
|
|
|
|
return (
|
|
app || {
|
|
id: "",
|
|
name: "",
|
|
}
|
|
);
|
|
};
|
|
const getApplicationSearchKeyword = (state: AppState) =>
|
|
state.ui.applications.searchKeyword;
|
|
export const getIsDeletingApplication = (state: AppState) =>
|
|
state.ui.applications.deletingApplication;
|
|
export const getIsDuplicatingApplication = (state: AppState) =>
|
|
state.ui.applications.duplicatingApplication;
|
|
export const getIsSavingAppName = (state: AppState) =>
|
|
state.ui.applications.isSavingAppName;
|
|
export const getUserApplicationsOrgs = (state: AppState) => {
|
|
return state.ui.applications.userOrgs;
|
|
};
|
|
|
|
export const getImportedCollections = (state: AppState) =>
|
|
state.ui.importedCollections.importedCollections;
|
|
|
|
export const getProviders = (state: AppState) => state.ui.providers.providers;
|
|
export const getProvidersLoadingState = (state: AppState) =>
|
|
state.ui.providers.isFetchingProviders;
|
|
export const getProviderTemplates = (state: AppState) =>
|
|
state.ui.providers.providerTemplates;
|
|
export const getProvidersTemplatesLoadingState = (state: AppState) =>
|
|
state.ui.providers.isFetchingProviderTemplates;
|
|
|
|
export const getApplicationList = createSelector(
|
|
getApplications,
|
|
getApplicationSearchKeyword,
|
|
(
|
|
applications?: ApplicationPayload[],
|
|
keyword?: string,
|
|
): ApplicationPayload[] => {
|
|
if (
|
|
applications &&
|
|
applications.length > 0 &&
|
|
keyword &&
|
|
keyword.trim().length > 0
|
|
) {
|
|
const fuzzy = new Fuse(applications, fuzzySearchOptions);
|
|
return fuzzy.search(keyword) as ApplicationPayload[];
|
|
} else if (
|
|
applications &&
|
|
(keyword === undefined || keyword.trim().length === 0)
|
|
) {
|
|
return applications;
|
|
}
|
|
return [];
|
|
},
|
|
);
|
|
|
|
export const getUserApplicationsOrgsList = createSelector(
|
|
getUserApplicationsOrgs,
|
|
getApplicationSearchKeyword,
|
|
(applicationsOrgs?: [], keyword?: string): OrganizationDetails[] => {
|
|
if (
|
|
applicationsOrgs &&
|
|
applicationsOrgs.length > 0 &&
|
|
keyword &&
|
|
keyword.trim().length > 0
|
|
) {
|
|
const fuzzy = new Fuse(applicationsOrgs, fuzzySearchOptions);
|
|
let organizationList = fuzzy.search(keyword) as OrganizationDetails[];
|
|
organizationList = organizationList.map(org => {
|
|
const applicationFuzzy = new Fuse(org.applications, {
|
|
...fuzzySearchOptions,
|
|
keys: ["name"],
|
|
});
|
|
const applications = applicationFuzzy.search(keyword) as [];
|
|
|
|
return {
|
|
...org,
|
|
applications,
|
|
};
|
|
});
|
|
|
|
return organizationList;
|
|
} else if (
|
|
applicationsOrgs &&
|
|
(keyword === undefined || keyword.trim().length === 0)
|
|
) {
|
|
return applicationsOrgs;
|
|
}
|
|
return [];
|
|
},
|
|
);
|
|
|
|
export const getIsFetchingApplications = createSelector(
|
|
getApplicationsState,
|
|
(applications: ApplicationsReduxState): boolean =>
|
|
applications.isFetchingApplications,
|
|
);
|
|
|
|
export const getIsCreatingApplication = createSelector(
|
|
getApplicationsState,
|
|
(applications: ApplicationsReduxState): boolean =>
|
|
applications.creatingApplication,
|
|
);
|
|
|
|
export const getCreateApplicationError = createSelector(
|
|
getApplicationsState,
|
|
(applications: ApplicationsReduxState): string | undefined =>
|
|
applications.createApplicationError,
|
|
);
|