Skip to content

Commit

Permalink
Removed namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas345 committed May 14, 2024
1 parent cd0e648 commit b6b965a
Show file tree
Hide file tree
Showing 33 changed files with 462 additions and 685 deletions.
10 changes: 5 additions & 5 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ declare const POWER_LOCALE_PATH: string;
declare const POWER_AZURE_TENANT_ID: string;
declare const POWER_AZURE_CLIENT_ID: string;

export namespace CONFIG {
export const APP_PATH: string = POWER_APP_PATH;
export const LOCALE_PATH = POWER_LOCALE_PATH;
export const AZURE_TENANT_ID = POWER_AZURE_TENANT_ID;
export const AZURE_CLIENT_ID = POWER_AZURE_CLIENT_ID;
export class CONFIG {
public static readonly APP_PATH: string = POWER_APP_PATH;
public static readonly LOCALE_PATH = POWER_LOCALE_PATH;
public static readonly AZURE_TENANT_ID = POWER_AZURE_TENANT_ID;
public static readonly AZURE_CLIENT_ID = POWER_AZURE_CLIENT_ID;

}
3 changes: 1 addition & 2 deletions src/localization/PowerLocalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import {StringUtils} from '../utils/StringUtil';
import deDE from './de-DE.json';
import formatString = StringUtils.formatString;

/**
* Quick localizer that localizes localizations. For localizing locales.
Expand Down Expand Up @@ -45,7 +44,7 @@ export class PowerLocalize {

public static getFormatted(field: string, ...args: any[]): string {
let val = PowerLocalize.get(field);
return formatString(val, ...args);
return StringUtils.formatString(val, ...args);
}


Expand Down
8 changes: 4 additions & 4 deletions src/model/admin/AdminNotificationReason.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ export enum AdminNotificationReason {
DANGEROUS_SKILL_ADDED_BLACKLISTED
}

export namespace AdminNotificationReasonUtil {
export class AdminNotificationReasonUtil {

export function keys(): Array<number> {
public static keys(): Array<number> {
return Object.keys(AdminNotificationReason)
.filter(key => !isNaN(Number(AdminNotificationReason[key])))
.map(key => Number(key));
}

export function fromString(reason: string): AdminNotificationReason {
for (let key in keys()) {
public static fromString(reason: string): AdminNotificationReason {
for (let key in AdminNotificationReasonUtil.keys()) {
if (AdminNotificationReason[key] === reason) {
return key as any as number;
}
Expand Down
3 changes: 1 addition & 2 deletions src/modules/admin/info/category-searcher_module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {PowerLocalize} from '../../../localization/PowerLocalizer';
import {Comparators} from '../../../utils/Comparators';
import {getInverseCategoryHierarchy, SkillStore} from '../../../model/skill/SkillStore';
import {StringUtils} from '../../../utils/StringUtil';
import filterFuzzy = StringUtils.filterFuzzy;


interface CategorySearcherProps {
Expand Down Expand Up @@ -78,7 +77,7 @@ export class CategorySearcher extends React.Component<CategorySearcherProps, Cat
private renderCategories = () => {
let categories = this.props.categories;
if (this.state.filterText !== '') {
categories = categories.filter(category => filterFuzzy(this.state.filterText, category.qualifier));
categories = categories.filter(category => StringUtils.filterFuzzy(this.state.filterText, category.qualifier));
}
categories.sort(Comparators.compareCategories);
return categories.map(this.mapListItem);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/admin/info/skill/edit-skill-dialog_module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Button, Dialog, DialogContent, DialogTitle, Step, StepLabel, Stepper} fr
import {ConsultantInfo} from '../../../../model/ConsultantInfo';
import {SkillSearcher} from '../../../general/skill-search_module';
import {AdminActionCreator} from '../../../../reducers/admin/AdminActionCreator';
import {SkillReducer} from '../../../../reducers/skill/SkillReducer';
import {buildHierarchy} from '../../../../reducers/skill/SkillReducer';
import {PowerLocalize} from '../../../../localization/PowerLocalizer';
import * as Immutable from 'immutable';
import {SkillServiceClient} from '../../../../clients/SkillServiceClient';
Expand Down Expand Up @@ -97,7 +97,7 @@ class EditSkillDialogModule extends React.Component<EditSkillDialogProps & EditS
private loadSkillHierarchy = () => {

SkillServiceClient.instance().postCategorizeSkill(this.state.newSkillName)
.then(category => this.setState({skillHierarchy: this.state.newSkillName + ' => ' + SkillReducer.buildHierarchy(category)}))
.then(category => this.setState({skillHierarchy: this.state.newSkillName + ' => ' + buildHierarchy(category)}))
.catch(error => console.error(error))
.catch(() => this.setState({skillHierarchy: 'Not available.'}));
};
Expand Down
3 changes: 1 addition & 2 deletions src/modules/admin/info/skill/used-skill-overview_module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {StringUtils} from '../../../../utils/StringUtil';
import {UsedSkillInfoBox} from './used-skill-info-box';
import {toArray} from '../../../../utils/ImmutableUtils';
import {SuggestionAsyncActionCreator} from '../../../../reducers/suggestions/SuggestionAsyncActionCreator';
import filterFuzzy = StringUtils.filterFuzzy;
import {ThunkDispatch} from 'redux-thunk';


Expand Down Expand Up @@ -131,7 +130,7 @@ class UsedSkillOverviewModule extends React.Component<UsedSkillOverviewProps
render() {
let res;
if (this.state.filterString !== '') {
res = this.props.usedSkillNames.filter((value) => filterFuzzy(this.state.filterString, value)).sort(Comparators.getStringComparator(true));
res = this.props.usedSkillNames.filter((value) => StringUtils.filterFuzzy(this.state.filterString, value)).sort(Comparators.getStringComparator(true));
} else {
res = this.props.usedSkillNames.sort(Comparators.getStringComparator(true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {NotificationDialog} from './notification-dialog_module';
import {StringUtils} from '../../../utils/StringUtil';
import Checkbox from '@material-ui/core/Checkbox/Checkbox';
import FormGroup from '@material-ui/core/FormGroup/FormGroup';
import formatString = StringUtils.formatString;


interface ProfileEntryNotificationTableLocalProps {
Expand Down Expand Up @@ -61,7 +60,7 @@ export class ProfileEntryNotificationTable extends React.Component<ProfileEntryN
className="cursor-pointer"
onClick={() => this.showNotificationDialog(key)}
>
{formatString(
{StringUtils.formatString(
PowerLocalize.get('NotificationInbox.NameEntityNotification.SubjectTextTemplate'),
notification.nameEntity.name(),
NameEntityUtil.typeToLocalizedType(notification.nameEntity))
Expand Down
3 changes: 1 addition & 2 deletions src/modules/general/pwr-auto-complete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {StringUtils} from '../../utils/StringUtil';
import match from 'autosuggest-highlight/match';
import parse from 'autosuggest-highlight/parse';
import {ValidationError} from '../../utils/ValidationUtils';
import filterFuzzy = StringUtils.filterFuzzy;
import * as ReactDOM from "react-dom";

// Documentation: https://github.com/TeamWertarbyte/material-ui-chip-input
Expand Down Expand Up @@ -72,7 +71,7 @@ export class PwrAutoCompleteModule extends React.Component<PwrAutoCompleteProps
if (this.props.disableFiltering) {
return this.props.data;
} else {
return filter(this.props.data, value, filterFuzzy);
return filter(this.props.data, value, StringUtils.filterFuzzy);
}
};

Expand Down
49 changes: 0 additions & 49 deletions src/modules/general/pwr-text-length_module.tsx

This file was deleted.

49 changes: 0 additions & 49 deletions src/modules/general/pwr-year-picker.tsx

This file was deleted.

18 changes: 8 additions & 10 deletions src/modules/general/skill/localization-searcher_module.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import * as React from 'react';
import {LanguageUtils} from '../../../utils/LanguageUtils';
import {ISO639_2DataSet, LanguageUtils} from '../../../utils/LanguageUtils';
import {Dialog, DialogContent, DialogTitle, List, ListItem, TextField} from '@material-ui/core';
import {PowerLocalize} from '../../../localization/PowerLocalizer';
import {StringUtils} from '../../../utils/StringUtil';
import ISOData = LanguageUtils.ISO639_2DataSet;
import filterFuzzy = StringUtils.filterFuzzy;

interface LocalizationSearcherProps {
open: boolean;

onClose?(): void;

onSelectIsoData?(data: ISOData): void;
onSelectIsoData?(data: ISO639_2DataSet): void;

maxHeight?: string;
}

interface LocalizationSearcherState {
isoData: Array<ISOData>;
isoData: Array<ISO639_2DataSet>;
selected: any;
searchString: string;
}
Expand Down Expand Up @@ -50,9 +48,9 @@ export class LocalizationSearcher extends React.Component<LocalizationSearcherPr
});
}

private static filterIsoData = (data: ISOData, searchString: string) => {
return data.int.some((value, index, array) => filterFuzzy(searchString, value)) ||
data.native.some(((value, index, array) => filterFuzzy(searchString, value)));
private static filterIsoData = (data: ISO639_2DataSet, searchString: string) => {
return data.int.some((value, index, array) => StringUtils.filterFuzzy(searchString, value)) ||
data.native.some(((value, index, array) => StringUtils.filterFuzzy(searchString, value)));
};

public handleSearchStringChange = (e: any) => {
Expand All @@ -67,11 +65,11 @@ export class LocalizationSearcher extends React.Component<LocalizationSearcherPr
});
};

private handleSelectIsoData = (isoData: ISOData) => {
private handleSelectIsoData = (isoData: ISO639_2DataSet) => {
this.props.onSelectIsoData(isoData);
};

private mapToListItem = (isoData: ISOData) => {
private mapToListItem = (isoData: ISO639_2DataSet) => {
return <ListItem
key={isoData.code}
onClick={() => this.handleSelectIsoData(isoData)}
Expand Down
5 changes: 2 additions & 3 deletions src/modules/general/skill/localization-table_module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ import {
TextField
} from '@material-ui/core';
import {PowerLocalize} from '../../../localization/PowerLocalizer';
import {LanguageUtils} from '../../../utils/LanguageUtils';
import {LocalizationSearcher} from './localization-searcher_module';
import DialogActions from '@material-ui/core/DialogActions/DialogActions';
import Tooltip from '@material-ui/core/Tooltip/Tooltip';
import ISOData = LanguageUtils.ISO639_2DataSet;
import {ISO639_2DataSet} from '../../../utils/LanguageUtils';

interface LocalizationTableProps {
localizations: Immutable.List<LocalizedQualifier>;
Expand Down Expand Up @@ -119,7 +118,7 @@ export class LocalizationTable extends React.Component<LocalizationTableProps, L
});
};

private handleSearcherSelect = (data: ISOData) => {
private handleSearcherSelect = (data: ISO639_2DataSet) => {
this.setState({
locale: data.code
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import {Card, CardContent, CardHeader, List, ListItem, Popover} from '@material-ui/core';
import {PowerLocalize} from '../../../localization/PowerLocalizer';
import {StringUtils} from '../../../utils/StringUtil';
import formatString = StringUtils.formatString;
import {APIAveragedSkill, APIConsultantClusterInfo} from '../../../model/statistics/ApiMetrics';


Expand Down Expand Up @@ -115,9 +114,9 @@ export class ConsultantClusterOverview extends React.Component<ConsultantCluster
title={skill.name}
/>
<CardContent>
{formatString('Der Skill {0} tritt {1} mal im Cluster auf.', skill.name, String(skill.numOccurances))}<br/>
{formatString('Damit haben {0}% der Berater in diesem Cluster diesen Skill.', (skill.relativeOccurance * 100).toFixed(2))}<br/>
{formatString('Das Durchschnittliche Skill-Level beträgt {0}/5.0.', skill.average.toFixed(2))}<br/>
{StringUtils.formatString('Der Skill {0} tritt {1} mal im Cluster auf.', skill.name, String(skill.numOccurances))}<br/>
{StringUtils.formatString('Damit haben {0}% der Berater in diesem Cluster diesen Skill.', (skill.relativeOccurance * 100).toFixed(2))}<br/>
{StringUtils.formatString('Das Durchschnittliche Skill-Level beträgt {0}/5.0.', skill.average.toFixed(2))}<br/>
</CardContent>
</Card>);
}
Expand Down Expand Up @@ -167,7 +166,7 @@ export class ConsultantClusterOverview extends React.Component<ConsultantCluster
<Card>
<CardHeader
title={PowerLocalize.get('ClusterInfo.CommonSkills.Title')}
subheader={formatString(PowerLocalize.get('ClusterInfo.CommonSkills.Subtitle'), String(this.props.info.commonSkills.length))}
subheader={StringUtils.formatString(PowerLocalize.get('ClusterInfo.CommonSkills.Subtitle'), String(this.props.info.commonSkills.length))}
/>
<CardContent className="row">
{this.renderCommonSkills()}
Expand All @@ -178,7 +177,7 @@ export class ConsultantClusterOverview extends React.Component<ConsultantCluster
<Card>
<CardHeader
title={PowerLocalize.get('ClusterInfo.Skills.Title')}
subheader={formatString(PowerLocalize.get('ClusterInfo.Skills.Subtitle'), String(this.props.info.clusterSkills.length))}
subheader={StringUtils.formatString(PowerLocalize.get('ClusterInfo.Skills.Subtitle'), String(this.props.info.clusterSkills.length))}
/>
<CardContent>
<TCloud
Expand Down
Loading

0 comments on commit b6b965a

Please sign in to comment.