Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NoQA] Add orderWeight to tag view and tag edit routes #42149

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
@@ -672,12 +672,12 @@ const ROUTES = {
getRoute: (policyID: string, orderWeight: number) => `settings/workspaces/${policyID}/tags/${orderWeight}/edit` as const,
},
WORKSPACE_TAG_EDIT: {
route: 'settings/workspace/:policyID/tag/:tagName/edit',
getRoute: (policyID: string, tagName: string) => `settings/workspace/${policyID}/tag/${encodeURIComponent(tagName)}/edit` as const,
route: 'settings/workspaces/:policyID/tag/:orderWeight/:tagName/edit',
getRoute: (policyID: string, orderWeight: number, tagName: string) => `settings/workspaces/${policyID}/tag/${orderWeight}/${encodeURIComponent(tagName)}/edit` as const,
},
WORKSPACE_TAG_SETTINGS: {
route: 'settings/workspaces/:policyID/tag/:tagName',
getRoute: (policyID: string, tagName: string) => `settings/workspaces/${policyID}/tag/${encodeURIComponent(tagName)}` as const,
route: 'settings/workspaces/:policyID/tag/:orderWeight/:tagName',
getRoute: (policyID: string, orderWeight: number, tagName: string) => `settings/workspaces/${policyID}/tag/${orderWeight}/${encodeURIComponent(tagName)}` as const,
},
WORKSPACE_TAG_LIST_VIEW: {
route: 'settings/workspaces/:policyID/tag-list/:orderWeight',
2 changes: 2 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
@@ -427,12 +427,14 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.TAG_EDIT]: {
path: ROUTES.WORKSPACE_TAG_EDIT.route,
parse: {
orderWeight: Number,
tagName: (tagName: string) => decodeURIComponent(tagName),
},
},
[SCREENS.WORKSPACE.TAG_SETTINGS]: {
path: ROUTES.WORKSPACE_TAG_SETTINGS.route,
parse: {
orderWeight: Number,
tagName: (tagName: string) => decodeURIComponent(tagName),
},
},
3 changes: 2 additions & 1 deletion src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
@@ -211,6 +211,7 @@ type SettingsNavigatorParamList = {
};
[SCREENS.WORKSPACE.TAG_SETTINGS]: {
policyID: string;
orderWeight: number;
tagName: string;
};
[SCREENS.WORKSPACE.TAG_LIST_VIEW]: {
@@ -223,6 +224,7 @@ type SettingsNavigatorParamList = {
};
[SCREENS.WORKSPACE.TAG_EDIT]: {
policyID: string;
orderWeight: number;
tagName: string;
};
[SCREENS.WORKSPACE.TAXES_SETTINGS]: {
@@ -791,7 +793,6 @@ type FullScreenNavigatorParamList = {
};
[SCREENS.WORKSPACE.TAGS]: {
policyID: string;
tagName: string;
};
[SCREENS.WORKSPACE.TAXES]: {
policyID: string;
4 changes: 2 additions & 2 deletions src/pages/workspace/tags/EditTagPage.tsx
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ function EditTagPage({route, policyTags}: EditTagPageProps) {
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_TAG_FORM>) => {
const errors: FormInputErrors<typeof ONYXKEYS.FORMS.WORKSPACE_TAG_FORM> = {};
const tagName = values.tagName.trim();
const {tags} = PolicyUtils.getTagList(policyTags, 0);
const {tags} = PolicyUtils.getTagList(policyTags, route.params.orderWeight);
if (!ValidationUtils.isRequiredFulfilled(tagName)) {
errors.tagName = 'workspace.tags.tagRequiredError';
} else if (tags?.[tagName] && currentTagName !== tagName) {
@@ -50,7 +50,7 @@ function EditTagPage({route, policyTags}: EditTagPageProps) {

return errors;
},
[currentTagName, policyTags],
[route.params.orderWeight, currentTagName, policyTags],
);

const editTag = useCallback(
4 changes: 2 additions & 2 deletions src/pages/workspace/tags/TagSettingsPage.tsx
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ type TagSettingsPageProps = TagSettingsPageOnyxProps & StackScreenProps<Settings
function TagSettingsPage({route, policyTags, navigation}: TagSettingsPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const policyTag = useMemo(() => PolicyUtils.getTagList(policyTags, 0), [policyTags]);
const policyTag = useMemo(() => PolicyUtils.getTagList(policyTags, route.params.orderWeight), [policyTags, route.params.orderWeight]);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${route.params.policyID}`);

const {windowWidth} = useWindowDimensions();
@@ -70,7 +70,7 @@ function TagSettingsPage({route, policyTags, navigation}: TagSettingsPageProps)
};

const navigateToEditTag = () => {
Navigation.navigate(ROUTES.WORKSPACE_TAG_EDIT.getRoute(route.params.policyID, currentPolicyTag.name));
Navigation.navigate(ROUTES.WORKSPACE_TAG_EDIT.getRoute(route.params.policyID, route.params.orderWeight, currentPolicyTag.name));
};

const isThereAnyAccountingConnection = Object.keys(policy?.connections ?? {}).length !== 0;
4 changes: 2 additions & 2 deletions src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
@@ -154,11 +154,11 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {
};

const navigateToTagSettings = (tag: TagListItem) => {
if (tag.orderWeight != null) {
if (tag.orderWeight !== undefined) {
Navigation.navigate(ROUTES.WORKSPACE_TAG_LIST_VIEW.getRoute(policyID, tag.orderWeight));
return;
}
Navigation.navigate(ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, tag.value));
Navigation.navigate(ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, 0, tag.value));
};

const selectedTagsArray = Object.keys(selectedTags).filter((key) => selectedTags[key]);
2 changes: 1 addition & 1 deletion src/pages/workspace/tags/WorkspaceViewTagsPage.tsx
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
);

const navigateToTagSettings = (tag: TagListItem) => {
Navigation.navigate(ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, tag.value));
Navigation.navigate(ROUTES.WORKSPACE_TAG_SETTINGS.getRoute(policyID, route.params.orderWeight, tag.value));
};

const selectedTagsArray = Object.keys(selectedTags).filter((key) => selectedTags[key]);