makabe.t ef4f22029b Merged PR 551: 画面実装(代行操作中のヘッダー表示)
## 概要
[Task2911: 画面実装(代行操作中のヘッダー表示)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2911)

- 代行操作中に表示されるヘッダのタブを以下のタブのみに設定しました。
  - User
  - Workflow
  - License

## レビューポイント
- 代行操作タブ表示の判断材料としてヘッダコンポーネント内でselectorで代行操作の有無を判断してタブ表示用メソッドに渡していますが、データの取り扱いとして不自然なところはないでしょうか?

## UIの変更
- [Task2911](https://ndstokyo.sharepoint.com/:f:/r/sites/Piranha/Shared%20Documents/General/OMDS/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88/Task2911?csf=1&web=1&e=zFW1zj)

## 動作確認状況
- ローカルで確認
2023-11-07 06:25:42 +00:00

69 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { isAdminUser, isApproveTier, isStandardUser } from "features/auth";
import { LoginedPaths } from "./types";
import {
ADMIN_ONLY_TABS,
HEADER_MENUS,
TIER1_TO_TIER4_ONLY_TABS,
INVALID_ACCOUNT_TABS,
DELEGATE_TABS,
} from "./constants";
import { TIERS } from "../auth/constants";
// ログイン後のパスかどうか判定
export const isLoginPaths = (d: string): d is LoginedPaths => {
// caseに入力補完で取りうるリテラルしか出なくする
const type = d as LoginedPaths;
switch (type) {
case "/account":
case "/user":
case "/license":
case "/dictations":
case "/workflow":
case "/partners":
case "/xxx":
return true;
default: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _: never = type;
return false;
}
}
};
// 権限、階層ごとに表示するヘッダーをわける
export const getFilteredMenus = (isDelegation: boolean) => {
const isAdmin = isAdminUser();
const isStandard = isStandardUser();
const isTier5 = isApproveTier([TIERS.TIER5]);
const tier1ToTier4 = isApproveTier([
TIERS.TIER1,
TIERS.TIER2,
TIERS.TIER3,
TIERS.TIER4,
]);
if (isDelegation) {
return HEADER_MENUS.filter((item) => DELEGATE_TABS.includes(item.key));
}
if (tier1ToTier4) {
if (isAdmin) {
return HEADER_MENUS;
}
if (isStandard) {
return HEADER_MENUS.filter((item) => !ADMIN_ONLY_TABS.includes(item.key));
}
}
if (isTier5) {
if (isAdmin) {
return HEADER_MENUS.filter(
(item) => !TIER1_TO_TIER4_ONLY_TABS.includes(item.key)
);
}
if (isStandard) {
return HEADER_MENUS.filter((item) => !ADMIN_ONLY_TABS.includes(item.key));
}
}
// admin,standardでなく、第15階層でもないアカウントに表示する空のヘッダータブ
return INVALID_ACCOUNT_TABS;
};