Skip to content

Commit

Permalink
Fix bugs in resolving icon and color for file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Nov 23, 2023
1 parent 929b5ee commit c12bd99
Show file tree
Hide file tree
Showing 8 changed files with 275 additions and 679 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-icon-extension-mapping
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Icon extension mapping

We have simplified the mapping between file extensions and their display in the web UI (icon and its color). Now, further formats/extensions (`.tar.gz`,`.tar.bz2`, ...) get displayed correctly.

https://github.com/owncloud/web/issues/10031
https://github.com/owncloud/web/pull/10059
4 changes: 0 additions & 4 deletions packages/design-system/build/webpack.system.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ const webpackConfig = merge(baseWebpackConfig, {
{
from: path.resolve(__dirname, '../l10n/translations.json'),
to: config.system.assetsSubDirectory
},
{
from: path.resolve(__dirname, '../src/helpers/resourceIconMapping.json'),
to: config.system.assetsSubDirectory
}
]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const resourceIconMapping: OcResourceIconMapping = {
},
mimeType: {
'not-a-real-mimetype': {
name: 'resource-type-madeup-mimetype',
color: 'blue'
name: 'resource-type-file',
color: 'var(--oc-color-text-default)'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@
</template>

<script lang="ts">
import { computed, defineComponent, inject, PropType, unref } from 'vue'
import { computed, defineComponent, PropType, unref } from 'vue'
import { Resource } from '@ownclouders/web-client'
import OcIcon from '../OcIcon/OcIcon.vue'
import { AVAILABLE_SIZES, IconType } from '../../helpers'
import * as iconMapping from '../../helpers/resourceIconMapping.json'
import { OcResourceIconMapping, ocResourceIconMappingInjectionKey } from './types'
import { AVAILABLE_SIZES, IconType, resolveFileIcon } from '../../helpers'
const defaultFolderIcon: IconType = {
name: 'resource-type-folder',
Expand Down Expand Up @@ -65,8 +62,6 @@ export default defineComponent({
}
},
setup(props) {
const iconMappingInjection = inject<OcResourceIconMapping>(ocResourceIconMappingInjectionKey)
const isFolder = computed(() => {
// fallback is necessary since
// sometimes resources without a type
Expand All @@ -92,12 +87,9 @@ export default defineComponent({
return defaultFolderIcon
}
let icon =
(iconMapping[unref(extension)] as IconType) ||
iconMappingInjection?.mimeType[unref(mimeType)] ||
iconMappingInjection?.extension[unref(extension)]
let icon = resolveFileIcon(unref(extension))
return {
...defaultFallbackIcon,
...icon
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,98 +51,98 @@ exports[`OcResourceIcon renders OcIcon for resource type file in size xxxlarge 1

exports[`OcResourceIcon renders OcIcon for resource type file with extension "not-a-real-extension" in size large 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="red" filltype="fill" name="resource-type-madeup-extension" size="large" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="large" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with extension "not-a-real-extension" in size medium 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="red" filltype="fill" name="resource-type-madeup-extension" size="medium" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="medium" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with extension "not-a-real-extension" in size small 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="red" filltype="fill" name="resource-type-madeup-extension" size="small" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="small" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with extension "not-a-real-extension" in size xlarge 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="red" filltype="fill" name="resource-type-madeup-extension" size="xlarge" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="xlarge" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with extension "not-a-real-extension" in size xsmall 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="red" filltype="fill" name="resource-type-madeup-extension" size="xsmall" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="xsmall" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with extension "not-a-real-extension" in size xxlarge 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="red" filltype="fill" name="resource-type-madeup-extension" size="xxlarge" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="xxlarge" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with extension "not-a-real-extension" in size xxxlarge 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="red" filltype="fill" name="resource-type-madeup-extension" size="xxxlarge" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="xxxlarge" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with mimetype "not-a-real-mimetype" in size large 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="blue" filltype="fill" name="resource-type-madeup-mimetype" size="large" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="large" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with mimetype "not-a-real-mimetype" in size medium 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="blue" filltype="fill" name="resource-type-madeup-mimetype" size="medium" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="medium" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with mimetype "not-a-real-mimetype" in size small 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="blue" filltype="fill" name="resource-type-madeup-mimetype" size="small" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="small" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with mimetype "not-a-real-mimetype" in size xlarge 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="blue" filltype="fill" name="resource-type-madeup-mimetype" size="xlarge" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="xlarge" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with mimetype "not-a-real-mimetype" in size xsmall 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="blue" filltype="fill" name="resource-type-madeup-mimetype" size="xsmall" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="xsmall" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with mimetype "not-a-real-mimetype" in size xxlarge 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="blue" filltype="fill" name="resource-type-madeup-mimetype" size="xxlarge" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="xxlarge" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;

exports[`OcResourceIcon renders OcIcon for resource type file with mimetype "not-a-real-mimetype" in size xxxlarge 1`] = `
<span>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="blue" filltype="fill" name="resource-type-madeup-mimetype" size="xxxlarge" type="span" variation="passive"></oc-icon-stub>
<oc-icon-stub accessiblelabel="" class="oc-resource-icon oc-resource-icon-file" color="var(--oc-color-text-default)" filltype="fill" name="resource-type-file" size="xxxlarge" type="span" variation="passive"></oc-icon-stub>
<!--v-if-->
</span>
`;
Expand Down
3 changes: 2 additions & 1 deletion packages/design-system/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './colors'
export * from './constants'
export * from './resolveFileIcon'
export * from './types'
export * from './colors'
Loading

0 comments on commit c12bd99

Please sign in to comment.