Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 1 addition & 8 deletions localization/TranscriberAdmin-en-1.2.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,6 @@
<context context-type="sourcefile">resourceRows.ts</context>
</context-group>
</trans-unit>
<trans-unit id="artifactType.projectresource">
<source>General Resource</source>
<target/>
<context-group>
<context context-type="sourcefile">AlertDialog.tsx</context>
</context-group>
</trans-unit>
<trans-unit id="artifactType.qanda">
<source>Community Test Question and Answer</source>
<target/>
Expand Down Expand Up @@ -6630,7 +6623,7 @@
<source>General</source>
<target/>
<context-group>
<context context-type="sourcefile">PassageDetailsArtifactsMobile.tsx</context>
<context context-type="sourcefile">useRowTypeLabel.ts</context>
</context-group>
</trans-unit>
<trans-unit id="passageDetailArtifacts.generalResources">
Expand Down
6 changes: 0 additions & 6 deletions localization/TranscriberAdmin-en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,6 @@
<target/>
</segment>
</unit>
<unit id="artifactType.projectresource">
<segment>
<source>General Resource</source>
<target/>
</segment>
</unit>
<unit id="artifactType.qanda">
<segment>
<source>Community Test Question and Answer</source>
Expand Down
3 changes: 2 additions & 1 deletion web/cypress/support/pbtHarness.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,8 @@ function rowFromMediafile(m: MediaFileD, isVernacular: boolean): IRow {
mediafile: m,
playItem: '',
artifactName: '',
artifactType: isVernacular ? '' : 'backtranslation',
artifactTypeSlug: isVernacular ? '' : 'backtranslation',
isGeneralResource: false,
artifactCategory: '',
done: false,
editAction: null,
Expand Down
1 change: 0 additions & 1 deletion web/public/localization/strings0a33bab6.json

This file was deleted.

1 change: 1 addition & 0 deletions web/public/localization/stringsf040e202.json

Large diffs are not rendered by default.

46 changes: 13 additions & 33 deletions web/src/components/PassageDetail/ConsultantCheckReview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ jest.mock('../../crud', () => ({
ArtifactTypeSlug: jest.requireActual('../../crud/artifactTypeSlug')
.ArtifactTypeSlug,
findRecord: jest.fn(),
useArtifactType: () => ({
localizedArtifactType: jest.fn((slug: ArtifactTypeSlug) => {
if (slug === 'vernacular') {
return 'Vernacular';
} else if (slug === 'backtranslation') {
return 'Phrase Back Translation';
}
}),
}),
related: jest.requireActual('../../crud/related').related,
mediaFileName: (mf: MediaFile | undefined) =>
mf?.attributes?.s3file || mf?.attributes?.originalFile || '',
Expand Down Expand Up @@ -62,17 +53,6 @@ jest.mock('../../crud/useOrgDefaults', () => ({
getOrgDefault: jest.fn().mockReturnValue(mockbtDefaultSegParams),
}),
}));
jest.mock('../../crud/useArtifactType', () => ({
useArtifactType: () => ({
localizedArtifactType: jest.fn((slug: ArtifactTypeSlug) => {
if (slug === 'vernacular') {
return 'Vernacular';
} else if (slug === 'backtranslation') {
return 'Phrase Back Translation';
}
}),
}),
}));
jest.mock('../ArtifactStatus', () => ({
__esModule: true,
default: (props: ArtifactStatusProps) => (
Expand Down Expand Up @@ -116,7 +96,7 @@ describe('ConsultantCheckReview', () => {
mockRowData = [
{
id: '1',
artifactType: 'Vernacular',
artifactTypeSlug: 'vernacular',
mediafile: {
id: '1',
attributes: {
Expand All @@ -135,7 +115,7 @@ describe('ConsultantCheckReview', () => {
mockRowData = [
{
id: '1',
artifactType: 'Vernacular',
artifactTypeSlug: 'vernacular',
mediafile: {
id: '1',
attributes: {
Expand All @@ -162,7 +142,7 @@ describe('ConsultantCheckReview', () => {
mockRowData = [
{
id: '1',
artifactType: 'Vernacular',
artifactTypeSlug: 'vernacular',
mediafile: {
id: '1',
attributes: {
Expand All @@ -187,7 +167,7 @@ describe('ConsultantCheckReview', () => {
mockRowData = [
{
id: '1',
artifactType: 'Vernacular',
artifactTypeSlug: 'vernacular',
mediafile: {
id: '1',
attributes: {
Expand All @@ -206,7 +186,7 @@ describe('ConsultantCheckReview', () => {
mockRowData = [
{
id: '1',
artifactType: 'Vernacular',
artifactTypeSlug: 'vernacular',
mediafile: {
id: '1',
attributes: {} as any,
Expand All @@ -223,7 +203,7 @@ describe('ConsultantCheckReview', () => {
mockRowData = [
{
id: '1',
artifactType: 'Vernacular',
artifactTypeSlug: 'vernacular',
mediafile: {
id: '1',
attributes: {
Expand All @@ -235,7 +215,7 @@ describe('ConsultantCheckReview', () => {
{
type: 'mediafile',
id: '2',
artifactType: 'Phrase Back Translation',
artifactTypeSlug: 'backtranslation',
mediafile: {
id: '2',
attributes: {
Expand All @@ -262,7 +242,7 @@ describe('ConsultantCheckReview', () => {
mockRowData = [
{
id: '1',
artifactType: 'Vernacular',
artifactTypeSlug: 'vernacular',
mediafile: {
id: '1',
attributes: {
Expand All @@ -283,7 +263,7 @@ describe('ConsultantCheckReview', () => {
mockRowData = [
{
id: '1',
artifactType: 'Vernacular',
artifactTypeSlug: 'vernacular',
mediafile: {
id: '1',
attributes: {
Expand All @@ -295,7 +275,7 @@ describe('ConsultantCheckReview', () => {
{
type: 'mediafile',
id: '2',
artifactType: 'Phrase Back Translation',
artifactTypeSlug: 'backtranslation',
mediafile: {
id: '2',
attributes: {
Expand All @@ -322,7 +302,7 @@ describe('ConsultantCheckReview', () => {
mockRowData = [
{
id: '1',
artifactType: 'Vernacular',
artifactTypeSlug: 'vernacular',
mediafile: {
id: '1',
attributes: {
Expand All @@ -336,7 +316,7 @@ describe('ConsultantCheckReview', () => {
{
type: 'mediafile',
id: '2',
artifactType: 'Phrase Back Translation',
artifactTypeSlug: 'backtranslation',
mediafile: {
id: '2',
attributes: {
Expand All @@ -357,7 +337,7 @@ describe('ConsultantCheckReview', () => {
{
type: 'mediafile',
id: '3',
artifactType: 'Phrase Back Translation',
artifactTypeSlug: 'backtranslation',
mediafile: {
id: '3',
attributes: {
Expand Down
22 changes: 6 additions & 16 deletions web/src/components/PassageDetail/ConsultantCheckReview.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useMemo, useState } from 'react';
import { MediaFileD } from '../../model';
import { mediaFileName } from '../../crud/media';
import { useArtifactType } from '../../crud/useArtifactType';
import { related } from '../../crud/related';
import { ArtifactTypeSlug } from '../../crud/artifactTypeSlug';
import { IRow } from '../../context/PassageDetailContext';
Expand Down Expand Up @@ -46,12 +45,12 @@ interface IProps {

function languageOptionsFromRows(
rows: IRow[],
artifactType: string,
artifactTypeSlug: string,
vernacularId: string
): { bcp47: string; label: string }[] {
const map = new Map<string, string>();
for (const r of rows) {
if (r.artifactType !== artifactType) continue;
if (r.artifactTypeSlug !== artifactTypeSlug) continue;
if (related(r.mediafile, 'sourceMedia') !== vernacularId) continue;
const parsed = parseStepLanguageField(
r.mediafile.attributes?.languagebcp47
Expand All @@ -78,18 +77,16 @@ export default function ConsultantCheckReview({
const [allMedia, setAllMedia] = useState<MediaFileD[]>([]);
const [segments, setSegments] = useState('');
const [selectedLang, setSelectedLang] = useState<string>('');
const { localizedArtifactType } = useArtifactType();
const t = useSelector(consultantSelector, shallowEqual);

const vernacularId = rowData[0]?.mediafile?.id ?? '';
const artifactType = localizedArtifactType(item);

const langOptions = useMemo(
() =>
item === ArtifactTypeSlug.PhraseBackTranslation
? languageOptionsFromRows(rowData, artifactType, vernacularId)
? languageOptionsFromRows(rowData, item, vernacularId)
: [],
[item, rowData, artifactType, vernacularId]
[item, rowData, vernacularId]
);

useEffect(() => {
Expand Down Expand Up @@ -137,7 +134,7 @@ export default function ConsultantCheckReview({
const mediaId = rowData[0]?.mediafile.id ?? '';
const media = rowData
.filter((r) => {
if (r.artifactType !== artifactType) return false;
if (r.artifactTypeSlug !== item) return false;
if (related(r.mediafile, 'sourceMedia') !== mediaId) return false;
if (item === ArtifactTypeSlug.PhraseBackTranslation && selectedLang) {
const bcp = parseStepLanguageField(
Expand Down Expand Up @@ -181,14 +178,7 @@ export default function ConsultantCheckReview({
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
item,
selectedLang,
rowData,
mediafileId,
artifactType,
langOptions.length,
]);
}, [item, selectedLang, rowData, mediafileId, langOptions.length]);

const hasTranscription = allMedia.some((m) => m.attributes.transcription);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
ArtifactTypeSlug,
mediaFileName,
} from '../../../crud';
import { useRowTypeLabel } from './useRowTypeLabel';
import BigDialog from '../../../hoc/BigDialog';
import { BigDialogBp } from '../../../hoc/BigDialogBp';
import MediaDisplay from '../../MediaDisplay';
Expand Down Expand Up @@ -179,17 +180,14 @@ export function PassageDetailArtifactsMobile() {
[hasPermission, offline, offlineOnly]
);
const { userIsAdmin } = useRole();
const rowTypeLabel = useRowTypeLabel();
// Admins see badges for resources that are linked (shared) or general; other users don't.
const typeBadge = (row: IRow) =>
!userIsAdmin
? undefined
: // The badge stays short: "General" where the Type column says
// "General Resource".
row.isGeneralResource
? t.general
: row.artifactTypeSlug === ArtifactTypeSlug.SharedResource
? row.artifactType
: undefined;
userIsAdmin &&
(row.isGeneralResource ||
row.artifactTypeSlug === ArtifactTypeSlug.SharedResource)
? rowTypeLabel(row)
: undefined;
const [biblebrainClose, setBiblebrainClose] = useState(false);
const [editCloseConfirmation, setEditCloseConfirmation] = useState(false);
const handleLink = useHandleLink({ passage, setLink });
Expand Down
21 changes: 12 additions & 9 deletions web/src/components/PassageDetail/Internalization/SortableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TableRow, PlayButton, DoneButton, ResourceEditAction } from '.';
import { SectionResourceD } from '../../../model';
import { ViewButton } from './ViewButton';
import { MarkDownType, UriLinkType } from '../../../utils/contentType';
import { useRowTypeLabel } from './useRowTypeLabel';

interface IProps {
value: IRow;
Expand Down Expand Up @@ -30,12 +31,14 @@ export const SortableItem = ({
onEdit,
onDelete,
showDragHandle,
}: IProps) => (
<TableRow
showDragHandle={showDragHandle}
value={
{
}: IProps) => {
const rowTypeLabel = useRowTypeLabel();
return (
<TableRow
showDragHandle={showDragHandle}
value={{
...value,
artifactType: rowTypeLabel(value),
playItem:
contentType === UriLinkType ? (
<ViewButton id={value.id} cb={onLink} />
Expand All @@ -61,7 +64,7 @@ export const SortableItem = ({
onDelete={onDelete}
/>
),
} as any
}
/>
);
}}
/>
);
};
20 changes: 0 additions & 20 deletions web/src/components/PassageDetail/Internalization/resourceRows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ import {
} from './generalResourceMedia';
import { ArtifactTypeSlug } from '../../../crud/artifactTypeSlug';

/**
* Label key for shared resources. Not an {@link ArtifactTypeSlug}: no artifact
* type is stored under this name, it only names the `artifactType.linked`
* string.
*/
const LinkedTypeSlug = 'linked';

const isResource = (typeSlug: string) =>
['resource', 'sharedresource', 'airesource'].indexOf(typeSlug) !== -1;

Expand All @@ -32,7 +25,6 @@ interface DataProps {
userResources: SectionResourceUser[];
user: string;
localizedCategory: (slug: string) => string;
localizedType: (slug: string) => string;
}

interface RowProps extends DataProps {
Expand All @@ -55,7 +47,6 @@ export const oneMediaRow = ({
userResources,
user,
localizedCategory,
localizedType,
mediafiles = [],
}: RowProps) => {
const mediaAttr = media?.attributes;
Expand Down Expand Up @@ -85,16 +76,6 @@ export const oneMediaRow = ({
projectResourceTypeIds(artifactTypes)
)
);
// Label key, which is not always the media's own type: a derived copy reads
// as its general-resource root, and `sharedresource` reads as "Linked". The
// latter is its own string rather than a reworded `artifactType.sharedresource`
// so the existing translations of "Shared Resource" stay correct wherever that
// key is still shown.
const displayTypeSlug = isGeneralResource
? ArtifactTypeSlug.ProjectResource
: typeNameSlug === ArtifactTypeSlug.SharedResource
? LinkedTypeSlug
: typeNameSlug;
const catId = related(media, 'artifactCategory');
const category = categories.find((c) => c.id === catId);
const catNameSlug = category?.attributes?.categoryname || '';
Expand All @@ -115,7 +96,6 @@ export const oneMediaRow = ({
mediaAttr?.originalFile,
mediaContentType(media)
),
artifactType: localizedType(displayTypeSlug),
artifactTypeSlug: typeNameSlug,
isGeneralResource,
artifactCategory: localizedCategory(catNameSlug),
Expand Down
Loading
Loading